
/* int std::__facet_shims::__messages_open<wchar_t>(std::integral_constant<bool, false>,
   std::locale::facet const*, char const*, unsigned long, std::locale const&) */

int std::__facet_shims::__messages_open<wchar_t>
              (long *param_1,char *param_2,ulong param_3,undefined8 param_4)

{
  int *piVar1;
  int iVar2;
  int iVar3;
  allocator local_31;
  long local_30 [2];
  
  std::string::string((string *)local_30,param_2,param_3,&local_31);
                    /* try { // try from 00317191 to 00317193 has its CatchHandler @ 003171f3 */
  iVar2 = (**(code **)(*param_1 + 0x10))(param_1,(string *)local_30,param_4);
  if ((allocator *)(local_30[0] + -0x18) != (allocator *)PTR__S_empty_rep_storage_0043dc38) {
    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {
      iVar3 = *(int *)(local_30[0] + -8);
      *(int *)(local_30[0] + -8) = iVar3 + -1;
    }
    else {
      LOCK();
      piVar1 = (int *)(local_30[0] + -8);
      iVar3 = *piVar1;
      *piVar1 = *piVar1 + -1;
      UNLOCK();
    }
    if (iVar3 < 1) {
      std::string::_Rep::_M_destroy((allocator *)(local_30[0] + -0x18));
    }
  }
  return iVar2;
}



ulong FUN_00317160(long *param_1,undefined8 param_2,undefined8 param_3,undefined8 param_4)

{
  int *piVar1;
  int iVar2;
  ulong uVar3;
  undefined1 local_31;
  long local_30 [2];
  
  FUN_0030f2e0(local_30,param_2,param_3,&local_31);
                    /* try { // try from 00317191 to 00317193 has its CatchHandler @ 003171f3 */
  uVar3 = (**(code **)(*param_1 + 0x10))(param_1,local_30,param_4);
  if ((undefined *)(local_30[0] + -0x18) != PTR_DAT_0043dc38) {
    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {
      iVar2 = *(int *)(local_30[0] + -8);
      *(int *)(local_30[0] + -8) = iVar2 + -1;
    }
    else {
      LOCK();
      piVar1 = (int *)(local_30[0] + -8);
      iVar2 = *piVar1;
      *piVar1 = *piVar1 + -1;
      UNLOCK();
    }
    if (iVar2 < 1) {
      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);
      uVar3 = uVar3 & 0xffffffff;
    }
  }
  return uVar3;
}


PUSH R13
MOV R13,RCX
PUSH R12
PUSH RBP
PUSH RBX
MOV RBX,RDI
SUB RSP,0x28
LEA RBP,[RSP + 0x18]
LEA R12,[RSP + 0x17]
MOV RDI,RBP
MOV RCX,R12
CALL 0x0030f2e0
MOV RAX,qword ptr [RBX]
MOV RDX,R13
MOV RSI,RBP
MOV RDI,RBX
CALL qword ptr [RAX + 0x10]
MOV RDX,qword ptr [RSP + 0x18]
LEA RDI,[RDX + -0x18]
CMP RDI,qword ptr [0x0043dc38]
JNZ 0x003171b8
ADD RSP,0x28
POP RBX
POP RBP
POP R12
POP R13
RET
CMP qword ptr [0x0043dee8],0x0
JZ 0x003171e8
MOV ECX,0xffffffff
XADD.LOCK dword ptr [RDX + -0x8],ECX
TEST ECX,ECX
JG 0x003171a6
MOV RSI,R12
MOV dword ptr [RSP + 0xc],EAX
CALL 0x0030da40
MOV EAX,dword ptr [RSP + 0xc]
JMP 0x003171a6
MOV ECX,dword ptr [RDX + -0x8]
LEA ESI,[RCX + -0x1]
MOV dword ptr [RDX + -0x8],ESI
JMP 0x003171cc
(translation_unit "ulong FUN_00317160(long *param_1,undefined8 param_2,undefined8 param_3,undefined8 param_4)\n\n{\n  int *piVar1;\n  int iVar2;\n  ulong uVar3;\n  undefined1 local_31;\n  long local_30 [2];\n  \n  FUN_0030f2e0(local_30,param_2,param_3,&local_31);\n                    /* try { // try from 00317191 to 00317193 has its CatchHandler @ 003171f3 */\n  uVar3 = (**(code **)(*param_1 + 0x10))(param_1,local_30,param_4);\n  if ((undefined *)(local_30[0] + -0x18) != PTR_DAT_0043dc38) {\n    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar2 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar2 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }\n    if (iVar2 < 1) {\n      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);\n      uVar3 = uVar3 & 0xffffffff;\n    }\n  }\n  return uVar3;\n}\n\n" (function_definition "ulong FUN_00317160(long *param_1,undefined8 param_2,undefined8 param_3,undefined8 param_4)\n\n{\n  int *piVar1;\n  int iVar2;\n  ulong uVar3;\n  undefined1 local_31;\n  long local_30 [2];\n  \n  FUN_0030f2e0(local_30,param_2,param_3,&local_31);\n                    /* try { // try from 00317191 to 00317193 has its CatchHandler @ 003171f3 */\n  uVar3 = (**(code **)(*param_1 + 0x10))(param_1,local_30,param_4);\n  if ((undefined *)(local_30[0] + -0x18) != PTR_DAT_0043dc38) {\n    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar2 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar2 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }\n    if (iVar2 < 1) {\n      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);\n      uVar3 = uVar3 & 0xffffffff;\n    }\n  }\n  return uVar3;\n}" type_identifier (function_declarator "FUN_00317160(long *param_1,undefined8 param_2,undefined8 param_3,undefined8 param_4)" identifier (parameter_list "(long *param_1,undefined8 param_2,undefined8 param_3,undefined8 param_4)" ( (parameter_declaration "long *param_1" (sized_type_specifier "long" long) (pointer_declarator "*param_1" * identifier)) , (parameter_declaration "undefined8 param_2" type_identifier identifier) , (parameter_declaration "undefined8 param_3" type_identifier identifier) , (parameter_declaration "undefined8 param_4" type_identifier identifier) ))) (compound_statement "{\n  int *piVar1;\n  int iVar2;\n  ulong uVar3;\n  undefined1 local_31;\n  long local_30 [2];\n  \n  FUN_0030f2e0(local_30,param_2,param_3,&local_31);\n                    /* try { // try from 00317191 to 00317193 has its CatchHandler @ 003171f3 */\n  uVar3 = (**(code **)(*param_1 + 0x10))(param_1,local_30,param_4);\n  if ((undefined *)(local_30[0] + -0x18) != PTR_DAT_0043dc38) {\n    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar2 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar2 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }\n    if (iVar2 < 1) {\n      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);\n      uVar3 = uVar3 & 0xffffffff;\n    }\n  }\n  return uVar3;\n}" { (declaration "int *piVar1;" primitive_type (pointer_declarator "*piVar1" * identifier) ;) (declaration "int iVar2;" primitive_type identifier ;) (declaration "ulong uVar3;" type_identifier identifier ;) (declaration "undefined1 local_31;" type_identifier identifier ;) (declaration "long local_30 [2];" (sized_type_specifier "long" long) (array_declarator "local_30 [2]" identifier [ number_literal ]) ;) (expression_statement "FUN_0030f2e0(local_30,param_2,param_3,&local_31);" (call_expression "FUN_0030f2e0(local_30,param_2,param_3,&local_31)" identifier (argument_list "(local_30,param_2,param_3,&local_31)" ( identifier , identifier , identifier , (pointer_expression "&local_31" & identifier) ))) ;) comment (expression_statement "uVar3 = (**(code **)(*param_1 + 0x10))(param_1,local_30,param_4);" (assignment_expression "uVar3 = (**(code **)(*param_1 + 0x10))(param_1,local_30,param_4)" identifier = (call_expression "(**(code **)(*param_1 + 0x10))(param_1,local_30,param_4)" (parenthesized_expression "(**(code **)(*param_1 + 0x10))" ( (pointer_expression "**(code **)(*param_1 + 0x10)" * (pointer_expression "*(code **)(*param_1 + 0x10)" * (cast_expression "(code **)(*param_1 + 0x10)" ( (type_descriptor "code **" type_identifier (abstract_pointer_declarator "**" * (abstract_pointer_declarator "*" *))) ) (parenthesized_expression "(*param_1 + 0x10)" ( (binary_expression "*param_1 + 0x10" (pointer_expression "*param_1" * identifier) + number_literal) ))))) )) (argument_list "(param_1,local_30,param_4)" ( identifier , identifier , identifier )))) ;) (if_statement "if ((undefined *)(local_30[0] + -0x18) != PTR_DAT_0043dc38) {\n    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar2 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar2 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }\n    if (iVar2 < 1) {\n      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);\n      uVar3 = uVar3 & 0xffffffff;\n    }\n  }" if (parenthesized_expression "((undefined *)(local_30[0] + -0x18) != PTR_DAT_0043dc38)" ( (binary_expression "(undefined *)(local_30[0] + -0x18) != PTR_DAT_0043dc38" (cast_expression "(undefined *)(local_30[0] + -0x18)" ( (type_descriptor "undefined *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(local_30[0] + -0x18)" ( (binary_expression "local_30[0] + -0x18" (subscript_expression "local_30[0]" identifier [ number_literal ]) + number_literal) ))) != identifier) )) (compound_statement "{\n    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar2 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar2 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }\n    if (iVar2 < 1) {\n      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);\n      uVar3 = uVar3 & 0xffffffff;\n    }\n  }" { (if_statement "if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar2 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar2 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }" if (parenthesized_expression "(PTR___pthread_key_create_0043dee8 == (undefined *)0x0)" ( (binary_expression "PTR___pthread_key_create_0043dee8 == (undefined *)0x0" identifier == (cast_expression "(undefined *)0x0" ( (type_descriptor "undefined *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal)) )) (compound_statement "{\n      iVar2 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar2 + -1;\n    }" { (expression_statement "iVar2 = *(int *)(local_30[0] + -8);" (assignment_expression "iVar2 = *(int *)(local_30[0] + -8)" identifier = (pointer_expression "*(int *)(local_30[0] + -8)" * (cast_expression "(int *)(local_30[0] + -8)" ( (type_descriptor "int *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(local_30[0] + -8)" ( (binary_expression "local_30[0] + -8" (subscript_expression "local_30[0]" identifier [ number_literal ]) + number_literal) ))))) ;) (expression_statement "*(int *)(local_30[0] + -8) = iVar2 + -1;" (assignment_expression "*(int *)(local_30[0] + -8) = iVar2 + -1" (pointer_expression "*(int *)(local_30[0] + -8)" * (cast_expression "(int *)(local_30[0] + -8)" ( (type_descriptor "int *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(local_30[0] + -8)" ( (binary_expression "local_30[0] + -8" (subscript_expression "local_30[0]" identifier [ number_literal ]) + number_literal) )))) = (binary_expression "iVar2 + -1" identifier + number_literal)) ;) }) (else_clause "else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }" else (compound_statement "{\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }" { (expression_statement "LOCK();" (call_expression "LOCK()" identifier (argument_list "()" ( ))) ;) (expression_statement "piVar1 = (int *)(local_30[0] + -8);" (assignment_expression "piVar1 = (int *)(local_30[0] + -8)" identifier = (cast_expression "(int *)(local_30[0] + -8)" ( (type_descriptor "int *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(local_30[0] + -8)" ( (binary_expression "local_30[0] + -8" (subscript_expression "local_30[0]" identifier [ number_literal ]) + number_literal) )))) ;) (expression_statement "iVar2 = *piVar1;" (assignment_expression "iVar2 = *piVar1" identifier = (pointer_expression "*piVar1" * identifier)) ;) (expression_statement "*piVar1 = *piVar1 + -1;" (assignment_expression "*piVar1 = *piVar1 + -1" (pointer_expression "*piVar1" * identifier) = (binary_expression "*piVar1 + -1" (pointer_expression "*piVar1" * identifier) + number_literal)) ;) (expression_statement "UNLOCK();" (call_expression "UNLOCK()" identifier (argument_list "()" ( ))) ;) }))) (if_statement "if (iVar2 < 1) {\n      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);\n      uVar3 = uVar3 & 0xffffffff;\n    }" if (parenthesized_expression "(iVar2 < 1)" ( (binary_expression "iVar2 < 1" identifier < number_literal) )) (compound_statement "{\n      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);\n      uVar3 = uVar3 & 0xffffffff;\n    }" { (expression_statement "thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);" (call_expression "thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31)" identifier (argument_list "((undefined *)(local_30[0] + -0x18),&local_31)" ( (cast_expression "(undefined *)(local_30[0] + -0x18)" ( (type_descriptor "undefined *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(local_30[0] + -0x18)" ( (binary_expression "local_30[0] + -0x18" (subscript_expression "local_30[0]" identifier [ number_literal ]) + number_literal) ))) , (pointer_expression "&local_31" & identifier) ))) ;) (expression_statement "uVar3 = uVar3 & 0xffffffff;" (assignment_expression "uVar3 = uVar3 & 0xffffffff" identifier = (binary_expression "uVar3 & 0xffffffff" identifier & number_literal)) ;) })) })) (return_statement "return uVar3;" return identifier ;) })))
(translation_unit "/* int std::__facet_shims::__messages_open<wchar_t>(std::integral_constant<bool, false>,\n   std::locale::facet const*, char const*, unsigned long, std::locale const&) */\n\nint std::__facet_shims::__messages_open<wchar_t>\n              (long *param_1,char *param_2,ulong param_3,undefined8 param_4)\n\n{\n  int *piVar1;\n  int iVar2;\n  int iVar3;\n  allocator local_31;\n  long local_30 [2];\n  \n  std::string::string((string *)local_30,param_2,param_3,&local_31);\n                    /* try { // try from 00317191 to 00317193 has its CatchHandler @ 003171f3 */\n  iVar2 = (**(code **)(*param_1 + 0x10))(param_1,(string *)local_30,param_4);\n  if ((allocator *)(local_30[0] + -0x18) != (allocator *)PTR__S_empty_rep_storage_0043dc38) {\n    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar3 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar3 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar3 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }\n    if (iVar3 < 1) {\n      std::string::_Rep::_M_destroy((allocator *)(local_30[0] + -0x18));\n    }\n  }\n  return iVar2;\n}\n\n" comment (function_definition "int std::__facet_shims::__messages_open<wchar_t>\n              (long *param_1,char *param_2,ulong param_3,undefined8 param_4)\n\n{\n  int *piVar1;\n  int iVar2;\n  int iVar3;\n  allocator local_31;\n  long local_30 [2];\n  \n  std::string::string((string *)local_30,param_2,param_3,&local_31);\n                    /* try { // try from 00317191 to 00317193 has its CatchHandler @ 003171f3 */\n  iVar2 = (**(code **)(*param_1 + 0x10))(param_1,(string *)local_30,param_4);\n  if ((allocator *)(local_30[0] + -0x18) != (allocator *)PTR__S_empty_rep_storage_0043dc38) {\n    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar3 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar3 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar3 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }\n    if (iVar3 < 1) {\n      std::string::_Rep::_M_destroy((allocator *)(local_30[0] + -0x18));\n    }\n  }\n  return iVar2;\n}" primitive_type (ERROR "std::__facet_shims::__messages_open<" identifier : : identifier : : identifier <) (function_declarator "wchar_t>\n              (long *param_1,char *param_2,ulong param_3,undefined8 param_4)" identifier (ERROR ">" >) (parameter_list "(long *param_1,char *param_2,ulong param_3,undefined8 param_4)" ( (parameter_declaration "long *param_1" (sized_type_specifier "long" long) (pointer_declarator "*param_1" * identifier)) , (parameter_declaration "char *param_2" primitive_type (pointer_declarator "*param_2" * identifier)) , (parameter_declaration "ulong param_3" type_identifier identifier) , (parameter_declaration "undefined8 param_4" type_identifier identifier) ))) (compound_statement "{\n  int *piVar1;\n  int iVar2;\n  int iVar3;\n  allocator local_31;\n  long local_30 [2];\n  \n  std::string::string((string *)local_30,param_2,param_3,&local_31);\n                    /* try { // try from 00317191 to 00317193 has its CatchHandler @ 003171f3 */\n  iVar2 = (**(code **)(*param_1 + 0x10))(param_1,(string *)local_30,param_4);\n  if ((allocator *)(local_30[0] + -0x18) != (allocator *)PTR__S_empty_rep_storage_0043dc38) {\n    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar3 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar3 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar3 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }\n    if (iVar3 < 1) {\n      std::string::_Rep::_M_destroy((allocator *)(local_30[0] + -0x18));\n    }\n  }\n  return iVar2;\n}" { (declaration "int *piVar1;" primitive_type (pointer_declarator "*piVar1" * identifier) ;) (declaration "int iVar2;" primitive_type identifier ;) (declaration "int iVar3;" primitive_type identifier ;) (declaration "allocator local_31;" type_identifier identifier ;) (declaration "long local_30 [2];" (sized_type_specifier "long" long) (array_declarator "local_30 [2]" identifier [ number_literal ]) ;) (labeled_statement "std::string::string((string *)local_30,param_2,param_3,&local_31);" statement_identifier : (ERROR ":" :) (labeled_statement "string::string((string *)local_30,param_2,param_3,&local_31);" statement_identifier : (ERROR ":" :) (expression_statement "string((string *)local_30,param_2,param_3,&local_31);" (call_expression "string((string *)local_30,param_2,param_3,&local_31)" identifier (argument_list "((string *)local_30,param_2,param_3,&local_31)" ( (cast_expression "(string *)local_30" ( (type_descriptor "string *" type_identifier (abstract_pointer_declarator "*" *)) ) identifier) , identifier , identifier , (pointer_expression "&local_31" & identifier) ))) ;))) comment (expression_statement "iVar2 = (**(code **)(*param_1 + 0x10))(param_1,(string *)local_30,param_4);" (assignment_expression "iVar2 = (**(code **)(*param_1 + 0x10))(param_1,(string *)local_30,param_4)" identifier = (call_expression "(**(code **)(*param_1 + 0x10))(param_1,(string *)local_30,param_4)" (parenthesized_expression "(**(code **)(*param_1 + 0x10))" ( (pointer_expression "**(code **)(*param_1 + 0x10)" * (pointer_expression "*(code **)(*param_1 + 0x10)" * (cast_expression "(code **)(*param_1 + 0x10)" ( (type_descriptor "code **" type_identifier (abstract_pointer_declarator "**" * (abstract_pointer_declarator "*" *))) ) (parenthesized_expression "(*param_1 + 0x10)" ( (binary_expression "*param_1 + 0x10" (pointer_expression "*param_1" * identifier) + number_literal) ))))) )) (argument_list "(param_1,(string *)local_30,param_4)" ( identifier , (cast_expression "(string *)local_30" ( (type_descriptor "string *" type_identifier (abstract_pointer_declarator "*" *)) ) identifier) , identifier )))) ;) (if_statement "if ((allocator *)(local_30[0] + -0x18) != (allocator *)PTR__S_empty_rep_storage_0043dc38) {\n    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar3 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar3 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar3 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }\n    if (iVar3 < 1) {\n      std::string::_Rep::_M_destroy((allocator *)(local_30[0] + -0x18));\n    }\n  }" if (parenthesized_expression "((allocator *)(local_30[0] + -0x18) != (allocator *)PTR__S_empty_rep_storage_0043dc38)" ( (binary_expression "(allocator *)(local_30[0] + -0x18) != (allocator *)PTR__S_empty_rep_storage_0043dc38" (cast_expression "(allocator *)(local_30[0] + -0x18)" ( (type_descriptor "allocator *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(local_30[0] + -0x18)" ( (binary_expression "local_30[0] + -0x18" (subscript_expression "local_30[0]" identifier [ number_literal ]) + number_literal) ))) != (cast_expression "(allocator *)PTR__S_empty_rep_storage_0043dc38" ( (type_descriptor "allocator *" type_identifier (abstract_pointer_declarator "*" *)) ) identifier)) )) (compound_statement "{\n    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar3 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar3 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar3 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }\n    if (iVar3 < 1) {\n      std::string::_Rep::_M_destroy((allocator *)(local_30[0] + -0x18));\n    }\n  }" { (if_statement "if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar3 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar3 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar3 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }" if (parenthesized_expression "(PTR___pthread_key_create_0043dee8 == (undefined *)0x0)" ( (binary_expression "PTR___pthread_key_create_0043dee8 == (undefined *)0x0" identifier == (cast_expression "(undefined *)0x0" ( (type_descriptor "undefined *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal)) )) (compound_statement "{\n      iVar3 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar3 + -1;\n    }" { (expression_statement "iVar3 = *(int *)(local_30[0] + -8);" (assignment_expression "iVar3 = *(int *)(local_30[0] + -8)" identifier = (pointer_expression "*(int *)(local_30[0] + -8)" * (cast_expression "(int *)(local_30[0] + -8)" ( (type_descriptor "int *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(local_30[0] + -8)" ( (binary_expression "local_30[0] + -8" (subscript_expression "local_30[0]" identifier [ number_literal ]) + number_literal) ))))) ;) (expression_statement "*(int *)(local_30[0] + -8) = iVar3 + -1;" (assignment_expression "*(int *)(local_30[0] + -8) = iVar3 + -1" (pointer_expression "*(int *)(local_30[0] + -8)" * (cast_expression "(int *)(local_30[0] + -8)" ( (type_descriptor "int *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(local_30[0] + -8)" ( (binary_expression "local_30[0] + -8" (subscript_expression "local_30[0]" identifier [ number_literal ]) + number_literal) )))) = (binary_expression "iVar3 + -1" identifier + number_literal)) ;) }) (else_clause "else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar3 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }" else (compound_statement "{\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar3 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }" { (expression_statement "LOCK();" (call_expression "LOCK()" identifier (argument_list "()" ( ))) ;) (expression_statement "piVar1 = (int *)(local_30[0] + -8);" (assignment_expression "piVar1 = (int *)(local_30[0] + -8)" identifier = (cast_expression "(int *)(local_30[0] + -8)" ( (type_descriptor "int *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(local_30[0] + -8)" ( (binary_expression "local_30[0] + -8" (subscript_expression "local_30[0]" identifier [ number_literal ]) + number_literal) )))) ;) (expression_statement "iVar3 = *piVar1;" (assignment_expression "iVar3 = *piVar1" identifier = (pointer_expression "*piVar1" * identifier)) ;) (expression_statement "*piVar1 = *piVar1 + -1;" (assignment_expression "*piVar1 = *piVar1 + -1" (pointer_expression "*piVar1" * identifier) = (binary_expression "*piVar1 + -1" (pointer_expression "*piVar1" * identifier) + number_literal)) ;) (expression_statement "UNLOCK();" (call_expression "UNLOCK()" identifier (argument_list "()" ( ))) ;) }))) (if_statement "if (iVar3 < 1) {\n      std::string::_Rep::_M_destroy((allocator *)(local_30[0] + -0x18));\n    }" if (parenthesized_expression "(iVar3 < 1)" ( (binary_expression "iVar3 < 1" identifier < number_literal) )) (compound_statement "{\n      std::string::_Rep::_M_destroy((allocator *)(local_30[0] + -0x18));\n    }" { (labeled_statement "std::string::_Rep::_M_destroy((allocator *)(local_30[0] + -0x18));" statement_identifier : (ERROR ":" :) (labeled_statement "string::_Rep::_M_destroy((allocator *)(local_30[0] + -0x18));" statement_identifier : (ERROR ":" :) (labeled_statement "_Rep::_M_destroy((allocator *)(local_30[0] + -0x18));" statement_identifier : (ERROR ":" :) (expression_statement "_M_destroy((allocator *)(local_30[0] + -0x18));" (call_expression "_M_destroy((allocator *)(local_30[0] + -0x18))" identifier (argument_list "((allocator *)(local_30[0] + -0x18))" ( (cast_expression "(allocator *)(local_30[0] + -0x18)" ( (type_descriptor "allocator *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(local_30[0] + -0x18)" ( (binary_expression "local_30[0] + -0x18" (subscript_expression "local_30[0]" identifier [ number_literal ]) + number_literal) ))) ))) ;)))) })) })) (return_statement "return iVar2;" return identifier ;) })))
(translation_unit "ulong FUN_00317160(long *param_1,undefined8 param_2,undefined8 param_3,undefined8 param_4)\n\n{\n  int *piVar1;\n  int iVar2;\n  ulong uVar3;\n  undefined1 local_31;\n  long local_30 [2];\n  \n  FUN_0030f2e0(local_30,param_2,param_3,&local_31);\n                    \n  uVar3 = (**(code **)(*param_1 + 0x10))(param_1,local_30,param_4);\n  if ((undefined *)(local_30[0] + -0x18) != PTR_DAT_0043dc38) {\n    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar2 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar2 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }\n    if (iVar2 < 1) {\n      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);\n      uVar3 = uVar3 & 0xffffffff;\n    }\n  }\n  return uVar3;\n}\n\n" (function_definition "ulong FUN_00317160(long *param_1,undefined8 param_2,undefined8 param_3,undefined8 param_4)\n\n{\n  int *piVar1;\n  int iVar2;\n  ulong uVar3;\n  undefined1 local_31;\n  long local_30 [2];\n  \n  FUN_0030f2e0(local_30,param_2,param_3,&local_31);\n                    \n  uVar3 = (**(code **)(*param_1 + 0x10))(param_1,local_30,param_4);\n  if ((undefined *)(local_30[0] + -0x18) != PTR_DAT_0043dc38) {\n    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar2 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar2 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }\n    if (iVar2 < 1) {\n      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);\n      uVar3 = uVar3 & 0xffffffff;\n    }\n  }\n  return uVar3;\n}" type_identifier (function_declarator "FUN_00317160(long *param_1,undefined8 param_2,undefined8 param_3,undefined8 param_4)" identifier (parameter_list "(long *param_1,undefined8 param_2,undefined8 param_3,undefined8 param_4)" ( (parameter_declaration "long *param_1" (sized_type_specifier "long" long) (pointer_declarator "*param_1" * identifier)) , (parameter_declaration "undefined8 param_2" type_identifier identifier) , (parameter_declaration "undefined8 param_3" type_identifier identifier) , (parameter_declaration "undefined8 param_4" type_identifier identifier) ))) (compound_statement "{\n  int *piVar1;\n  int iVar2;\n  ulong uVar3;\n  undefined1 local_31;\n  long local_30 [2];\n  \n  FUN_0030f2e0(local_30,param_2,param_3,&local_31);\n                    \n  uVar3 = (**(code **)(*param_1 + 0x10))(param_1,local_30,param_4);\n  if ((undefined *)(local_30[0] + -0x18) != PTR_DAT_0043dc38) {\n    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar2 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar2 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }\n    if (iVar2 < 1) {\n      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);\n      uVar3 = uVar3 & 0xffffffff;\n    }\n  }\n  return uVar3;\n}" { (declaration "int *piVar1;" primitive_type (pointer_declarator "*piVar1" * identifier) ;) (declaration "int iVar2;" primitive_type identifier ;) (declaration "ulong uVar3;" type_identifier identifier ;) (declaration "undefined1 local_31;" type_identifier identifier ;) (declaration "long local_30 [2];" (sized_type_specifier "long" long) (array_declarator "local_30 [2]" identifier [ number_literal ]) ;) (expression_statement "FUN_0030f2e0(local_30,param_2,param_3,&local_31);" (call_expression "FUN_0030f2e0(local_30,param_2,param_3,&local_31)" identifier (argument_list "(local_30,param_2,param_3,&local_31)" ( identifier , identifier , identifier , (pointer_expression "&local_31" & identifier) ))) ;) (expression_statement "uVar3 = (**(code **)(*param_1 + 0x10))(param_1,local_30,param_4);" (assignment_expression "uVar3 = (**(code **)(*param_1 + 0x10))(param_1,local_30,param_4)" identifier = (call_expression "(**(code **)(*param_1 + 0x10))(param_1,local_30,param_4)" (parenthesized_expression "(**(code **)(*param_1 + 0x10))" ( (pointer_expression "**(code **)(*param_1 + 0x10)" * (pointer_expression "*(code **)(*param_1 + 0x10)" * (cast_expression "(code **)(*param_1 + 0x10)" ( (type_descriptor "code **" type_identifier (abstract_pointer_declarator "**" * (abstract_pointer_declarator "*" *))) ) (parenthesized_expression "(*param_1 + 0x10)" ( (binary_expression "*param_1 + 0x10" (pointer_expression "*param_1" * identifier) + number_literal) ))))) )) (argument_list "(param_1,local_30,param_4)" ( identifier , identifier , identifier )))) ;) (if_statement "if ((undefined *)(local_30[0] + -0x18) != PTR_DAT_0043dc38) {\n    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar2 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar2 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }\n    if (iVar2 < 1) {\n      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);\n      uVar3 = uVar3 & 0xffffffff;\n    }\n  }" if (parenthesized_expression "((undefined *)(local_30[0] + -0x18) != PTR_DAT_0043dc38)" ( (binary_expression "(undefined *)(local_30[0] + -0x18) != PTR_DAT_0043dc38" (cast_expression "(undefined *)(local_30[0] + -0x18)" ( (type_descriptor "undefined *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(local_30[0] + -0x18)" ( (binary_expression "local_30[0] + -0x18" (subscript_expression "local_30[0]" identifier [ number_literal ]) + number_literal) ))) != identifier) )) (compound_statement "{\n    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar2 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar2 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }\n    if (iVar2 < 1) {\n      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);\n      uVar3 = uVar3 & 0xffffffff;\n    }\n  }" { (if_statement "if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar2 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar2 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }" if (parenthesized_expression "(PTR___pthread_key_create_0043dee8 == (undefined *)0x0)" ( (binary_expression "PTR___pthread_key_create_0043dee8 == (undefined *)0x0" identifier == (cast_expression "(undefined *)0x0" ( (type_descriptor "undefined *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal)) )) (compound_statement "{\n      iVar2 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar2 + -1;\n    }" { (expression_statement "iVar2 = *(int *)(local_30[0] + -8);" (assignment_expression "iVar2 = *(int *)(local_30[0] + -8)" identifier = (pointer_expression "*(int *)(local_30[0] + -8)" * (cast_expression "(int *)(local_30[0] + -8)" ( (type_descriptor "int *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(local_30[0] + -8)" ( (binary_expression "local_30[0] + -8" (subscript_expression "local_30[0]" identifier [ number_literal ]) + number_literal) ))))) ;) (expression_statement "*(int *)(local_30[0] + -8) = iVar2 + -1;" (assignment_expression "*(int *)(local_30[0] + -8) = iVar2 + -1" (pointer_expression "*(int *)(local_30[0] + -8)" * (cast_expression "(int *)(local_30[0] + -8)" ( (type_descriptor "int *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(local_30[0] + -8)" ( (binary_expression "local_30[0] + -8" (subscript_expression "local_30[0]" identifier [ number_literal ]) + number_literal) )))) = (binary_expression "iVar2 + -1" identifier + number_literal)) ;) }) (else_clause "else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }" else (compound_statement "{\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }" { (expression_statement "LOCK();" (call_expression "LOCK()" identifier (argument_list "()" ( ))) ;) (expression_statement "piVar1 = (int *)(local_30[0] + -8);" (assignment_expression "piVar1 = (int *)(local_30[0] + -8)" identifier = (cast_expression "(int *)(local_30[0] + -8)" ( (type_descriptor "int *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(local_30[0] + -8)" ( (binary_expression "local_30[0] + -8" (subscript_expression "local_30[0]" identifier [ number_literal ]) + number_literal) )))) ;) (expression_statement "iVar2 = *piVar1;" (assignment_expression "iVar2 = *piVar1" identifier = (pointer_expression "*piVar1" * identifier)) ;) (expression_statement "*piVar1 = *piVar1 + -1;" (assignment_expression "*piVar1 = *piVar1 + -1" (pointer_expression "*piVar1" * identifier) = (binary_expression "*piVar1 + -1" (pointer_expression "*piVar1" * identifier) + number_literal)) ;) (expression_statement "UNLOCK();" (call_expression "UNLOCK()" identifier (argument_list "()" ( ))) ;) }))) (if_statement "if (iVar2 < 1) {\n      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);\n      uVar3 = uVar3 & 0xffffffff;\n    }" if (parenthesized_expression "(iVar2 < 1)" ( (binary_expression "iVar2 < 1" identifier < number_literal) )) (compound_statement "{\n      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);\n      uVar3 = uVar3 & 0xffffffff;\n    }" { (expression_statement "thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);" (call_expression "thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31)" identifier (argument_list "((undefined *)(local_30[0] + -0x18),&local_31)" ( (cast_expression "(undefined *)(local_30[0] + -0x18)" ( (type_descriptor "undefined *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(local_30[0] + -0x18)" ( (binary_expression "local_30[0] + -0x18" (subscript_expression "local_30[0]" identifier [ number_literal ]) + number_literal) ))) , (pointer_expression "&local_31" & identifier) ))) ;) (expression_statement "uVar3 = uVar3 & 0xffffffff;" (assignment_expression "uVar3 = uVar3 & 0xffffffff" identifier = (binary_expression "uVar3 & 0xffffffff" identifier & number_literal)) ;) })) })) (return_statement "return uVar3;" return identifier ;) })))
(translation_unit (function_definition TYPE (function_declarator IDENT (parameter_list ( (parameter_declaration (sized_type_specifier long) (pointer_declarator * IDENT)) , (parameter_declaration TYPE IDENT) , (parameter_declaration TYPE IDENT) , (parameter_declaration TYPE IDENT) ))) (compound_statement { (declaration TYPE (pointer_declarator * IDENT) ;) (declaration TYPE IDENT ;) (declaration TYPE IDENT ;) (declaration TYPE IDENT ;) (declaration (sized_type_specifier long) (array_declarator IDENT [ LIT ]) ;) (expression_statement (call_expression IDENT (argument_list ( IDENT , IDENT , IDENT , (pointer_expression & IDENT) ))) ;) (expression_statement (assignment_expression IDENT = (call_expression (parenthesized_expression ( (pointer_expression * (pointer_expression * (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator * (abstract_pointer_declarator *))) ) (parenthesized_expression ( (binary_expression (pointer_expression * IDENT) + LIT) ))))) )) (argument_list ( IDENT , IDENT , IDENT )))) ;) (if_statement if (parenthesized_expression ( (binary_expression (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (parenthesized_expression ( (binary_expression (subscript_expression IDENT [ LIT ]) + LIT) ))) != IDENT) )) (compound_statement { (if_statement if (parenthesized_expression ( (binary_expression IDENT == (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) LIT)) )) (compound_statement { (expression_statement (assignment_expression IDENT = (pointer_expression * (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (parenthesized_expression ( (binary_expression (subscript_expression IDENT [ LIT ]) + LIT) ))))) ;) (expression_statement (assignment_expression (pointer_expression * (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (parenthesized_expression ( (binary_expression (subscript_expression IDENT [ LIT ]) + LIT) )))) = (binary_expression IDENT + LIT)) ;) }) (else_clause else (compound_statement { (expression_statement (call_expression IDENT (argument_list ( ))) ;) (expression_statement (assignment_expression IDENT = (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (parenthesized_expression ( (binary_expression (subscript_expression IDENT [ LIT ]) + LIT) )))) ;) (expression_statement (assignment_expression IDENT = (pointer_expression * IDENT)) ;) (expression_statement (assignment_expression (pointer_expression * IDENT) = (binary_expression (pointer_expression * IDENT) + LIT)) ;) (expression_statement (call_expression IDENT (argument_list ( ))) ;) }))) (if_statement if (parenthesized_expression ( (binary_expression IDENT < LIT) )) (compound_statement { (expression_statement (call_expression IDENT (argument_list ( (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (parenthesized_expression ( (binary_expression (subscript_expression IDENT [ LIT ]) + LIT) ))) , (pointer_expression & IDENT) ))) ;) (expression_statement (assignment_expression IDENT = (binary_expression IDENT & LIT)) ;) })) })) (return_statement return IDENT ;) })))
(function_definition "ulong FUN_00317160(long *param_1,undefined8 param_2,undefined8 param_3,undefined8 param_4)\n\n{\n  int *piVar1;\n  int iVar2;\n  ulong uVar3;\n  undefined1 local_31;\n  long local_30 [2];\n  \n  FUN_0030f2e0(local_30,param_2,param_3,&local_31);\n                    \n  uVar3 = (**(code **)(*param_1 + 0x10))(param_1,local_30,param_4);\n  if ((undefined *)(local_30[0] + -0x18) != PTR_DAT_0043dc38) {\n    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar2 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar2 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }\n    if (iVar2 < 1) {\n      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);\n      uVar3 = uVar3 & 0xffffffff;\n    }\n  }\n  return uVar3;\n}" (type_identifier "ulong") (function_declarator "FUN_00317160(long *param_1,undefined8 param_2,undefined8 param_3,undefined8 param_4)" (identifier "FUN_00317160") (parameter_list "(long *param_1,undefined8 param_2,undefined8 param_3,undefined8 param_4)" (( "(") (parameter_declaration "long *param_1" (sized_type_specifier "long" (long "long")) (pointer_declarator "*param_1" (* "*") (identifier "param_1"))) (, ",") (parameter_declaration "undefined8 param_2" (type_identifier "undefined8") (identifier "param_2")) (, ",") (parameter_declaration "undefined8 param_3" (type_identifier "undefined8") (identifier "param_3")) (, ",") (parameter_declaration "undefined8 param_4" (type_identifier "undefined8") (identifier "param_4")) () ")"))) (compound_statement "{\n  int *piVar1;\n  int iVar2;\n  ulong uVar3;\n  undefined1 local_31;\n  long local_30 [2];\n  \n  FUN_0030f2e0(local_30,param_2,param_3,&local_31);\n                    \n  uVar3 = (**(code **)(*param_1 + 0x10))(param_1,local_30,param_4);\n  if ((undefined *)(local_30[0] + -0x18) != PTR_DAT_0043dc38) {\n    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar2 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar2 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }\n    if (iVar2 < 1) {\n      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);\n      uVar3 = uVar3 & 0xffffffff;\n    }\n  }\n  return uVar3;\n}" ({ "{") (declaration "int *piVar1;" (primitive_type "int") (pointer_declarator "*piVar1" (* "*") (identifier "piVar1")) (; ";")) (declaration "int iVar2;" (primitive_type "int") (identifier "iVar2") (; ";")) (declaration "ulong uVar3;" (type_identifier "ulong") (identifier "uVar3") (; ";")) (declaration "undefined1 local_31;" (type_identifier "undefined1") (identifier "local_31") (; ";")) (declaration "long local_30 [2];" (sized_type_specifier "long" (long "long")) (array_declarator "local_30 [2]" (identifier "local_30") ([ "[") (number_literal "2") (] "]")) (; ";")) (expression_statement "FUN_0030f2e0(local_30,param_2,param_3,&local_31);" (call_expression "FUN_0030f2e0(local_30,param_2,param_3,&local_31)" (identifier "FUN_0030f2e0") (argument_list "(local_30,param_2,param_3,&local_31)" (( "(") (identifier "local_30") (, ",") (identifier "param_2") (, ",") (identifier "param_3") (, ",") (pointer_expression "&local_31" (& "&") (identifier "local_31")) () ")"))) (; ";")) (expression_statement "uVar3 = (**(code **)(*param_1 + 0x10))(param_1,local_30,param_4);" (assignment_expression "uVar3 = (**(code **)(*param_1 + 0x10))(param_1,local_30,param_4)" (identifier "uVar3") (= "=") (call_expression "(**(code **)(*param_1 + 0x10))(param_1,local_30,param_4)" (parenthesized_expression "(**(code **)(*param_1 + 0x10))" (( "(") (pointer_expression "**(code **)(*param_1 + 0x10)" (* "*") (pointer_expression "*(code **)(*param_1 + 0x10)" (* "*") (cast_expression "(code **)(*param_1 + 0x10)" (( "(") (type_descriptor "code **" (type_identifier "code") (abstract_pointer_declarator "**" (* "*") (abstract_pointer_declarator "*" (* "*")))) () ")") (parenthesized_expression "(*param_1 + 0x10)" (( "(") (binary_expression "*param_1 + 0x10" (pointer_expression "*param_1" (* "*") (identifier "param_1")) (+ "+") (number_literal "0x10")) () ")"))))) () ")")) (argument_list "(param_1,local_30,param_4)" (( "(") (identifier "param_1") (, ",") (identifier "local_30") (, ",") (identifier "param_4") () ")")))) (; ";")) (if_statement "if ((undefined *)(local_30[0] + -0x18) != PTR_DAT_0043dc38) {\n    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar2 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar2 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }\n    if (iVar2 < 1) {\n      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);\n      uVar3 = uVar3 & 0xffffffff;\n    }\n  }" (if "if") (parenthesized_expression "((undefined *)(local_30[0] + -0x18) != PTR_DAT_0043dc38)" (( "(") (binary_expression "(undefined *)(local_30[0] + -0x18) != PTR_DAT_0043dc38" (cast_expression "(undefined *)(local_30[0] + -0x18)" (( "(") (type_descriptor "undefined *" (type_identifier "undefined") (abstract_pointer_declarator "*" (* "*"))) () ")") (parenthesized_expression "(local_30[0] + -0x18)" (( "(") (binary_expression "local_30[0] + -0x18" (subscript_expression "local_30[0]" (identifier "local_30") ([ "[") (number_literal "0") (] "]")) (+ "+") (number_literal "-0x18")) () ")"))) (!= "!=") (identifier "PTR_DAT_0043dc38")) () ")")) (compound_statement "{\n    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar2 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar2 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }\n    if (iVar2 < 1) {\n      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);\n      uVar3 = uVar3 & 0xffffffff;\n    }\n  }" ({ "{") (if_statement "if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {\n      iVar2 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar2 + -1;\n    }\n    else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }" (if "if") (parenthesized_expression "(PTR___pthread_key_create_0043dee8 == (undefined *)0x0)" (( "(") (binary_expression "PTR___pthread_key_create_0043dee8 == (undefined *)0x0" (identifier "PTR___pthread_key_create_0043dee8") (== "==") (cast_expression "(undefined *)0x0" (( "(") (type_descriptor "undefined *" (type_identifier "undefined") (abstract_pointer_declarator "*" (* "*"))) () ")") (number_literal "0x0"))) () ")")) (compound_statement "{\n      iVar2 = *(int *)(local_30[0] + -8);\n      *(int *)(local_30[0] + -8) = iVar2 + -1;\n    }" ({ "{") (expression_statement "iVar2 = *(int *)(local_30[0] + -8);" (assignment_expression "iVar2 = *(int *)(local_30[0] + -8)" (identifier "iVar2") (= "=") (pointer_expression "*(int *)(local_30[0] + -8)" (* "*") (cast_expression "(int *)(local_30[0] + -8)" (( "(") (type_descriptor "int *" (primitive_type "int") (abstract_pointer_declarator "*" (* "*"))) () ")") (parenthesized_expression "(local_30[0] + -8)" (( "(") (binary_expression "local_30[0] + -8" (subscript_expression "local_30[0]" (identifier "local_30") ([ "[") (number_literal "0") (] "]")) (+ "+") (number_literal "-8")) () ")"))))) (; ";")) (expression_statement "*(int *)(local_30[0] + -8) = iVar2 + -1;" (assignment_expression "*(int *)(local_30[0] + -8) = iVar2 + -1" (pointer_expression "*(int *)(local_30[0] + -8)" (* "*") (cast_expression "(int *)(local_30[0] + -8)" (( "(") (type_descriptor "int *" (primitive_type "int") (abstract_pointer_declarator "*" (* "*"))) () ")") (parenthesized_expression "(local_30[0] + -8)" (( "(") (binary_expression "local_30[0] + -8" (subscript_expression "local_30[0]" (identifier "local_30") ([ "[") (number_literal "0") (] "]")) (+ "+") (number_literal "-8")) () ")")))) (= "=") (binary_expression "iVar2 + -1" (identifier "iVar2") (+ "+") (number_literal "-1"))) (; ";")) (} "}")) (else_clause "else {\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }" (else "else") (compound_statement "{\n      LOCK();\n      piVar1 = (int *)(local_30[0] + -8);\n      iVar2 = *piVar1;\n      *piVar1 = *piVar1 + -1;\n      UNLOCK();\n    }" ({ "{") (expression_statement "LOCK();" (call_expression "LOCK()" (identifier "LOCK") (argument_list "()" (( "(") () ")"))) (; ";")) (expression_statement "piVar1 = (int *)(local_30[0] + -8);" (assignment_expression "piVar1 = (int *)(local_30[0] + -8)" (identifier "piVar1") (= "=") (cast_expression "(int *)(local_30[0] + -8)" (( "(") (type_descriptor "int *" (primitive_type "int") (abstract_pointer_declarator "*" (* "*"))) () ")") (parenthesized_expression "(local_30[0] + -8)" (( "(") (binary_expression "local_30[0] + -8" (subscript_expression "local_30[0]" (identifier "local_30") ([ "[") (number_literal "0") (] "]")) (+ "+") (number_literal "-8")) () ")")))) (; ";")) (expression_statement "iVar2 = *piVar1;" (assignment_expression "iVar2 = *piVar1" (identifier "iVar2") (= "=") (pointer_expression "*piVar1" (* "*") (identifier "piVar1"))) (; ";")) (expression_statement "*piVar1 = *piVar1 + -1;" (assignment_expression "*piVar1 = *piVar1 + -1" (pointer_expression "*piVar1" (* "*") (identifier "piVar1")) (= "=") (binary_expression "*piVar1 + -1" (pointer_expression "*piVar1" (* "*") (identifier "piVar1")) (+ "+") (number_literal "-1"))) (; ";")) (expression_statement "UNLOCK();" (call_expression "UNLOCK()" (identifier "UNLOCK") (argument_list "()" (( "(") () ")"))) (; ";")) (} "}")))) (if_statement "if (iVar2 < 1) {\n      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);\n      uVar3 = uVar3 & 0xffffffff;\n    }" (if "if") (parenthesized_expression "(iVar2 < 1)" (( "(") (binary_expression "iVar2 < 1" (identifier "iVar2") (< "<") (number_literal "1")) () ")")) (compound_statement "{\n      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);\n      uVar3 = uVar3 & 0xffffffff;\n    }" ({ "{") (expression_statement "thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);" (call_expression "thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31)" (identifier "thunk_FUN_002dac70") (argument_list "((undefined *)(local_30[0] + -0x18),&local_31)" (( "(") (cast_expression "(undefined *)(local_30[0] + -0x18)" (( "(") (type_descriptor "undefined *" (type_identifier "undefined") (abstract_pointer_declarator "*" (* "*"))) () ")") (parenthesized_expression "(local_30[0] + -0x18)" (( "(") (binary_expression "local_30[0] + -0x18" (subscript_expression "local_30[0]" (identifier "local_30") ([ "[") (number_literal "0") (] "]")) (+ "+") (number_literal "-0x18")) () ")"))) (, ",") (pointer_expression "&local_31" (& "&") (identifier "local_31")) () ")"))) (; ";")) (expression_statement "uVar3 = uVar3 & 0xffffffff;" (assignment_expression "uVar3 = uVar3 & 0xffffffff" (identifier "uVar3") (= "=") (binary_expression "uVar3 & 0xffffffff" (identifier "uVar3") (& "&") (number_literal "0xffffffff"))) (; ";")) (} "}"))) (} "}"))) (return_statement "return uVar3;" (return "return") (identifier "uVar3") (; ";")) (} "}")))

/* int std::__facet_shims::__messages_open<wchar_t>(std::integral_constant<bool, false>,
   std::locale::facet const*, char const*, unsigned long, std::locale const&) */

int std::__facet_shims::__messages_open<function_1>
              (long *param_1,char *param_2,type_1 param_3,type_2 param_4)

{
  int *piVar1;
  int iVar2;
  int var_3;
  type_3 local_31;
  long local_30 [2];
  
  std::string::var_1((var_1 *)local_30,param_2,param_3,&local_31);
                    /* try { // try from 00317191 to 00317193 has its CatchHandler @ 003171f3 */
  iVar2 = (**(type_4 **)(*param_1 + 0x10))(param_1,(var_1 *)local_30,param_4);
  if ((type_3 *)(local_30[0] + -0x18) != (type_3 *)PTR__S_empty_rep_storage_0043dc38) {
    if (var_2 == (type_5 *)0x0) {
      var_3 = *(int *)(local_30[0] + -8);
      *(int *)(local_30[0] + -8) = var_3 + -1;
    }
    else {
      var_4();
      piVar1 = (int *)(local_30[0] + -8);
      var_3 = *piVar1;
      *piVar1 = *piVar1 + -1;
      var_5();
    }
    if (var_3 < 1) {
      std::string::_Rep::var_6((type_3 *)(local_30[0] + -0x18));
    }
  }
  return iVar2;
}


(translation_unit (function_definition type: (type_identifier) declarator: (function_declarator declarator: (identifier) parameters: (parameter_list (parameter_declaration type: (sized_type_specifier) declarator: (pointer_declarator declarator: (identifier))) (parameter_declaration type: (type_identifier) declarator: (identifier)) (parameter_declaration type: (type_identifier) declarator: (identifier)) (parameter_declaration type: (type_identifier) declarator: (identifier)))) body: (compound_statement (declaration type: (primitive_type) declarator: (pointer_declarator declarator: (identifier))) (declaration type: (primitive_type) declarator: (identifier)) (declaration type: (type_identifier) declarator: (identifier)) (declaration type: (type_identifier) declarator: (identifier)) (declaration type: (sized_type_specifier) declarator: (array_declarator declarator: (identifier) size: (number_literal))) (expression_statement (call_expression function: (identifier) arguments: (argument_list (identifier) (identifier) (identifier) (pointer_expression argument: (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (call_expression function: (parenthesized_expression (pointer_expression argument: (pointer_expression argument: (cast_expression type: (type_descriptor type: (type_identifier) declarator: (abstract_pointer_declarator declarator: (abstract_pointer_declarator))) value: (parenthesized_expression (binary_expression left: (pointer_expression argument: (identifier)) right: (number_literal))))))) arguments: (argument_list (identifier) (identifier) (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (cast_expression type: (type_descriptor type: (type_identifier) declarator: (abstract_pointer_declarator)) value: (parenthesized_expression (binary_expression left: (subscript_expression argument: (identifier) index: (number_literal)) right: (number_literal)))) right: (identifier))) consequence: (compound_statement (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: (pointer_expression argument: (cast_expression type: (type_descriptor type: (primitive_type) declarator: (abstract_pointer_declarator)) value: (parenthesized_expression (binary_expression left: (subscript_expression argument: (identifier) index: (number_literal)) right: (number_literal))))))) (expression_statement (assignment_expression left: (pointer_expression argument: (cast_expression type: (type_descriptor type: (primitive_type) declarator: (abstract_pointer_declarator)) value: (parenthesized_expression (binary_expression left: (subscript_expression argument: (identifier) index: (number_literal)) right: (number_literal))))) right: (binary_expression left: (identifier) right: (number_literal))))) alternative: (else_clause (compound_statement (expression_statement (call_expression function: (identifier) arguments: (argument_list))) (expression_statement (assignment_expression left: (identifier) right: (cast_expression type: (type_descriptor type: (primitive_type) declarator: (abstract_pointer_declarator)) value: (parenthesized_expression (binary_expression left: (subscript_expression argument: (identifier) index: (number_literal)) right: (number_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (pointer_expression argument: (identifier)))) (expression_statement (assignment_expression left: (pointer_expression argument: (identifier)) right: (binary_expression left: (pointer_expression argument: (identifier)) right: (number_literal)))) (expression_statement (call_expression function: (identifier) arguments: (argument_list)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (number_literal))) consequence: (compound_statement (expression_statement (call_expression function: (identifier) arguments: (argument_list (cast_expression type: (type_descriptor type: (type_identifier) declarator: (abstract_pointer_declarator)) value: (parenthesized_expression (binary_expression left: (subscript_expression argument: (identifier) index: (number_literal)) right: (number_literal)))) (pointer_expression argument: (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (number_literal)))))))) (return_statement (identifier)))))

ulong MASKED(long *param_1,undefined8 param_2,undefined8 param_3,undefined8 param_4)

{
  int *piVar1;
  int iVar2;
  ulong uVar3;
  undefined1 local_31;
  long local_30 [2];
  
  FUN_0030f2e0(local_30,param_2,param_3,&local_31);
                    /* try { // try from 00317191 to 00317193 has its CatchHandler @ 003171f3 */
  uVar3 = (**(code **)(*param_1 + 0x10))(param_1,local_30,param_4);
  if ((undefined *)(local_30[0] + -0x18) != PTR_DAT_0043dc38) {
    if (PTR___pthread_key_create_0043dee8 == (undefined *)0x0) {
      iVar2 = *(int *)(local_30[0] + -8);
      *(int *)(local_30[0] + -8) = iVar2 + -1;
    }
    else {
      LOCK();
      piVar1 = (int *)(local_30[0] + -8);
      iVar2 = *piVar1;
      *piVar1 = *piVar1 + -1;
      UNLOCK();
    }
    if (iVar2 < 1) {
      thunk_FUN_002dac70((undefined *)(local_30[0] + -0x18),&local_31);
      uVar3 = uVar3 & 0xffffffff;
    }
  }
  return uVar3;
}

