
/* std::string::replace(unsigned long, unsigned long, char const*, unsigned long) */

string * __thiscall
std::string::replace(string *this,ulong param_1,ulong param_2,char *param_3,ulong param_4)

{
  int *piVar1;
  ulong uVar2;
  long lVar3;
  string *psVar4;
  int iVar5;
  ulong uVar6;
  char *pcVar7;
  allocator local_31;
  char *local_30 [2];
  
  pcVar7 = *(char **)this;
  uVar2 = *(ulong *)(pcVar7 + -0x18);
  if (uVar2 < param_1) {
                    /* WARNING: Subroutine does not return */
    __throw_out_of_range_fmt
              ("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",
               param_1);
  }
  uVar6 = uVar2 - param_1;
  if (param_2 < uVar2 - param_1) {
    uVar6 = param_2;
  }
  if ((0x3ffffffffffffff9 - uVar2) + uVar6 < param_4) {
                    /* WARNING: Subroutine does not return */
    __throw_length_error("basic_string::replace");
  }
  if (((param_3 < pcVar7) || (pcVar7 + uVar2 < param_3)) || (0 < *(int *)(pcVar7 + -8))) {
    this = (string *)_M_replace_safe(this,param_1,uVar6,param_3,param_4);
  }
  else {
    lVar3 = *(long *)this;
    if ((char *)(lVar3 + param_1) < param_3 + param_4) {
      if (param_3 < (char *)(param_1 + uVar6 + lVar3)) {
        string((string *)local_30,param_3,param_4,&local_31);
                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */
        psVar4 = (string *)_M_replace_safe(this,param_1,uVar6,local_30[0],param_4);
        if ((allocator *)(local_30[0] + -0x18) == (allocator *)PTR__S_empty_rep_storage_003bdc38) {
          return psVar4;
        }
        if (PTR___pthread_key_create_003bdee8 == (undefined *)0x0) {
          iVar5 = *(int *)(local_30[0] + -8);
          *(int *)(local_30[0] + -8) = iVar5 + -1;
        }
        else {
          LOCK();
          piVar1 = (int *)(local_30[0] + -8);
          iVar5 = *piVar1;
          *piVar1 = *piVar1 + -1;
          UNLOCK();
        }
        if (0 < iVar5) {
          return psVar4;
        }
        _Rep::_M_destroy((allocator *)(local_30[0] + -0x18));
        return psVar4;
      }
      lVar3 = (param_4 - lVar3) - uVar6;
    }
    else {
      lVar3 = -lVar3;
    }
    _M_mutate(this,param_1,uVar6,param_4);
    pcVar7 = (char *)(*(long *)this + param_1);
    if (param_4 == 1) {
      *pcVar7 = param_3[*(long *)this + lVar3];
    }
    else if (param_4 != 0) {
      memcpy(pcVar7,param_3 + *(long *)this + lVar3,param_4);
    }
  }
  return this;
}



ulong * FUN_002ab3b0(ulong *param_1,ulong param_2,ulong param_3,ulong param_4,ulong param_5)

{
  int *piVar1;
  undefined1 *__src;
  int iVar2;
  ulong uVar3;
  ulong uVar4;
  ulong *puVar5;
  ulong uVar6;
  long lVar7;
  undefined1 *__dest;
  undefined1 local_31;
  long local_30 [2];
  
  uVar3 = *param_1;
  uVar4 = *(ulong *)(uVar3 - 0x18);
  if (uVar4 < param_2) {
                    /* WARNING: Subroutine does not return */
    FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",
                 param_2);
  }
  uVar6 = uVar4 - param_2;
  if (param_3 < uVar4 - param_2) {
    uVar6 = param_3;
  }
  if ((0x3ffffffffffffff9 - uVar4) + uVar6 < param_5) {
                    /* WARNING: Subroutine does not return */
    FUN_002b5650("basic_string::replace");
  }
  if (((param_4 < uVar3) || (uVar4 + uVar3 < param_4)) || (0 < *(int *)(uVar3 - 8))) {
    param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4);
  }
  else {
    uVar3 = *param_1;
    if (uVar3 + param_2 < param_4 + param_5) {
      if (param_4 < param_2 + uVar6 + uVar3) {
        FUN_002ab390(local_30,param_4,param_5,&local_31);
                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */
        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);
        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {
          return puVar5;
        }
        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {
          return puVar5;
        }
        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);
        return puVar5;
      }
      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;
    }
    else {
      lVar7 = param_4 - uVar3;
    }
    FUN_002a9c80(param_1,param_2,uVar6,param_5);
    __src = (undefined1 *)(*param_1 + lVar7);
    __dest = (undefined1 *)(*param_1 + param_2);
    if (param_5 == 1) {
      *__dest = *__src;
    }
    else if (param_5 != 0) {
      memcpy(__dest,__src,param_5);
    }
  }
  return param_1;
}


PUSH R13
PUSH R12
MOV R12,RSI
MOV RSI,RCX
PUSH RBP
PUSH RBX
SUB RSP,0x28
MOV RAX,qword ptr [RDI]
MOV RCX,qword ptr [RAX + -0x18]
CMP R12,RCX
JA 0x002ab549
MOV RBX,RCX
SUB RBX,R12
CMP RBX,RDX
CMOVA RBX,RDX
MOV RDX,0x3ffffffffffffff9
SUB RDX,RCX
ADD RDX,RBX
CMP R8,RDX
JA 0x002ab53d
MOV RBP,RDI
CMP RAX,RSI
JBE 0x002ab420
MOV RCX,RSI
MOV RDI,RBP
MOV RDX,RBX
MOV RSI,R12
CALL 0x002aa320
MOV RBP,RAX
ADD RSP,0x28
MOV RAX,RBP
POP RBX
POP RBP
POP R12
POP R13
RET
ADD RCX,RAX
CMP RCX,RSI
JC 0x002ab3fe
MOV EAX,dword ptr [RAX + -0x8]
TEST EAX,EAX
JG 0x002ab3fe
MOV RAX,qword ptr [RDI]
LEA RCX,[RSI + R8*0x1]
LEA RDX,[RAX + R12*0x1]
CMP RCX,RDX
JBE 0x002ab518
LEA RDX,[R12 + RBX*0x1]
ADD RDX,RAX
CMP RSI,RDX
JC 0x002ab4a0
SUB RSI,RAX
ADD RSI,R8
SUB RSI,RBX
MOV R13,RSI
MOV RCX,R8
MOV RSI,R12
MOV RDI,RBP
MOV RDX,RBX
MOV qword ptr [RSP + 0x8],R8
CALL 0x002a9c80
MOV RDI,qword ptr [RBP]
MOV R8,qword ptr [RSP + 0x8]
LEA RSI,[RDI + R13*0x1]
ADD RDI,R12
CMP R8,0x1
JZ 0x002ab528
TEST R8,R8
JZ 0x002ab412
MOV RDX,R8
CALL 0x0013eaa0
JMP 0x002ab412
LEA R13,[RSP + 0x17]
MOV RDX,R8
LEA RDI,[RSP + 0x18]
MOV qword ptr [RSP + 0x8],R8
MOV RCX,R13
CALL 0x002ab390
MOV R8,qword ptr [RSP + 0x8]
MOV RDX,RBX
MOV RSI,R12
MOV RCX,qword ptr [RSP + 0x18]
MOV RDI,RBP
CALL 0x002aa320
MOV RBP,RAX
MOV RAX,qword ptr [RSP + 0x18]
LEA RDI,[RAX + -0x18]
CMP RDI,qword ptr [0x003bdc38]
JZ 0x002ab412
CMP qword ptr [0x003bdee8],0x0
JZ 0x002ab532
MOV EDX,0xffffffff
XADD.LOCK dword ptr [RAX + -0x8],EDX
TEST EDX,EDX
JG 0x002ab412
MOV RSI,R13
CALL 0x002a9af0
JMP 0x002ab412
SUB RSI,RAX
MOV R13,RSI
JMP 0x002ab45b
MOVZX EAX,byte ptr [RSI]
MOV byte ptr [RDI],AL
JMP 0x002ab412
MOV EDX,dword ptr [RAX + -0x8]
LEA ECX,[RDX + -0x1]
MOV dword ptr [RAX + -0x8],ECX
JMP 0x002ab4ff
LEA RDI,[0x329286]
CALL 0x002b5650
MOV RDX,R12
LEA RSI,[0x329286]
LEA RDI,[0x311130]
XOR EAX,EAX
CALL 0x002b56d0
(translation_unit "ulong * FUN_002ab3b0(ulong *param_1,ulong param_2,ulong param_3,ulong param_4,ulong param_5)\n\n{\n  int *piVar1;\n  undefined1 *__src;\n  int iVar2;\n  ulong uVar3;\n  ulong uVar4;\n  ulong *puVar5;\n  ulong uVar6;\n  long lVar7;\n  undefined1 *__dest;\n  undefined1 local_31;\n  long local_30 [2];\n  \n  uVar3 = *param_1;\n  uVar4 = *(ulong *)(uVar3 - 0x18);\n  if (uVar4 < param_2) {\n                    /* WARNING: Subroutine does not return */\n    FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2);\n  }\n  uVar6 = uVar4 - param_2;\n  if (param_3 < uVar4 - param_2) {\n    uVar6 = param_3;\n  }\n  if ((0x3ffffffffffffff9 - uVar4) + uVar6 < param_5) {\n                    /* WARNING: Subroutine does not return */\n    FUN_002b5650("basic_string::replace");\n  }\n  if (((param_4 < uVar3) || (uVar4 + uVar3 < param_4)) || (0 < *(int *)(uVar3 - 8))) {\n    param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4);\n  }\n  else {\n    uVar3 = *param_1;\n    if (uVar3 + param_2 < param_4 + param_5) {\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */\n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }\n    else {\n      lVar7 = param_4 - uVar3;\n    }\n    FUN_002a9c80(param_1,param_2,uVar6,param_5);\n    __src = (undefined1 *)(*param_1 + lVar7);\n    __dest = (undefined1 *)(*param_1 + param_2);\n    if (param_5 == 1) {\n      *__dest = *__src;\n    }\n    else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }\n  }\n  return param_1;\n}\n\n" (function_definition "ulong * FUN_002ab3b0(ulong *param_1,ulong param_2,ulong param_3,ulong param_4,ulong param_5)\n\n{\n  int *piVar1;\n  undefined1 *__src;\n  int iVar2;\n  ulong uVar3;\n  ulong uVar4;\n  ulong *puVar5;\n  ulong uVar6;\n  long lVar7;\n  undefined1 *__dest;\n  undefined1 local_31;\n  long local_30 [2];\n  \n  uVar3 = *param_1;\n  uVar4 = *(ulong *)(uVar3 - 0x18);\n  if (uVar4 < param_2) {\n                    /* WARNING: Subroutine does not return */\n    FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2);\n  }\n  uVar6 = uVar4 - param_2;\n  if (param_3 < uVar4 - param_2) {\n    uVar6 = param_3;\n  }\n  if ((0x3ffffffffffffff9 - uVar4) + uVar6 < param_5) {\n                    /* WARNING: Subroutine does not return */\n    FUN_002b5650("basic_string::replace");\n  }\n  if (((param_4 < uVar3) || (uVar4 + uVar3 < param_4)) || (0 < *(int *)(uVar3 - 8))) {\n    param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4);\n  }\n  else {\n    uVar3 = *param_1;\n    if (uVar3 + param_2 < param_4 + param_5) {\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */\n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }\n    else {\n      lVar7 = param_4 - uVar3;\n    }\n    FUN_002a9c80(param_1,param_2,uVar6,param_5);\n    __src = (undefined1 *)(*param_1 + lVar7);\n    __dest = (undefined1 *)(*param_1 + param_2);\n    if (param_5 == 1) {\n      *__dest = *__src;\n    }\n    else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }\n  }\n  return param_1;\n}" type_identifier (pointer_declarator "* FUN_002ab3b0(ulong *param_1,ulong param_2,ulong param_3,ulong param_4,ulong param_5)" * (function_declarator "FUN_002ab3b0(ulong *param_1,ulong param_2,ulong param_3,ulong param_4,ulong param_5)" identifier (parameter_list "(ulong *param_1,ulong param_2,ulong param_3,ulong param_4,ulong param_5)" ( (parameter_declaration "ulong *param_1" type_identifier (pointer_declarator "*param_1" * identifier)) , (parameter_declaration "ulong param_2" type_identifier identifier) , (parameter_declaration "ulong param_3" type_identifier identifier) , (parameter_declaration "ulong param_4" type_identifier identifier) , (parameter_declaration "ulong param_5" type_identifier identifier) )))) (compound_statement "{\n  int *piVar1;\n  undefined1 *__src;\n  int iVar2;\n  ulong uVar3;\n  ulong uVar4;\n  ulong *puVar5;\n  ulong uVar6;\n  long lVar7;\n  undefined1 *__dest;\n  undefined1 local_31;\n  long local_30 [2];\n  \n  uVar3 = *param_1;\n  uVar4 = *(ulong *)(uVar3 - 0x18);\n  if (uVar4 < param_2) {\n                    /* WARNING: Subroutine does not return */\n    FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2);\n  }\n  uVar6 = uVar4 - param_2;\n  if (param_3 < uVar4 - param_2) {\n    uVar6 = param_3;\n  }\n  if ((0x3ffffffffffffff9 - uVar4) + uVar6 < param_5) {\n                    /* WARNING: Subroutine does not return */\n    FUN_002b5650("basic_string::replace");\n  }\n  if (((param_4 < uVar3) || (uVar4 + uVar3 < param_4)) || (0 < *(int *)(uVar3 - 8))) {\n    param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4);\n  }\n  else {\n    uVar3 = *param_1;\n    if (uVar3 + param_2 < param_4 + param_5) {\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */\n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }\n    else {\n      lVar7 = param_4 - uVar3;\n    }\n    FUN_002a9c80(param_1,param_2,uVar6,param_5);\n    __src = (undefined1 *)(*param_1 + lVar7);\n    __dest = (undefined1 *)(*param_1 + param_2);\n    if (param_5 == 1) {\n      *__dest = *__src;\n    }\n    else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }\n  }\n  return param_1;\n}" { (declaration "int *piVar1;" primitive_type (pointer_declarator "*piVar1" * identifier) ;) (declaration "undefined1 *__src;" type_identifier (pointer_declarator "*__src" * identifier) ;) (declaration "int iVar2;" primitive_type identifier ;) (declaration "ulong uVar3;" type_identifier identifier ;) (declaration "ulong uVar4;" type_identifier identifier ;) (declaration "ulong *puVar5;" type_identifier (pointer_declarator "*puVar5" * identifier) ;) (declaration "ulong uVar6;" type_identifier identifier ;) (declaration "long lVar7;" (sized_type_specifier "long" long) identifier ;) (declaration "undefined1 *__dest;" type_identifier (pointer_declarator "*__dest" * 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 "uVar3 = *param_1;" (assignment_expression "uVar3 = *param_1" identifier = (pointer_expression "*param_1" * identifier)) ;) (expression_statement "uVar4 = *(ulong *)(uVar3 - 0x18);" (assignment_expression "uVar4 = *(ulong *)(uVar3 - 0x18)" identifier = (pointer_expression "*(ulong *)(uVar3 - 0x18)" * (cast_expression "(ulong *)(uVar3 - 0x18)" ( (type_descriptor "ulong *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(uVar3 - 0x18)" ( (binary_expression "uVar3 - 0x18" identifier - number_literal) ))))) ;) (if_statement "if (uVar4 < param_2) {\n                    /* WARNING: Subroutine does not return */\n    FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2);\n  }" if (parenthesized_expression "(uVar4 < param_2)" ( (binary_expression "uVar4 < param_2" identifier < identifier) )) (compound_statement "{\n                    /* WARNING: Subroutine does not return */\n    FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2);\n  }" { comment (expression_statement "FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2);" (call_expression "FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2)" identifier (argument_list "("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2)" ( (string_literal ""%s: __pos (which is %zu) > this->size() (which is %zu)"" " string_content ") , (string_literal ""basic_string::replace"" " string_content ") , identifier ))) ;) })) (expression_statement "uVar6 = uVar4 - param_2;" (assignment_expression "uVar6 = uVar4 - param_2" identifier = (binary_expression "uVar4 - param_2" identifier - identifier)) ;) (if_statement "if (param_3 < uVar4 - param_2) {\n    uVar6 = param_3;\n  }" if (parenthesized_expression "(param_3 < uVar4 - param_2)" ( (binary_expression "param_3 < uVar4 - param_2" identifier < (binary_expression "uVar4 - param_2" identifier - identifier)) )) (compound_statement "{\n    uVar6 = param_3;\n  }" { (expression_statement "uVar6 = param_3;" (assignment_expression "uVar6 = param_3" identifier = identifier) ;) })) (if_statement "if ((0x3ffffffffffffff9 - uVar4) + uVar6 < param_5) {\n                    /* WARNING: Subroutine does not return */\n    FUN_002b5650("basic_string::replace");\n  }" if (parenthesized_expression "((0x3ffffffffffffff9 - uVar4) + uVar6 < param_5)" ( (binary_expression "(0x3ffffffffffffff9 - uVar4) + uVar6 < param_5" (binary_expression "(0x3ffffffffffffff9 - uVar4) + uVar6" (parenthesized_expression "(0x3ffffffffffffff9 - uVar4)" ( (binary_expression "0x3ffffffffffffff9 - uVar4" number_literal - identifier) )) + identifier) < identifier) )) (compound_statement "{\n                    /* WARNING: Subroutine does not return */\n    FUN_002b5650("basic_string::replace");\n  }" { comment (expression_statement "FUN_002b5650("basic_string::replace");" (call_expression "FUN_002b5650("basic_string::replace")" identifier (argument_list "("basic_string::replace")" ( (string_literal ""basic_string::replace"" " string_content ") ))) ;) })) (if_statement "if (((param_4 < uVar3) || (uVar4 + uVar3 < param_4)) || (0 < *(int *)(uVar3 - 8))) {\n    param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4);\n  }\n  else {\n    uVar3 = *param_1;\n    if (uVar3 + param_2 < param_4 + param_5) {\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */\n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }\n    else {\n      lVar7 = param_4 - uVar3;\n    }\n    FUN_002a9c80(param_1,param_2,uVar6,param_5);\n    __src = (undefined1 *)(*param_1 + lVar7);\n    __dest = (undefined1 *)(*param_1 + param_2);\n    if (param_5 == 1) {\n      *__dest = *__src;\n    }\n    else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }\n  }" if (parenthesized_expression "(((param_4 < uVar3) || (uVar4 + uVar3 < param_4)) || (0 < *(int *)(uVar3 - 8)))" ( (binary_expression "((param_4 < uVar3) || (uVar4 + uVar3 < param_4)) || (0 < *(int *)(uVar3 - 8))" (parenthesized_expression "((param_4 < uVar3) || (uVar4 + uVar3 < param_4))" ( (binary_expression "(param_4 < uVar3) || (uVar4 + uVar3 < param_4)" (parenthesized_expression "(param_4 < uVar3)" ( (binary_expression "param_4 < uVar3" identifier < identifier) )) || (parenthesized_expression "(uVar4 + uVar3 < param_4)" ( (binary_expression "uVar4 + uVar3 < param_4" (binary_expression "uVar4 + uVar3" identifier + identifier) < identifier) ))) )) || (parenthesized_expression "(0 < *(int *)(uVar3 - 8))" ( (binary_expression "0 < *(int *)(uVar3 - 8)" number_literal < (pointer_expression "*(int *)(uVar3 - 8)" * (cast_expression "(int *)(uVar3 - 8)" ( (type_descriptor "int *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(uVar3 - 8)" ( (binary_expression "uVar3 - 8" identifier - number_literal) ))))) ))) )) (compound_statement "{\n    param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4);\n  }" { (expression_statement "param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4);" (assignment_expression "param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4)" identifier = (cast_expression "(ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4)" ( (type_descriptor "ulong *" type_identifier (abstract_pointer_declarator "*" *)) ) (call_expression "FUN_002aa320(param_1,param_2,uVar6,param_4)" identifier (argument_list "(param_1,param_2,uVar6,param_4)" ( identifier , identifier , identifier , identifier ))))) ;) }) (else_clause "else {\n    uVar3 = *param_1;\n    if (uVar3 + param_2 < param_4 + param_5) {\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */\n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }\n    else {\n      lVar7 = param_4 - uVar3;\n    }\n    FUN_002a9c80(param_1,param_2,uVar6,param_5);\n    __src = (undefined1 *)(*param_1 + lVar7);\n    __dest = (undefined1 *)(*param_1 + param_2);\n    if (param_5 == 1) {\n      *__dest = *__src;\n    }\n    else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }\n  }" else (compound_statement "{\n    uVar3 = *param_1;\n    if (uVar3 + param_2 < param_4 + param_5) {\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */\n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }\n    else {\n      lVar7 = param_4 - uVar3;\n    }\n    FUN_002a9c80(param_1,param_2,uVar6,param_5);\n    __src = (undefined1 *)(*param_1 + lVar7);\n    __dest = (undefined1 *)(*param_1 + param_2);\n    if (param_5 == 1) {\n      *__dest = *__src;\n    }\n    else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }\n  }" { (expression_statement "uVar3 = *param_1;" (assignment_expression "uVar3 = *param_1" identifier = (pointer_expression "*param_1" * identifier)) ;) (if_statement "if (uVar3 + param_2 < param_4 + param_5) {\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */\n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }\n    else {\n      lVar7 = param_4 - uVar3;\n    }" if (parenthesized_expression "(uVar3 + param_2 < param_4 + param_5)" ( (binary_expression "uVar3 + param_2 < param_4 + param_5" (binary_expression "uVar3 + param_2" identifier + identifier) < (binary_expression "param_4 + param_5" identifier + identifier)) )) (compound_statement "{\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */\n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }" { (if_statement "if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */\n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }" if (parenthesized_expression "(param_4 < param_2 + uVar6 + uVar3)" ( (binary_expression "param_4 < param_2 + uVar6 + uVar3" identifier < (binary_expression "param_2 + uVar6 + uVar3" (binary_expression "param_2 + uVar6" identifier + identifier) + identifier)) )) (compound_statement "{\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */\n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }" { (expression_statement "FUN_002ab390(local_30,param_4,param_5,&local_31);" (call_expression "FUN_002ab390(local_30,param_4,param_5,&local_31)" identifier (argument_list "(local_30,param_4,param_5,&local_31)" ( identifier , identifier , identifier , (pointer_expression "&local_31" & identifier) ))) ;) comment (expression_statement "puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);" (assignment_expression "puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5)" identifier = (cast_expression "(ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5)" ( (type_descriptor "ulong *" type_identifier (abstract_pointer_declarator "*" *)) ) (call_expression "FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5)" identifier (argument_list "(param_1,param_2,uVar6,local_30[0],param_5)" ( identifier , identifier , identifier , (subscript_expression "local_30[0]" identifier [ number_literal ]) , identifier ))))) ;) (if_statement "if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }" if (parenthesized_expression "((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38)" ( (binary_expression "(undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38" (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          return puVar5;\n        }" { (return_statement "return puVar5;" return identifier ;) })) (if_statement "if (PTR___pthread_key_create_003bdee8 == (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_003bdee8 == (undefined *)0x0)" ( (binary_expression "PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }" if (parenthesized_expression "(0 < iVar2)" ( (binary_expression "0 < iVar2" number_literal < identifier) )) (compound_statement "{\n          return puVar5;\n        }" { (return_statement "return puVar5;" return identifier ;) })) (expression_statement "thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);" (call_expression "thunk_FUN_00276d20((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) ))) ;) (return_statement "return puVar5;" return identifier ;) })) (expression_statement "lVar7 = ((param_4 - uVar3) + param_5) - uVar6;" (assignment_expression "lVar7 = ((param_4 - uVar3) + param_5) - uVar6" identifier = (binary_expression "((param_4 - uVar3) + param_5) - uVar6" (parenthesized_expression "((param_4 - uVar3) + param_5)" ( (binary_expression "(param_4 - uVar3) + param_5" (parenthesized_expression "(param_4 - uVar3)" ( (binary_expression "param_4 - uVar3" identifier - identifier) )) + identifier) )) - identifier)) ;) }) (else_clause "else {\n      lVar7 = param_4 - uVar3;\n    }" else (compound_statement "{\n      lVar7 = param_4 - uVar3;\n    }" { (expression_statement "lVar7 = param_4 - uVar3;" (assignment_expression "lVar7 = param_4 - uVar3" identifier = (binary_expression "param_4 - uVar3" identifier - identifier)) ;) }))) (expression_statement "FUN_002a9c80(param_1,param_2,uVar6,param_5);" (call_expression "FUN_002a9c80(param_1,param_2,uVar6,param_5)" identifier (argument_list "(param_1,param_2,uVar6,param_5)" ( identifier , identifier , identifier , identifier ))) ;) (expression_statement "__src = (undefined1 *)(*param_1 + lVar7);" (assignment_expression "__src = (undefined1 *)(*param_1 + lVar7)" identifier = (cast_expression "(undefined1 *)(*param_1 + lVar7)" ( (type_descriptor "undefined1 *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(*param_1 + lVar7)" ( (binary_expression "*param_1 + lVar7" (pointer_expression "*param_1" * identifier) + identifier) )))) ;) (expression_statement "__dest = (undefined1 *)(*param_1 + param_2);" (assignment_expression "__dest = (undefined1 *)(*param_1 + param_2)" identifier = (cast_expression "(undefined1 *)(*param_1 + param_2)" ( (type_descriptor "undefined1 *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(*param_1 + param_2)" ( (binary_expression "*param_1 + param_2" (pointer_expression "*param_1" * identifier) + identifier) )))) ;) (if_statement "if (param_5 == 1) {\n      *__dest = *__src;\n    }\n    else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }" if (parenthesized_expression "(param_5 == 1)" ( (binary_expression "param_5 == 1" identifier == number_literal) )) (compound_statement "{\n      *__dest = *__src;\n    }" { (expression_statement "*__dest = *__src;" (assignment_expression "*__dest = *__src" (pointer_expression "*__dest" * identifier) = (pointer_expression "*__src" * identifier)) ;) }) (else_clause "else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }" else (if_statement "if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }" if (parenthesized_expression "(param_5 != 0)" ( (binary_expression "param_5 != 0" identifier != number_literal) )) (compound_statement "{\n      memcpy(__dest,__src,param_5);\n    }" { (expression_statement "memcpy(__dest,__src,param_5);" (call_expression "memcpy(__dest,__src,param_5)" identifier (argument_list "(__dest,__src,param_5)" ( identifier , identifier , identifier ))) ;) })))) }))) (return_statement "return param_1;" return identifier ;) })))
(translation_unit "/* std::string::replace(unsigned long, unsigned long, char const*, unsigned long) */\n\nstring * __thiscall\nstd::string::replace(string *this,ulong param_1,ulong param_2,char *param_3,ulong param_4)\n\n{\n  int *piVar1;\n  ulong uVar2;\n  long lVar3;\n  string *psVar4;\n  int iVar5;\n  ulong uVar6;\n  char *pcVar7;\n  allocator local_31;\n  char *local_30 [2];\n  \n  pcVar7 = *(char **)this;\n  uVar2 = *(ulong *)(pcVar7 + -0x18);\n  if (uVar2 < param_1) {\n                    /* WARNING: Subroutine does not return */\n    __throw_out_of_range_fmt\n              ("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n               param_1);\n  }\n  uVar6 = uVar2 - param_1;\n  if (param_2 < uVar2 - param_1) {\n    uVar6 = param_2;\n  }\n  if ((0x3ffffffffffffff9 - uVar2) + uVar6 < param_4) {\n                    /* WARNING: Subroutine does not return */\n    __throw_length_error("basic_string::replace");\n  }\n  if (((param_3 < pcVar7) || (pcVar7 + uVar2 < param_3)) || (0 < *(int *)(pcVar7 + -8))) {\n    this = (string *)_M_replace_safe(this,param_1,uVar6,param_3,param_4);\n  }\n  else {\n    lVar3 = *(long *)this;\n    if ((char *)(lVar3 + param_1) < param_3 + param_4) {\n      if (param_3 < (char *)(param_1 + uVar6 + lVar3)) {\n        string((string *)local_30,param_3,param_4,&local_31);\n                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */\n        psVar4 = (string *)_M_replace_safe(this,param_1,uVar6,local_30[0],param_4);\n        if ((allocator *)(local_30[0] + -0x18) == (allocator *)PTR__S_empty_rep_storage_003bdc38) {\n          return psVar4;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (undefined *)0x0) {\n          iVar5 = *(int *)(local_30[0] + -8);\n          *(int *)(local_30[0] + -8) = iVar5 + -1;\n        }\n        else {\n          LOCK();\n          piVar1 = (int *)(local_30[0] + -8);\n          iVar5 = *piVar1;\n          *piVar1 = *piVar1 + -1;\n          UNLOCK();\n        }\n        if (0 < iVar5) {\n          return psVar4;\n        }\n        _Rep::_M_destroy((allocator *)(local_30[0] + -0x18));\n        return psVar4;\n      }\n      lVar3 = (param_4 - lVar3) - uVar6;\n    }\n    else {\n      lVar3 = -lVar3;\n    }\n    _M_mutate(this,param_1,uVar6,param_4);\n    pcVar7 = (char *)(*(long *)this + param_1);\n    if (param_4 == 1) {\n      *pcVar7 = param_3[*(long *)this + lVar3];\n    }\n    else if (param_4 != 0) {\n      memcpy(pcVar7,param_3 + *(long *)this + lVar3,param_4);\n    }\n  }\n  return this;\n}\n\n" comment (ERROR "string * __thiscall\nstd::string::replace(string *this," (binary_expression "string * __thiscall\nstd::string::replace(string *this" (binary_expression "string * __thiscall" identifier * identifier) (ERROR "std::string::replace(string" identifier : : identifier : : identifier ( identifier) * identifier) ,) (declaration "ulong param_1,ulong param_2,char *param_3,ulong param_4)\n\n{\n  int *piVar1;" type_identifier identifier , (ERROR "ulong" identifier) identifier , (ERROR "char" identifier) (pointer_declarator "*param_3" * identifier) , (ERROR "ulong param_4)\n\n{\n  int" identifier identifier ) { primitive_type) (pointer_declarator "*piVar1" * identifier) ;) (declaration "ulong uVar2;" type_identifier identifier ;) (declaration "long lVar3;" (sized_type_specifier "long" long) identifier ;) (declaration "string *psVar4;" type_identifier (pointer_declarator "*psVar4" * identifier) ;) (declaration "int iVar5;" primitive_type identifier ;) (declaration "ulong uVar6;" type_identifier identifier ;) (declaration "char *pcVar7;" primitive_type (pointer_declarator "*pcVar7" * identifier) ;) (declaration "allocator local_31;" type_identifier identifier ;) (declaration "char *local_30 [2];" primitive_type (pointer_declarator "*local_30 [2]" * (array_declarator "local_30 [2]" identifier [ number_literal ])) ;) (expression_statement "pcVar7 = *(char **)this;" (assignment_expression "pcVar7 = *(char **)this" identifier = (pointer_expression "*(char **)this" * (cast_expression "(char **)this" ( (type_descriptor "char **" primitive_type (abstract_pointer_declarator "**" * (abstract_pointer_declarator "*" *))) ) identifier))) ;) (expression_statement "uVar2 = *(ulong *)(pcVar7 + -0x18);" (assignment_expression "uVar2 = *(ulong *)(pcVar7 + -0x18)" identifier = (pointer_expression "*(ulong *)(pcVar7 + -0x18)" * (cast_expression "(ulong *)(pcVar7 + -0x18)" ( (type_descriptor "ulong *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(pcVar7 + -0x18)" ( (binary_expression "pcVar7 + -0x18" identifier + number_literal) ))))) ;) (if_statement "if (uVar2 < param_1) {\n                    /* WARNING: Subroutine does not return */\n    __throw_out_of_range_fmt\n              ("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n               param_1);\n  }" if (parenthesized_expression "(uVar2 < param_1)" ( (binary_expression "uVar2 < param_1" identifier < identifier) )) (compound_statement "{\n                    /* WARNING: Subroutine does not return */\n    __throw_out_of_range_fmt\n              ("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n               param_1);\n  }" { comment (expression_statement "__throw_out_of_range_fmt\n              ("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n               param_1);" (call_expression "__throw_out_of_range_fmt\n              ("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n               param_1)" identifier (argument_list "("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n               param_1)" ( (string_literal ""%s: __pos (which is %zu) > this->size() (which is %zu)"" " string_content ") , (string_literal ""basic_string::replace"" " string_content ") , identifier ))) ;) })) (expression_statement "uVar6 = uVar2 - param_1;" (assignment_expression "uVar6 = uVar2 - param_1" identifier = (binary_expression "uVar2 - param_1" identifier - identifier)) ;) (if_statement "if (param_2 < uVar2 - param_1) {\n    uVar6 = param_2;\n  }" if (parenthesized_expression "(param_2 < uVar2 - param_1)" ( (binary_expression "param_2 < uVar2 - param_1" identifier < (binary_expression "uVar2 - param_1" identifier - identifier)) )) (compound_statement "{\n    uVar6 = param_2;\n  }" { (expression_statement "uVar6 = param_2;" (assignment_expression "uVar6 = param_2" identifier = identifier) ;) })) (if_statement "if ((0x3ffffffffffffff9 - uVar2) + uVar6 < param_4) {\n                    /* WARNING: Subroutine does not return */\n    __throw_length_error("basic_string::replace");\n  }" if (parenthesized_expression "((0x3ffffffffffffff9 - uVar2) + uVar6 < param_4)" ( (binary_expression "(0x3ffffffffffffff9 - uVar2) + uVar6 < param_4" (binary_expression "(0x3ffffffffffffff9 - uVar2) + uVar6" (parenthesized_expression "(0x3ffffffffffffff9 - uVar2)" ( (binary_expression "0x3ffffffffffffff9 - uVar2" number_literal - identifier) )) + identifier) < identifier) )) (compound_statement "{\n                    /* WARNING: Subroutine does not return */\n    __throw_length_error("basic_string::replace");\n  }" { comment (expression_statement "__throw_length_error("basic_string::replace");" (call_expression "__throw_length_error("basic_string::replace")" identifier (argument_list "("basic_string::replace")" ( (string_literal ""basic_string::replace"" " string_content ") ))) ;) })) (if_statement "if (((param_3 < pcVar7) || (pcVar7 + uVar2 < param_3)) || (0 < *(int *)(pcVar7 + -8))) {\n    this = (string *)_M_replace_safe(this,param_1,uVar6,param_3,param_4);\n  }\n  else {\n    lVar3 = *(long *)this;\n    if ((char *)(lVar3 + param_1) < param_3 + param_4) {\n      if (param_3 < (char *)(param_1 + uVar6 + lVar3)) {\n        string((string *)local_30,param_3,param_4,&local_31);\n                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */\n        psVar4 = (string *)_M_replace_safe(this,param_1,uVar6,local_30[0],param_4);\n        if ((allocator *)(local_30[0] + -0x18) == (allocator *)PTR__S_empty_rep_storage_003bdc38) {\n          return psVar4;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (undefined *)0x0) {\n          iVar5 = *(int *)(local_30[0] + -8);\n          *(int *)(local_30[0] + -8) = iVar5 + -1;\n        }\n        else {\n          LOCK();\n          piVar1 = (int *)(local_30[0] + -8);\n          iVar5 = *piVar1;\n          *piVar1 = *piVar1 + -1;\n          UNLOCK();\n        }\n        if (0 < iVar5) {\n          return psVar4;\n        }\n        _Rep::_M_destroy((allocator *)(local_30[0] + -0x18));\n        return psVar4;\n      }\n      lVar3 = (param_4 - lVar3) - uVar6;\n    }\n    else {\n      lVar3 = -lVar3;\n    }\n    _M_mutate(this,param_1,uVar6,param_4);\n    pcVar7 = (char *)(*(long *)this + param_1);\n    if (param_4 == 1) {\n      *pcVar7 = param_3[*(long *)this + lVar3];\n    }\n    else if (param_4 != 0) {\n      memcpy(pcVar7,param_3 + *(long *)this + lVar3,param_4);\n    }\n  }" if (parenthesized_expression "(((param_3 < pcVar7) || (pcVar7 + uVar2 < param_3)) || (0 < *(int *)(pcVar7 + -8)))" ( (binary_expression "((param_3 < pcVar7) || (pcVar7 + uVar2 < param_3)) || (0 < *(int *)(pcVar7 + -8))" (parenthesized_expression "((param_3 < pcVar7) || (pcVar7 + uVar2 < param_3))" ( (binary_expression "(param_3 < pcVar7) || (pcVar7 + uVar2 < param_3)" (parenthesized_expression "(param_3 < pcVar7)" ( (binary_expression "param_3 < pcVar7" identifier < identifier) )) || (parenthesized_expression "(pcVar7 + uVar2 < param_3)" ( (binary_expression "pcVar7 + uVar2 < param_3" (binary_expression "pcVar7 + uVar2" identifier + identifier) < identifier) ))) )) || (parenthesized_expression "(0 < *(int *)(pcVar7 + -8))" ( (binary_expression "0 < *(int *)(pcVar7 + -8)" number_literal < (pointer_expression "*(int *)(pcVar7 + -8)" * (cast_expression "(int *)(pcVar7 + -8)" ( (type_descriptor "int *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(pcVar7 + -8)" ( (binary_expression "pcVar7 + -8" identifier + number_literal) ))))) ))) )) (compound_statement "{\n    this = (string *)_M_replace_safe(this,param_1,uVar6,param_3,param_4);\n  }" { (expression_statement "this = (string *)_M_replace_safe(this,param_1,uVar6,param_3,param_4);" (assignment_expression "this = (string *)_M_replace_safe(this,param_1,uVar6,param_3,param_4)" identifier = (cast_expression "(string *)_M_replace_safe(this,param_1,uVar6,param_3,param_4)" ( (type_descriptor "string *" type_identifier (abstract_pointer_declarator "*" *)) ) (call_expression "_M_replace_safe(this,param_1,uVar6,param_3,param_4)" identifier (argument_list "(this,param_1,uVar6,param_3,param_4)" ( identifier , identifier , identifier , identifier , identifier ))))) ;) }) (else_clause "else {\n    lVar3 = *(long *)this;\n    if ((char *)(lVar3 + param_1) < param_3 + param_4) {\n      if (param_3 < (char *)(param_1 + uVar6 + lVar3)) {\n        string((string *)local_30,param_3,param_4,&local_31);\n                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */\n        psVar4 = (string *)_M_replace_safe(this,param_1,uVar6,local_30[0],param_4);\n        if ((allocator *)(local_30[0] + -0x18) == (allocator *)PTR__S_empty_rep_storage_003bdc38) {\n          return psVar4;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (undefined *)0x0) {\n          iVar5 = *(int *)(local_30[0] + -8);\n          *(int *)(local_30[0] + -8) = iVar5 + -1;\n        }\n        else {\n          LOCK();\n          piVar1 = (int *)(local_30[0] + -8);\n          iVar5 = *piVar1;\n          *piVar1 = *piVar1 + -1;\n          UNLOCK();\n        }\n        if (0 < iVar5) {\n          return psVar4;\n        }\n        _Rep::_M_destroy((allocator *)(local_30[0] + -0x18));\n        return psVar4;\n      }\n      lVar3 = (param_4 - lVar3) - uVar6;\n    }\n    else {\n      lVar3 = -lVar3;\n    }\n    _M_mutate(this,param_1,uVar6,param_4);\n    pcVar7 = (char *)(*(long *)this + param_1);\n    if (param_4 == 1) {\n      *pcVar7 = param_3[*(long *)this + lVar3];\n    }\n    else if (param_4 != 0) {\n      memcpy(pcVar7,param_3 + *(long *)this + lVar3,param_4);\n    }\n  }" else (compound_statement "{\n    lVar3 = *(long *)this;\n    if ((char *)(lVar3 + param_1) < param_3 + param_4) {\n      if (param_3 < (char *)(param_1 + uVar6 + lVar3)) {\n        string((string *)local_30,param_3,param_4,&local_31);\n                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */\n        psVar4 = (string *)_M_replace_safe(this,param_1,uVar6,local_30[0],param_4);\n        if ((allocator *)(local_30[0] + -0x18) == (allocator *)PTR__S_empty_rep_storage_003bdc38) {\n          return psVar4;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (undefined *)0x0) {\n          iVar5 = *(int *)(local_30[0] + -8);\n          *(int *)(local_30[0] + -8) = iVar5 + -1;\n        }\n        else {\n          LOCK();\n          piVar1 = (int *)(local_30[0] + -8);\n          iVar5 = *piVar1;\n          *piVar1 = *piVar1 + -1;\n          UNLOCK();\n        }\n        if (0 < iVar5) {\n          return psVar4;\n        }\n        _Rep::_M_destroy((allocator *)(local_30[0] + -0x18));\n        return psVar4;\n      }\n      lVar3 = (param_4 - lVar3) - uVar6;\n    }\n    else {\n      lVar3 = -lVar3;\n    }\n    _M_mutate(this,param_1,uVar6,param_4);\n    pcVar7 = (char *)(*(long *)this + param_1);\n    if (param_4 == 1) {\n      *pcVar7 = param_3[*(long *)this + lVar3];\n    }\n    else if (param_4 != 0) {\n      memcpy(pcVar7,param_3 + *(long *)this + lVar3,param_4);\n    }\n  }" { (expression_statement "lVar3 = *(long *)this;" (assignment_expression "lVar3 = *(long *)this" identifier = (pointer_expression "*(long *)this" * (cast_expression "(long *)this" ( (type_descriptor "long *" (sized_type_specifier "long" long) (abstract_pointer_declarator "*" *)) ) identifier))) ;) (if_statement "if ((char *)(lVar3 + param_1) < param_3 + param_4) {\n      if (param_3 < (char *)(param_1 + uVar6 + lVar3)) {\n        string((string *)local_30,param_3,param_4,&local_31);\n                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */\n        psVar4 = (string *)_M_replace_safe(this,param_1,uVar6,local_30[0],param_4);\n        if ((allocator *)(local_30[0] + -0x18) == (allocator *)PTR__S_empty_rep_storage_003bdc38) {\n          return psVar4;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (undefined *)0x0) {\n          iVar5 = *(int *)(local_30[0] + -8);\n          *(int *)(local_30[0] + -8) = iVar5 + -1;\n        }\n        else {\n          LOCK();\n          piVar1 = (int *)(local_30[0] + -8);\n          iVar5 = *piVar1;\n          *piVar1 = *piVar1 + -1;\n          UNLOCK();\n        }\n        if (0 < iVar5) {\n          return psVar4;\n        }\n        _Rep::_M_destroy((allocator *)(local_30[0] + -0x18));\n        return psVar4;\n      }\n      lVar3 = (param_4 - lVar3) - uVar6;\n    }\n    else {\n      lVar3 = -lVar3;\n    }" if (parenthesized_expression "((char *)(lVar3 + param_1) < param_3 + param_4)" ( (binary_expression "(char *)(lVar3 + param_1) < param_3 + param_4" (cast_expression "(char *)(lVar3 + param_1)" ( (type_descriptor "char *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(lVar3 + param_1)" ( (binary_expression "lVar3 + param_1" identifier + identifier) ))) < (binary_expression "param_3 + param_4" identifier + identifier)) )) (compound_statement "{\n      if (param_3 < (char *)(param_1 + uVar6 + lVar3)) {\n        string((string *)local_30,param_3,param_4,&local_31);\n                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */\n        psVar4 = (string *)_M_replace_safe(this,param_1,uVar6,local_30[0],param_4);\n        if ((allocator *)(local_30[0] + -0x18) == (allocator *)PTR__S_empty_rep_storage_003bdc38) {\n          return psVar4;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (undefined *)0x0) {\n          iVar5 = *(int *)(local_30[0] + -8);\n          *(int *)(local_30[0] + -8) = iVar5 + -1;\n        }\n        else {\n          LOCK();\n          piVar1 = (int *)(local_30[0] + -8);\n          iVar5 = *piVar1;\n          *piVar1 = *piVar1 + -1;\n          UNLOCK();\n        }\n        if (0 < iVar5) {\n          return psVar4;\n        }\n        _Rep::_M_destroy((allocator *)(local_30[0] + -0x18));\n        return psVar4;\n      }\n      lVar3 = (param_4 - lVar3) - uVar6;\n    }" { (if_statement "if (param_3 < (char *)(param_1 + uVar6 + lVar3)) {\n        string((string *)local_30,param_3,param_4,&local_31);\n                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */\n        psVar4 = (string *)_M_replace_safe(this,param_1,uVar6,local_30[0],param_4);\n        if ((allocator *)(local_30[0] + -0x18) == (allocator *)PTR__S_empty_rep_storage_003bdc38) {\n          return psVar4;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (undefined *)0x0) {\n          iVar5 = *(int *)(local_30[0] + -8);\n          *(int *)(local_30[0] + -8) = iVar5 + -1;\n        }\n        else {\n          LOCK();\n          piVar1 = (int *)(local_30[0] + -8);\n          iVar5 = *piVar1;\n          *piVar1 = *piVar1 + -1;\n          UNLOCK();\n        }\n        if (0 < iVar5) {\n          return psVar4;\n        }\n        _Rep::_M_destroy((allocator *)(local_30[0] + -0x18));\n        return psVar4;\n      }" if (parenthesized_expression "(param_3 < (char *)(param_1 + uVar6 + lVar3))" ( (binary_expression "param_3 < (char *)(param_1 + uVar6 + lVar3)" identifier < (cast_expression "(char *)(param_1 + uVar6 + lVar3)" ( (type_descriptor "char *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(param_1 + uVar6 + lVar3)" ( (binary_expression "param_1 + uVar6 + lVar3" (binary_expression "param_1 + uVar6" identifier + identifier) + identifier) )))) )) (compound_statement "{\n        string((string *)local_30,param_3,param_4,&local_31);\n                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */\n        psVar4 = (string *)_M_replace_safe(this,param_1,uVar6,local_30[0],param_4);\n        if ((allocator *)(local_30[0] + -0x18) == (allocator *)PTR__S_empty_rep_storage_003bdc38) {\n          return psVar4;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (undefined *)0x0) {\n          iVar5 = *(int *)(local_30[0] + -8);\n          *(int *)(local_30[0] + -8) = iVar5 + -1;\n        }\n        else {\n          LOCK();\n          piVar1 = (int *)(local_30[0] + -8);\n          iVar5 = *piVar1;\n          *piVar1 = *piVar1 + -1;\n          UNLOCK();\n        }\n        if (0 < iVar5) {\n          return psVar4;\n        }\n        _Rep::_M_destroy((allocator *)(local_30[0] + -0x18));\n        return psVar4;\n      }" { (expression_statement "string((string *)local_30,param_3,param_4,&local_31);" (call_expression "string((string *)local_30,param_3,param_4,&local_31)" identifier (argument_list "((string *)local_30,param_3,param_4,&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 "psVar4 = (string *)_M_replace_safe(this,param_1,uVar6,local_30[0],param_4);" (assignment_expression "psVar4 = (string *)_M_replace_safe(this,param_1,uVar6,local_30[0],param_4)" identifier = (cast_expression "(string *)_M_replace_safe(this,param_1,uVar6,local_30[0],param_4)" ( (type_descriptor "string *" type_identifier (abstract_pointer_declarator "*" *)) ) (call_expression "_M_replace_safe(this,param_1,uVar6,local_30[0],param_4)" identifier (argument_list "(this,param_1,uVar6,local_30[0],param_4)" ( identifier , identifier , identifier , (subscript_expression "local_30[0]" identifier [ number_literal ]) , identifier ))))) ;) (if_statement "if ((allocator *)(local_30[0] + -0x18) == (allocator *)PTR__S_empty_rep_storage_003bdc38) {\n          return psVar4;\n        }" if (parenthesized_expression "((allocator *)(local_30[0] + -0x18) == (allocator *)PTR__S_empty_rep_storage_003bdc38)" ( (binary_expression "(allocator *)(local_30[0] + -0x18) == (allocator *)PTR__S_empty_rep_storage_003bdc38" (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_003bdc38" ( (type_descriptor "allocator *" type_identifier (abstract_pointer_declarator "*" *)) ) identifier)) )) (compound_statement "{\n          return psVar4;\n        }" { (return_statement "return psVar4;" return identifier ;) })) (if_statement "if (PTR___pthread_key_create_003bdee8 == (undefined *)0x0) {\n          iVar5 = *(int *)(local_30[0] + -8);\n          *(int *)(local_30[0] + -8) = iVar5 + -1;\n        }\n        else {\n          LOCK();\n          piVar1 = (int *)(local_30[0] + -8);\n          iVar5 = *piVar1;\n          *piVar1 = *piVar1 + -1;\n          UNLOCK();\n        }" if (parenthesized_expression "(PTR___pthread_key_create_003bdee8 == (undefined *)0x0)" ( (binary_expression "PTR___pthread_key_create_003bdee8 == (undefined *)0x0" identifier == (cast_expression "(undefined *)0x0" ( (type_descriptor "undefined *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal)) )) (compound_statement "{\n          iVar5 = *(int *)(local_30[0] + -8);\n          *(int *)(local_30[0] + -8) = iVar5 + -1;\n        }" { (expression_statement "iVar5 = *(int *)(local_30[0] + -8);" (assignment_expression "iVar5 = *(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) = iVar5 + -1;" (assignment_expression "*(int *)(local_30[0] + -8) = iVar5 + -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 "iVar5 + -1" identifier + number_literal)) ;) }) (else_clause "else {\n          LOCK();\n          piVar1 = (int *)(local_30[0] + -8);\n          iVar5 = *piVar1;\n          *piVar1 = *piVar1 + -1;\n          UNLOCK();\n        }" else (compound_statement "{\n          LOCK();\n          piVar1 = (int *)(local_30[0] + -8);\n          iVar5 = *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 "iVar5 = *piVar1;" (assignment_expression "iVar5 = *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 (0 < iVar5) {\n          return psVar4;\n        }" if (parenthesized_expression "(0 < iVar5)" ( (binary_expression "0 < iVar5" number_literal < identifier) )) (compound_statement "{\n          return psVar4;\n        }" { (return_statement "return psVar4;" return identifier ;) })) (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 psVar4;" return identifier ;) })) (expression_statement "lVar3 = (param_4 - lVar3) - uVar6;" (assignment_expression "lVar3 = (param_4 - lVar3) - uVar6" identifier = (binary_expression "(param_4 - lVar3) - uVar6" (parenthesized_expression "(param_4 - lVar3)" ( (binary_expression "param_4 - lVar3" identifier - identifier) )) - identifier)) ;) }) (else_clause "else {\n      lVar3 = -lVar3;\n    }" else (compound_statement "{\n      lVar3 = -lVar3;\n    }" { (expression_statement "lVar3 = -lVar3;" (assignment_expression "lVar3 = -lVar3" identifier = (unary_expression "-lVar3" - identifier)) ;) }))) (expression_statement "_M_mutate(this,param_1,uVar6,param_4);" (call_expression "_M_mutate(this,param_1,uVar6,param_4)" identifier (argument_list "(this,param_1,uVar6,param_4)" ( identifier , identifier , identifier , identifier ))) ;) (expression_statement "pcVar7 = (char *)(*(long *)this + param_1);" (assignment_expression "pcVar7 = (char *)(*(long *)this + param_1)" identifier = (cast_expression "(char *)(*(long *)this + param_1)" ( (type_descriptor "char *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(*(long *)this + param_1)" ( (binary_expression "*(long *)this + param_1" (pointer_expression "*(long *)this" * (cast_expression "(long *)this" ( (type_descriptor "long *" (sized_type_specifier "long" long) (abstract_pointer_declarator "*" *)) ) identifier)) + identifier) )))) ;) (if_statement "if (param_4 == 1) {\n      *pcVar7 = param_3[*(long *)this + lVar3];\n    }\n    else if (param_4 != 0) {\n      memcpy(pcVar7,param_3 + *(long *)this + lVar3,param_4);\n    }" if (parenthesized_expression "(param_4 == 1)" ( (binary_expression "param_4 == 1" identifier == number_literal) )) (compound_statement "{\n      *pcVar7 = param_3[*(long *)this + lVar3];\n    }" { (expression_statement "*pcVar7 = param_3[*(long *)this + lVar3];" (assignment_expression "*pcVar7 = param_3[*(long *)this + lVar3]" (pointer_expression "*pcVar7" * identifier) = (subscript_expression "param_3[*(long *)this + lVar3]" identifier [ (binary_expression "*(long *)this + lVar3" (pointer_expression "*(long *)this" * (cast_expression "(long *)this" ( (type_descriptor "long *" (sized_type_specifier "long" long) (abstract_pointer_declarator "*" *)) ) identifier)) + identifier) ])) ;) }) (else_clause "else if (param_4 != 0) {\n      memcpy(pcVar7,param_3 + *(long *)this + lVar3,param_4);\n    }" else (if_statement "if (param_4 != 0) {\n      memcpy(pcVar7,param_3 + *(long *)this + lVar3,param_4);\n    }" if (parenthesized_expression "(param_4 != 0)" ( (binary_expression "param_4 != 0" identifier != number_literal) )) (compound_statement "{\n      memcpy(pcVar7,param_3 + *(long *)this + lVar3,param_4);\n    }" { (expression_statement "memcpy(pcVar7,param_3 + *(long *)this + lVar3,param_4);" (call_expression "memcpy(pcVar7,param_3 + *(long *)this + lVar3,param_4)" identifier (argument_list "(pcVar7,param_3 + *(long *)this + lVar3,param_4)" ( identifier , (binary_expression "param_3 + *(long *)this + lVar3" (binary_expression "param_3 + *(long *)this" identifier + (pointer_expression "*(long *)this" * (cast_expression "(long *)this" ( (type_descriptor "long *" (sized_type_specifier "long" long) (abstract_pointer_declarator "*" *)) ) identifier))) + identifier) , identifier ))) ;) })))) }))) (return_statement "return this;" return identifier ;) (ERROR "}" }))
(translation_unit "ulong * FUN_002ab3b0(ulong *param_1,ulong param_2,ulong param_3,ulong param_4,ulong param_5)\n\n{\n  int *piVar1;\n  undefined1 *__src;\n  int iVar2;\n  ulong uVar3;\n  ulong uVar4;\n  ulong *puVar5;\n  ulong uVar6;\n  long lVar7;\n  undefined1 *__dest;\n  undefined1 local_31;\n  long local_30 [2];\n  \n  uVar3 = *param_1;\n  uVar4 = *(ulong *)(uVar3 - 0x18);\n  if (uVar4 < param_2) {\n                    \n    FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2);\n  }\n  uVar6 = uVar4 - param_2;\n  if (param_3 < uVar4 - param_2) {\n    uVar6 = param_3;\n  }\n  if ((0x3ffffffffffffff9 - uVar4) + uVar6 < param_5) {\n                    \n    FUN_002b5650("basic_string::replace");\n  }\n  if (((param_4 < uVar3) || (uVar4 + uVar3 < param_4)) || (0 < *(int *)(uVar3 - 8))) {\n    param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4);\n  }\n  else {\n    uVar3 = *param_1;\n    if (uVar3 + param_2 < param_4 + param_5) {\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    \n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }\n    else {\n      lVar7 = param_4 - uVar3;\n    }\n    FUN_002a9c80(param_1,param_2,uVar6,param_5);\n    __src = (undefined1 *)(*param_1 + lVar7);\n    __dest = (undefined1 *)(*param_1 + param_2);\n    if (param_5 == 1) {\n      *__dest = *__src;\n    }\n    else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }\n  }\n  return param_1;\n}\n\n" (function_definition "ulong * FUN_002ab3b0(ulong *param_1,ulong param_2,ulong param_3,ulong param_4,ulong param_5)\n\n{\n  int *piVar1;\n  undefined1 *__src;\n  int iVar2;\n  ulong uVar3;\n  ulong uVar4;\n  ulong *puVar5;\n  ulong uVar6;\n  long lVar7;\n  undefined1 *__dest;\n  undefined1 local_31;\n  long local_30 [2];\n  \n  uVar3 = *param_1;\n  uVar4 = *(ulong *)(uVar3 - 0x18);\n  if (uVar4 < param_2) {\n                    \n    FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2);\n  }\n  uVar6 = uVar4 - param_2;\n  if (param_3 < uVar4 - param_2) {\n    uVar6 = param_3;\n  }\n  if ((0x3ffffffffffffff9 - uVar4) + uVar6 < param_5) {\n                    \n    FUN_002b5650("basic_string::replace");\n  }\n  if (((param_4 < uVar3) || (uVar4 + uVar3 < param_4)) || (0 < *(int *)(uVar3 - 8))) {\n    param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4);\n  }\n  else {\n    uVar3 = *param_1;\n    if (uVar3 + param_2 < param_4 + param_5) {\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    \n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }\n    else {\n      lVar7 = param_4 - uVar3;\n    }\n    FUN_002a9c80(param_1,param_2,uVar6,param_5);\n    __src = (undefined1 *)(*param_1 + lVar7);\n    __dest = (undefined1 *)(*param_1 + param_2);\n    if (param_5 == 1) {\n      *__dest = *__src;\n    }\n    else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }\n  }\n  return param_1;\n}" type_identifier (pointer_declarator "* FUN_002ab3b0(ulong *param_1,ulong param_2,ulong param_3,ulong param_4,ulong param_5)" * (function_declarator "FUN_002ab3b0(ulong *param_1,ulong param_2,ulong param_3,ulong param_4,ulong param_5)" identifier (parameter_list "(ulong *param_1,ulong param_2,ulong param_3,ulong param_4,ulong param_5)" ( (parameter_declaration "ulong *param_1" type_identifier (pointer_declarator "*param_1" * identifier)) , (parameter_declaration "ulong param_2" type_identifier identifier) , (parameter_declaration "ulong param_3" type_identifier identifier) , (parameter_declaration "ulong param_4" type_identifier identifier) , (parameter_declaration "ulong param_5" type_identifier identifier) )))) (compound_statement "{\n  int *piVar1;\n  undefined1 *__src;\n  int iVar2;\n  ulong uVar3;\n  ulong uVar4;\n  ulong *puVar5;\n  ulong uVar6;\n  long lVar7;\n  undefined1 *__dest;\n  undefined1 local_31;\n  long local_30 [2];\n  \n  uVar3 = *param_1;\n  uVar4 = *(ulong *)(uVar3 - 0x18);\n  if (uVar4 < param_2) {\n                    \n    FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2);\n  }\n  uVar6 = uVar4 - param_2;\n  if (param_3 < uVar4 - param_2) {\n    uVar6 = param_3;\n  }\n  if ((0x3ffffffffffffff9 - uVar4) + uVar6 < param_5) {\n                    \n    FUN_002b5650("basic_string::replace");\n  }\n  if (((param_4 < uVar3) || (uVar4 + uVar3 < param_4)) || (0 < *(int *)(uVar3 - 8))) {\n    param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4);\n  }\n  else {\n    uVar3 = *param_1;\n    if (uVar3 + param_2 < param_4 + param_5) {\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    \n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }\n    else {\n      lVar7 = param_4 - uVar3;\n    }\n    FUN_002a9c80(param_1,param_2,uVar6,param_5);\n    __src = (undefined1 *)(*param_1 + lVar7);\n    __dest = (undefined1 *)(*param_1 + param_2);\n    if (param_5 == 1) {\n      *__dest = *__src;\n    }\n    else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }\n  }\n  return param_1;\n}" { (declaration "int *piVar1;" primitive_type (pointer_declarator "*piVar1" * identifier) ;) (declaration "undefined1 *__src;" type_identifier (pointer_declarator "*__src" * identifier) ;) (declaration "int iVar2;" primitive_type identifier ;) (declaration "ulong uVar3;" type_identifier identifier ;) (declaration "ulong uVar4;" type_identifier identifier ;) (declaration "ulong *puVar5;" type_identifier (pointer_declarator "*puVar5" * identifier) ;) (declaration "ulong uVar6;" type_identifier identifier ;) (declaration "long lVar7;" (sized_type_specifier "long" long) identifier ;) (declaration "undefined1 *__dest;" type_identifier (pointer_declarator "*__dest" * 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 "uVar3 = *param_1;" (assignment_expression "uVar3 = *param_1" identifier = (pointer_expression "*param_1" * identifier)) ;) (expression_statement "uVar4 = *(ulong *)(uVar3 - 0x18);" (assignment_expression "uVar4 = *(ulong *)(uVar3 - 0x18)" identifier = (pointer_expression "*(ulong *)(uVar3 - 0x18)" * (cast_expression "(ulong *)(uVar3 - 0x18)" ( (type_descriptor "ulong *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(uVar3 - 0x18)" ( (binary_expression "uVar3 - 0x18" identifier - number_literal) ))))) ;) (if_statement "if (uVar4 < param_2) {\n                    \n    FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2);\n  }" if (parenthesized_expression "(uVar4 < param_2)" ( (binary_expression "uVar4 < param_2" identifier < identifier) )) (compound_statement "{\n                    \n    FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2);\n  }" { (expression_statement "FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2);" (call_expression "FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2)" identifier (argument_list "("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2)" ( (string_literal ""%s: __pos (which is %zu) > this->size() (which is %zu)"" " string_content ") , (string_literal ""basic_string::replace"" " string_content ") , identifier ))) ;) })) (expression_statement "uVar6 = uVar4 - param_2;" (assignment_expression "uVar6 = uVar4 - param_2" identifier = (binary_expression "uVar4 - param_2" identifier - identifier)) ;) (if_statement "if (param_3 < uVar4 - param_2) {\n    uVar6 = param_3;\n  }" if (parenthesized_expression "(param_3 < uVar4 - param_2)" ( (binary_expression "param_3 < uVar4 - param_2" identifier < (binary_expression "uVar4 - param_2" identifier - identifier)) )) (compound_statement "{\n    uVar6 = param_3;\n  }" { (expression_statement "uVar6 = param_3;" (assignment_expression "uVar6 = param_3" identifier = identifier) ;) })) (if_statement "if ((0x3ffffffffffffff9 - uVar4) + uVar6 < param_5) {\n                    \n    FUN_002b5650("basic_string::replace");\n  }" if (parenthesized_expression "((0x3ffffffffffffff9 - uVar4) + uVar6 < param_5)" ( (binary_expression "(0x3ffffffffffffff9 - uVar4) + uVar6 < param_5" (binary_expression "(0x3ffffffffffffff9 - uVar4) + uVar6" (parenthesized_expression "(0x3ffffffffffffff9 - uVar4)" ( (binary_expression "0x3ffffffffffffff9 - uVar4" number_literal - identifier) )) + identifier) < identifier) )) (compound_statement "{\n                    \n    FUN_002b5650("basic_string::replace");\n  }" { (expression_statement "FUN_002b5650("basic_string::replace");" (call_expression "FUN_002b5650("basic_string::replace")" identifier (argument_list "("basic_string::replace")" ( (string_literal ""basic_string::replace"" " string_content ") ))) ;) })) (if_statement "if (((param_4 < uVar3) || (uVar4 + uVar3 < param_4)) || (0 < *(int *)(uVar3 - 8))) {\n    param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4);\n  }\n  else {\n    uVar3 = *param_1;\n    if (uVar3 + param_2 < param_4 + param_5) {\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    \n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }\n    else {\n      lVar7 = param_4 - uVar3;\n    }\n    FUN_002a9c80(param_1,param_2,uVar6,param_5);\n    __src = (undefined1 *)(*param_1 + lVar7);\n    __dest = (undefined1 *)(*param_1 + param_2);\n    if (param_5 == 1) {\n      *__dest = *__src;\n    }\n    else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }\n  }" if (parenthesized_expression "(((param_4 < uVar3) || (uVar4 + uVar3 < param_4)) || (0 < *(int *)(uVar3 - 8)))" ( (binary_expression "((param_4 < uVar3) || (uVar4 + uVar3 < param_4)) || (0 < *(int *)(uVar3 - 8))" (parenthesized_expression "((param_4 < uVar3) || (uVar4 + uVar3 < param_4))" ( (binary_expression "(param_4 < uVar3) || (uVar4 + uVar3 < param_4)" (parenthesized_expression "(param_4 < uVar3)" ( (binary_expression "param_4 < uVar3" identifier < identifier) )) || (parenthesized_expression "(uVar4 + uVar3 < param_4)" ( (binary_expression "uVar4 + uVar3 < param_4" (binary_expression "uVar4 + uVar3" identifier + identifier) < identifier) ))) )) || (parenthesized_expression "(0 < *(int *)(uVar3 - 8))" ( (binary_expression "0 < *(int *)(uVar3 - 8)" number_literal < (pointer_expression "*(int *)(uVar3 - 8)" * (cast_expression "(int *)(uVar3 - 8)" ( (type_descriptor "int *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(uVar3 - 8)" ( (binary_expression "uVar3 - 8" identifier - number_literal) ))))) ))) )) (compound_statement "{\n    param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4);\n  }" { (expression_statement "param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4);" (assignment_expression "param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4)" identifier = (cast_expression "(ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4)" ( (type_descriptor "ulong *" type_identifier (abstract_pointer_declarator "*" *)) ) (call_expression "FUN_002aa320(param_1,param_2,uVar6,param_4)" identifier (argument_list "(param_1,param_2,uVar6,param_4)" ( identifier , identifier , identifier , identifier ))))) ;) }) (else_clause "else {\n    uVar3 = *param_1;\n    if (uVar3 + param_2 < param_4 + param_5) {\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    \n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }\n    else {\n      lVar7 = param_4 - uVar3;\n    }\n    FUN_002a9c80(param_1,param_2,uVar6,param_5);\n    __src = (undefined1 *)(*param_1 + lVar7);\n    __dest = (undefined1 *)(*param_1 + param_2);\n    if (param_5 == 1) {\n      *__dest = *__src;\n    }\n    else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }\n  }" else (compound_statement "{\n    uVar3 = *param_1;\n    if (uVar3 + param_2 < param_4 + param_5) {\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    \n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }\n    else {\n      lVar7 = param_4 - uVar3;\n    }\n    FUN_002a9c80(param_1,param_2,uVar6,param_5);\n    __src = (undefined1 *)(*param_1 + lVar7);\n    __dest = (undefined1 *)(*param_1 + param_2);\n    if (param_5 == 1) {\n      *__dest = *__src;\n    }\n    else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }\n  }" { (expression_statement "uVar3 = *param_1;" (assignment_expression "uVar3 = *param_1" identifier = (pointer_expression "*param_1" * identifier)) ;) (if_statement "if (uVar3 + param_2 < param_4 + param_5) {\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    \n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }\n    else {\n      lVar7 = param_4 - uVar3;\n    }" if (parenthesized_expression "(uVar3 + param_2 < param_4 + param_5)" ( (binary_expression "uVar3 + param_2 < param_4 + param_5" (binary_expression "uVar3 + param_2" identifier + identifier) < (binary_expression "param_4 + param_5" identifier + identifier)) )) (compound_statement "{\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    \n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }" { (if_statement "if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    \n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }" if (parenthesized_expression "(param_4 < param_2 + uVar6 + uVar3)" ( (binary_expression "param_4 < param_2 + uVar6 + uVar3" identifier < (binary_expression "param_2 + uVar6 + uVar3" (binary_expression "param_2 + uVar6" identifier + identifier) + identifier)) )) (compound_statement "{\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    \n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }" { (expression_statement "FUN_002ab390(local_30,param_4,param_5,&local_31);" (call_expression "FUN_002ab390(local_30,param_4,param_5,&local_31)" identifier (argument_list "(local_30,param_4,param_5,&local_31)" ( identifier , identifier , identifier , (pointer_expression "&local_31" & identifier) ))) ;) (expression_statement "puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);" (assignment_expression "puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5)" identifier = (cast_expression "(ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5)" ( (type_descriptor "ulong *" type_identifier (abstract_pointer_declarator "*" *)) ) (call_expression "FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5)" identifier (argument_list "(param_1,param_2,uVar6,local_30[0],param_5)" ( identifier , identifier , identifier , (subscript_expression "local_30[0]" identifier [ number_literal ]) , identifier ))))) ;) (if_statement "if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }" if (parenthesized_expression "((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38)" ( (binary_expression "(undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38" (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          return puVar5;\n        }" { (return_statement "return puVar5;" return identifier ;) })) (if_statement "if (PTR___pthread_key_create_003bdee8 == (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_003bdee8 == (undefined *)0x0)" ( (binary_expression "PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }" if (parenthesized_expression "(0 < iVar2)" ( (binary_expression "0 < iVar2" number_literal < identifier) )) (compound_statement "{\n          return puVar5;\n        }" { (return_statement "return puVar5;" return identifier ;) })) (expression_statement "thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);" (call_expression "thunk_FUN_00276d20((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) ))) ;) (return_statement "return puVar5;" return identifier ;) })) (expression_statement "lVar7 = ((param_4 - uVar3) + param_5) - uVar6;" (assignment_expression "lVar7 = ((param_4 - uVar3) + param_5) - uVar6" identifier = (binary_expression "((param_4 - uVar3) + param_5) - uVar6" (parenthesized_expression "((param_4 - uVar3) + param_5)" ( (binary_expression "(param_4 - uVar3) + param_5" (parenthesized_expression "(param_4 - uVar3)" ( (binary_expression "param_4 - uVar3" identifier - identifier) )) + identifier) )) - identifier)) ;) }) (else_clause "else {\n      lVar7 = param_4 - uVar3;\n    }" else (compound_statement "{\n      lVar7 = param_4 - uVar3;\n    }" { (expression_statement "lVar7 = param_4 - uVar3;" (assignment_expression "lVar7 = param_4 - uVar3" identifier = (binary_expression "param_4 - uVar3" identifier - identifier)) ;) }))) (expression_statement "FUN_002a9c80(param_1,param_2,uVar6,param_5);" (call_expression "FUN_002a9c80(param_1,param_2,uVar6,param_5)" identifier (argument_list "(param_1,param_2,uVar6,param_5)" ( identifier , identifier , identifier , identifier ))) ;) (expression_statement "__src = (undefined1 *)(*param_1 + lVar7);" (assignment_expression "__src = (undefined1 *)(*param_1 + lVar7)" identifier = (cast_expression "(undefined1 *)(*param_1 + lVar7)" ( (type_descriptor "undefined1 *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(*param_1 + lVar7)" ( (binary_expression "*param_1 + lVar7" (pointer_expression "*param_1" * identifier) + identifier) )))) ;) (expression_statement "__dest = (undefined1 *)(*param_1 + param_2);" (assignment_expression "__dest = (undefined1 *)(*param_1 + param_2)" identifier = (cast_expression "(undefined1 *)(*param_1 + param_2)" ( (type_descriptor "undefined1 *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(*param_1 + param_2)" ( (binary_expression "*param_1 + param_2" (pointer_expression "*param_1" * identifier) + identifier) )))) ;) (if_statement "if (param_5 == 1) {\n      *__dest = *__src;\n    }\n    else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }" if (parenthesized_expression "(param_5 == 1)" ( (binary_expression "param_5 == 1" identifier == number_literal) )) (compound_statement "{\n      *__dest = *__src;\n    }" { (expression_statement "*__dest = *__src;" (assignment_expression "*__dest = *__src" (pointer_expression "*__dest" * identifier) = (pointer_expression "*__src" * identifier)) ;) }) (else_clause "else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }" else (if_statement "if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }" if (parenthesized_expression "(param_5 != 0)" ( (binary_expression "param_5 != 0" identifier != number_literal) )) (compound_statement "{\n      memcpy(__dest,__src,param_5);\n    }" { (expression_statement "memcpy(__dest,__src,param_5);" (call_expression "memcpy(__dest,__src,param_5)" identifier (argument_list "(__dest,__src,param_5)" ( identifier , identifier , identifier ))) ;) })))) }))) (return_statement "return param_1;" return identifier ;) })))
(translation_unit (function_definition TYPE (pointer_declarator * (function_declarator IDENT (parameter_list ( (parameter_declaration TYPE (pointer_declarator * IDENT)) , (parameter_declaration TYPE IDENT) , (parameter_declaration TYPE IDENT) , (parameter_declaration TYPE IDENT) , (parameter_declaration TYPE IDENT) )))) (compound_statement { (declaration TYPE (pointer_declarator * IDENT) ;) (declaration TYPE (pointer_declarator * IDENT) ;) (declaration TYPE IDENT ;) (declaration TYPE IDENT ;) (declaration TYPE IDENT ;) (declaration TYPE (pointer_declarator * IDENT) ;) (declaration TYPE IDENT ;) (declaration (sized_type_specifier long) IDENT ;) (declaration TYPE (pointer_declarator * IDENT) ;) (declaration TYPE IDENT ;) (declaration (sized_type_specifier long) (array_declarator IDENT [ LIT ]) ;) (expression_statement (assignment_expression IDENT = (pointer_expression * IDENT)) ;) (expression_statement (assignment_expression IDENT = (pointer_expression * (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (parenthesized_expression ( (binary_expression IDENT - LIT) ))))) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT < IDENT) )) (compound_statement { (expression_statement (call_expression IDENT (argument_list ( (string_literal " string_content ") , (string_literal " string_content ") , IDENT ))) ;) })) (expression_statement (assignment_expression IDENT = (binary_expression IDENT - IDENT)) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT < (binary_expression IDENT - IDENT)) )) (compound_statement { (expression_statement (assignment_expression IDENT = IDENT) ;) })) (if_statement if (parenthesized_expression ( (binary_expression (binary_expression (parenthesized_expression ( (binary_expression LIT - IDENT) )) + IDENT) < IDENT) )) (compound_statement { (expression_statement (call_expression IDENT (argument_list ( (string_literal " string_content ") ))) ;) })) (if_statement if (parenthesized_expression ( (binary_expression (parenthesized_expression ( (binary_expression (parenthesized_expression ( (binary_expression IDENT < IDENT) )) || (parenthesized_expression ( (binary_expression (binary_expression IDENT + IDENT) < IDENT) ))) )) || (parenthesized_expression ( (binary_expression LIT < (pointer_expression * (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (parenthesized_expression ( (binary_expression IDENT - LIT) ))))) ))) )) (compound_statement { (expression_statement (assignment_expression IDENT = (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (call_expression IDENT (argument_list ( IDENT , IDENT , IDENT , IDENT ))))) ;) }) (else_clause else (compound_statement { (expression_statement (assignment_expression IDENT = (pointer_expression * IDENT)) ;) (if_statement if (parenthesized_expression ( (binary_expression (binary_expression IDENT + IDENT) < (binary_expression IDENT + IDENT)) )) (compound_statement { (if_statement if (parenthesized_expression ( (binary_expression IDENT < (binary_expression (binary_expression IDENT + IDENT) + IDENT)) )) (compound_statement { (expression_statement (call_expression IDENT (argument_list ( IDENT , IDENT , IDENT , (pointer_expression & IDENT) ))) ;) (expression_statement (assignment_expression IDENT = (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (call_expression IDENT (argument_list ( IDENT , IDENT , IDENT , (subscript_expression IDENT [ LIT ]) , 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 { (return_statement return 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 = (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 LIT < IDENT) )) (compound_statement { (return_statement return IDENT ;) })) (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) ))) ;) (return_statement return IDENT ;) })) (expression_statement (assignment_expression IDENT = (binary_expression (parenthesized_expression ( (binary_expression (parenthesized_expression ( (binary_expression IDENT - IDENT) )) + IDENT) )) - IDENT)) ;) }) (else_clause else (compound_statement { (expression_statement (assignment_expression IDENT = (binary_expression IDENT - IDENT)) ;) }))) (expression_statement (call_expression IDENT (argument_list ( IDENT , IDENT , IDENT , IDENT ))) ;) (expression_statement (assignment_expression IDENT = (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (parenthesized_expression ( (binary_expression (pointer_expression * IDENT) + IDENT) )))) ;) (expression_statement (assignment_expression IDENT = (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (parenthesized_expression ( (binary_expression (pointer_expression * IDENT) + IDENT) )))) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT == LIT) )) (compound_statement { (expression_statement (assignment_expression (pointer_expression * IDENT) = (pointer_expression * IDENT)) ;) }) (else_clause else (if_statement if (parenthesized_expression ( (binary_expression IDENT != LIT) )) (compound_statement { (expression_statement (call_expression IDENT (argument_list ( IDENT , IDENT , IDENT ))) ;) })))) }))) (return_statement return IDENT ;) })))
(function_definition "ulong * FUN_002ab3b0(ulong *param_1,ulong param_2,ulong param_3,ulong param_4,ulong param_5)\n\n{\n  int *piVar1;\n  undefined1 *__src;\n  int iVar2;\n  ulong uVar3;\n  ulong uVar4;\n  ulong *puVar5;\n  ulong uVar6;\n  long lVar7;\n  undefined1 *__dest;\n  undefined1 local_31;\n  long local_30 [2];\n  \n  uVar3 = *param_1;\n  uVar4 = *(ulong *)(uVar3 - 0x18);\n  if (uVar4 < param_2) {\n                    \n    FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2);\n  }\n  uVar6 = uVar4 - param_2;\n  if (param_3 < uVar4 - param_2) {\n    uVar6 = param_3;\n  }\n  if ((0x3ffffffffffffff9 - uVar4) + uVar6 < param_5) {\n                    \n    FUN_002b5650("basic_string::replace");\n  }\n  if (((param_4 < uVar3) || (uVar4 + uVar3 < param_4)) || (0 < *(int *)(uVar3 - 8))) {\n    param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4);\n  }\n  else {\n    uVar3 = *param_1;\n    if (uVar3 + param_2 < param_4 + param_5) {\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    \n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }\n    else {\n      lVar7 = param_4 - uVar3;\n    }\n    FUN_002a9c80(param_1,param_2,uVar6,param_5);\n    __src = (undefined1 *)(*param_1 + lVar7);\n    __dest = (undefined1 *)(*param_1 + param_2);\n    if (param_5 == 1) {\n      *__dest = *__src;\n    }\n    else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }\n  }\n  return param_1;\n}" (type_identifier "ulong") (pointer_declarator "* FUN_002ab3b0(ulong *param_1,ulong param_2,ulong param_3,ulong param_4,ulong param_5)" (* "*") (function_declarator "FUN_002ab3b0(ulong *param_1,ulong param_2,ulong param_3,ulong param_4,ulong param_5)" (identifier "FUN_002ab3b0") (parameter_list "(ulong *param_1,ulong param_2,ulong param_3,ulong param_4,ulong param_5)" (( "(") (parameter_declaration "ulong *param_1" (type_identifier "ulong") (pointer_declarator "*param_1" (* "*") (identifier "param_1"))) (, ",") (parameter_declaration "ulong param_2" (type_identifier "ulong") (identifier "param_2")) (, ",") (parameter_declaration "ulong param_3" (type_identifier "ulong") (identifier "param_3")) (, ",") (parameter_declaration "ulong param_4" (type_identifier "ulong") (identifier "param_4")) (, ",") (parameter_declaration "ulong param_5" (type_identifier "ulong") (identifier "param_5")) () ")")))) (compound_statement "{\n  int *piVar1;\n  undefined1 *__src;\n  int iVar2;\n  ulong uVar3;\n  ulong uVar4;\n  ulong *puVar5;\n  ulong uVar6;\n  long lVar7;\n  undefined1 *__dest;\n  undefined1 local_31;\n  long local_30 [2];\n  \n  uVar3 = *param_1;\n  uVar4 = *(ulong *)(uVar3 - 0x18);\n  if (uVar4 < param_2) {\n                    \n    FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2);\n  }\n  uVar6 = uVar4 - param_2;\n  if (param_3 < uVar4 - param_2) {\n    uVar6 = param_3;\n  }\n  if ((0x3ffffffffffffff9 - uVar4) + uVar6 < param_5) {\n                    \n    FUN_002b5650("basic_string::replace");\n  }\n  if (((param_4 < uVar3) || (uVar4 + uVar3 < param_4)) || (0 < *(int *)(uVar3 - 8))) {\n    param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4);\n  }\n  else {\n    uVar3 = *param_1;\n    if (uVar3 + param_2 < param_4 + param_5) {\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    \n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }\n    else {\n      lVar7 = param_4 - uVar3;\n    }\n    FUN_002a9c80(param_1,param_2,uVar6,param_5);\n    __src = (undefined1 *)(*param_1 + lVar7);\n    __dest = (undefined1 *)(*param_1 + param_2);\n    if (param_5 == 1) {\n      *__dest = *__src;\n    }\n    else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }\n  }\n  return param_1;\n}" ({ "{") (declaration "int *piVar1;" (primitive_type "int") (pointer_declarator "*piVar1" (* "*") (identifier "piVar1")) (; ";")) (declaration "undefined1 *__src;" (type_identifier "undefined1") (pointer_declarator "*__src" (* "*") (identifier "__src")) (; ";")) (declaration "int iVar2;" (primitive_type "int") (identifier "iVar2") (; ";")) (declaration "ulong uVar3;" (type_identifier "ulong") (identifier "uVar3") (; ";")) (declaration "ulong uVar4;" (type_identifier "ulong") (identifier "uVar4") (; ";")) (declaration "ulong *puVar5;" (type_identifier "ulong") (pointer_declarator "*puVar5" (* "*") (identifier "puVar5")) (; ";")) (declaration "ulong uVar6;" (type_identifier "ulong") (identifier "uVar6") (; ";")) (declaration "long lVar7;" (sized_type_specifier "long" (long "long")) (identifier "lVar7") (; ";")) (declaration "undefined1 *__dest;" (type_identifier "undefined1") (pointer_declarator "*__dest" (* "*") (identifier "__dest")) (; ";")) (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 "uVar3 = *param_1;" (assignment_expression "uVar3 = *param_1" (identifier "uVar3") (= "=") (pointer_expression "*param_1" (* "*") (identifier "param_1"))) (; ";")) (expression_statement "uVar4 = *(ulong *)(uVar3 - 0x18);" (assignment_expression "uVar4 = *(ulong *)(uVar3 - 0x18)" (identifier "uVar4") (= "=") (pointer_expression "*(ulong *)(uVar3 - 0x18)" (* "*") (cast_expression "(ulong *)(uVar3 - 0x18)" (( "(") (type_descriptor "ulong *" (type_identifier "ulong") (abstract_pointer_declarator "*" (* "*"))) () ")") (parenthesized_expression "(uVar3 - 0x18)" (( "(") (binary_expression "uVar3 - 0x18" (identifier "uVar3") (- "-") (number_literal "0x18")) () ")"))))) (; ";")) (if_statement "if (uVar4 < param_2) {\n                    \n    FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2);\n  }" (if "if") (parenthesized_expression "(uVar4 < param_2)" (( "(") (binary_expression "uVar4 < param_2" (identifier "uVar4") (< "<") (identifier "param_2")) () ")")) (compound_statement "{\n                    \n    FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2);\n  }" ({ "{") (expression_statement "FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2);" (call_expression "FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2)" (identifier "FUN_002b56d0") (argument_list "("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",\n                 param_2)" (( "(") (string_literal ""%s: __pos (which is %zu) > this->size() (which is %zu)"" (" """) (string_content "%s: __pos (which is %zu) > this->size() (which is %zu)") (" """)) (, ",") (string_literal ""basic_string::replace"" (" """) (string_content "basic_string::replace") (" """)) (, ",") (identifier "param_2") () ")"))) (; ";")) (} "}"))) (expression_statement "uVar6 = uVar4 - param_2;" (assignment_expression "uVar6 = uVar4 - param_2" (identifier "uVar6") (= "=") (binary_expression "uVar4 - param_2" (identifier "uVar4") (- "-") (identifier "param_2"))) (; ";")) (if_statement "if (param_3 < uVar4 - param_2) {\n    uVar6 = param_3;\n  }" (if "if") (parenthesized_expression "(param_3 < uVar4 - param_2)" (( "(") (binary_expression "param_3 < uVar4 - param_2" (identifier "param_3") (< "<") (binary_expression "uVar4 - param_2" (identifier "uVar4") (- "-") (identifier "param_2"))) () ")")) (compound_statement "{\n    uVar6 = param_3;\n  }" ({ "{") (expression_statement "uVar6 = param_3;" (assignment_expression "uVar6 = param_3" (identifier "uVar6") (= "=") (identifier "param_3")) (; ";")) (} "}"))) (if_statement "if ((0x3ffffffffffffff9 - uVar4) + uVar6 < param_5) {\n                    \n    FUN_002b5650("basic_string::replace");\n  }" (if "if") (parenthesized_expression "((0x3ffffffffffffff9 - uVar4) + uVar6 < param_5)" (( "(") (binary_expression "(0x3ffffffffffffff9 - uVar4) + uVar6 < param_5" (binary_expression "(0x3ffffffffffffff9 - uVar4) + uVar6" (parenthesized_expression "(0x3ffffffffffffff9 - uVar4)" (( "(") (binary_expression "0x3ffffffffffffff9 - uVar4" (number_literal "0x3ffffffffffffff9") (- "-") (identifier "uVar4")) () ")")) (+ "+") (identifier "uVar6")) (< "<") (identifier "param_5")) () ")")) (compound_statement "{\n                    \n    FUN_002b5650("basic_string::replace");\n  }" ({ "{") (expression_statement "FUN_002b5650("basic_string::replace");" (call_expression "FUN_002b5650("basic_string::replace")" (identifier "FUN_002b5650") (argument_list "("basic_string::replace")" (( "(") (string_literal ""basic_string::replace"" (" """) (string_content "basic_string::replace") (" """)) () ")"))) (; ";")) (} "}"))) (if_statement "if (((param_4 < uVar3) || (uVar4 + uVar3 < param_4)) || (0 < *(int *)(uVar3 - 8))) {\n    param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4);\n  }\n  else {\n    uVar3 = *param_1;\n    if (uVar3 + param_2 < param_4 + param_5) {\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    \n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }\n    else {\n      lVar7 = param_4 - uVar3;\n    }\n    FUN_002a9c80(param_1,param_2,uVar6,param_5);\n    __src = (undefined1 *)(*param_1 + lVar7);\n    __dest = (undefined1 *)(*param_1 + param_2);\n    if (param_5 == 1) {\n      *__dest = *__src;\n    }\n    else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }\n  }" (if "if") (parenthesized_expression "(((param_4 < uVar3) || (uVar4 + uVar3 < param_4)) || (0 < *(int *)(uVar3 - 8)))" (( "(") (binary_expression "((param_4 < uVar3) || (uVar4 + uVar3 < param_4)) || (0 < *(int *)(uVar3 - 8))" (parenthesized_expression "((param_4 < uVar3) || (uVar4 + uVar3 < param_4))" (( "(") (binary_expression "(param_4 < uVar3) || (uVar4 + uVar3 < param_4)" (parenthesized_expression "(param_4 < uVar3)" (( "(") (binary_expression "param_4 < uVar3" (identifier "param_4") (< "<") (identifier "uVar3")) () ")")) (|| "||") (parenthesized_expression "(uVar4 + uVar3 < param_4)" (( "(") (binary_expression "uVar4 + uVar3 < param_4" (binary_expression "uVar4 + uVar3" (identifier "uVar4") (+ "+") (identifier "uVar3")) (< "<") (identifier "param_4")) () ")"))) () ")")) (|| "||") (parenthesized_expression "(0 < *(int *)(uVar3 - 8))" (( "(") (binary_expression "0 < *(int *)(uVar3 - 8)" (number_literal "0") (< "<") (pointer_expression "*(int *)(uVar3 - 8)" (* "*") (cast_expression "(int *)(uVar3 - 8)" (( "(") (type_descriptor "int *" (primitive_type "int") (abstract_pointer_declarator "*" (* "*"))) () ")") (parenthesized_expression "(uVar3 - 8)" (( "(") (binary_expression "uVar3 - 8" (identifier "uVar3") (- "-") (number_literal "8")) () ")"))))) () ")"))) () ")")) (compound_statement "{\n    param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4);\n  }" ({ "{") (expression_statement "param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4);" (assignment_expression "param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4)" (identifier "param_1") (= "=") (cast_expression "(ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4)" (( "(") (type_descriptor "ulong *" (type_identifier "ulong") (abstract_pointer_declarator "*" (* "*"))) () ")") (call_expression "FUN_002aa320(param_1,param_2,uVar6,param_4)" (identifier "FUN_002aa320") (argument_list "(param_1,param_2,uVar6,param_4)" (( "(") (identifier "param_1") (, ",") (identifier "param_2") (, ",") (identifier "uVar6") (, ",") (identifier "param_4") () ")"))))) (; ";")) (} "}")) (else_clause "else {\n    uVar3 = *param_1;\n    if (uVar3 + param_2 < param_4 + param_5) {\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    \n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }\n    else {\n      lVar7 = param_4 - uVar3;\n    }\n    FUN_002a9c80(param_1,param_2,uVar6,param_5);\n    __src = (undefined1 *)(*param_1 + lVar7);\n    __dest = (undefined1 *)(*param_1 + param_2);\n    if (param_5 == 1) {\n      *__dest = *__src;\n    }\n    else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }\n  }" (else "else") (compound_statement "{\n    uVar3 = *param_1;\n    if (uVar3 + param_2 < param_4 + param_5) {\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    \n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }\n    else {\n      lVar7 = param_4 - uVar3;\n    }\n    FUN_002a9c80(param_1,param_2,uVar6,param_5);\n    __src = (undefined1 *)(*param_1 + lVar7);\n    __dest = (undefined1 *)(*param_1 + param_2);\n    if (param_5 == 1) {\n      *__dest = *__src;\n    }\n    else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }\n  }" ({ "{") (expression_statement "uVar3 = *param_1;" (assignment_expression "uVar3 = *param_1" (identifier "uVar3") (= "=") (pointer_expression "*param_1" (* "*") (identifier "param_1"))) (; ";")) (if_statement "if (uVar3 + param_2 < param_4 + param_5) {\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    \n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }\n    else {\n      lVar7 = param_4 - uVar3;\n    }" (if "if") (parenthesized_expression "(uVar3 + param_2 < param_4 + param_5)" (( "(") (binary_expression "uVar3 + param_2 < param_4 + param_5" (binary_expression "uVar3 + param_2" (identifier "uVar3") (+ "+") (identifier "param_2")) (< "<") (binary_expression "param_4 + param_5" (identifier "param_4") (+ "+") (identifier "param_5"))) () ")")) (compound_statement "{\n      if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    \n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }\n      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;\n    }" ({ "{") (if_statement "if (param_4 < param_2 + uVar6 + uVar3) {\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    \n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }" (if "if") (parenthesized_expression "(param_4 < param_2 + uVar6 + uVar3)" (( "(") (binary_expression "param_4 < param_2 + uVar6 + uVar3" (identifier "param_4") (< "<") (binary_expression "param_2 + uVar6 + uVar3" (binary_expression "param_2 + uVar6" (identifier "param_2") (+ "+") (identifier "uVar6")) (+ "+") (identifier "uVar3"))) () ")")) (compound_statement "{\n        FUN_002ab390(local_30,param_4,param_5,&local_31);\n                    \n        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);\n        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }\n        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {\n          return puVar5;\n        }\n        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);\n        return puVar5;\n      }" ({ "{") (expression_statement "FUN_002ab390(local_30,param_4,param_5,&local_31);" (call_expression "FUN_002ab390(local_30,param_4,param_5,&local_31)" (identifier "FUN_002ab390") (argument_list "(local_30,param_4,param_5,&local_31)" (( "(") (identifier "local_30") (, ",") (identifier "param_4") (, ",") (identifier "param_5") (, ",") (pointer_expression "&local_31" (& "&") (identifier "local_31")) () ")"))) (; ";")) (expression_statement "puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);" (assignment_expression "puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5)" (identifier "puVar5") (= "=") (cast_expression "(ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5)" (( "(") (type_descriptor "ulong *" (type_identifier "ulong") (abstract_pointer_declarator "*" (* "*"))) () ")") (call_expression "FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5)" (identifier "FUN_002aa320") (argument_list "(param_1,param_2,uVar6,local_30[0],param_5)" (( "(") (identifier "param_1") (, ",") (identifier "param_2") (, ",") (identifier "uVar6") (, ",") (subscript_expression "local_30[0]" (identifier "local_30") ([ "[") (number_literal "0") (] "]")) (, ",") (identifier "param_5") () ")"))))) (; ";")) (if_statement "if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {\n          return puVar5;\n        }" (if "if") (parenthesized_expression "((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38)" (( "(") (binary_expression "(undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38" (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_003bdc38")) () ")")) (compound_statement "{\n          return puVar5;\n        }" ({ "{") (return_statement "return puVar5;" (return "return") (identifier "puVar5") (; ";")) (} "}"))) (if_statement "if (PTR___pthread_key_create_003bdee8 == (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_003bdee8 == (undefined *)0x0)" (( "(") (binary_expression "PTR___pthread_key_create_003bdee8 == (undefined *)0x0" (identifier "PTR___pthread_key_create_003bdee8") (== "==") (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 (0 < iVar2) {\n          return puVar5;\n        }" (if "if") (parenthesized_expression "(0 < iVar2)" (( "(") (binary_expression "0 < iVar2" (number_literal "0") (< "<") (identifier "iVar2")) () ")")) (compound_statement "{\n          return puVar5;\n        }" ({ "{") (return_statement "return puVar5;" (return "return") (identifier "puVar5") (; ";")) (} "}"))) (expression_statement "thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);" (call_expression "thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31)" (identifier "thunk_FUN_00276d20") (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")) () ")"))) (; ";")) (return_statement "return puVar5;" (return "return") (identifier "puVar5") (; ";")) (} "}"))) (expression_statement "lVar7 = ((param_4 - uVar3) + param_5) - uVar6;" (assignment_expression "lVar7 = ((param_4 - uVar3) + param_5) - uVar6" (identifier "lVar7") (= "=") (binary_expression "((param_4 - uVar3) + param_5) - uVar6" (parenthesized_expression "((param_4 - uVar3) + param_5)" (( "(") (binary_expression "(param_4 - uVar3) + param_5" (parenthesized_expression "(param_4 - uVar3)" (( "(") (binary_expression "param_4 - uVar3" (identifier "param_4") (- "-") (identifier "uVar3")) () ")")) (+ "+") (identifier "param_5")) () ")")) (- "-") (identifier "uVar6"))) (; ";")) (} "}")) (else_clause "else {\n      lVar7 = param_4 - uVar3;\n    }" (else "else") (compound_statement "{\n      lVar7 = param_4 - uVar3;\n    }" ({ "{") (expression_statement "lVar7 = param_4 - uVar3;" (assignment_expression "lVar7 = param_4 - uVar3" (identifier "lVar7") (= "=") (binary_expression "param_4 - uVar3" (identifier "param_4") (- "-") (identifier "uVar3"))) (; ";")) (} "}")))) (expression_statement "FUN_002a9c80(param_1,param_2,uVar6,param_5);" (call_expression "FUN_002a9c80(param_1,param_2,uVar6,param_5)" (identifier "FUN_002a9c80") (argument_list "(param_1,param_2,uVar6,param_5)" (( "(") (identifier "param_1") (, ",") (identifier "param_2") (, ",") (identifier "uVar6") (, ",") (identifier "param_5") () ")"))) (; ";")) (expression_statement "__src = (undefined1 *)(*param_1 + lVar7);" (assignment_expression "__src = (undefined1 *)(*param_1 + lVar7)" (identifier "__src") (= "=") (cast_expression "(undefined1 *)(*param_1 + lVar7)" (( "(") (type_descriptor "undefined1 *" (type_identifier "undefined1") (abstract_pointer_declarator "*" (* "*"))) () ")") (parenthesized_expression "(*param_1 + lVar7)" (( "(") (binary_expression "*param_1 + lVar7" (pointer_expression "*param_1" (* "*") (identifier "param_1")) (+ "+") (identifier "lVar7")) () ")")))) (; ";")) (expression_statement "__dest = (undefined1 *)(*param_1 + param_2);" (assignment_expression "__dest = (undefined1 *)(*param_1 + param_2)" (identifier "__dest") (= "=") (cast_expression "(undefined1 *)(*param_1 + param_2)" (( "(") (type_descriptor "undefined1 *" (type_identifier "undefined1") (abstract_pointer_declarator "*" (* "*"))) () ")") (parenthesized_expression "(*param_1 + param_2)" (( "(") (binary_expression "*param_1 + param_2" (pointer_expression "*param_1" (* "*") (identifier "param_1")) (+ "+") (identifier "param_2")) () ")")))) (; ";")) (if_statement "if (param_5 == 1) {\n      *__dest = *__src;\n    }\n    else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }" (if "if") (parenthesized_expression "(param_5 == 1)" (( "(") (binary_expression "param_5 == 1" (identifier "param_5") (== "==") (number_literal "1")) () ")")) (compound_statement "{\n      *__dest = *__src;\n    }" ({ "{") (expression_statement "*__dest = *__src;" (assignment_expression "*__dest = *__src" (pointer_expression "*__dest" (* "*") (identifier "__dest")) (= "=") (pointer_expression "*__src" (* "*") (identifier "__src"))) (; ";")) (} "}")) (else_clause "else if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }" (else "else") (if_statement "if (param_5 != 0) {\n      memcpy(__dest,__src,param_5);\n    }" (if "if") (parenthesized_expression "(param_5 != 0)" (( "(") (binary_expression "param_5 != 0" (identifier "param_5") (!= "!=") (number_literal "0")) () ")")) (compound_statement "{\n      memcpy(__dest,__src,param_5);\n    }" ({ "{") (expression_statement "memcpy(__dest,__src,param_5);" (call_expression "memcpy(__dest,__src,param_5)" (identifier "memcpy") (argument_list "(__dest,__src,param_5)" (( "(") (identifier "__dest") (, ",") (identifier "__src") (, ",") (identifier "param_5") () ")"))) (; ";")) (} "}"))))) (} "}")))) (return_statement "return param_1;" (return "return") (identifier "param_1") (; ";")) (} "}")))

/* std::string::replace(unsigned long, unsigned long, char const*, unsigned long) */

type_2 * __thiscall
std::type_2::replace(type_2 *this,type_1 var_3,type_1 var_5,char *var_9,type_1 var_7)

{
  int *piVar1;
  type_1 var_2;
  long var_11;
  type_2 *psVar4;
  int var_13;
  type_1 var_6;
  char *var_1;
  type_3 local_31;
  char *local_30 [2];
  
  var_1 = *(char **)this;
  var_2 = *(type_1 *)(var_1 + -0x18);
  if (var_2 < var_3) {
                    /* WARNING: Subroutine does not return */
    var_4
              ("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",
               var_3);
  }
  var_6 = var_2 - var_3;
  if (var_5 < var_2 - var_3) {
    var_6 = var_5;
  }
  if ((0x3ffffffffffffff9 - var_2) + var_6 < var_7) {
                    /* WARNING: Subroutine does not return */
    var_8("basic_string::replace");
  }
  if (((var_9 < var_1) || (var_1 + var_2 < var_9)) || (0 < *(int *)(var_1 + -8))) {
    this = (type_2 *)var_10(this,var_3,var_6,var_9,var_7);
  }
  else {
    var_11 = *(long *)this;
    if ((char *)(var_11 + var_3) < var_9 + var_7) {
      if (var_9 < (char *)(var_3 + var_6 + var_11)) {
        type_2((type_2 *)local_30,var_9,var_7,&local_31);
                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */
        psVar4 = (type_2 *)var_10(this,var_3,var_6,local_30[0],var_7);
        if ((type_3 *)(local_30[0] + -0x18) == (type_3 *)PTR__S_empty_rep_storage_003bdc38) {
          return psVar4;
        }
        if (var_12 == (type_4 *)0x0) {
          var_13 = *(int *)(local_30[0] + -8);
          *(int *)(local_30[0] + -8) = var_13 + -1;
        }
        else {
          var_14();
          piVar1 = (int *)(local_30[0] + -8);
          var_13 = *piVar1;
          *piVar1 = *piVar1 + -1;
          var_15();
        }
        if (0 < var_13) {
          return psVar4;
        }
        _Rep::var_16((type_3 *)(local_30[0] + -0x18));
        return psVar4;
      }
      var_11 = (var_7 - var_11) - var_6;
    }
    else {
      var_11 = -var_11;
    }
    var_17(this,var_3,var_6,var_7);
    var_1 = (char *)(*(long *)this + var_3);
    if (var_7 == 1) {
      *var_1 = var_9[*(long *)this + var_11];
    }
    else if (var_7 != 0) {
      var_18(var_1,var_9 + *(long *)this + var_11,var_7);
    }
  }
  return this;
}


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

ulong * MASKED(ulong *param_1,ulong param_2,ulong param_3,ulong param_4,ulong param_5)

{
  int *piVar1;
  undefined1 *__src;
  int iVar2;
  ulong uVar3;
  ulong uVar4;
  ulong *puVar5;
  ulong uVar6;
  long lVar7;
  undefined1 *__dest;
  undefined1 local_31;
  long local_30 [2];
  
  uVar3 = *param_1;
  uVar4 = *(ulong *)(uVar3 - 0x18);
  if (uVar4 < param_2) {
                    /* WARNING: Subroutine does not return */
    FUN_002b56d0("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::replace",
                 param_2);
  }
  uVar6 = uVar4 - param_2;
  if (param_3 < uVar4 - param_2) {
    uVar6 = param_3;
  }
  if ((0x3ffffffffffffff9 - uVar4) + uVar6 < param_5) {
                    /* WARNING: Subroutine does not return */
    FUN_002b5650("basic_string::replace");
  }
  if (((param_4 < uVar3) || (uVar4 + uVar3 < param_4)) || (0 < *(int *)(uVar3 - 8))) {
    param_1 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,param_4);
  }
  else {
    uVar3 = *param_1;
    if (uVar3 + param_2 < param_4 + param_5) {
      if (param_4 < param_2 + uVar6 + uVar3) {
        FUN_002ab390(local_30,param_4,param_5,&local_31);
                    /* try { // try from 002ab4cd to 002ab4d1 has its CatchHandler @ 002ab561 */
        puVar5 = (ulong *)FUN_002aa320(param_1,param_2,uVar6,local_30[0],param_5);
        if ((undefined *)(local_30[0] + -0x18) == PTR_DAT_003bdc38) {
          return puVar5;
        }
        if (PTR___pthread_key_create_003bdee8 == (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 (0 < iVar2) {
          return puVar5;
        }
        thunk_FUN_00276d20((undefined *)(local_30[0] + -0x18),&local_31);
        return puVar5;
      }
      lVar7 = ((param_4 - uVar3) + param_5) - uVar6;
    }
    else {
      lVar7 = param_4 - uVar3;
    }
    FUN_002a9c80(param_1,param_2,uVar6,param_5);
    __src = (undefined1 *)(*param_1 + lVar7);
    __dest = (undefined1 *)(*param_1 + param_2);
    if (param_5 == 1) {
      *__dest = *__src;
    }
    else if (param_5 != 0) {
      memcpy(__dest,__src,param_5);
    }
  }
  return param_1;
}

