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

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

{
  _M_mutate(this,param_1,param_2,param_4);
  if (param_4 != 0) {
    if (param_4 == 1) {
      *(char *)(*(long *)this + param_1) = *param_3;
      return this;
    }
    memcpy((char *)(*(long *)this + param_1),param_3,param_4);
  }
  return this;
}



long * FUN_0036c050(long *param_1,long param_2,undefined8 param_3,undefined1 *param_4,size_t param_5
                   )

{
  FUN_0036b9b0();
  if (param_5 != 0) {
    if (param_5 == 1) {
      *(undefined1 *)(*param_1 + param_2) = *param_4;
      return param_1;
    }
    memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5);
  }
  return param_1;
}


PUSH R13
MOV R13,RCX
MOV RCX,R8
PUSH R12
MOV R12,RSI
PUSH RBP
MOV RBP,RDI
PUSH RBX
MOV RBX,R8
SUB RSP,0x8
CALL 0x0036b9b0
TEST RBX,RBX
JZ 0x0036c08b
MOV RDI,qword ptr [RBP]
ADD RDI,R12
CMP RBX,0x1
JZ 0x0036c0a0
MOV RDX,RBX
MOV RSI,R13
CALL 0x00150a90
ADD RSP,0x8
MOV RAX,RBP
POP RBX
POP RBP
POP R12
POP R13
RET
MOVZX EAX,byte ptr [R13]
MOV byte ptr [RDI],AL
ADD RSP,0x8
MOV RAX,RBP
POP RBX
POP RBP
POP R12
POP R13
RET
(translation_unit "long * FUN_0036c050(long *param_1,long param_2,undefined8 param_3,undefined1 *param_4,size_t param_5\n                   )\n\n{\n  FUN_0036b9b0();\n  if (param_5 != 0) {\n    if (param_5 == 1) {\n      *(undefined1 *)(*param_1 + param_2) = *param_4;\n      return param_1;\n    }\n    memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5);\n  }\n  return param_1;\n}\n\n" (function_definition "long * FUN_0036c050(long *param_1,long param_2,undefined8 param_3,undefined1 *param_4,size_t param_5\n                   )\n\n{\n  FUN_0036b9b0();\n  if (param_5 != 0) {\n    if (param_5 == 1) {\n      *(undefined1 *)(*param_1 + param_2) = *param_4;\n      return param_1;\n    }\n    memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5);\n  }\n  return param_1;\n}" (sized_type_specifier "long" long) (pointer_declarator "* FUN_0036c050(long *param_1,long param_2,undefined8 param_3,undefined1 *param_4,size_t param_5\n                   )" * (function_declarator "FUN_0036c050(long *param_1,long param_2,undefined8 param_3,undefined1 *param_4,size_t param_5\n                   )" identifier (parameter_list "(long *param_1,long param_2,undefined8 param_3,undefined1 *param_4,size_t param_5\n                   )" ( (parameter_declaration "long *param_1" (sized_type_specifier "long" long) (pointer_declarator "*param_1" * identifier)) , (parameter_declaration "long param_2" (sized_type_specifier "long" long) identifier) , (parameter_declaration "undefined8 param_3" type_identifier identifier) , (parameter_declaration "undefined1 *param_4" type_identifier (pointer_declarator "*param_4" * identifier)) , (parameter_declaration "size_t param_5" primitive_type identifier) )))) (compound_statement "{\n  FUN_0036b9b0();\n  if (param_5 != 0) {\n    if (param_5 == 1) {\n      *(undefined1 *)(*param_1 + param_2) = *param_4;\n      return param_1;\n    }\n    memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5);\n  }\n  return param_1;\n}" { (expression_statement "FUN_0036b9b0();" (call_expression "FUN_0036b9b0()" identifier (argument_list "()" ( ))) ;) (if_statement "if (param_5 != 0) {\n    if (param_5 == 1) {\n      *(undefined1 *)(*param_1 + param_2) = *param_4;\n      return param_1;\n    }\n    memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5);\n  }" if (parenthesized_expression "(param_5 != 0)" ( (binary_expression "param_5 != 0" identifier != number_literal) )) (compound_statement "{\n    if (param_5 == 1) {\n      *(undefined1 *)(*param_1 + param_2) = *param_4;\n      return param_1;\n    }\n    memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5);\n  }" { (if_statement "if (param_5 == 1) {\n      *(undefined1 *)(*param_1 + param_2) = *param_4;\n      return param_1;\n    }" if (parenthesized_expression "(param_5 == 1)" ( (binary_expression "param_5 == 1" identifier == number_literal) )) (compound_statement "{\n      *(undefined1 *)(*param_1 + param_2) = *param_4;\n      return param_1;\n    }" { (expression_statement "*(undefined1 *)(*param_1 + param_2) = *param_4;" (assignment_expression "*(undefined1 *)(*param_1 + param_2) = *param_4" (pointer_expression "*(undefined1 *)(*param_1 + param_2)" * (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) )))) = (pointer_expression "*param_4" * identifier)) ;) (return_statement "return param_1;" return identifier ;) })) (expression_statement "memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5);" (call_expression "memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5)" identifier (argument_list "((undefined1 *)(*param_1 + param_2),param_4,param_5)" ( (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) ))) , identifier , identifier ))) ;) })) (return_statement "return param_1;" return identifier ;) })))
(translation_unit "/* std::string::_M_replace_safe(unsigned long, unsigned long, char const*, unsigned long) */\n\nstring * __thiscall\nstd::string::_M_replace_safe(string *this,ulong param_1,ulong param_2,char *param_3,ulong param_4)\n\n{\n  _M_mutate(this,param_1,param_2,param_4);\n  if (param_4 != 0) {\n    if (param_4 == 1) {\n      *(char *)(*(long *)this + param_1) = *param_3;\n      return this;\n    }\n    memcpy((char *)(*(long *)this + param_1),param_3,param_4);\n  }\n  return this;\n}\n\n" comment (ERROR "string * __thiscall\nstd::string::_M_replace_safe(string *this," (binary_expression "string * __thiscall\nstd::string::_M_replace_safe(string *this" (binary_expression "string * __thiscall" identifier * identifier) (ERROR "std::string::_M_replace_safe(string" identifier : : identifier : : identifier ( identifier) * identifier) ,) (declaration "ulong param_1,ulong param_2,char *param_3,ulong param_4)\n\n{\n  _M_mutate(this,param_1,param_2,param_4);" type_identifier identifier , (ERROR "ulong" identifier) identifier , (ERROR "char" identifier) (pointer_declarator "*param_3" * identifier) , (ERROR "ulong param_4)\n\n{" identifier identifier ) {) (function_declarator "_M_mutate(this,param_1,param_2,param_4)" identifier (parameter_list "(this,param_1,param_2,param_4)" ( (parameter_declaration "this" type_identifier) , (parameter_declaration "param_1" type_identifier) , (parameter_declaration "param_2" type_identifier) , (parameter_declaration "param_4" type_identifier) ))) ;) (if_statement "if (param_4 != 0) {\n    if (param_4 == 1) {\n      *(char *)(*(long *)this + param_1) = *param_3;\n      return this;\n    }\n    memcpy((char *)(*(long *)this + param_1),param_3,param_4);\n  }" if (parenthesized_expression "(param_4 != 0)" ( (binary_expression "param_4 != 0" identifier != number_literal) )) (compound_statement "{\n    if (param_4 == 1) {\n      *(char *)(*(long *)this + param_1) = *param_3;\n      return this;\n    }\n    memcpy((char *)(*(long *)this + param_1),param_3,param_4);\n  }" { (if_statement "if (param_4 == 1) {\n      *(char *)(*(long *)this + param_1) = *param_3;\n      return this;\n    }" if (parenthesized_expression "(param_4 == 1)" ( (binary_expression "param_4 == 1" identifier == number_literal) )) (compound_statement "{\n      *(char *)(*(long *)this + param_1) = *param_3;\n      return this;\n    }" { (expression_statement "*(char *)(*(long *)this + param_1) = *param_3;" (assignment_expression "*(char *)(*(long *)this + param_1) = *param_3" (pointer_expression "*(char *)(*(long *)this + param_1)" * (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) )))) = (pointer_expression "*param_3" * identifier)) ;) (return_statement "return this;" return identifier ;) })) (expression_statement "memcpy((char *)(*(long *)this + param_1),param_3,param_4);" (call_expression "memcpy((char *)(*(long *)this + param_1),param_3,param_4)" identifier (argument_list "((char *)(*(long *)this + param_1),param_3,param_4)" ( (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) ))) , identifier , identifier ))) ;) })) (return_statement "return this;" return identifier ;) (ERROR "}" }))
(translation_unit "long * FUN_0036c050(long *param_1,long param_2,undefined8 param_3,undefined1 *param_4,size_t param_5\n                   )\n\n{\n  FUN_0036b9b0();\n  if (param_5 != 0) {\n    if (param_5 == 1) {\n      *(undefined1 *)(*param_1 + param_2) = *param_4;\n      return param_1;\n    }\n    memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5);\n  }\n  return param_1;\n}\n\n" (function_definition "long * FUN_0036c050(long *param_1,long param_2,undefined8 param_3,undefined1 *param_4,size_t param_5\n                   )\n\n{\n  FUN_0036b9b0();\n  if (param_5 != 0) {\n    if (param_5 == 1) {\n      *(undefined1 *)(*param_1 + param_2) = *param_4;\n      return param_1;\n    }\n    memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5);\n  }\n  return param_1;\n}" (sized_type_specifier "long" long) (pointer_declarator "* FUN_0036c050(long *param_1,long param_2,undefined8 param_3,undefined1 *param_4,size_t param_5\n                   )" * (function_declarator "FUN_0036c050(long *param_1,long param_2,undefined8 param_3,undefined1 *param_4,size_t param_5\n                   )" identifier (parameter_list "(long *param_1,long param_2,undefined8 param_3,undefined1 *param_4,size_t param_5\n                   )" ( (parameter_declaration "long *param_1" (sized_type_specifier "long" long) (pointer_declarator "*param_1" * identifier)) , (parameter_declaration "long param_2" (sized_type_specifier "long" long) identifier) , (parameter_declaration "undefined8 param_3" type_identifier identifier) , (parameter_declaration "undefined1 *param_4" type_identifier (pointer_declarator "*param_4" * identifier)) , (parameter_declaration "size_t param_5" primitive_type identifier) )))) (compound_statement "{\n  FUN_0036b9b0();\n  if (param_5 != 0) {\n    if (param_5 == 1) {\n      *(undefined1 *)(*param_1 + param_2) = *param_4;\n      return param_1;\n    }\n    memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5);\n  }\n  return param_1;\n}" { (expression_statement "FUN_0036b9b0();" (call_expression "FUN_0036b9b0()" identifier (argument_list "()" ( ))) ;) (if_statement "if (param_5 != 0) {\n    if (param_5 == 1) {\n      *(undefined1 *)(*param_1 + param_2) = *param_4;\n      return param_1;\n    }\n    memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5);\n  }" if (parenthesized_expression "(param_5 != 0)" ( (binary_expression "param_5 != 0" identifier != number_literal) )) (compound_statement "{\n    if (param_5 == 1) {\n      *(undefined1 *)(*param_1 + param_2) = *param_4;\n      return param_1;\n    }\n    memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5);\n  }" { (if_statement "if (param_5 == 1) {\n      *(undefined1 *)(*param_1 + param_2) = *param_4;\n      return param_1;\n    }" if (parenthesized_expression "(param_5 == 1)" ( (binary_expression "param_5 == 1" identifier == number_literal) )) (compound_statement "{\n      *(undefined1 *)(*param_1 + param_2) = *param_4;\n      return param_1;\n    }" { (expression_statement "*(undefined1 *)(*param_1 + param_2) = *param_4;" (assignment_expression "*(undefined1 *)(*param_1 + param_2) = *param_4" (pointer_expression "*(undefined1 *)(*param_1 + param_2)" * (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) )))) = (pointer_expression "*param_4" * identifier)) ;) (return_statement "return param_1;" return identifier ;) })) (expression_statement "memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5);" (call_expression "memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5)" identifier (argument_list "((undefined1 *)(*param_1 + param_2),param_4,param_5)" ( (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) ))) , identifier , identifier ))) ;) })) (return_statement "return param_1;" return identifier ;) })))
(translation_unit (function_definition (sized_type_specifier long) (pointer_declarator * (function_declarator IDENT (parameter_list ( (parameter_declaration (sized_type_specifier long) (pointer_declarator * IDENT)) , (parameter_declaration (sized_type_specifier long) IDENT) , (parameter_declaration TYPE IDENT) , (parameter_declaration TYPE (pointer_declarator * IDENT)) , (parameter_declaration TYPE IDENT) )))) (compound_statement { (expression_statement (call_expression IDENT (argument_list ( ))) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT != LIT) )) (compound_statement { (if_statement if (parenthesized_expression ( (binary_expression IDENT == LIT) )) (compound_statement { (expression_statement (assignment_expression (pointer_expression * (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (parenthesized_expression ( (binary_expression (pointer_expression * IDENT) + IDENT) )))) = (pointer_expression * IDENT)) ;) (return_statement return IDENT ;) })) (expression_statement (call_expression IDENT (argument_list ( (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (parenthesized_expression ( (binary_expression (pointer_expression * IDENT) + IDENT) ))) , IDENT , IDENT ))) ;) })) (return_statement return IDENT ;) })))
(function_definition "long * FUN_0036c050(long *param_1,long param_2,undefined8 param_3,undefined1 *param_4,size_t param_5\n                   )\n\n{\n  FUN_0036b9b0();\n  if (param_5 != 0) {\n    if (param_5 == 1) {\n      *(undefined1 *)(*param_1 + param_2) = *param_4;\n      return param_1;\n    }\n    memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5);\n  }\n  return param_1;\n}" (sized_type_specifier "long" (long "long")) (pointer_declarator "* FUN_0036c050(long *param_1,long param_2,undefined8 param_3,undefined1 *param_4,size_t param_5\n                   )" (* "*") (function_declarator "FUN_0036c050(long *param_1,long param_2,undefined8 param_3,undefined1 *param_4,size_t param_5\n                   )" (identifier "FUN_0036c050") (parameter_list "(long *param_1,long param_2,undefined8 param_3,undefined1 *param_4,size_t param_5\n                   )" (( "(") (parameter_declaration "long *param_1" (sized_type_specifier "long" (long "long")) (pointer_declarator "*param_1" (* "*") (identifier "param_1"))) (, ",") (parameter_declaration "long param_2" (sized_type_specifier "long" (long "long")) (identifier "param_2")) (, ",") (parameter_declaration "undefined8 param_3" (type_identifier "undefined8") (identifier "param_3")) (, ",") (parameter_declaration "undefined1 *param_4" (type_identifier "undefined1") (pointer_declarator "*param_4" (* "*") (identifier "param_4"))) (, ",") (parameter_declaration "size_t param_5" (primitive_type "size_t") (identifier "param_5")) () ")")))) (compound_statement "{\n  FUN_0036b9b0();\n  if (param_5 != 0) {\n    if (param_5 == 1) {\n      *(undefined1 *)(*param_1 + param_2) = *param_4;\n      return param_1;\n    }\n    memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5);\n  }\n  return param_1;\n}" ({ "{") (expression_statement "FUN_0036b9b0();" (call_expression "FUN_0036b9b0()" (identifier "FUN_0036b9b0") (argument_list "()" (( "(") () ")"))) (; ";")) (if_statement "if (param_5 != 0) {\n    if (param_5 == 1) {\n      *(undefined1 *)(*param_1 + param_2) = *param_4;\n      return param_1;\n    }\n    memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5);\n  }" (if "if") (parenthesized_expression "(param_5 != 0)" (( "(") (binary_expression "param_5 != 0" (identifier "param_5") (!= "!=") (number_literal "0")) () ")")) (compound_statement "{\n    if (param_5 == 1) {\n      *(undefined1 *)(*param_1 + param_2) = *param_4;\n      return param_1;\n    }\n    memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5);\n  }" ({ "{") (if_statement "if (param_5 == 1) {\n      *(undefined1 *)(*param_1 + param_2) = *param_4;\n      return param_1;\n    }" (if "if") (parenthesized_expression "(param_5 == 1)" (( "(") (binary_expression "param_5 == 1" (identifier "param_5") (== "==") (number_literal "1")) () ")")) (compound_statement "{\n      *(undefined1 *)(*param_1 + param_2) = *param_4;\n      return param_1;\n    }" ({ "{") (expression_statement "*(undefined1 *)(*param_1 + param_2) = *param_4;" (assignment_expression "*(undefined1 *)(*param_1 + param_2) = *param_4" (pointer_expression "*(undefined1 *)(*param_1 + param_2)" (* "*") (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")) () ")")))) (= "=") (pointer_expression "*param_4" (* "*") (identifier "param_4"))) (; ";")) (return_statement "return param_1;" (return "return") (identifier "param_1") (; ";")) (} "}"))) (expression_statement "memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5);" (call_expression "memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5)" (identifier "memcpy") (argument_list "((undefined1 *)(*param_1 + param_2),param_4,param_5)" (( "(") (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")) () ")"))) (, ",") (identifier "param_4") (, ",") (identifier "param_5") () ")"))) (; ";")) (} "}"))) (return_statement "return param_1;" (return "return") (identifier "param_1") (; ";")) (} "}")))

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

string * __thiscall
std::string::_M_replace_safe(string *type_2,type_1 type_3,type_1 type_4,char *param_3,type_1 type_5)

{
  function_1(type_2,type_3,type_4,type_5);
  if (type_5 != 0) {
    if (type_5 == 1) {
      *(char *)(*(long *)type_2 + type_3) = *param_3;
      return type_2;
    }
    var_1((char *)(*(long *)type_2 + type_3),param_3,type_5);
  }
  return type_2;
}


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

long * MASKED(long *param_1,long param_2,undefined8 param_3,undefined1 *param_4,size_t param_5
                   )

{
  FUN_0036b9b0();
  if (param_5 != 0) {
    if (param_5 == 1) {
      *(undefined1 *)(*param_1 + param_2) = *param_4;
      return param_1;
    }
    memcpy((undefined1 *)(*param_1 + param_2),param_4,param_5);
  }
  return param_1;
}

