
/* WARNING: Function: __x86.get_pc_thunk.bx replaced with injection: get_pc_thunk_bx */
/* WARNING: Unknown calling convention */

FILE * rpl_freopen(char *filename,char *mode,FILE *stream)

{
  FILE *__stream;
  int iVar1;
  int iVar2;
  int *piVar3;
  
  __stream = freopen64(filename,mode,(FILE *)stream);
  if ((__stream != (FILE *)0x0) && (filename != (char *)0x0)) {
    iVar1 = fileno(__stream);
    iVar2 = dup2(iVar1,iVar1);
    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {
      iVar2 = open64("/dev/null",0x80000);
      if (iVar1 != iVar2) {
        iVar1 = dup2(iVar2,iVar1);
        if (iVar1 < 0) {
          close(iVar2);
          return (FILE *)__stream;
        }
        close(iVar2);
      }
      __stream = freopen64(filename,mode,__stream);
    }
  }
  return (FILE *)__stream;
}



/* WARNING: Function: __i686.get_pc_thunk.bx replaced with injection: get_pc_thunk_bx */

FILE * FUN_00017f20(char *param_1,char *param_2,FILE *param_3)

{
  FILE *__stream;
  int iVar1;
  int iVar2;
  int *piVar3;
  
  __stream = freopen64(param_1,param_2,param_3);
  if ((__stream != (FILE *)0x0) && (param_1 != (char *)0x0)) {
    iVar1 = fileno(__stream);
    iVar2 = dup2(iVar1,iVar1);
    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {
      iVar2 = open64("/dev/null",0x80000);
      if (iVar1 != iVar2) {
        iVar1 = dup2(iVar2,iVar1);
        if (iVar1 < 0) {
          close(iVar2);
          return __stream;
        }
        close(iVar2);
      }
      __stream = freopen64(param_1,param_2,__stream);
    }
  }
  return __stream;
}


PUSH EBP
PUSH EDI
PUSH ESI
PUSH EBX
CALL 0x00011530
ADD EBX,0x70d7
SUB ESP,0x20
MOV EDI,dword ptr [ESP + 0x34]
PUSH dword ptr [ESP + 0x3c]
PUSH dword ptr [ESP + 0x3c]
PUSH EDI
CALL 0x00011040
ADD ESP,0x10
MOV ESI,EAX
TEST EAX,EAX
JZ 0x00017f6c
TEST EDI,EDI
JZ 0x00017f6c
SUB ESP,0xc
PUSH EAX
CALL 0x00011270
MOV EBP,EAX
POP EAX
POP EDX
PUSH EBP
PUSH EBP
CALL 0x00011050
ADD ESP,0x10
TEST EAX,EAX
JS 0x00017f80
ADD ESP,0x1c
MOV EAX,ESI
POP EBX
POP ESI
POP EDI
POP EBP
RET
CALL 0x00011260
CMP dword ptr [EAX],0x9
JNZ 0x00017f6c
SUB ESP,0x8
LEA EAX,[EBX + 0xffffb38c]
PUSH 0x80000
PUSH EAX
CALL 0x00011070
ADD ESP,0x10
CMP EBP,EAX
JZ 0x00017fca
SUB ESP,0x8
PUSH EBP
PUSH EAX
MOV dword ptr [ESP + 0x1c],EAX
CALL 0x00011050
ADD ESP,0x10
MOV EDX,dword ptr [ESP + 0xc]
TEST EAX,EAX
JS 0x00017fdf
SUB ESP,0xc
PUSH EDX
CALL 0x00011350
ADD ESP,0x10
SUB ESP,0x4
PUSH ESI
PUSH dword ptr [ESP + 0x3c]
PUSH EDI
CALL 0x00011040
ADD ESP,0x10
MOV ESI,EAX
JMP 0x00017f6c
SUB ESP,0xc
PUSH EDX
CALL 0x00011350
ADD ESP,0x10
JMP 0x00017f6c
(translation_unit "/* WARNING: Function: __i686.get_pc_thunk.bx replaced with injection: get_pc_thunk_bx */\n\nFILE * FUN_00017f20(char *param_1,char *param_2,FILE *param_3)\n\n{\n  FILE *__stream;\n  int iVar1;\n  int iVar2;\n  int *piVar3;\n  \n  __stream = freopen64(param_1,param_2,param_3);\n  if ((__stream != (FILE *)0x0) && (param_1 != (char *)0x0)) {\n    iVar1 = fileno(__stream);\n    iVar2 = dup2(iVar1,iVar1);\n    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(param_1,param_2,__stream);\n    }\n  }\n  return __stream;\n}\n\n" comment (function_definition "FILE * FUN_00017f20(char *param_1,char *param_2,FILE *param_3)\n\n{\n  FILE *__stream;\n  int iVar1;\n  int iVar2;\n  int *piVar3;\n  \n  __stream = freopen64(param_1,param_2,param_3);\n  if ((__stream != (FILE *)0x0) && (param_1 != (char *)0x0)) {\n    iVar1 = fileno(__stream);\n    iVar2 = dup2(iVar1,iVar1);\n    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(param_1,param_2,__stream);\n    }\n  }\n  return __stream;\n}" type_identifier (pointer_declarator "* FUN_00017f20(char *param_1,char *param_2,FILE *param_3)" * (function_declarator "FUN_00017f20(char *param_1,char *param_2,FILE *param_3)" identifier (parameter_list "(char *param_1,char *param_2,FILE *param_3)" ( (parameter_declaration "char *param_1" primitive_type (pointer_declarator "*param_1" * identifier)) , (parameter_declaration "char *param_2" primitive_type (pointer_declarator "*param_2" * identifier)) , (parameter_declaration "FILE *param_3" type_identifier (pointer_declarator "*param_3" * identifier)) )))) (compound_statement "{\n  FILE *__stream;\n  int iVar1;\n  int iVar2;\n  int *piVar3;\n  \n  __stream = freopen64(param_1,param_2,param_3);\n  if ((__stream != (FILE *)0x0) && (param_1 != (char *)0x0)) {\n    iVar1 = fileno(__stream);\n    iVar2 = dup2(iVar1,iVar1);\n    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(param_1,param_2,__stream);\n    }\n  }\n  return __stream;\n}" { (declaration "FILE *__stream;" type_identifier (pointer_declarator "*__stream" * identifier) ;) (declaration "int iVar1;" primitive_type identifier ;) (declaration "int iVar2;" primitive_type identifier ;) (declaration "int *piVar3;" primitive_type (pointer_declarator "*piVar3" * identifier) ;) (expression_statement "__stream = freopen64(param_1,param_2,param_3);" (assignment_expression "__stream = freopen64(param_1,param_2,param_3)" identifier = (call_expression "freopen64(param_1,param_2,param_3)" identifier (argument_list "(param_1,param_2,param_3)" ( identifier , identifier , identifier )))) ;) (if_statement "if ((__stream != (FILE *)0x0) && (param_1 != (char *)0x0)) {\n    iVar1 = fileno(__stream);\n    iVar2 = dup2(iVar1,iVar1);\n    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(param_1,param_2,__stream);\n    }\n  }" if (parenthesized_expression "((__stream != (FILE *)0x0) && (param_1 != (char *)0x0))" ( (binary_expression "(__stream != (FILE *)0x0) && (param_1 != (char *)0x0)" (parenthesized_expression "(__stream != (FILE *)0x0)" ( (binary_expression "__stream != (FILE *)0x0" identifier != (cast_expression "(FILE *)0x0" ( (type_descriptor "FILE *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal)) )) && (parenthesized_expression "(param_1 != (char *)0x0)" ( (binary_expression "param_1 != (char *)0x0" identifier != (cast_expression "(char *)0x0" ( (type_descriptor "char *" primitive_type (abstract_pointer_declarator "*" *)) ) number_literal)) ))) )) (compound_statement "{\n    iVar1 = fileno(__stream);\n    iVar2 = dup2(iVar1,iVar1);\n    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(param_1,param_2,__stream);\n    }\n  }" { (expression_statement "iVar1 = fileno(__stream);" (assignment_expression "iVar1 = fileno(__stream)" identifier = (call_expression "fileno(__stream)" identifier (argument_list "(__stream)" ( identifier )))) ;) (expression_statement "iVar2 = dup2(iVar1,iVar1);" (assignment_expression "iVar2 = dup2(iVar1,iVar1)" identifier = (call_expression "dup2(iVar1,iVar1)" identifier (argument_list "(iVar1,iVar1)" ( identifier , identifier )))) ;) (if_statement "if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(param_1,param_2,__stream);\n    }" if (parenthesized_expression "((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9))" ( (binary_expression "(iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)" (parenthesized_expression "(iVar2 < 0)" ( (binary_expression "iVar2 < 0" identifier < number_literal) )) && (parenthesized_expression "(piVar3 = __errno_location(), *piVar3 == 9)" ( (comma_expression "piVar3 = __errno_location(), *piVar3 == 9" (assignment_expression "piVar3 = __errno_location()" identifier = (call_expression "__errno_location()" identifier (argument_list "()" ( )))) , (binary_expression "*piVar3 == 9" (pointer_expression "*piVar3" * identifier) == number_literal)) ))) )) (compound_statement "{\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(param_1,param_2,__stream);\n    }" { (expression_statement "iVar2 = open64("/dev/null",0x80000);" (assignment_expression "iVar2 = open64("/dev/null",0x80000)" identifier = (call_expression "open64("/dev/null",0x80000)" identifier (argument_list "("/dev/null",0x80000)" ( (string_literal ""/dev/null"" " string_content ") , number_literal )))) ;) (if_statement "if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }" if (parenthesized_expression "(iVar1 != iVar2)" ( (binary_expression "iVar1 != iVar2" identifier != identifier) )) (compound_statement "{\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }" { (expression_statement "iVar1 = dup2(iVar2,iVar1);" (assignment_expression "iVar1 = dup2(iVar2,iVar1)" identifier = (call_expression "dup2(iVar2,iVar1)" identifier (argument_list "(iVar2,iVar1)" ( identifier , identifier )))) ;) (if_statement "if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }" if (parenthesized_expression "(iVar1 < 0)" ( (binary_expression "iVar1 < 0" identifier < number_literal) )) (compound_statement "{\n          close(iVar2);\n          return __stream;\n        }" { (expression_statement "close(iVar2);" (call_expression "close(iVar2)" identifier (argument_list "(iVar2)" ( identifier ))) ;) (return_statement "return __stream;" return identifier ;) })) (expression_statement "close(iVar2);" (call_expression "close(iVar2)" identifier (argument_list "(iVar2)" ( identifier ))) ;) })) (expression_statement "__stream = freopen64(param_1,param_2,__stream);" (assignment_expression "__stream = freopen64(param_1,param_2,__stream)" identifier = (call_expression "freopen64(param_1,param_2,__stream)" identifier (argument_list "(param_1,param_2,__stream)" ( identifier , identifier , identifier )))) ;) })) })) (return_statement "return __stream;" return identifier ;) })))
(translation_unit "/* WARNING: Function: __x86.get_pc_thunk.bx replaced with injection: get_pc_thunk_bx */\n/* WARNING: Unknown calling convention */\n\nFILE * rpl_freopen(char *filename,char *mode,FILE *stream)\n\n{\n  FILE *__stream;\n  int iVar1;\n  int iVar2;\n  int *piVar3;\n  \n  __stream = freopen64(filename,mode,(FILE *)stream);\n  if ((__stream != (FILE *)0x0) && (filename != (char *)0x0)) {\n    iVar1 = fileno(__stream);\n    iVar2 = dup2(iVar1,iVar1);\n    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return (FILE *)__stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(filename,mode,__stream);\n    }\n  }\n  return (FILE *)__stream;\n}\n\n" comment comment (function_definition "FILE * rpl_freopen(char *filename,char *mode,FILE *stream)\n\n{\n  FILE *__stream;\n  int iVar1;\n  int iVar2;\n  int *piVar3;\n  \n  __stream = freopen64(filename,mode,(FILE *)stream);\n  if ((__stream != (FILE *)0x0) && (filename != (char *)0x0)) {\n    iVar1 = fileno(__stream);\n    iVar2 = dup2(iVar1,iVar1);\n    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return (FILE *)__stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(filename,mode,__stream);\n    }\n  }\n  return (FILE *)__stream;\n}" type_identifier (pointer_declarator "* rpl_freopen(char *filename,char *mode,FILE *stream)" * (function_declarator "rpl_freopen(char *filename,char *mode,FILE *stream)" identifier (parameter_list "(char *filename,char *mode,FILE *stream)" ( (parameter_declaration "char *filename" primitive_type (pointer_declarator "*filename" * identifier)) , (parameter_declaration "char *mode" primitive_type (pointer_declarator "*mode" * identifier)) , (parameter_declaration "FILE *stream" type_identifier (pointer_declarator "*stream" * identifier)) )))) (compound_statement "{\n  FILE *__stream;\n  int iVar1;\n  int iVar2;\n  int *piVar3;\n  \n  __stream = freopen64(filename,mode,(FILE *)stream);\n  if ((__stream != (FILE *)0x0) && (filename != (char *)0x0)) {\n    iVar1 = fileno(__stream);\n    iVar2 = dup2(iVar1,iVar1);\n    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return (FILE *)__stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(filename,mode,__stream);\n    }\n  }\n  return (FILE *)__stream;\n}" { (declaration "FILE *__stream;" type_identifier (pointer_declarator "*__stream" * identifier) ;) (declaration "int iVar1;" primitive_type identifier ;) (declaration "int iVar2;" primitive_type identifier ;) (declaration "int *piVar3;" primitive_type (pointer_declarator "*piVar3" * identifier) ;) (expression_statement "__stream = freopen64(filename,mode,(FILE *)stream);" (assignment_expression "__stream = freopen64(filename,mode,(FILE *)stream)" identifier = (call_expression "freopen64(filename,mode,(FILE *)stream)" identifier (argument_list "(filename,mode,(FILE *)stream)" ( identifier , identifier , (cast_expression "(FILE *)stream" ( (type_descriptor "FILE *" type_identifier (abstract_pointer_declarator "*" *)) ) identifier) )))) ;) (if_statement "if ((__stream != (FILE *)0x0) && (filename != (char *)0x0)) {\n    iVar1 = fileno(__stream);\n    iVar2 = dup2(iVar1,iVar1);\n    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return (FILE *)__stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(filename,mode,__stream);\n    }\n  }" if (parenthesized_expression "((__stream != (FILE *)0x0) && (filename != (char *)0x0))" ( (binary_expression "(__stream != (FILE *)0x0) && (filename != (char *)0x0)" (parenthesized_expression "(__stream != (FILE *)0x0)" ( (binary_expression "__stream != (FILE *)0x0" identifier != (cast_expression "(FILE *)0x0" ( (type_descriptor "FILE *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal)) )) && (parenthesized_expression "(filename != (char *)0x0)" ( (binary_expression "filename != (char *)0x0" identifier != (cast_expression "(char *)0x0" ( (type_descriptor "char *" primitive_type (abstract_pointer_declarator "*" *)) ) number_literal)) ))) )) (compound_statement "{\n    iVar1 = fileno(__stream);\n    iVar2 = dup2(iVar1,iVar1);\n    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return (FILE *)__stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(filename,mode,__stream);\n    }\n  }" { (expression_statement "iVar1 = fileno(__stream);" (assignment_expression "iVar1 = fileno(__stream)" identifier = (call_expression "fileno(__stream)" identifier (argument_list "(__stream)" ( identifier )))) ;) (expression_statement "iVar2 = dup2(iVar1,iVar1);" (assignment_expression "iVar2 = dup2(iVar1,iVar1)" identifier = (call_expression "dup2(iVar1,iVar1)" identifier (argument_list "(iVar1,iVar1)" ( identifier , identifier )))) ;) (if_statement "if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return (FILE *)__stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(filename,mode,__stream);\n    }" if (parenthesized_expression "((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9))" ( (binary_expression "(iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)" (parenthesized_expression "(iVar2 < 0)" ( (binary_expression "iVar2 < 0" identifier < number_literal) )) && (parenthesized_expression "(piVar3 = __errno_location(), *piVar3 == 9)" ( (comma_expression "piVar3 = __errno_location(), *piVar3 == 9" (assignment_expression "piVar3 = __errno_location()" identifier = (call_expression "__errno_location()" identifier (argument_list "()" ( )))) , (binary_expression "*piVar3 == 9" (pointer_expression "*piVar3" * identifier) == number_literal)) ))) )) (compound_statement "{\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return (FILE *)__stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(filename,mode,__stream);\n    }" { (expression_statement "iVar2 = open64("/dev/null",0x80000);" (assignment_expression "iVar2 = open64("/dev/null",0x80000)" identifier = (call_expression "open64("/dev/null",0x80000)" identifier (argument_list "("/dev/null",0x80000)" ( (string_literal ""/dev/null"" " string_content ") , number_literal )))) ;) (if_statement "if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return (FILE *)__stream;\n        }\n        close(iVar2);\n      }" if (parenthesized_expression "(iVar1 != iVar2)" ( (binary_expression "iVar1 != iVar2" identifier != identifier) )) (compound_statement "{\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return (FILE *)__stream;\n        }\n        close(iVar2);\n      }" { (expression_statement "iVar1 = dup2(iVar2,iVar1);" (assignment_expression "iVar1 = dup2(iVar2,iVar1)" identifier = (call_expression "dup2(iVar2,iVar1)" identifier (argument_list "(iVar2,iVar1)" ( identifier , identifier )))) ;) (if_statement "if (iVar1 < 0) {\n          close(iVar2);\n          return (FILE *)__stream;\n        }" if (parenthesized_expression "(iVar1 < 0)" ( (binary_expression "iVar1 < 0" identifier < number_literal) )) (compound_statement "{\n          close(iVar2);\n          return (FILE *)__stream;\n        }" { (expression_statement "close(iVar2);" (call_expression "close(iVar2)" identifier (argument_list "(iVar2)" ( identifier ))) ;) (return_statement "return (FILE *)__stream;" return (cast_expression "(FILE *)__stream" ( (type_descriptor "FILE *" type_identifier (abstract_pointer_declarator "*" *)) ) identifier) ;) })) (expression_statement "close(iVar2);" (call_expression "close(iVar2)" identifier (argument_list "(iVar2)" ( identifier ))) ;) })) (expression_statement "__stream = freopen64(filename,mode,__stream);" (assignment_expression "__stream = freopen64(filename,mode,__stream)" identifier = (call_expression "freopen64(filename,mode,__stream)" identifier (argument_list "(filename,mode,__stream)" ( identifier , identifier , identifier )))) ;) })) })) (return_statement "return (FILE *)__stream;" return (cast_expression "(FILE *)__stream" ( (type_descriptor "FILE *" type_identifier (abstract_pointer_declarator "*" *)) ) identifier) ;) })))
(translation_unit "FILE * FUN_00017f20(char *param_1,char *param_2,FILE *param_3)\n\n{\n  FILE *__stream;\n  int iVar1;\n  int iVar2;\n  int *piVar3;\n  \n  __stream = freopen64(param_1,param_2,param_3);\n  if ((__stream != (FILE *)0x0) && (param_1 != (char *)0x0)) {\n    iVar1 = fileno(__stream);\n    iVar2 = dup2(iVar1,iVar1);\n    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(param_1,param_2,__stream);\n    }\n  }\n  return __stream;\n}\n\n" (function_definition "FILE * FUN_00017f20(char *param_1,char *param_2,FILE *param_3)\n\n{\n  FILE *__stream;\n  int iVar1;\n  int iVar2;\n  int *piVar3;\n  \n  __stream = freopen64(param_1,param_2,param_3);\n  if ((__stream != (FILE *)0x0) && (param_1 != (char *)0x0)) {\n    iVar1 = fileno(__stream);\n    iVar2 = dup2(iVar1,iVar1);\n    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(param_1,param_2,__stream);\n    }\n  }\n  return __stream;\n}" type_identifier (pointer_declarator "* FUN_00017f20(char *param_1,char *param_2,FILE *param_3)" * (function_declarator "FUN_00017f20(char *param_1,char *param_2,FILE *param_3)" identifier (parameter_list "(char *param_1,char *param_2,FILE *param_3)" ( (parameter_declaration "char *param_1" primitive_type (pointer_declarator "*param_1" * identifier)) , (parameter_declaration "char *param_2" primitive_type (pointer_declarator "*param_2" * identifier)) , (parameter_declaration "FILE *param_3" type_identifier (pointer_declarator "*param_3" * identifier)) )))) (compound_statement "{\n  FILE *__stream;\n  int iVar1;\n  int iVar2;\n  int *piVar3;\n  \n  __stream = freopen64(param_1,param_2,param_3);\n  if ((__stream != (FILE *)0x0) && (param_1 != (char *)0x0)) {\n    iVar1 = fileno(__stream);\n    iVar2 = dup2(iVar1,iVar1);\n    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(param_1,param_2,__stream);\n    }\n  }\n  return __stream;\n}" { (declaration "FILE *__stream;" type_identifier (pointer_declarator "*__stream" * identifier) ;) (declaration "int iVar1;" primitive_type identifier ;) (declaration "int iVar2;" primitive_type identifier ;) (declaration "int *piVar3;" primitive_type (pointer_declarator "*piVar3" * identifier) ;) (expression_statement "__stream = freopen64(param_1,param_2,param_3);" (assignment_expression "__stream = freopen64(param_1,param_2,param_3)" identifier = (call_expression "freopen64(param_1,param_2,param_3)" identifier (argument_list "(param_1,param_2,param_3)" ( identifier , identifier , identifier )))) ;) (if_statement "if ((__stream != (FILE *)0x0) && (param_1 != (char *)0x0)) {\n    iVar1 = fileno(__stream);\n    iVar2 = dup2(iVar1,iVar1);\n    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(param_1,param_2,__stream);\n    }\n  }" if (parenthesized_expression "((__stream != (FILE *)0x0) && (param_1 != (char *)0x0))" ( (binary_expression "(__stream != (FILE *)0x0) && (param_1 != (char *)0x0)" (parenthesized_expression "(__stream != (FILE *)0x0)" ( (binary_expression "__stream != (FILE *)0x0" identifier != (cast_expression "(FILE *)0x0" ( (type_descriptor "FILE *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal)) )) && (parenthesized_expression "(param_1 != (char *)0x0)" ( (binary_expression "param_1 != (char *)0x0" identifier != (cast_expression "(char *)0x0" ( (type_descriptor "char *" primitive_type (abstract_pointer_declarator "*" *)) ) number_literal)) ))) )) (compound_statement "{\n    iVar1 = fileno(__stream);\n    iVar2 = dup2(iVar1,iVar1);\n    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(param_1,param_2,__stream);\n    }\n  }" { (expression_statement "iVar1 = fileno(__stream);" (assignment_expression "iVar1 = fileno(__stream)" identifier = (call_expression "fileno(__stream)" identifier (argument_list "(__stream)" ( identifier )))) ;) (expression_statement "iVar2 = dup2(iVar1,iVar1);" (assignment_expression "iVar2 = dup2(iVar1,iVar1)" identifier = (call_expression "dup2(iVar1,iVar1)" identifier (argument_list "(iVar1,iVar1)" ( identifier , identifier )))) ;) (if_statement "if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(param_1,param_2,__stream);\n    }" if (parenthesized_expression "((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9))" ( (binary_expression "(iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)" (parenthesized_expression "(iVar2 < 0)" ( (binary_expression "iVar2 < 0" identifier < number_literal) )) && (parenthesized_expression "(piVar3 = __errno_location(), *piVar3 == 9)" ( (comma_expression "piVar3 = __errno_location(), *piVar3 == 9" (assignment_expression "piVar3 = __errno_location()" identifier = (call_expression "__errno_location()" identifier (argument_list "()" ( )))) , (binary_expression "*piVar3 == 9" (pointer_expression "*piVar3" * identifier) == number_literal)) ))) )) (compound_statement "{\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(param_1,param_2,__stream);\n    }" { (expression_statement "iVar2 = open64("/dev/null",0x80000);" (assignment_expression "iVar2 = open64("/dev/null",0x80000)" identifier = (call_expression "open64("/dev/null",0x80000)" identifier (argument_list "("/dev/null",0x80000)" ( (string_literal ""/dev/null"" " string_content ") , number_literal )))) ;) (if_statement "if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }" if (parenthesized_expression "(iVar1 != iVar2)" ( (binary_expression "iVar1 != iVar2" identifier != identifier) )) (compound_statement "{\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }" { (expression_statement "iVar1 = dup2(iVar2,iVar1);" (assignment_expression "iVar1 = dup2(iVar2,iVar1)" identifier = (call_expression "dup2(iVar2,iVar1)" identifier (argument_list "(iVar2,iVar1)" ( identifier , identifier )))) ;) (if_statement "if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }" if (parenthesized_expression "(iVar1 < 0)" ( (binary_expression "iVar1 < 0" identifier < number_literal) )) (compound_statement "{\n          close(iVar2);\n          return __stream;\n        }" { (expression_statement "close(iVar2);" (call_expression "close(iVar2)" identifier (argument_list "(iVar2)" ( identifier ))) ;) (return_statement "return __stream;" return identifier ;) })) (expression_statement "close(iVar2);" (call_expression "close(iVar2)" identifier (argument_list "(iVar2)" ( identifier ))) ;) })) (expression_statement "__stream = freopen64(param_1,param_2,__stream);" (assignment_expression "__stream = freopen64(param_1,param_2,__stream)" identifier = (call_expression "freopen64(param_1,param_2,__stream)" identifier (argument_list "(param_1,param_2,__stream)" ( identifier , identifier , identifier )))) ;) })) })) (return_statement "return __stream;" return identifier ;) })))
(translation_unit (function_definition TYPE (pointer_declarator * (function_declarator IDENT (parameter_list ( (parameter_declaration TYPE (pointer_declarator * IDENT)) , (parameter_declaration TYPE (pointer_declarator * IDENT)) , (parameter_declaration TYPE (pointer_declarator * IDENT)) )))) (compound_statement { (declaration TYPE (pointer_declarator * IDENT) ;) (declaration TYPE IDENT ;) (declaration TYPE IDENT ;) (declaration TYPE (pointer_declarator * IDENT) ;) (expression_statement (assignment_expression IDENT = (call_expression IDENT (argument_list ( IDENT , IDENT , IDENT )))) ;) (if_statement if (parenthesized_expression ( (binary_expression (parenthesized_expression ( (binary_expression IDENT != (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) LIT)) )) && (parenthesized_expression ( (binary_expression IDENT != (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) LIT)) ))) )) (compound_statement { (expression_statement (assignment_expression IDENT = (call_expression IDENT (argument_list ( IDENT )))) ;) (expression_statement (assignment_expression IDENT = (call_expression IDENT (argument_list ( IDENT , IDENT )))) ;) (if_statement if (parenthesized_expression ( (binary_expression (parenthesized_expression ( (binary_expression IDENT < LIT) )) && (parenthesized_expression ( (comma_expression (assignment_expression IDENT = (call_expression IDENT (argument_list ( )))) , (binary_expression (pointer_expression * IDENT) == LIT)) ))) )) (compound_statement { (expression_statement (assignment_expression IDENT = (call_expression IDENT (argument_list ( (string_literal " string_content ") , LIT )))) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT != IDENT) )) (compound_statement { (expression_statement (assignment_expression IDENT = (call_expression IDENT (argument_list ( IDENT , IDENT )))) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT < LIT) )) (compound_statement { (expression_statement (call_expression IDENT (argument_list ( IDENT ))) ;) (return_statement return IDENT ;) })) (expression_statement (call_expression IDENT (argument_list ( IDENT ))) ;) })) (expression_statement (assignment_expression IDENT = (call_expression IDENT (argument_list ( IDENT , IDENT , IDENT )))) ;) })) })) (return_statement return IDENT ;) })))
(function_definition "FILE * FUN_00017f20(char *param_1,char *param_2,FILE *param_3)\n\n{\n  FILE *__stream;\n  int iVar1;\n  int iVar2;\n  int *piVar3;\n  \n  __stream = freopen64(param_1,param_2,param_3);\n  if ((__stream != (FILE *)0x0) && (param_1 != (char *)0x0)) {\n    iVar1 = fileno(__stream);\n    iVar2 = dup2(iVar1,iVar1);\n    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(param_1,param_2,__stream);\n    }\n  }\n  return __stream;\n}" (type_identifier "FILE") (pointer_declarator "* FUN_00017f20(char *param_1,char *param_2,FILE *param_3)" (* "*") (function_declarator "FUN_00017f20(char *param_1,char *param_2,FILE *param_3)" (identifier "FUN_00017f20") (parameter_list "(char *param_1,char *param_2,FILE *param_3)" (( "(") (parameter_declaration "char *param_1" (primitive_type "char") (pointer_declarator "*param_1" (* "*") (identifier "param_1"))) (, ",") (parameter_declaration "char *param_2" (primitive_type "char") (pointer_declarator "*param_2" (* "*") (identifier "param_2"))) (, ",") (parameter_declaration "FILE *param_3" (type_identifier "FILE") (pointer_declarator "*param_3" (* "*") (identifier "param_3"))) () ")")))) (compound_statement "{\n  FILE *__stream;\n  int iVar1;\n  int iVar2;\n  int *piVar3;\n  \n  __stream = freopen64(param_1,param_2,param_3);\n  if ((__stream != (FILE *)0x0) && (param_1 != (char *)0x0)) {\n    iVar1 = fileno(__stream);\n    iVar2 = dup2(iVar1,iVar1);\n    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(param_1,param_2,__stream);\n    }\n  }\n  return __stream;\n}" ({ "{") (declaration "FILE *__stream;" (type_identifier "FILE") (pointer_declarator "*__stream" (* "*") (identifier "__stream")) (; ";")) (declaration "int iVar1;" (primitive_type "int") (identifier "iVar1") (; ";")) (declaration "int iVar2;" (primitive_type "int") (identifier "iVar2") (; ";")) (declaration "int *piVar3;" (primitive_type "int") (pointer_declarator "*piVar3" (* "*") (identifier "piVar3")) (; ";")) (expression_statement "__stream = freopen64(param_1,param_2,param_3);" (assignment_expression "__stream = freopen64(param_1,param_2,param_3)" (identifier "__stream") (= "=") (call_expression "freopen64(param_1,param_2,param_3)" (identifier "freopen64") (argument_list "(param_1,param_2,param_3)" (( "(") (identifier "param_1") (, ",") (identifier "param_2") (, ",") (identifier "param_3") () ")")))) (; ";")) (if_statement "if ((__stream != (FILE *)0x0) && (param_1 != (char *)0x0)) {\n    iVar1 = fileno(__stream);\n    iVar2 = dup2(iVar1,iVar1);\n    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(param_1,param_2,__stream);\n    }\n  }" (if "if") (parenthesized_expression "((__stream != (FILE *)0x0) && (param_1 != (char *)0x0))" (( "(") (binary_expression "(__stream != (FILE *)0x0) && (param_1 != (char *)0x0)" (parenthesized_expression "(__stream != (FILE *)0x0)" (( "(") (binary_expression "__stream != (FILE *)0x0" (identifier "__stream") (!= "!=") (cast_expression "(FILE *)0x0" (( "(") (type_descriptor "FILE *" (type_identifier "FILE") (abstract_pointer_declarator "*" (* "*"))) () ")") (number_literal "0x0"))) () ")")) (&& "&&") (parenthesized_expression "(param_1 != (char *)0x0)" (( "(") (binary_expression "param_1 != (char *)0x0" (identifier "param_1") (!= "!=") (cast_expression "(char *)0x0" (( "(") (type_descriptor "char *" (primitive_type "char") (abstract_pointer_declarator "*" (* "*"))) () ")") (number_literal "0x0"))) () ")"))) () ")")) (compound_statement "{\n    iVar1 = fileno(__stream);\n    iVar2 = dup2(iVar1,iVar1);\n    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(param_1,param_2,__stream);\n    }\n  }" ({ "{") (expression_statement "iVar1 = fileno(__stream);" (assignment_expression "iVar1 = fileno(__stream)" (identifier "iVar1") (= "=") (call_expression "fileno(__stream)" (identifier "fileno") (argument_list "(__stream)" (( "(") (identifier "__stream") () ")")))) (; ";")) (expression_statement "iVar2 = dup2(iVar1,iVar1);" (assignment_expression "iVar2 = dup2(iVar1,iVar1)" (identifier "iVar2") (= "=") (call_expression "dup2(iVar1,iVar1)" (identifier "dup2") (argument_list "(iVar1,iVar1)" (( "(") (identifier "iVar1") (, ",") (identifier "iVar1") () ")")))) (; ";")) (if_statement "if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(param_1,param_2,__stream);\n    }" (if "if") (parenthesized_expression "((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9))" (( "(") (binary_expression "(iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)" (parenthesized_expression "(iVar2 < 0)" (( "(") (binary_expression "iVar2 < 0" (identifier "iVar2") (< "<") (number_literal "0")) () ")")) (&& "&&") (parenthesized_expression "(piVar3 = __errno_location(), *piVar3 == 9)" (( "(") (comma_expression "piVar3 = __errno_location(), *piVar3 == 9" (assignment_expression "piVar3 = __errno_location()" (identifier "piVar3") (= "=") (call_expression "__errno_location()" (identifier "__errno_location") (argument_list "()" (( "(") () ")")))) (, ",") (binary_expression "*piVar3 == 9" (pointer_expression "*piVar3" (* "*") (identifier "piVar3")) (== "==") (number_literal "9"))) () ")"))) () ")")) (compound_statement "{\n      iVar2 = open64("/dev/null",0x80000);\n      if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }\n      __stream = freopen64(param_1,param_2,__stream);\n    }" ({ "{") (expression_statement "iVar2 = open64("/dev/null",0x80000);" (assignment_expression "iVar2 = open64("/dev/null",0x80000)" (identifier "iVar2") (= "=") (call_expression "open64("/dev/null",0x80000)" (identifier "open64") (argument_list "("/dev/null",0x80000)" (( "(") (string_literal ""/dev/null"" (" """) (string_content "/dev/null") (" """)) (, ",") (number_literal "0x80000") () ")")))) (; ";")) (if_statement "if (iVar1 != iVar2) {\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }" (if "if") (parenthesized_expression "(iVar1 != iVar2)" (( "(") (binary_expression "iVar1 != iVar2" (identifier "iVar1") (!= "!=") (identifier "iVar2")) () ")")) (compound_statement "{\n        iVar1 = dup2(iVar2,iVar1);\n        if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }\n        close(iVar2);\n      }" ({ "{") (expression_statement "iVar1 = dup2(iVar2,iVar1);" (assignment_expression "iVar1 = dup2(iVar2,iVar1)" (identifier "iVar1") (= "=") (call_expression "dup2(iVar2,iVar1)" (identifier "dup2") (argument_list "(iVar2,iVar1)" (( "(") (identifier "iVar2") (, ",") (identifier "iVar1") () ")")))) (; ";")) (if_statement "if (iVar1 < 0) {\n          close(iVar2);\n          return __stream;\n        }" (if "if") (parenthesized_expression "(iVar1 < 0)" (( "(") (binary_expression "iVar1 < 0" (identifier "iVar1") (< "<") (number_literal "0")) () ")")) (compound_statement "{\n          close(iVar2);\n          return __stream;\n        }" ({ "{") (expression_statement "close(iVar2);" (call_expression "close(iVar2)" (identifier "close") (argument_list "(iVar2)" (( "(") (identifier "iVar2") () ")"))) (; ";")) (return_statement "return __stream;" (return "return") (identifier "__stream") (; ";")) (} "}"))) (expression_statement "close(iVar2);" (call_expression "close(iVar2)" (identifier "close") (argument_list "(iVar2)" (( "(") (identifier "iVar2") () ")"))) (; ";")) (} "}"))) (expression_statement "__stream = freopen64(param_1,param_2,__stream);" (assignment_expression "__stream = freopen64(param_1,param_2,__stream)" (identifier "__stream") (= "=") (call_expression "freopen64(param_1,param_2,__stream)" (identifier "freopen64") (argument_list "(param_1,param_2,__stream)" (( "(") (identifier "param_1") (, ",") (identifier "param_2") (, ",") (identifier "__stream") () ")")))) (; ";")) (} "}"))) (} "}"))) (return_statement "return __stream;" (return "return") (identifier "__stream") (; ";")) (} "}")))

/* WARNING: Function: __x86.get_pc_thunk.bx replaced with injection: get_pc_thunk_bx */
/* WARNING: Unknown calling convention */

type_1 * function_1(char *var_3,char *mode,type_1 *stream)

{
  type_1 *var_2;
  int var_9;
  int var_6;
  int *piVar3;
  
  var_2 = var_1(var_3,mode,(type_1 *)stream);
  if ((var_2 != (type_1 *)0x0) && (var_3 != (char *)0x0)) {
    var_9 = var_4(var_2);
    var_6 = var_5(var_9,var_9);
    if ((var_6 < 0) && (piVar3 = var_7(), *piVar3 == 9)) {
      var_6 = var_8("/dev/null",0x80000);
      if (var_9 != var_6) {
        var_9 = var_5(var_6,var_9);
        if (var_9 < 0) {
          var_10(var_6);
          return (type_1 *)var_2;
        }
        var_10(var_6);
      }
      var_2 = var_1(var_3,mode,var_2);
    }
  }
  return (type_1 *)var_2;
}


(translation_unit (function_definition type: (type_identifier) declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) parameters: (parameter_list (parameter_declaration type: (primitive_type) declarator: (pointer_declarator declarator: (identifier))) (parameter_declaration type: (primitive_type) declarator: (pointer_declarator declarator: (identifier))) (parameter_declaration type: (type_identifier) declarator: (pointer_declarator declarator: (identifier)))))) body: (compound_statement (declaration type: (type_identifier) declarator: (pointer_declarator declarator: (identifier))) (declaration type: (primitive_type) declarator: (identifier)) (declaration type: (primitive_type) declarator: (identifier)) (declaration type: (primitive_type) declarator: (pointer_declarator declarator: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (call_expression function: (identifier) arguments: (argument_list (identifier) (identifier) (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (cast_expression type: (type_descriptor type: (type_identifier) declarator: (abstract_pointer_declarator)) value: (number_literal)))) right: (parenthesized_expression (binary_expression left: (identifier) right: (cast_expression type: (type_descriptor type: (primitive_type) declarator: (abstract_pointer_declarator)) value: (number_literal)))))) consequence: (compound_statement (expression_statement (assignment_expression left: (identifier) right: (call_expression function: (identifier) arguments: (argument_list (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (call_expression function: (identifier) arguments: (argument_list (identifier) (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (number_literal))) right: (parenthesized_expression (comma_expression left: (assignment_expression left: (identifier) right: (call_expression function: (identifier) arguments: (argument_list))) right: (binary_expression left: (pointer_expression argument: (identifier)) right: (number_literal)))))) consequence: (compound_statement (expression_statement (assignment_expression left: (identifier) right: (call_expression function: (identifier) arguments: (argument_list (string_literal (string_content)) (number_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (compound_statement (expression_statement (assignment_expression left: (identifier) right: (call_expression function: (identifier) arguments: (argument_list (identifier) (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (number_literal))) consequence: (compound_statement (expression_statement (call_expression function: (identifier) arguments: (argument_list (identifier)))) (return_statement (identifier)))) (expression_statement (call_expression function: (identifier) arguments: (argument_list (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (call_expression function: (identifier) arguments: (argument_list (identifier) (identifier) (identifier))))))))) (return_statement (identifier)))))

/* WARNING: Function: __i686.get_pc_thunk.bx replaced with injection: get_pc_thunk_bx */

FILE * MASKED(char *param_1,char *param_2,FILE *param_3)

{
  FILE *__stream;
  int iVar1;
  int iVar2;
  int *piVar3;
  
  __stream = freopen64(param_1,param_2,param_3);
  if ((__stream != (FILE *)0x0) && (param_1 != (char *)0x0)) {
    iVar1 = fileno(__stream);
    iVar2 = dup2(iVar1,iVar1);
    if ((iVar2 < 0) && (piVar3 = __errno_location(), *piVar3 == 9)) {
      iVar2 = open64("/dev/null",0x80000);
      if (iVar1 != iVar2) {
        iVar1 = dup2(iVar2,iVar1);
        if (iVar1 < 0) {
          close(iVar2);
          return __stream;
        }
        close(iVar2);
      }
      __stream = freopen64(param_1,param_2,__stream);
    }
  }
  return __stream;
}

