
/* std::wstring::copy(wchar_t*, unsigned long, unsigned long) const */

size_t __thiscall std::wstring::copy(wstring *this,wchar_t *param_1,ulong param_2,ulong param_3)

{
  wchar_t *__s2;
  ulong uVar1;
  ulong __n;
  
  uVar1 = *(ulong *)(this + 8);
  if (uVar1 < param_3) {
                    /* WARNING: Subroutine does not return */
    __throw_out_of_range_fmt
              ("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",param_3
               ,uVar1);
  }
  __n = uVar1 - param_3;
  if (param_2 < uVar1 - param_3) {
    __n = param_2;
  }
  if (__n != 0) {
    __s2 = (wchar_t *)(*(long *)this + param_3 * 4);
    if (__n == 1) {
      *param_1 = *__s2;
      return 1;
    }
    wmemcpy(param_1,__s2,__n);
  }
  return __n;
}



size_t FUN_002a8040(long *param_1,wchar_t *param_2,ulong param_3,ulong param_4)

{
  wchar_t *__s2;
  ulong uVar1;
  ulong __n;
  
  uVar1 = param_1[1];
  if (uVar1 < param_4) {
                    /* WARNING: Subroutine does not return */
    FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",
                 param_4,uVar1);
  }
  __n = uVar1 - param_4;
  if (param_3 < uVar1 - param_4) {
    __n = param_3;
  }
  if (__n != 0) {
    __s2 = (wchar_t *)(*param_1 + param_4 * 4);
    if (__n == 1) {
      *param_2 = *__s2;
      return 1;
    }
    wmemcpy(param_2,__s2,__n);
  }
  return __n;
}


PUSH RBX
MOV RBX,qword ptr [RDI + 0x8]
MOV RAX,RCX
CMP RCX,RBX
JA 0x002a808a
SUB RBX,RCX
CMP RBX,RDX
CMOVA RBX,RDX
TEST RBX,RBX
JZ 0x002a8077
MOV RDX,qword ptr [RDI]
MOV R8,RSI
LEA RSI,[RDX + RCX*0x4]
CMP RBX,0x1
JZ 0x002a8080
MOV RDX,RBX
MOV RDI,R8
CALL 0x001440f0
MOV RAX,RBX
POP RBX
RET
MOV EAX,dword ptr [RSI]
MOV dword ptr [R8],EAX
MOV RAX,RBX
POP RBX
RET
MOV RDX,RAX
MOV RCX,RBX
LEA RSI,[0x35b10a]
XOR EAX,EAX
LEA RDI,[0x342fd0]
CALL 0x002e1330
(translation_unit "size_t FUN_002a8040(long *param_1,wchar_t *param_2,ulong param_3,ulong param_4)\n\n{\n  wchar_t *__s2;\n  ulong uVar1;\n  ulong __n;\n  \n  uVar1 = param_1[1];\n  if (uVar1 < param_4) {\n                    /* WARNING: Subroutine does not return */\n    FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1);\n  }\n  __n = uVar1 - param_4;\n  if (param_3 < uVar1 - param_4) {\n    __n = param_3;\n  }\n  if (__n != 0) {\n    __s2 = (wchar_t *)(*param_1 + param_4 * 4);\n    if (__n == 1) {\n      *param_2 = *__s2;\n      return 1;\n    }\n    wmemcpy(param_2,__s2,__n);\n  }\n  return __n;\n}\n\n" (function_definition "size_t FUN_002a8040(long *param_1,wchar_t *param_2,ulong param_3,ulong param_4)\n\n{\n  wchar_t *__s2;\n  ulong uVar1;\n  ulong __n;\n  \n  uVar1 = param_1[1];\n  if (uVar1 < param_4) {\n                    /* WARNING: Subroutine does not return */\n    FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1);\n  }\n  __n = uVar1 - param_4;\n  if (param_3 < uVar1 - param_4) {\n    __n = param_3;\n  }\n  if (__n != 0) {\n    __s2 = (wchar_t *)(*param_1 + param_4 * 4);\n    if (__n == 1) {\n      *param_2 = *__s2;\n      return 1;\n    }\n    wmemcpy(param_2,__s2,__n);\n  }\n  return __n;\n}" primitive_type (function_declarator "FUN_002a8040(long *param_1,wchar_t *param_2,ulong param_3,ulong param_4)" identifier (parameter_list "(long *param_1,wchar_t *param_2,ulong param_3,ulong param_4)" ( (parameter_declaration "long *param_1" (sized_type_specifier "long" long) (pointer_declarator "*param_1" * identifier)) , (parameter_declaration "wchar_t *param_2" type_identifier (pointer_declarator "*param_2" * identifier)) , (parameter_declaration "ulong param_3" type_identifier identifier) , (parameter_declaration "ulong param_4" type_identifier identifier) ))) (compound_statement "{\n  wchar_t *__s2;\n  ulong uVar1;\n  ulong __n;\n  \n  uVar1 = param_1[1];\n  if (uVar1 < param_4) {\n                    /* WARNING: Subroutine does not return */\n    FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1);\n  }\n  __n = uVar1 - param_4;\n  if (param_3 < uVar1 - param_4) {\n    __n = param_3;\n  }\n  if (__n != 0) {\n    __s2 = (wchar_t *)(*param_1 + param_4 * 4);\n    if (__n == 1) {\n      *param_2 = *__s2;\n      return 1;\n    }\n    wmemcpy(param_2,__s2,__n);\n  }\n  return __n;\n}" { (declaration "wchar_t *__s2;" type_identifier (pointer_declarator "*__s2" * identifier) ;) (declaration "ulong uVar1;" type_identifier identifier ;) (declaration "ulong __n;" type_identifier identifier ;) (expression_statement "uVar1 = param_1[1];" (assignment_expression "uVar1 = param_1[1]" identifier = (subscript_expression "param_1[1]" identifier [ number_literal ])) ;) (if_statement "if (uVar1 < param_4) {\n                    /* WARNING: Subroutine does not return */\n    FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1);\n  }" if (parenthesized_expression "(uVar1 < param_4)" ( (binary_expression "uVar1 < param_4" identifier < identifier) )) (compound_statement "{\n                    /* WARNING: Subroutine does not return */\n    FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1);\n  }" { comment (expression_statement "FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1);" (call_expression "FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1)" identifier (argument_list "("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1)" ( (string_literal ""%s: __pos (which is %zu) > this->size() (which is %zu)"" " string_content ") , (string_literal ""basic_string::copy"" " string_content ") , identifier , identifier ))) ;) })) (expression_statement "__n = uVar1 - param_4;" (assignment_expression "__n = uVar1 - param_4" identifier = (binary_expression "uVar1 - param_4" identifier - identifier)) ;) (if_statement "if (param_3 < uVar1 - param_4) {\n    __n = param_3;\n  }" if (parenthesized_expression "(param_3 < uVar1 - param_4)" ( (binary_expression "param_3 < uVar1 - param_4" identifier < (binary_expression "uVar1 - param_4" identifier - identifier)) )) (compound_statement "{\n    __n = param_3;\n  }" { (expression_statement "__n = param_3;" (assignment_expression "__n = param_3" identifier = identifier) ;) })) (if_statement "if (__n != 0) {\n    __s2 = (wchar_t *)(*param_1 + param_4 * 4);\n    if (__n == 1) {\n      *param_2 = *__s2;\n      return 1;\n    }\n    wmemcpy(param_2,__s2,__n);\n  }" if (parenthesized_expression "(__n != 0)" ( (binary_expression "__n != 0" identifier != number_literal) )) (compound_statement "{\n    __s2 = (wchar_t *)(*param_1 + param_4 * 4);\n    if (__n == 1) {\n      *param_2 = *__s2;\n      return 1;\n    }\n    wmemcpy(param_2,__s2,__n);\n  }" { (expression_statement "__s2 = (wchar_t *)(*param_1 + param_4 * 4);" (assignment_expression "__s2 = (wchar_t *)(*param_1 + param_4 * 4)" identifier = (cast_expression "(wchar_t *)(*param_1 + param_4 * 4)" ( (type_descriptor "wchar_t *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(*param_1 + param_4 * 4)" ( (binary_expression "*param_1 + param_4 * 4" (pointer_expression "*param_1" * identifier) + (binary_expression "param_4 * 4" identifier * number_literal)) )))) ;) (if_statement "if (__n == 1) {\n      *param_2 = *__s2;\n      return 1;\n    }" if (parenthesized_expression "(__n == 1)" ( (binary_expression "__n == 1" identifier == number_literal) )) (compound_statement "{\n      *param_2 = *__s2;\n      return 1;\n    }" { (expression_statement "*param_2 = *__s2;" (assignment_expression "*param_2 = *__s2" (pointer_expression "*param_2" * identifier) = (pointer_expression "*__s2" * identifier)) ;) (return_statement "return 1;" return number_literal ;) })) (expression_statement "wmemcpy(param_2,__s2,__n);" (call_expression "wmemcpy(param_2,__s2,__n)" identifier (argument_list "(param_2,__s2,__n)" ( identifier , identifier , identifier ))) ;) })) (return_statement "return __n;" return identifier ;) })))
(translation_unit "/* std::wstring::copy(wchar_t*, unsigned long, unsigned long) const */\n\nsize_t __thiscall std::wstring::copy(wstring *this,wchar_t *param_1,ulong param_2,ulong param_3)\n\n{\n  wchar_t *__s2;\n  ulong uVar1;\n  ulong __n;\n  \n  uVar1 = *(ulong *)(this + 8);\n  if (uVar1 < param_3) {\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::copy",param_3\n               ,uVar1);\n  }\n  __n = uVar1 - param_3;\n  if (param_2 < uVar1 - param_3) {\n    __n = param_2;\n  }\n  if (__n != 0) {\n    __s2 = (wchar_t *)(*(long *)this + param_3 * 4);\n    if (__n == 1) {\n      *param_1 = *__s2;\n      return 1;\n    }\n    wmemcpy(param_1,__s2,__n);\n  }\n  return __n;\n}\n\n" comment (function_definition "size_t __thiscall std::wstring::copy(wstring *this,wchar_t *param_1,ulong param_2,ulong param_3)\n\n{\n  wchar_t *__s2;\n  ulong uVar1;\n  ulong __n;\n  \n  uVar1 = *(ulong *)(this + 8);\n  if (uVar1 < param_3) {\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::copy",param_3\n               ,uVar1);\n  }\n  __n = uVar1 - param_3;\n  if (param_2 < uVar1 - param_3) {\n    __n = param_2;\n  }\n  if (__n != 0) {\n    __s2 = (wchar_t *)(*(long *)this + param_3 * 4);\n    if (__n == 1) {\n      *param_1 = *__s2;\n      return 1;\n    }\n    wmemcpy(param_1,__s2,__n);\n  }\n  return __n;\n}" primitive_type (ms_call_modifier "__thiscall" __thiscall) (ERROR "std::wstring::" identifier : : identifier : :) (function_declarator "copy(wstring *this,wchar_t *param_1,ulong param_2,ulong param_3)" identifier (parameter_list "(wstring *this,wchar_t *param_1,ulong param_2,ulong param_3)" ( (parameter_declaration "wstring *this" type_identifier (pointer_declarator "*this" * identifier)) , (parameter_declaration "wchar_t *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) ))) (compound_statement "{\n  wchar_t *__s2;\n  ulong uVar1;\n  ulong __n;\n  \n  uVar1 = *(ulong *)(this + 8);\n  if (uVar1 < param_3) {\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::copy",param_3\n               ,uVar1);\n  }\n  __n = uVar1 - param_3;\n  if (param_2 < uVar1 - param_3) {\n    __n = param_2;\n  }\n  if (__n != 0) {\n    __s2 = (wchar_t *)(*(long *)this + param_3 * 4);\n    if (__n == 1) {\n      *param_1 = *__s2;\n      return 1;\n    }\n    wmemcpy(param_1,__s2,__n);\n  }\n  return __n;\n}" { (declaration "wchar_t *__s2;" type_identifier (pointer_declarator "*__s2" * identifier) ;) (declaration "ulong uVar1;" type_identifier identifier ;) (declaration "ulong __n;" type_identifier identifier ;) (expression_statement "uVar1 = *(ulong *)(this + 8);" (assignment_expression "uVar1 = *(ulong *)(this + 8)" identifier = (pointer_expression "*(ulong *)(this + 8)" * (cast_expression "(ulong *)(this + 8)" ( (type_descriptor "ulong *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(this + 8)" ( (binary_expression "this + 8" identifier + number_literal) ))))) ;) (if_statement "if (uVar1 < param_3) {\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::copy",param_3\n               ,uVar1);\n  }" if (parenthesized_expression "(uVar1 < param_3)" ( (binary_expression "uVar1 < param_3" 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::copy",param_3\n               ,uVar1);\n  }" { comment (expression_statement "__throw_out_of_range_fmt\n              ("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",param_3\n               ,uVar1);" (call_expression "__throw_out_of_range_fmt\n              ("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",param_3\n               ,uVar1)" identifier (argument_list "("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",param_3\n               ,uVar1)" ( (string_literal ""%s: __pos (which is %zu) > this->size() (which is %zu)"" " string_content ") , (string_literal ""basic_string::copy"" " string_content ") , identifier , identifier ))) ;) })) (expression_statement "__n = uVar1 - param_3;" (assignment_expression "__n = uVar1 - param_3" identifier = (binary_expression "uVar1 - param_3" identifier - identifier)) ;) (if_statement "if (param_2 < uVar1 - param_3) {\n    __n = param_2;\n  }" if (parenthesized_expression "(param_2 < uVar1 - param_3)" ( (binary_expression "param_2 < uVar1 - param_3" identifier < (binary_expression "uVar1 - param_3" identifier - identifier)) )) (compound_statement "{\n    __n = param_2;\n  }" { (expression_statement "__n = param_2;" (assignment_expression "__n = param_2" identifier = identifier) ;) })) (if_statement "if (__n != 0) {\n    __s2 = (wchar_t *)(*(long *)this + param_3 * 4);\n    if (__n == 1) {\n      *param_1 = *__s2;\n      return 1;\n    }\n    wmemcpy(param_1,__s2,__n);\n  }" if (parenthesized_expression "(__n != 0)" ( (binary_expression "__n != 0" identifier != number_literal) )) (compound_statement "{\n    __s2 = (wchar_t *)(*(long *)this + param_3 * 4);\n    if (__n == 1) {\n      *param_1 = *__s2;\n      return 1;\n    }\n    wmemcpy(param_1,__s2,__n);\n  }" { (expression_statement "__s2 = (wchar_t *)(*(long *)this + param_3 * 4);" (assignment_expression "__s2 = (wchar_t *)(*(long *)this + param_3 * 4)" identifier = (cast_expression "(wchar_t *)(*(long *)this + param_3 * 4)" ( (type_descriptor "wchar_t *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(*(long *)this + param_3 * 4)" ( (binary_expression "*(long *)this + param_3 * 4" (pointer_expression "*(long *)this" * (cast_expression "(long *)this" ( (type_descriptor "long *" (sized_type_specifier "long" long) (abstract_pointer_declarator "*" *)) ) identifier)) + (binary_expression "param_3 * 4" identifier * number_literal)) )))) ;) (if_statement "if (__n == 1) {\n      *param_1 = *__s2;\n      return 1;\n    }" if (parenthesized_expression "(__n == 1)" ( (binary_expression "__n == 1" identifier == number_literal) )) (compound_statement "{\n      *param_1 = *__s2;\n      return 1;\n    }" { (expression_statement "*param_1 = *__s2;" (assignment_expression "*param_1 = *__s2" (pointer_expression "*param_1" * identifier) = (pointer_expression "*__s2" * identifier)) ;) (return_statement "return 1;" return number_literal ;) })) (expression_statement "wmemcpy(param_1,__s2,__n);" (call_expression "wmemcpy(param_1,__s2,__n)" identifier (argument_list "(param_1,__s2,__n)" ( identifier , identifier , identifier ))) ;) })) (return_statement "return __n;" return identifier ;) })))
(translation_unit "size_t FUN_002a8040(long *param_1,wchar_t *param_2,ulong param_3,ulong param_4)\n\n{\n  wchar_t *__s2;\n  ulong uVar1;\n  ulong __n;\n  \n  uVar1 = param_1[1];\n  if (uVar1 < param_4) {\n                    \n    FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1);\n  }\n  __n = uVar1 - param_4;\n  if (param_3 < uVar1 - param_4) {\n    __n = param_3;\n  }\n  if (__n != 0) {\n    __s2 = (wchar_t *)(*param_1 + param_4 * 4);\n    if (__n == 1) {\n      *param_2 = *__s2;\n      return 1;\n    }\n    wmemcpy(param_2,__s2,__n);\n  }\n  return __n;\n}\n\n" (function_definition "size_t FUN_002a8040(long *param_1,wchar_t *param_2,ulong param_3,ulong param_4)\n\n{\n  wchar_t *__s2;\n  ulong uVar1;\n  ulong __n;\n  \n  uVar1 = param_1[1];\n  if (uVar1 < param_4) {\n                    \n    FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1);\n  }\n  __n = uVar1 - param_4;\n  if (param_3 < uVar1 - param_4) {\n    __n = param_3;\n  }\n  if (__n != 0) {\n    __s2 = (wchar_t *)(*param_1 + param_4 * 4);\n    if (__n == 1) {\n      *param_2 = *__s2;\n      return 1;\n    }\n    wmemcpy(param_2,__s2,__n);\n  }\n  return __n;\n}" primitive_type (function_declarator "FUN_002a8040(long *param_1,wchar_t *param_2,ulong param_3,ulong param_4)" identifier (parameter_list "(long *param_1,wchar_t *param_2,ulong param_3,ulong param_4)" ( (parameter_declaration "long *param_1" (sized_type_specifier "long" long) (pointer_declarator "*param_1" * identifier)) , (parameter_declaration "wchar_t *param_2" type_identifier (pointer_declarator "*param_2" * identifier)) , (parameter_declaration "ulong param_3" type_identifier identifier) , (parameter_declaration "ulong param_4" type_identifier identifier) ))) (compound_statement "{\n  wchar_t *__s2;\n  ulong uVar1;\n  ulong __n;\n  \n  uVar1 = param_1[1];\n  if (uVar1 < param_4) {\n                    \n    FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1);\n  }\n  __n = uVar1 - param_4;\n  if (param_3 < uVar1 - param_4) {\n    __n = param_3;\n  }\n  if (__n != 0) {\n    __s2 = (wchar_t *)(*param_1 + param_4 * 4);\n    if (__n == 1) {\n      *param_2 = *__s2;\n      return 1;\n    }\n    wmemcpy(param_2,__s2,__n);\n  }\n  return __n;\n}" { (declaration "wchar_t *__s2;" type_identifier (pointer_declarator "*__s2" * identifier) ;) (declaration "ulong uVar1;" type_identifier identifier ;) (declaration "ulong __n;" type_identifier identifier ;) (expression_statement "uVar1 = param_1[1];" (assignment_expression "uVar1 = param_1[1]" identifier = (subscript_expression "param_1[1]" identifier [ number_literal ])) ;) (if_statement "if (uVar1 < param_4) {\n                    \n    FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1);\n  }" if (parenthesized_expression "(uVar1 < param_4)" ( (binary_expression "uVar1 < param_4" identifier < identifier) )) (compound_statement "{\n                    \n    FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1);\n  }" { (expression_statement "FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1);" (call_expression "FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1)" identifier (argument_list "("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1)" ( (string_literal ""%s: __pos (which is %zu) > this->size() (which is %zu)"" " string_content ") , (string_literal ""basic_string::copy"" " string_content ") , identifier , identifier ))) ;) })) (expression_statement "__n = uVar1 - param_4;" (assignment_expression "__n = uVar1 - param_4" identifier = (binary_expression "uVar1 - param_4" identifier - identifier)) ;) (if_statement "if (param_3 < uVar1 - param_4) {\n    __n = param_3;\n  }" if (parenthesized_expression "(param_3 < uVar1 - param_4)" ( (binary_expression "param_3 < uVar1 - param_4" identifier < (binary_expression "uVar1 - param_4" identifier - identifier)) )) (compound_statement "{\n    __n = param_3;\n  }" { (expression_statement "__n = param_3;" (assignment_expression "__n = param_3" identifier = identifier) ;) })) (if_statement "if (__n != 0) {\n    __s2 = (wchar_t *)(*param_1 + param_4 * 4);\n    if (__n == 1) {\n      *param_2 = *__s2;\n      return 1;\n    }\n    wmemcpy(param_2,__s2,__n);\n  }" if (parenthesized_expression "(__n != 0)" ( (binary_expression "__n != 0" identifier != number_literal) )) (compound_statement "{\n    __s2 = (wchar_t *)(*param_1 + param_4 * 4);\n    if (__n == 1) {\n      *param_2 = *__s2;\n      return 1;\n    }\n    wmemcpy(param_2,__s2,__n);\n  }" { (expression_statement "__s2 = (wchar_t *)(*param_1 + param_4 * 4);" (assignment_expression "__s2 = (wchar_t *)(*param_1 + param_4 * 4)" identifier = (cast_expression "(wchar_t *)(*param_1 + param_4 * 4)" ( (type_descriptor "wchar_t *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(*param_1 + param_4 * 4)" ( (binary_expression "*param_1 + param_4 * 4" (pointer_expression "*param_1" * identifier) + (binary_expression "param_4 * 4" identifier * number_literal)) )))) ;) (if_statement "if (__n == 1) {\n      *param_2 = *__s2;\n      return 1;\n    }" if (parenthesized_expression "(__n == 1)" ( (binary_expression "__n == 1" identifier == number_literal) )) (compound_statement "{\n      *param_2 = *__s2;\n      return 1;\n    }" { (expression_statement "*param_2 = *__s2;" (assignment_expression "*param_2 = *__s2" (pointer_expression "*param_2" * identifier) = (pointer_expression "*__s2" * identifier)) ;) (return_statement "return 1;" return number_literal ;) })) (expression_statement "wmemcpy(param_2,__s2,__n);" (call_expression "wmemcpy(param_2,__s2,__n)" identifier (argument_list "(param_2,__s2,__n)" ( identifier , identifier , identifier ))) ;) })) (return_statement "return __n;" return identifier ;) })))
(translation_unit (function_definition TYPE (function_declarator IDENT (parameter_list ( (parameter_declaration (sized_type_specifier long) (pointer_declarator * IDENT)) , (parameter_declaration TYPE (pointer_declarator * IDENT)) , (parameter_declaration TYPE IDENT) , (parameter_declaration TYPE IDENT) ))) (compound_statement { (declaration TYPE (pointer_declarator * IDENT) ;) (declaration TYPE IDENT ;) (declaration TYPE IDENT ;) (expression_statement (assignment_expression IDENT = (subscript_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 , 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 IDENT != LIT) )) (compound_statement { (expression_statement (assignment_expression IDENT = (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (parenthesized_expression ( (binary_expression (pointer_expression * IDENT) + (binary_expression IDENT * LIT)) )))) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT == LIT) )) (compound_statement { (expression_statement (assignment_expression (pointer_expression * IDENT) = (pointer_expression * IDENT)) ;) (return_statement return LIT ;) })) (expression_statement (call_expression IDENT (argument_list ( IDENT , IDENT , IDENT ))) ;) })) (return_statement return IDENT ;) })))
(function_definition "size_t FUN_002a8040(long *param_1,wchar_t *param_2,ulong param_3,ulong param_4)\n\n{\n  wchar_t *__s2;\n  ulong uVar1;\n  ulong __n;\n  \n  uVar1 = param_1[1];\n  if (uVar1 < param_4) {\n                    \n    FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1);\n  }\n  __n = uVar1 - param_4;\n  if (param_3 < uVar1 - param_4) {\n    __n = param_3;\n  }\n  if (__n != 0) {\n    __s2 = (wchar_t *)(*param_1 + param_4 * 4);\n    if (__n == 1) {\n      *param_2 = *__s2;\n      return 1;\n    }\n    wmemcpy(param_2,__s2,__n);\n  }\n  return __n;\n}" (primitive_type "size_t") (function_declarator "FUN_002a8040(long *param_1,wchar_t *param_2,ulong param_3,ulong param_4)" (identifier "FUN_002a8040") (parameter_list "(long *param_1,wchar_t *param_2,ulong param_3,ulong param_4)" (( "(") (parameter_declaration "long *param_1" (sized_type_specifier "long" (long "long")) (pointer_declarator "*param_1" (* "*") (identifier "param_1"))) (, ",") (parameter_declaration "wchar_t *param_2" (type_identifier "wchar_t") (pointer_declarator "*param_2" (* "*") (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")) () ")"))) (compound_statement "{\n  wchar_t *__s2;\n  ulong uVar1;\n  ulong __n;\n  \n  uVar1 = param_1[1];\n  if (uVar1 < param_4) {\n                    \n    FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1);\n  }\n  __n = uVar1 - param_4;\n  if (param_3 < uVar1 - param_4) {\n    __n = param_3;\n  }\n  if (__n != 0) {\n    __s2 = (wchar_t *)(*param_1 + param_4 * 4);\n    if (__n == 1) {\n      *param_2 = *__s2;\n      return 1;\n    }\n    wmemcpy(param_2,__s2,__n);\n  }\n  return __n;\n}" ({ "{") (declaration "wchar_t *__s2;" (type_identifier "wchar_t") (pointer_declarator "*__s2" (* "*") (identifier "__s2")) (; ";")) (declaration "ulong uVar1;" (type_identifier "ulong") (identifier "uVar1") (; ";")) (declaration "ulong __n;" (type_identifier "ulong") (identifier "__n") (; ";")) (expression_statement "uVar1 = param_1[1];" (assignment_expression "uVar1 = param_1[1]" (identifier "uVar1") (= "=") (subscript_expression "param_1[1]" (identifier "param_1") ([ "[") (number_literal "1") (] "]"))) (; ";")) (if_statement "if (uVar1 < param_4) {\n                    \n    FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1);\n  }" (if "if") (parenthesized_expression "(uVar1 < param_4)" (( "(") (binary_expression "uVar1 < param_4" (identifier "uVar1") (< "<") (identifier "param_4")) () ")")) (compound_statement "{\n                    \n    FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1);\n  }" ({ "{") (expression_statement "FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1);" (call_expression "FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1)" (identifier "FUN_002e1330") (argument_list "("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",\n                 param_4,uVar1)" (( "(") (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::copy"" (" """) (string_content "basic_string::copy") (" """)) (, ",") (identifier "param_4") (, ",") (identifier "uVar1") () ")"))) (; ";")) (} "}"))) (expression_statement "__n = uVar1 - param_4;" (assignment_expression "__n = uVar1 - param_4" (identifier "__n") (= "=") (binary_expression "uVar1 - param_4" (identifier "uVar1") (- "-") (identifier "param_4"))) (; ";")) (if_statement "if (param_3 < uVar1 - param_4) {\n    __n = param_3;\n  }" (if "if") (parenthesized_expression "(param_3 < uVar1 - param_4)" (( "(") (binary_expression "param_3 < uVar1 - param_4" (identifier "param_3") (< "<") (binary_expression "uVar1 - param_4" (identifier "uVar1") (- "-") (identifier "param_4"))) () ")")) (compound_statement "{\n    __n = param_3;\n  }" ({ "{") (expression_statement "__n = param_3;" (assignment_expression "__n = param_3" (identifier "__n") (= "=") (identifier "param_3")) (; ";")) (} "}"))) (if_statement "if (__n != 0) {\n    __s2 = (wchar_t *)(*param_1 + param_4 * 4);\n    if (__n == 1) {\n      *param_2 = *__s2;\n      return 1;\n    }\n    wmemcpy(param_2,__s2,__n);\n  }" (if "if") (parenthesized_expression "(__n != 0)" (( "(") (binary_expression "__n != 0" (identifier "__n") (!= "!=") (number_literal "0")) () ")")) (compound_statement "{\n    __s2 = (wchar_t *)(*param_1 + param_4 * 4);\n    if (__n == 1) {\n      *param_2 = *__s2;\n      return 1;\n    }\n    wmemcpy(param_2,__s2,__n);\n  }" ({ "{") (expression_statement "__s2 = (wchar_t *)(*param_1 + param_4 * 4);" (assignment_expression "__s2 = (wchar_t *)(*param_1 + param_4 * 4)" (identifier "__s2") (= "=") (cast_expression "(wchar_t *)(*param_1 + param_4 * 4)" (( "(") (type_descriptor "wchar_t *" (type_identifier "wchar_t") (abstract_pointer_declarator "*" (* "*"))) () ")") (parenthesized_expression "(*param_1 + param_4 * 4)" (( "(") (binary_expression "*param_1 + param_4 * 4" (pointer_expression "*param_1" (* "*") (identifier "param_1")) (+ "+") (binary_expression "param_4 * 4" (identifier "param_4") (* "*") (number_literal "4"))) () ")")))) (; ";")) (if_statement "if (__n == 1) {\n      *param_2 = *__s2;\n      return 1;\n    }" (if "if") (parenthesized_expression "(__n == 1)" (( "(") (binary_expression "__n == 1" (identifier "__n") (== "==") (number_literal "1")) () ")")) (compound_statement "{\n      *param_2 = *__s2;\n      return 1;\n    }" ({ "{") (expression_statement "*param_2 = *__s2;" (assignment_expression "*param_2 = *__s2" (pointer_expression "*param_2" (* "*") (identifier "param_2")) (= "=") (pointer_expression "*__s2" (* "*") (identifier "__s2"))) (; ";")) (return_statement "return 1;" (return "return") (number_literal "1") (; ";")) (} "}"))) (expression_statement "wmemcpy(param_2,__s2,__n);" (call_expression "wmemcpy(param_2,__s2,__n)" (identifier "wmemcpy") (argument_list "(param_2,__s2,__n)" (( "(") (identifier "param_2") (, ",") (identifier "__s2") (, ",") (identifier "__n") () ")"))) (; ";")) (} "}"))) (return_statement "return __n;" (return "return") (identifier "__n") (; ";")) (} "}")))

/* std::wstring::copy(wchar_t*, unsigned long, unsigned long) const */

size_t __thiscall std::type_1::function_1(type_1 *var_1,type_2 *param_1,type_3 var_5,type_3 var_3)

{
  type_2 *__s2;
  type_3 var_2;
  type_3 var_6;
  
  var_2 = *(type_3 *)(var_1 + 8);
  if (var_2 < var_3) {
                    /* WARNING: Subroutine does not return */
    var_4
              ("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",var_3
               ,var_2);
  }
  var_6 = var_2 - var_3;
  if (var_5 < var_2 - var_3) {
    var_6 = var_5;
  }
  if (var_6 != 0) {
    __s2 = (type_2 *)(*(long *)var_1 + var_3 * 4);
    if (var_6 == 1) {
      *param_1 = *__s2;
      return 1;
    }
    var_7(param_1,__s2,var_6);
  }
  return var_6;
}


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

size_t MASKED(long *param_1,wchar_t *param_2,ulong param_3,ulong param_4)

{
  wchar_t *__s2;
  ulong uVar1;
  ulong __n;
  
  uVar1 = param_1[1];
  if (uVar1 < param_4) {
                    /* WARNING: Subroutine does not return */
    FUN_002e1330("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::copy",
                 param_4,uVar1);
  }
  __n = uVar1 - param_4;
  if (param_3 < uVar1 - param_4) {
    __n = param_3;
  }
  if (__n != 0) {
    __s2 = (wchar_t *)(*param_1 + param_4 * 4);
    if (__n == 1) {
      *param_2 = *__s2;
      return 1;
    }
    wmemcpy(param_2,__s2,__n);
  }
  return __n;
}

