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

DIR * opendir_safer(char *name)

{
  DIR *__dirp;
  uint fd;
  int __fd;
  int *piVar1;
  DIR *pDVar2;
  undefined4 local_24;
  
  __dirp = opendir(name);
  if (__dirp != (DIR *)0x0) {
    fd = dirfd(__dirp);
    if (fd < 3) {
      __fd = rpl_fcntl(fd,0x406,3);
      piVar1 = __errno_location();
      if (__fd < 0) {
        local_24 = *piVar1;
        pDVar2 = (DIR *)0x0;
      }
      else {
        pDVar2 = fdopendir(__fd);
        local_24 = *piVar1;
        if (pDVar2 == (DIR *)0x0) {
          close(__fd);
        }
      }
      closedir(__dirp);
      *piVar1 = local_24;
      return (DIR *)pDVar2;
    }
  }
  return (DIR *)__dirp;
}



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

DIR * FUN_0001cc60(char *param_1)

{
  DIR *__dirp;
  uint uVar1;
  int __fd;
  int *piVar2;
  DIR *pDVar3;
  undefined4 local_24;
  
  __dirp = opendir(param_1);
  if (__dirp != (DIR *)0x0) {
    uVar1 = dirfd(__dirp);
    if (uVar1 < 3) {
      __fd = FUN_00024aa0(uVar1,0x406,3);
      piVar2 = __errno_location();
      if (__fd < 0) {
        local_24 = *piVar2;
        pDVar3 = (DIR *)0x0;
      }
      else {
        pDVar3 = fdopendir(__fd);
        local_24 = *piVar2;
        if (pDVar3 == (DIR *)0x0) {
          close(__fd);
        }
      }
      closedir(__dirp);
      *piVar2 = local_24;
      return pDVar3;
    }
  }
  return __dirp;
}


PUSH EBP
PUSH EDI
PUSH ESI
PUSH EBX
CALL 0x00013950
ADD EBX,0x1e397
SUB ESP,0x28
PUSH dword ptr [ESP + 0x3c]
CALL 0x00012a00
ADD ESP,0x10
MOV ESI,EAX
TEST EAX,EAX
JZ 0x0001cc95
SUB ESP,0xc
PUSH EAX
CALL 0x00012170
ADD ESP,0x10
CMP EAX,0x2
JBE 0x0001cca0
ADD ESP,0x1c
MOV EAX,ESI
POP EBX
POP ESI
POP EDI
POP EBP
RET
SUB ESP,0x4
PUSH 0x3
PUSH 0x406
PUSH EAX
CALL 0x00024aa0
MOV EDI,EAX
CALL 0x00012640
ADD ESP,0x10
MOV EBP,EAX
TEST EDI,EDI
JNS 0x0001ccf0
MOV EAX,dword ptr [EAX]
XOR EDX,EDX
MOV dword ptr [ESP + 0x8],EAX
MOV dword ptr [ESP + 0xc],EDX
SUB ESP,0xc
PUSH ESI
CALL 0x000129c0
MOV EAX,dword ptr [ESP + 0x18]
ADD ESP,0x10
MOV EDX,dword ptr [ESP + 0xc]
MOV dword ptr [EBP],EAX
MOV ESI,EDX
ADD ESP,0x1c
POP EBX
MOV EAX,ESI
POP ESI
POP EDI
POP EBP
RET
SUB ESP,0xc
PUSH EDI
CALL 0x000127f0
MOV EDX,EAX
MOV EAX,dword ptr [EBP]
MOV dword ptr [ESP + 0x18],EAX
ADD ESP,0x10
TEST EDX,EDX
JNZ 0x0001ccc8
MOV dword ptr [ESP + 0xc],EDX
SUB ESP,0xc
PUSH EDI
CALL 0x000129b0
ADD ESP,0x10
MOV EDX,dword ptr [ESP + 0xc]
JMP 0x0001ccc8
(translation_unit "/* WARNING: Function: __i686.get_pc_thunk.bx replaced with injection: get_pc_thunk_bx */\n\nDIR * FUN_0001cc60(char *param_1)\n\n{\n  DIR *__dirp;\n  uint uVar1;\n  int __fd;\n  int *piVar2;\n  DIR *pDVar3;\n  undefined4 local_24;\n  \n  __dirp = opendir(param_1);\n  if (__dirp != (DIR *)0x0) {\n    uVar1 = dirfd(__dirp);\n    if (uVar1 < 3) {\n      __fd = FUN_00024aa0(uVar1,0x406,3);\n      piVar2 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar2 = local_24;\n      return pDVar3;\n    }\n  }\n  return __dirp;\n}\n\n" comment (function_definition "DIR * FUN_0001cc60(char *param_1)\n\n{\n  DIR *__dirp;\n  uint uVar1;\n  int __fd;\n  int *piVar2;\n  DIR *pDVar3;\n  undefined4 local_24;\n  \n  __dirp = opendir(param_1);\n  if (__dirp != (DIR *)0x0) {\n    uVar1 = dirfd(__dirp);\n    if (uVar1 < 3) {\n      __fd = FUN_00024aa0(uVar1,0x406,3);\n      piVar2 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar2 = local_24;\n      return pDVar3;\n    }\n  }\n  return __dirp;\n}" type_identifier (pointer_declarator "* FUN_0001cc60(char *param_1)" * (function_declarator "FUN_0001cc60(char *param_1)" identifier (parameter_list "(char *param_1)" ( (parameter_declaration "char *param_1" primitive_type (pointer_declarator "*param_1" * identifier)) )))) (compound_statement "{\n  DIR *__dirp;\n  uint uVar1;\n  int __fd;\n  int *piVar2;\n  DIR *pDVar3;\n  undefined4 local_24;\n  \n  __dirp = opendir(param_1);\n  if (__dirp != (DIR *)0x0) {\n    uVar1 = dirfd(__dirp);\n    if (uVar1 < 3) {\n      __fd = FUN_00024aa0(uVar1,0x406,3);\n      piVar2 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar2 = local_24;\n      return pDVar3;\n    }\n  }\n  return __dirp;\n}" { (declaration "DIR *__dirp;" type_identifier (pointer_declarator "*__dirp" * identifier) ;) (declaration "uint uVar1;" type_identifier identifier ;) (declaration "int __fd;" primitive_type identifier ;) (declaration "int *piVar2;" primitive_type (pointer_declarator "*piVar2" * identifier) ;) (declaration "DIR *pDVar3;" type_identifier (pointer_declarator "*pDVar3" * identifier) ;) (declaration "undefined4 local_24;" type_identifier identifier ;) (expression_statement "__dirp = opendir(param_1);" (assignment_expression "__dirp = opendir(param_1)" identifier = (call_expression "opendir(param_1)" identifier (argument_list "(param_1)" ( identifier )))) ;) (if_statement "if (__dirp != (DIR *)0x0) {\n    uVar1 = dirfd(__dirp);\n    if (uVar1 < 3) {\n      __fd = FUN_00024aa0(uVar1,0x406,3);\n      piVar2 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar2 = local_24;\n      return pDVar3;\n    }\n  }" if (parenthesized_expression "(__dirp != (DIR *)0x0)" ( (binary_expression "__dirp != (DIR *)0x0" identifier != (cast_expression "(DIR *)0x0" ( (type_descriptor "DIR *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal)) )) (compound_statement "{\n    uVar1 = dirfd(__dirp);\n    if (uVar1 < 3) {\n      __fd = FUN_00024aa0(uVar1,0x406,3);\n      piVar2 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar2 = local_24;\n      return pDVar3;\n    }\n  }" { (expression_statement "uVar1 = dirfd(__dirp);" (assignment_expression "uVar1 = dirfd(__dirp)" identifier = (call_expression "dirfd(__dirp)" identifier (argument_list "(__dirp)" ( identifier )))) ;) (if_statement "if (uVar1 < 3) {\n      __fd = FUN_00024aa0(uVar1,0x406,3);\n      piVar2 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar2 = local_24;\n      return pDVar3;\n    }" if (parenthesized_expression "(uVar1 < 3)" ( (binary_expression "uVar1 < 3" identifier < number_literal) )) (compound_statement "{\n      __fd = FUN_00024aa0(uVar1,0x406,3);\n      piVar2 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar2 = local_24;\n      return pDVar3;\n    }" { (expression_statement "__fd = FUN_00024aa0(uVar1,0x406,3);" (assignment_expression "__fd = FUN_00024aa0(uVar1,0x406,3)" identifier = (call_expression "FUN_00024aa0(uVar1,0x406,3)" identifier (argument_list "(uVar1,0x406,3)" ( identifier , number_literal , number_literal )))) ;) (expression_statement "piVar2 = __errno_location();" (assignment_expression "piVar2 = __errno_location()" identifier = (call_expression "__errno_location()" identifier (argument_list "()" ( )))) ;) (if_statement "if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }" if (parenthesized_expression "(__fd < 0)" ( (binary_expression "__fd < 0" identifier < number_literal) )) (compound_statement "{\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }" { (expression_statement "local_24 = *piVar2;" (assignment_expression "local_24 = *piVar2" identifier = (pointer_expression "*piVar2" * identifier)) ;) (expression_statement "pDVar3 = (DIR *)0x0;" (assignment_expression "pDVar3 = (DIR *)0x0" identifier = (cast_expression "(DIR *)0x0" ( (type_descriptor "DIR *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal)) ;) }) (else_clause "else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }" else (compound_statement "{\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }" { (expression_statement "pDVar3 = fdopendir(__fd);" (assignment_expression "pDVar3 = fdopendir(__fd)" identifier = (call_expression "fdopendir(__fd)" identifier (argument_list "(__fd)" ( identifier )))) ;) (expression_statement "local_24 = *piVar2;" (assignment_expression "local_24 = *piVar2" identifier = (pointer_expression "*piVar2" * identifier)) ;) (if_statement "if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }" if (parenthesized_expression "(pDVar3 == (DIR *)0x0)" ( (binary_expression "pDVar3 == (DIR *)0x0" identifier == (cast_expression "(DIR *)0x0" ( (type_descriptor "DIR *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal)) )) (compound_statement "{\n          close(__fd);\n        }" { (expression_statement "close(__fd);" (call_expression "close(__fd)" identifier (argument_list "(__fd)" ( identifier ))) ;) })) }))) (expression_statement "closedir(__dirp);" (call_expression "closedir(__dirp)" identifier (argument_list "(__dirp)" ( identifier ))) ;) (expression_statement "*piVar2 = local_24;" (assignment_expression "*piVar2 = local_24" (pointer_expression "*piVar2" * identifier) = identifier) ;) (return_statement "return pDVar3;" return identifier ;) })) })) (return_statement "return __dirp;" return identifier ;) })))
(translation_unit "/* WARNING: Function: __x86.get_pc_thunk.bx replaced with injection: get_pc_thunk_bx */\n/* WARNING: Unknown calling convention */\n\nDIR * opendir_safer(char *name)\n\n{\n  DIR *__dirp;\n  uint fd;\n  int __fd;\n  int *piVar1;\n  DIR *pDVar2;\n  undefined4 local_24;\n  \n  __dirp = opendir(name);\n  if (__dirp != (DIR *)0x0) {\n    fd = dirfd(__dirp);\n    if (fd < 3) {\n      __fd = rpl_fcntl(fd,0x406,3);\n      piVar1 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar1;\n        pDVar2 = (DIR *)0x0;\n      }\n      else {\n        pDVar2 = fdopendir(__fd);\n        local_24 = *piVar1;\n        if (pDVar2 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar1 = local_24;\n      return (DIR *)pDVar2;\n    }\n  }\n  return (DIR *)__dirp;\n}\n\n" comment comment (function_definition "DIR * opendir_safer(char *name)\n\n{\n  DIR *__dirp;\n  uint fd;\n  int __fd;\n  int *piVar1;\n  DIR *pDVar2;\n  undefined4 local_24;\n  \n  __dirp = opendir(name);\n  if (__dirp != (DIR *)0x0) {\n    fd = dirfd(__dirp);\n    if (fd < 3) {\n      __fd = rpl_fcntl(fd,0x406,3);\n      piVar1 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar1;\n        pDVar2 = (DIR *)0x0;\n      }\n      else {\n        pDVar2 = fdopendir(__fd);\n        local_24 = *piVar1;\n        if (pDVar2 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar1 = local_24;\n      return (DIR *)pDVar2;\n    }\n  }\n  return (DIR *)__dirp;\n}" type_identifier (pointer_declarator "* opendir_safer(char *name)" * (function_declarator "opendir_safer(char *name)" identifier (parameter_list "(char *name)" ( (parameter_declaration "char *name" primitive_type (pointer_declarator "*name" * identifier)) )))) (compound_statement "{\n  DIR *__dirp;\n  uint fd;\n  int __fd;\n  int *piVar1;\n  DIR *pDVar2;\n  undefined4 local_24;\n  \n  __dirp = opendir(name);\n  if (__dirp != (DIR *)0x0) {\n    fd = dirfd(__dirp);\n    if (fd < 3) {\n      __fd = rpl_fcntl(fd,0x406,3);\n      piVar1 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar1;\n        pDVar2 = (DIR *)0x0;\n      }\n      else {\n        pDVar2 = fdopendir(__fd);\n        local_24 = *piVar1;\n        if (pDVar2 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar1 = local_24;\n      return (DIR *)pDVar2;\n    }\n  }\n  return (DIR *)__dirp;\n}" { (declaration "DIR *__dirp;" type_identifier (pointer_declarator "*__dirp" * identifier) ;) (declaration "uint fd;" type_identifier identifier ;) (declaration "int __fd;" primitive_type identifier ;) (declaration "int *piVar1;" primitive_type (pointer_declarator "*piVar1" * identifier) ;) (declaration "DIR *pDVar2;" type_identifier (pointer_declarator "*pDVar2" * identifier) ;) (declaration "undefined4 local_24;" type_identifier identifier ;) (expression_statement "__dirp = opendir(name);" (assignment_expression "__dirp = opendir(name)" identifier = (call_expression "opendir(name)" identifier (argument_list "(name)" ( identifier )))) ;) (if_statement "if (__dirp != (DIR *)0x0) {\n    fd = dirfd(__dirp);\n    if (fd < 3) {\n      __fd = rpl_fcntl(fd,0x406,3);\n      piVar1 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar1;\n        pDVar2 = (DIR *)0x0;\n      }\n      else {\n        pDVar2 = fdopendir(__fd);\n        local_24 = *piVar1;\n        if (pDVar2 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar1 = local_24;\n      return (DIR *)pDVar2;\n    }\n  }" if (parenthesized_expression "(__dirp != (DIR *)0x0)" ( (binary_expression "__dirp != (DIR *)0x0" identifier != (cast_expression "(DIR *)0x0" ( (type_descriptor "DIR *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal)) )) (compound_statement "{\n    fd = dirfd(__dirp);\n    if (fd < 3) {\n      __fd = rpl_fcntl(fd,0x406,3);\n      piVar1 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar1;\n        pDVar2 = (DIR *)0x0;\n      }\n      else {\n        pDVar2 = fdopendir(__fd);\n        local_24 = *piVar1;\n        if (pDVar2 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar1 = local_24;\n      return (DIR *)pDVar2;\n    }\n  }" { (expression_statement "fd = dirfd(__dirp);" (assignment_expression "fd = dirfd(__dirp)" identifier = (call_expression "dirfd(__dirp)" identifier (argument_list "(__dirp)" ( identifier )))) ;) (if_statement "if (fd < 3) {\n      __fd = rpl_fcntl(fd,0x406,3);\n      piVar1 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar1;\n        pDVar2 = (DIR *)0x0;\n      }\n      else {\n        pDVar2 = fdopendir(__fd);\n        local_24 = *piVar1;\n        if (pDVar2 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar1 = local_24;\n      return (DIR *)pDVar2;\n    }" if (parenthesized_expression "(fd < 3)" ( (binary_expression "fd < 3" identifier < number_literal) )) (compound_statement "{\n      __fd = rpl_fcntl(fd,0x406,3);\n      piVar1 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar1;\n        pDVar2 = (DIR *)0x0;\n      }\n      else {\n        pDVar2 = fdopendir(__fd);\n        local_24 = *piVar1;\n        if (pDVar2 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar1 = local_24;\n      return (DIR *)pDVar2;\n    }" { (expression_statement "__fd = rpl_fcntl(fd,0x406,3);" (assignment_expression "__fd = rpl_fcntl(fd,0x406,3)" identifier = (call_expression "rpl_fcntl(fd,0x406,3)" identifier (argument_list "(fd,0x406,3)" ( identifier , number_literal , number_literal )))) ;) (expression_statement "piVar1 = __errno_location();" (assignment_expression "piVar1 = __errno_location()" identifier = (call_expression "__errno_location()" identifier (argument_list "()" ( )))) ;) (if_statement "if (__fd < 0) {\n        local_24 = *piVar1;\n        pDVar2 = (DIR *)0x0;\n      }\n      else {\n        pDVar2 = fdopendir(__fd);\n        local_24 = *piVar1;\n        if (pDVar2 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }" if (parenthesized_expression "(__fd < 0)" ( (binary_expression "__fd < 0" identifier < number_literal) )) (compound_statement "{\n        local_24 = *piVar1;\n        pDVar2 = (DIR *)0x0;\n      }" { (expression_statement "local_24 = *piVar1;" (assignment_expression "local_24 = *piVar1" identifier = (pointer_expression "*piVar1" * identifier)) ;) (expression_statement "pDVar2 = (DIR *)0x0;" (assignment_expression "pDVar2 = (DIR *)0x0" identifier = (cast_expression "(DIR *)0x0" ( (type_descriptor "DIR *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal)) ;) }) (else_clause "else {\n        pDVar2 = fdopendir(__fd);\n        local_24 = *piVar1;\n        if (pDVar2 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }" else (compound_statement "{\n        pDVar2 = fdopendir(__fd);\n        local_24 = *piVar1;\n        if (pDVar2 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }" { (expression_statement "pDVar2 = fdopendir(__fd);" (assignment_expression "pDVar2 = fdopendir(__fd)" identifier = (call_expression "fdopendir(__fd)" identifier (argument_list "(__fd)" ( identifier )))) ;) (expression_statement "local_24 = *piVar1;" (assignment_expression "local_24 = *piVar1" identifier = (pointer_expression "*piVar1" * identifier)) ;) (if_statement "if (pDVar2 == (DIR *)0x0) {\n          close(__fd);\n        }" if (parenthesized_expression "(pDVar2 == (DIR *)0x0)" ( (binary_expression "pDVar2 == (DIR *)0x0" identifier == (cast_expression "(DIR *)0x0" ( (type_descriptor "DIR *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal)) )) (compound_statement "{\n          close(__fd);\n        }" { (expression_statement "close(__fd);" (call_expression "close(__fd)" identifier (argument_list "(__fd)" ( identifier ))) ;) })) }))) (expression_statement "closedir(__dirp);" (call_expression "closedir(__dirp)" identifier (argument_list "(__dirp)" ( identifier ))) ;) (expression_statement "*piVar1 = local_24;" (assignment_expression "*piVar1 = local_24" (pointer_expression "*piVar1" * identifier) = identifier) ;) (return_statement "return (DIR *)pDVar2;" return (cast_expression "(DIR *)pDVar2" ( (type_descriptor "DIR *" type_identifier (abstract_pointer_declarator "*" *)) ) identifier) ;) })) })) (return_statement "return (DIR *)__dirp;" return (cast_expression "(DIR *)__dirp" ( (type_descriptor "DIR *" type_identifier (abstract_pointer_declarator "*" *)) ) identifier) ;) })))
(translation_unit "DIR * FUN_0001cc60(char *param_1)\n\n{\n  DIR *__dirp;\n  uint uVar1;\n  int __fd;\n  int *piVar2;\n  DIR *pDVar3;\n  undefined4 local_24;\n  \n  __dirp = opendir(param_1);\n  if (__dirp != (DIR *)0x0) {\n    uVar1 = dirfd(__dirp);\n    if (uVar1 < 3) {\n      __fd = FUN_00024aa0(uVar1,0x406,3);\n      piVar2 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar2 = local_24;\n      return pDVar3;\n    }\n  }\n  return __dirp;\n}\n\n" (function_definition "DIR * FUN_0001cc60(char *param_1)\n\n{\n  DIR *__dirp;\n  uint uVar1;\n  int __fd;\n  int *piVar2;\n  DIR *pDVar3;\n  undefined4 local_24;\n  \n  __dirp = opendir(param_1);\n  if (__dirp != (DIR *)0x0) {\n    uVar1 = dirfd(__dirp);\n    if (uVar1 < 3) {\n      __fd = FUN_00024aa0(uVar1,0x406,3);\n      piVar2 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar2 = local_24;\n      return pDVar3;\n    }\n  }\n  return __dirp;\n}" type_identifier (pointer_declarator "* FUN_0001cc60(char *param_1)" * (function_declarator "FUN_0001cc60(char *param_1)" identifier (parameter_list "(char *param_1)" ( (parameter_declaration "char *param_1" primitive_type (pointer_declarator "*param_1" * identifier)) )))) (compound_statement "{\n  DIR *__dirp;\n  uint uVar1;\n  int __fd;\n  int *piVar2;\n  DIR *pDVar3;\n  undefined4 local_24;\n  \n  __dirp = opendir(param_1);\n  if (__dirp != (DIR *)0x0) {\n    uVar1 = dirfd(__dirp);\n    if (uVar1 < 3) {\n      __fd = FUN_00024aa0(uVar1,0x406,3);\n      piVar2 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar2 = local_24;\n      return pDVar3;\n    }\n  }\n  return __dirp;\n}" { (declaration "DIR *__dirp;" type_identifier (pointer_declarator "*__dirp" * identifier) ;) (declaration "uint uVar1;" type_identifier identifier ;) (declaration "int __fd;" primitive_type identifier ;) (declaration "int *piVar2;" primitive_type (pointer_declarator "*piVar2" * identifier) ;) (declaration "DIR *pDVar3;" type_identifier (pointer_declarator "*pDVar3" * identifier) ;) (declaration "undefined4 local_24;" type_identifier identifier ;) (expression_statement "__dirp = opendir(param_1);" (assignment_expression "__dirp = opendir(param_1)" identifier = (call_expression "opendir(param_1)" identifier (argument_list "(param_1)" ( identifier )))) ;) (if_statement "if (__dirp != (DIR *)0x0) {\n    uVar1 = dirfd(__dirp);\n    if (uVar1 < 3) {\n      __fd = FUN_00024aa0(uVar1,0x406,3);\n      piVar2 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar2 = local_24;\n      return pDVar3;\n    }\n  }" if (parenthesized_expression "(__dirp != (DIR *)0x0)" ( (binary_expression "__dirp != (DIR *)0x0" identifier != (cast_expression "(DIR *)0x0" ( (type_descriptor "DIR *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal)) )) (compound_statement "{\n    uVar1 = dirfd(__dirp);\n    if (uVar1 < 3) {\n      __fd = FUN_00024aa0(uVar1,0x406,3);\n      piVar2 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar2 = local_24;\n      return pDVar3;\n    }\n  }" { (expression_statement "uVar1 = dirfd(__dirp);" (assignment_expression "uVar1 = dirfd(__dirp)" identifier = (call_expression "dirfd(__dirp)" identifier (argument_list "(__dirp)" ( identifier )))) ;) (if_statement "if (uVar1 < 3) {\n      __fd = FUN_00024aa0(uVar1,0x406,3);\n      piVar2 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar2 = local_24;\n      return pDVar3;\n    }" if (parenthesized_expression "(uVar1 < 3)" ( (binary_expression "uVar1 < 3" identifier < number_literal) )) (compound_statement "{\n      __fd = FUN_00024aa0(uVar1,0x406,3);\n      piVar2 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar2 = local_24;\n      return pDVar3;\n    }" { (expression_statement "__fd = FUN_00024aa0(uVar1,0x406,3);" (assignment_expression "__fd = FUN_00024aa0(uVar1,0x406,3)" identifier = (call_expression "FUN_00024aa0(uVar1,0x406,3)" identifier (argument_list "(uVar1,0x406,3)" ( identifier , number_literal , number_literal )))) ;) (expression_statement "piVar2 = __errno_location();" (assignment_expression "piVar2 = __errno_location()" identifier = (call_expression "__errno_location()" identifier (argument_list "()" ( )))) ;) (if_statement "if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }" if (parenthesized_expression "(__fd < 0)" ( (binary_expression "__fd < 0" identifier < number_literal) )) (compound_statement "{\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }" { (expression_statement "local_24 = *piVar2;" (assignment_expression "local_24 = *piVar2" identifier = (pointer_expression "*piVar2" * identifier)) ;) (expression_statement "pDVar3 = (DIR *)0x0;" (assignment_expression "pDVar3 = (DIR *)0x0" identifier = (cast_expression "(DIR *)0x0" ( (type_descriptor "DIR *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal)) ;) }) (else_clause "else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }" else (compound_statement "{\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }" { (expression_statement "pDVar3 = fdopendir(__fd);" (assignment_expression "pDVar3 = fdopendir(__fd)" identifier = (call_expression "fdopendir(__fd)" identifier (argument_list "(__fd)" ( identifier )))) ;) (expression_statement "local_24 = *piVar2;" (assignment_expression "local_24 = *piVar2" identifier = (pointer_expression "*piVar2" * identifier)) ;) (if_statement "if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }" if (parenthesized_expression "(pDVar3 == (DIR *)0x0)" ( (binary_expression "pDVar3 == (DIR *)0x0" identifier == (cast_expression "(DIR *)0x0" ( (type_descriptor "DIR *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal)) )) (compound_statement "{\n          close(__fd);\n        }" { (expression_statement "close(__fd);" (call_expression "close(__fd)" identifier (argument_list "(__fd)" ( identifier ))) ;) })) }))) (expression_statement "closedir(__dirp);" (call_expression "closedir(__dirp)" identifier (argument_list "(__dirp)" ( identifier ))) ;) (expression_statement "*piVar2 = local_24;" (assignment_expression "*piVar2 = local_24" (pointer_expression "*piVar2" * identifier) = identifier) ;) (return_statement "return pDVar3;" return identifier ;) })) })) (return_statement "return __dirp;" return identifier ;) })))
(translation_unit (function_definition TYPE (pointer_declarator * (function_declarator IDENT (parameter_list ( (parameter_declaration TYPE (pointer_declarator * IDENT)) )))) (compound_statement { (declaration TYPE (pointer_declarator * IDENT) ;) (declaration TYPE IDENT ;) (declaration TYPE IDENT ;) (declaration TYPE (pointer_declarator * IDENT) ;) (declaration TYPE (pointer_declarator * IDENT) ;) (declaration TYPE IDENT ;) (expression_statement (assignment_expression IDENT = (call_expression IDENT (argument_list ( IDENT )))) ;) (if_statement if (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 )))) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT < LIT) )) (compound_statement { (expression_statement (assignment_expression IDENT = (call_expression IDENT (argument_list ( IDENT , LIT , LIT )))) ;) (expression_statement (assignment_expression IDENT = (call_expression IDENT (argument_list ( )))) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT < LIT) )) (compound_statement { (expression_statement (assignment_expression IDENT = (pointer_expression * IDENT)) ;) (expression_statement (assignment_expression IDENT = (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) LIT)) ;) }) (else_clause else (compound_statement { (expression_statement (assignment_expression IDENT = (call_expression IDENT (argument_list ( IDENT )))) ;) (expression_statement (assignment_expression IDENT = (pointer_expression * IDENT)) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT == (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) LIT)) )) (compound_statement { (expression_statement (call_expression IDENT (argument_list ( IDENT ))) ;) })) }))) (expression_statement (call_expression IDENT (argument_list ( IDENT ))) ;) (expression_statement (assignment_expression (pointer_expression * IDENT) = IDENT) ;) (return_statement return IDENT ;) })) })) (return_statement return IDENT ;) })))
(function_definition "DIR * FUN_0001cc60(char *param_1)\n\n{\n  DIR *__dirp;\n  uint uVar1;\n  int __fd;\n  int *piVar2;\n  DIR *pDVar3;\n  undefined4 local_24;\n  \n  __dirp = opendir(param_1);\n  if (__dirp != (DIR *)0x0) {\n    uVar1 = dirfd(__dirp);\n    if (uVar1 < 3) {\n      __fd = FUN_00024aa0(uVar1,0x406,3);\n      piVar2 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar2 = local_24;\n      return pDVar3;\n    }\n  }\n  return __dirp;\n}" (type_identifier "DIR") (pointer_declarator "* FUN_0001cc60(char *param_1)" (* "*") (function_declarator "FUN_0001cc60(char *param_1)" (identifier "FUN_0001cc60") (parameter_list "(char *param_1)" (( "(") (parameter_declaration "char *param_1" (primitive_type "char") (pointer_declarator "*param_1" (* "*") (identifier "param_1"))) () ")")))) (compound_statement "{\n  DIR *__dirp;\n  uint uVar1;\n  int __fd;\n  int *piVar2;\n  DIR *pDVar3;\n  undefined4 local_24;\n  \n  __dirp = opendir(param_1);\n  if (__dirp != (DIR *)0x0) {\n    uVar1 = dirfd(__dirp);\n    if (uVar1 < 3) {\n      __fd = FUN_00024aa0(uVar1,0x406,3);\n      piVar2 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar2 = local_24;\n      return pDVar3;\n    }\n  }\n  return __dirp;\n}" ({ "{") (declaration "DIR *__dirp;" (type_identifier "DIR") (pointer_declarator "*__dirp" (* "*") (identifier "__dirp")) (; ";")) (declaration "uint uVar1;" (type_identifier "uint") (identifier "uVar1") (; ";")) (declaration "int __fd;" (primitive_type "int") (identifier "__fd") (; ";")) (declaration "int *piVar2;" (primitive_type "int") (pointer_declarator "*piVar2" (* "*") (identifier "piVar2")) (; ";")) (declaration "DIR *pDVar3;" (type_identifier "DIR") (pointer_declarator "*pDVar3" (* "*") (identifier "pDVar3")) (; ";")) (declaration "undefined4 local_24;" (type_identifier "undefined4") (identifier "local_24") (; ";")) (expression_statement "__dirp = opendir(param_1);" (assignment_expression "__dirp = opendir(param_1)" (identifier "__dirp") (= "=") (call_expression "opendir(param_1)" (identifier "opendir") (argument_list "(param_1)" (( "(") (identifier "param_1") () ")")))) (; ";")) (if_statement "if (__dirp != (DIR *)0x0) {\n    uVar1 = dirfd(__dirp);\n    if (uVar1 < 3) {\n      __fd = FUN_00024aa0(uVar1,0x406,3);\n      piVar2 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar2 = local_24;\n      return pDVar3;\n    }\n  }" (if "if") (parenthesized_expression "(__dirp != (DIR *)0x0)" (( "(") (binary_expression "__dirp != (DIR *)0x0" (identifier "__dirp") (!= "!=") (cast_expression "(DIR *)0x0" (( "(") (type_descriptor "DIR *" (type_identifier "DIR") (abstract_pointer_declarator "*" (* "*"))) () ")") (number_literal "0x0"))) () ")")) (compound_statement "{\n    uVar1 = dirfd(__dirp);\n    if (uVar1 < 3) {\n      __fd = FUN_00024aa0(uVar1,0x406,3);\n      piVar2 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar2 = local_24;\n      return pDVar3;\n    }\n  }" ({ "{") (expression_statement "uVar1 = dirfd(__dirp);" (assignment_expression "uVar1 = dirfd(__dirp)" (identifier "uVar1") (= "=") (call_expression "dirfd(__dirp)" (identifier "dirfd") (argument_list "(__dirp)" (( "(") (identifier "__dirp") () ")")))) (; ";")) (if_statement "if (uVar1 < 3) {\n      __fd = FUN_00024aa0(uVar1,0x406,3);\n      piVar2 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar2 = local_24;\n      return pDVar3;\n    }" (if "if") (parenthesized_expression "(uVar1 < 3)" (( "(") (binary_expression "uVar1 < 3" (identifier "uVar1") (< "<") (number_literal "3")) () ")")) (compound_statement "{\n      __fd = FUN_00024aa0(uVar1,0x406,3);\n      piVar2 = __errno_location();\n      if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }\n      closedir(__dirp);\n      *piVar2 = local_24;\n      return pDVar3;\n    }" ({ "{") (expression_statement "__fd = FUN_00024aa0(uVar1,0x406,3);" (assignment_expression "__fd = FUN_00024aa0(uVar1,0x406,3)" (identifier "__fd") (= "=") (call_expression "FUN_00024aa0(uVar1,0x406,3)" (identifier "FUN_00024aa0") (argument_list "(uVar1,0x406,3)" (( "(") (identifier "uVar1") (, ",") (number_literal "0x406") (, ",") (number_literal "3") () ")")))) (; ";")) (expression_statement "piVar2 = __errno_location();" (assignment_expression "piVar2 = __errno_location()" (identifier "piVar2") (= "=") (call_expression "__errno_location()" (identifier "__errno_location") (argument_list "()" (( "(") () ")")))) (; ";")) (if_statement "if (__fd < 0) {\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }\n      else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }" (if "if") (parenthesized_expression "(__fd < 0)" (( "(") (binary_expression "__fd < 0" (identifier "__fd") (< "<") (number_literal "0")) () ")")) (compound_statement "{\n        local_24 = *piVar2;\n        pDVar3 = (DIR *)0x0;\n      }" ({ "{") (expression_statement "local_24 = *piVar2;" (assignment_expression "local_24 = *piVar2" (identifier "local_24") (= "=") (pointer_expression "*piVar2" (* "*") (identifier "piVar2"))) (; ";")) (expression_statement "pDVar3 = (DIR *)0x0;" (assignment_expression "pDVar3 = (DIR *)0x0" (identifier "pDVar3") (= "=") (cast_expression "(DIR *)0x0" (( "(") (type_descriptor "DIR *" (type_identifier "DIR") (abstract_pointer_declarator "*" (* "*"))) () ")") (number_literal "0x0"))) (; ";")) (} "}")) (else_clause "else {\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }" (else "else") (compound_statement "{\n        pDVar3 = fdopendir(__fd);\n        local_24 = *piVar2;\n        if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }\n      }" ({ "{") (expression_statement "pDVar3 = fdopendir(__fd);" (assignment_expression "pDVar3 = fdopendir(__fd)" (identifier "pDVar3") (= "=") (call_expression "fdopendir(__fd)" (identifier "fdopendir") (argument_list "(__fd)" (( "(") (identifier "__fd") () ")")))) (; ";")) (expression_statement "local_24 = *piVar2;" (assignment_expression "local_24 = *piVar2" (identifier "local_24") (= "=") (pointer_expression "*piVar2" (* "*") (identifier "piVar2"))) (; ";")) (if_statement "if (pDVar3 == (DIR *)0x0) {\n          close(__fd);\n        }" (if "if") (parenthesized_expression "(pDVar3 == (DIR *)0x0)" (( "(") (binary_expression "pDVar3 == (DIR *)0x0" (identifier "pDVar3") (== "==") (cast_expression "(DIR *)0x0" (( "(") (type_descriptor "DIR *" (type_identifier "DIR") (abstract_pointer_declarator "*" (* "*"))) () ")") (number_literal "0x0"))) () ")")) (compound_statement "{\n          close(__fd);\n        }" ({ "{") (expression_statement "close(__fd);" (call_expression "close(__fd)" (identifier "close") (argument_list "(__fd)" (( "(") (identifier "__fd") () ")"))) (; ";")) (} "}"))) (} "}")))) (expression_statement "closedir(__dirp);" (call_expression "closedir(__dirp)" (identifier "closedir") (argument_list "(__dirp)" (( "(") (identifier "__dirp") () ")"))) (; ";")) (expression_statement "*piVar2 = local_24;" (assignment_expression "*piVar2 = local_24" (pointer_expression "*piVar2" (* "*") (identifier "piVar2")) (= "=") (identifier "local_24")) (; ";")) (return_statement "return pDVar3;" (return "return") (identifier "pDVar3") (; ";")) (} "}"))) (} "}"))) (return_statement "return __dirp;" (return "return") (identifier "__dirp") (; ";")) (} "}")))

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

type_1 * function_1(char *name)

{
  type_1 *var_2;
  type_2 var_4;
  int var_7;
  int *piVar1;
  type_1 *var_9;
  type_3 local_24;
  
  var_2 = var_1(name);
  if (var_2 != (type_1 *)0x0) {
    var_4 = var_3(var_2);
    if (var_4 < 3) {
      var_7 = var_5(var_4,0x406,3);
      piVar1 = var_6();
      if (var_7 < 0) {
        local_24 = *piVar1;
        var_9 = (type_1 *)0x0;
      }
      else {
        var_9 = var_8(var_7);
        local_24 = *piVar1;
        if (var_9 == (type_1 *)0x0) {
          var_10(var_7);
        }
      }
      var_11(var_2);
      *piVar1 = local_24;
      return (type_1 *)var_9;
    }
  }
  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)))))) body: (compound_statement (declaration type: (type_identifier) declarator: (pointer_declarator declarator: (identifier))) (declaration type: (type_identifier) declarator: (identifier)) (declaration type: (primitive_type) declarator: (identifier)) (declaration type: (primitive_type) declarator: (pointer_declarator declarator: (identifier))) (declaration type: (type_identifier) declarator: (pointer_declarator declarator: (identifier))) (declaration type: (type_identifier) declarator: (identifier)) (expression_statement (assignment_expression left: (identifier) right: (call_expression function: (identifier) arguments: (argument_list (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (cast_expression type: (type_descriptor type: (type_identifier) 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))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (number_literal))) consequence: (compound_statement (expression_statement (assignment_expression left: (identifier) right: (call_expression function: (identifier) arguments: (argument_list (identifier) (number_literal) (number_literal))))) (expression_statement (assignment_expression left: (identifier) right: (call_expression function: (identifier) arguments: (argument_list)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (number_literal))) consequence: (compound_statement (expression_statement (assignment_expression left: (identifier) right: (pointer_expression argument: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (cast_expression type: (type_descriptor type: (type_identifier) declarator: (abstract_pointer_declarator)) value: (number_literal))))) alternative: (else_clause (compound_statement (expression_statement (assignment_expression left: (identifier) right: (call_expression function: (identifier) arguments: (argument_list (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (pointer_expression argument: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (cast_expression type: (type_descriptor type: (type_identifier) declarator: (abstract_pointer_declarator)) value: (number_literal)))) consequence: (compound_statement (expression_statement (call_expression function: (identifier) arguments: (argument_list (identifier))))))))) (expression_statement (call_expression function: (identifier) arguments: (argument_list (identifier)))) (expression_statement (assignment_expression left: (pointer_expression argument: (identifier)) right: (identifier))) (return_statement (identifier)))))) (return_statement (identifier)))))

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

DIR * MASKED(char *param_1)

{
  DIR *__dirp;
  uint uVar1;
  int __fd;
  int *piVar2;
  DIR *pDVar3;
  undefined4 local_24;
  
  __dirp = opendir(param_1);
  if (__dirp != (DIR *)0x0) {
    uVar1 = dirfd(__dirp);
    if (uVar1 < 3) {
      __fd = FUN_00024aa0(uVar1,0x406,3);
      piVar2 = __errno_location();
      if (__fd < 0) {
        local_24 = *piVar2;
        pDVar3 = (DIR *)0x0;
      }
      else {
        pDVar3 = fdopendir(__fd);
        local_24 = *piVar2;
        if (pDVar3 == (DIR *)0x0) {
          close(__fd);
        }
      }
      closedir(__dirp);
      *piVar2 = local_24;
      return pDVar3;
    }
  }
  return __dirp;
}

