
/* std::__codecvt_utf16_base<char16_t>::do_length(__mbstate_t&, char const*, char const*, unsigned
   long) const */

long __thiscall
std::__codecvt_utf16_base<char16_t>::do_length
          (__codecvt_utf16_base<char16_t> *this,__mbstate_t *param_1,char *param_2,char *param_3,
          ulong param_4)

{
  wchar32 wVar1;
  uint uVar2;
  ulong uVar3;
  undefined4 local_2c;
  char *local_28;
  char *local_20;
  
  local_2c = *(undefined4 *)(this + 0x18);
  uVar2 = (uint)*(undefined8 *)(this + 0x10);
  local_28 = param_2;
  local_20 = param_3;
  (anonymous_namespace)::read_utf16_bom<false>((range *)&local_28,(codecvt_mode *)&local_2c);
  if (0xfffe < uVar2) {
    uVar2 = 0xffff;
  }
  uVar3 = (ulong)uVar2;
  if (param_4 != 0) {
    do {
      param_4 = param_4 - 1;
      wVar1 = (anonymous_namespace)::read_utf16_code_point<false>((range *)&local_28,uVar2,local_2c)
      ;
    } while (param_4 != 0 && (uint)wVar1 <= (uint)(wchar32)uVar3);
  }
  return (long)local_28 - (long)param_2;
}



long FUN_002f5f60(long param_1,undefined8 param_2,long param_3,undefined8 param_4,long param_5)

{
  uint uVar1;
  uint uVar2;
  ulong uVar3;
  undefined4 local_2c;
  long local_28;
  undefined8 local_20;
  
  local_2c = *(undefined4 *)(param_1 + 0x18);
  uVar2 = (uint)*(undefined8 *)(param_1 + 0x10);
  local_28 = param_3;
  local_20 = param_4;
  FUN_002f5bf0(&local_28,&local_2c);
  if (0xfffe < uVar2) {
    uVar2 = 0xffff;
  }
  uVar3 = (ulong)uVar2;
  if (param_5 != 0) {
    do {
      param_5 = param_5 + -1;
      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);
    } while (param_5 != 0 && uVar1 <= (uint)uVar3);
  }
  return local_28 - param_3;
}


PUSH R12
MOV R9,R8
PUSH RBP
PUSH RBX
MOV RBX,RDX
SUB RSP,0x20
MOV EAX,dword ptr [RDI + 0x18]
MOV R10,qword ptr [RDI + 0x10]
LEA RBP,[RSP + 0x10]
LEA RSI,[RSP + 0xc]
MOV qword ptr [RSP + 0x10],RDX
MOV RDI,RBP
MOV dword ptr [RSP + 0xc],EAX
MOV qword ptr [RSP + 0x18],RCX
CALL 0x002f5bf0
MOV EAX,0xffff
CMP R10D,0xffff
CMOVNC R10D,EAX
TEST R9,R9
JZ 0x002f5fdb
LEA R11,[R9 + -0x1]
MOV R12D,R10D
NOP dword ptr [RAX]
MOV EDX,dword ptr [RSP + 0xc]
MOV RSI,R12
MOV RDI,RBP
CALL 0x002f54f0
TEST R11,R11
SETNZ DL
CMP R10D,EAX
SETNC AL
SUB R11,0x1
TEST DL,AL
JNZ 0x002f5fb8
MOV RAX,qword ptr [RSP + 0x10]
ADD RSP,0x20
SUB RAX,RBX
POP RBX
POP RBP
POP R12
RET
(translation_unit "long FUN_002f5f60(long param_1,undefined8 param_2,long param_3,undefined8 param_4,long param_5)\n\n{\n  uint uVar1;\n  uint uVar2;\n  ulong uVar3;\n  undefined4 local_2c;\n  long local_28;\n  undefined8 local_20;\n  \n  local_2c = *(undefined4 *)(param_1 + 0x18);\n  uVar2 = (uint)*(undefined8 *)(param_1 + 0x10);\n  local_28 = param_3;\n  local_20 = param_4;\n  FUN_002f5bf0(&local_28,&local_2c);\n  if (0xfffe < uVar2) {\n    uVar2 = 0xffff;\n  }\n  uVar3 = (ulong)uVar2;\n  if (param_5 != 0) {\n    do {\n      param_5 = param_5 + -1;\n      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);\n    } while (param_5 != 0 && uVar1 <= (uint)uVar3);\n  }\n  return local_28 - param_3;\n}\n\n" (function_definition "long FUN_002f5f60(long param_1,undefined8 param_2,long param_3,undefined8 param_4,long param_5)\n\n{\n  uint uVar1;\n  uint uVar2;\n  ulong uVar3;\n  undefined4 local_2c;\n  long local_28;\n  undefined8 local_20;\n  \n  local_2c = *(undefined4 *)(param_1 + 0x18);\n  uVar2 = (uint)*(undefined8 *)(param_1 + 0x10);\n  local_28 = param_3;\n  local_20 = param_4;\n  FUN_002f5bf0(&local_28,&local_2c);\n  if (0xfffe < uVar2) {\n    uVar2 = 0xffff;\n  }\n  uVar3 = (ulong)uVar2;\n  if (param_5 != 0) {\n    do {\n      param_5 = param_5 + -1;\n      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);\n    } while (param_5 != 0 && uVar1 <= (uint)uVar3);\n  }\n  return local_28 - param_3;\n}" (sized_type_specifier "long" long) (function_declarator "FUN_002f5f60(long param_1,undefined8 param_2,long param_3,undefined8 param_4,long param_5)" identifier (parameter_list "(long param_1,undefined8 param_2,long param_3,undefined8 param_4,long param_5)" ( (parameter_declaration "long param_1" (sized_type_specifier "long" long) identifier) , (parameter_declaration "undefined8 param_2" type_identifier identifier) , (parameter_declaration "long param_3" (sized_type_specifier "long" long) identifier) , (parameter_declaration "undefined8 param_4" type_identifier identifier) , (parameter_declaration "long param_5" (sized_type_specifier "long" long) identifier) ))) (compound_statement "{\n  uint uVar1;\n  uint uVar2;\n  ulong uVar3;\n  undefined4 local_2c;\n  long local_28;\n  undefined8 local_20;\n  \n  local_2c = *(undefined4 *)(param_1 + 0x18);\n  uVar2 = (uint)*(undefined8 *)(param_1 + 0x10);\n  local_28 = param_3;\n  local_20 = param_4;\n  FUN_002f5bf0(&local_28,&local_2c);\n  if (0xfffe < uVar2) {\n    uVar2 = 0xffff;\n  }\n  uVar3 = (ulong)uVar2;\n  if (param_5 != 0) {\n    do {\n      param_5 = param_5 + -1;\n      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);\n    } while (param_5 != 0 && uVar1 <= (uint)uVar3);\n  }\n  return local_28 - param_3;\n}" { (declaration "uint uVar1;" type_identifier identifier ;) (declaration "uint uVar2;" type_identifier identifier ;) (declaration "ulong uVar3;" type_identifier identifier ;) (declaration "undefined4 local_2c;" type_identifier identifier ;) (declaration "long local_28;" (sized_type_specifier "long" long) identifier ;) (declaration "undefined8 local_20;" type_identifier identifier ;) (expression_statement "local_2c = *(undefined4 *)(param_1 + 0x18);" (assignment_expression "local_2c = *(undefined4 *)(param_1 + 0x18)" identifier = (pointer_expression "*(undefined4 *)(param_1 + 0x18)" * (cast_expression "(undefined4 *)(param_1 + 0x18)" ( (type_descriptor "undefined4 *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(param_1 + 0x18)" ( (binary_expression "param_1 + 0x18" identifier + number_literal) ))))) ;) (expression_statement "uVar2 = (uint)*(undefined8 *)(param_1 + 0x10);" (assignment_expression "uVar2 = (uint)*(undefined8 *)(param_1 + 0x10)" identifier = (binary_expression "(uint)*(undefined8 *)(param_1 + 0x10)" (parenthesized_expression "(uint)" ( identifier )) * (cast_expression "(undefined8 *)(param_1 + 0x10)" ( (type_descriptor "undefined8 *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(param_1 + 0x10)" ( (binary_expression "param_1 + 0x10" identifier + number_literal) ))))) ;) (expression_statement "local_28 = param_3;" (assignment_expression "local_28 = param_3" identifier = identifier) ;) (expression_statement "local_20 = param_4;" (assignment_expression "local_20 = param_4" identifier = identifier) ;) (expression_statement "FUN_002f5bf0(&local_28,&local_2c);" (call_expression "FUN_002f5bf0(&local_28,&local_2c)" identifier (argument_list "(&local_28,&local_2c)" ( (pointer_expression "&local_28" & identifier) , (pointer_expression "&local_2c" & identifier) ))) ;) (if_statement "if (0xfffe < uVar2) {\n    uVar2 = 0xffff;\n  }" if (parenthesized_expression "(0xfffe < uVar2)" ( (binary_expression "0xfffe < uVar2" number_literal < identifier) )) (compound_statement "{\n    uVar2 = 0xffff;\n  }" { (expression_statement "uVar2 = 0xffff;" (assignment_expression "uVar2 = 0xffff" identifier = number_literal) ;) })) (expression_statement "uVar3 = (ulong)uVar2;" (assignment_expression "uVar3 = (ulong)uVar2" identifier = (cast_expression "(ulong)uVar2" ( (type_descriptor "ulong" type_identifier) ) identifier)) ;) (if_statement "if (param_5 != 0) {\n    do {\n      param_5 = param_5 + -1;\n      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);\n    } while (param_5 != 0 && uVar1 <= (uint)uVar3);\n  }" if (parenthesized_expression "(param_5 != 0)" ( (binary_expression "param_5 != 0" identifier != number_literal) )) (compound_statement "{\n    do {\n      param_5 = param_5 + -1;\n      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);\n    } while (param_5 != 0 && uVar1 <= (uint)uVar3);\n  }" { (do_statement "do {\n      param_5 = param_5 + -1;\n      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);\n    } while (param_5 != 0 && uVar1 <= (uint)uVar3);" do (compound_statement "{\n      param_5 = param_5 + -1;\n      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);\n    }" { (expression_statement "param_5 = param_5 + -1;" (assignment_expression "param_5 = param_5 + -1" identifier = (binary_expression "param_5 + -1" identifier + number_literal)) ;) (expression_statement "uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);" (assignment_expression "uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c)" identifier = (call_expression "FUN_002f54f0(&local_28,uVar2,local_2c)" identifier (argument_list "(&local_28,uVar2,local_2c)" ( (pointer_expression "&local_28" & identifier) , identifier , identifier )))) ;) }) while (parenthesized_expression "(param_5 != 0 && uVar1 <= (uint)uVar3)" ( (binary_expression "param_5 != 0 && uVar1 <= (uint)uVar3" (binary_expression "param_5 != 0" identifier != number_literal) && (binary_expression "uVar1 <= (uint)uVar3" identifier <= (cast_expression "(uint)uVar3" ( (type_descriptor "uint" type_identifier) ) identifier))) )) ;) })) (return_statement "return local_28 - param_3;" return (binary_expression "local_28 - param_3" identifier - identifier) ;) })))
(translation_unit "/* std::__codecvt_utf16_base<char16_t>::do_length(__mbstate_t&, char const*, char const*, unsigned\n   long) const */\n\nlong __thiscall\nstd::__codecvt_utf16_base<char16_t>::do_length\n          (__codecvt_utf16_base<char16_t> *this,__mbstate_t *param_1,char *param_2,char *param_3,\n          ulong param_4)\n\n{\n  wchar32 wVar1;\n  uint uVar2;\n  ulong uVar3;\n  undefined4 local_2c;\n  char *local_28;\n  char *local_20;\n  \n  local_2c = *(undefined4 *)(this + 0x18);\n  uVar2 = (uint)*(undefined8 *)(this + 0x10);\n  local_28 = param_2;\n  local_20 = param_3;\n  (anonymous_namespace)::read_utf16_bom<false>((range *)&local_28,(codecvt_mode *)&local_2c);\n  if (0xfffe < uVar2) {\n    uVar2 = 0xffff;\n  }\n  uVar3 = (ulong)uVar2;\n  if (param_4 != 0) {\n    do {\n      param_4 = param_4 - 1;\n      wVar1 = (anonymous_namespace)::read_utf16_code_point<false>((range *)&local_28,uVar2,local_2c)\n      ;\n    } while (param_4 != 0 && (uint)wVar1 <= (uint)(wchar32)uVar3);\n  }\n  return (long)local_28 - (long)param_2;\n}\n\n" comment (function_definition "long __thiscall\nstd::__codecvt_utf16_base<char16_t>::do_length\n          (__codecvt_utf16_base<char16_t> *this,__mbstate_t *param_1,char *param_2,char *param_3,\n          ulong param_4)\n\n{\n  wchar32 wVar1;\n  uint uVar2;\n  ulong uVar3;\n  undefined4 local_2c;\n  char *local_28;\n  char *local_20;\n  \n  local_2c = *(undefined4 *)(this + 0x18);\n  uVar2 = (uint)*(undefined8 *)(this + 0x10);\n  local_28 = param_2;\n  local_20 = param_3;\n  (anonymous_namespace)::read_utf16_bom<false>((range *)&local_28,(codecvt_mode *)&local_2c);\n  if (0xfffe < uVar2) {\n    uVar2 = 0xffff;\n  }\n  uVar3 = (ulong)uVar2;\n  if (param_4 != 0) {\n    do {\n      param_4 = param_4 - 1;\n      wVar1 = (anonymous_namespace)::read_utf16_code_point<false>((range *)&local_28,uVar2,local_2c)\n      ;\n    } while (param_4 != 0 && (uint)wVar1 <= (uint)(wchar32)uVar3);\n  }\n  return (long)local_28 - (long)param_2;\n}" (sized_type_specifier "long" long) (ms_call_modifier "__thiscall" __thiscall) (ERROR "std::__codecvt_utf16_base<char16_t>::" identifier : : identifier < primitive_type > : :) (function_declarator "do_length\n          (__codecvt_utf16_base<char16_t> *this,__mbstate_t *param_1,char *param_2,char *param_3,\n          ulong param_4)" identifier (parameter_list "(__codecvt_utf16_base<char16_t> *this,__mbstate_t *param_1,char *param_2,char *param_3,\n          ulong param_4)" ( (parameter_declaration "__codecvt_utf16_base<char16_t> *this" type_identifier (ERROR "<char16_t>" < primitive_type >) (pointer_declarator "*this" * identifier)) , (parameter_declaration "__mbstate_t *param_1" type_identifier (pointer_declarator "*param_1" * identifier)) , (parameter_declaration "char *param_2" primitive_type (pointer_declarator "*param_2" * identifier)) , (parameter_declaration "char *param_3" primitive_type (pointer_declarator "*param_3" * identifier)) , (parameter_declaration "ulong param_4" type_identifier identifier) ))) (compound_statement "{\n  wchar32 wVar1;\n  uint uVar2;\n  ulong uVar3;\n  undefined4 local_2c;\n  char *local_28;\n  char *local_20;\n  \n  local_2c = *(undefined4 *)(this + 0x18);\n  uVar2 = (uint)*(undefined8 *)(this + 0x10);\n  local_28 = param_2;\n  local_20 = param_3;\n  (anonymous_namespace)::read_utf16_bom<false>((range *)&local_28,(codecvt_mode *)&local_2c);\n  if (0xfffe < uVar2) {\n    uVar2 = 0xffff;\n  }\n  uVar3 = (ulong)uVar2;\n  if (param_4 != 0) {\n    do {\n      param_4 = param_4 - 1;\n      wVar1 = (anonymous_namespace)::read_utf16_code_point<false>((range *)&local_28,uVar2,local_2c)\n      ;\n    } while (param_4 != 0 && (uint)wVar1 <= (uint)(wchar32)uVar3);\n  }\n  return (long)local_28 - (long)param_2;\n}" { (declaration "wchar32 wVar1;" type_identifier identifier ;) (declaration "uint uVar2;" type_identifier identifier ;) (declaration "ulong uVar3;" type_identifier identifier ;) (declaration "undefined4 local_2c;" type_identifier identifier ;) (declaration "char *local_28;" primitive_type (pointer_declarator "*local_28" * identifier) ;) (declaration "char *local_20;" primitive_type (pointer_declarator "*local_20" * identifier) ;) (expression_statement "local_2c = *(undefined4 *)(this + 0x18);" (assignment_expression "local_2c = *(undefined4 *)(this + 0x18)" identifier = (pointer_expression "*(undefined4 *)(this + 0x18)" * (cast_expression "(undefined4 *)(this + 0x18)" ( (type_descriptor "undefined4 *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(this + 0x18)" ( (binary_expression "this + 0x18" identifier + number_literal) ))))) ;) (expression_statement "uVar2 = (uint)*(undefined8 *)(this + 0x10);" (assignment_expression "uVar2 = (uint)*(undefined8 *)(this + 0x10)" identifier = (binary_expression "(uint)*(undefined8 *)(this + 0x10)" (parenthesized_expression "(uint)" ( identifier )) * (cast_expression "(undefined8 *)(this + 0x10)" ( (type_descriptor "undefined8 *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(this + 0x10)" ( (binary_expression "this + 0x10" identifier + number_literal) ))))) ;) (expression_statement "local_28 = param_2;" (assignment_expression "local_28 = param_2" identifier = identifier) ;) (expression_statement "local_20 = param_3;" (assignment_expression "local_20 = param_3" identifier = identifier) ;) (expression_statement "(anonymous_namespace)::read_utf16_bom<false>((range *)&local_28,(codecvt_mode *)&local_2c);" (binary_expression "(anonymous_namespace)::read_utf16_bom<false>((range *)&local_28,(codecvt_mode *)&local_2c)" (binary_expression "(anonymous_namespace)::read_utf16_bom<false" (parenthesized_expression "(anonymous_namespace)" ( identifier )) (ERROR "::read_utf16_bom" : : identifier) < false) > (parenthesized_expression "((range *)&local_28,(codecvt_mode *)&local_2c)" ( (comma_expression "(range *)&local_28,(codecvt_mode *)&local_2c" (cast_expression "(range *)&local_28" ( (type_descriptor "range *" type_identifier (abstract_pointer_declarator "*" *)) ) (pointer_expression "&local_28" & identifier)) , (cast_expression "(codecvt_mode *)&local_2c" ( (type_descriptor "codecvt_mode *" type_identifier (abstract_pointer_declarator "*" *)) ) (pointer_expression "&local_2c" & identifier))) ))) ;) (if_statement "if (0xfffe < uVar2) {\n    uVar2 = 0xffff;\n  }" if (parenthesized_expression "(0xfffe < uVar2)" ( (binary_expression "0xfffe < uVar2" number_literal < identifier) )) (compound_statement "{\n    uVar2 = 0xffff;\n  }" { (expression_statement "uVar2 = 0xffff;" (assignment_expression "uVar2 = 0xffff" identifier = number_literal) ;) })) (expression_statement "uVar3 = (ulong)uVar2;" (assignment_expression "uVar3 = (ulong)uVar2" identifier = (cast_expression "(ulong)uVar2" ( (type_descriptor "ulong" type_identifier) ) identifier)) ;) (if_statement "if (param_4 != 0) {\n    do {\n      param_4 = param_4 - 1;\n      wVar1 = (anonymous_namespace)::read_utf16_code_point<false>((range *)&local_28,uVar2,local_2c)\n      ;\n    } while (param_4 != 0 && (uint)wVar1 <= (uint)(wchar32)uVar3);\n  }" if (parenthesized_expression "(param_4 != 0)" ( (binary_expression "param_4 != 0" identifier != number_literal) )) (compound_statement "{\n    do {\n      param_4 = param_4 - 1;\n      wVar1 = (anonymous_namespace)::read_utf16_code_point<false>((range *)&local_28,uVar2,local_2c)\n      ;\n    } while (param_4 != 0 && (uint)wVar1 <= (uint)(wchar32)uVar3);\n  }" { (do_statement "do {\n      param_4 = param_4 - 1;\n      wVar1 = (anonymous_namespace)::read_utf16_code_point<false>((range *)&local_28,uVar2,local_2c)\n      ;\n    } while (param_4 != 0 && (uint)wVar1 <= (uint)(wchar32)uVar3);" do (compound_statement "{\n      param_4 = param_4 - 1;\n      wVar1 = (anonymous_namespace)::read_utf16_code_point<false>((range *)&local_28,uVar2,local_2c)\n      ;\n    }" { (expression_statement "param_4 = param_4 - 1;" (assignment_expression "param_4 = param_4 - 1" identifier = (binary_expression "param_4 - 1" identifier - number_literal)) ;) (expression_statement "wVar1 = (anonymous_namespace)::read_utf16_code_point<false>((range *)&local_28,uVar2,local_2c)\n      ;" (binary_expression "wVar1 = (anonymous_namespace)::read_utf16_code_point<false>((range *)&local_28,uVar2,local_2c)" (binary_expression "wVar1 = (anonymous_namespace)::read_utf16_code_point<false" (assignment_expression "wVar1 = (anonymous_namespace)" identifier = (parenthesized_expression "(anonymous_namespace)" ( identifier ))) (ERROR "::read_utf16_code_point" : : identifier) < false) > (parenthesized_expression "((range *)&local_28,uVar2,local_2c)" ( (comma_expression "(range *)&local_28,uVar2,local_2c" (cast_expression "(range *)&local_28" ( (type_descriptor "range *" type_identifier (abstract_pointer_declarator "*" *)) ) (pointer_expression "&local_28" & identifier)) , (comma_expression "uVar2,local_2c" identifier , identifier)) ))) ;) }) while (parenthesized_expression "(param_4 != 0 && (uint)wVar1 <= (uint)(wchar32)uVar3)" ( (binary_expression "param_4 != 0 && (uint)wVar1 <= (uint)(wchar32)uVar3" (binary_expression "param_4 != 0" identifier != number_literal) && (binary_expression "(uint)wVar1 <= (uint)(wchar32)uVar3" (cast_expression "(uint)wVar1" ( (type_descriptor "uint" type_identifier) ) identifier) <= (cast_expression "(uint)(wchar32)uVar3" ( (type_descriptor "uint" type_identifier) ) (cast_expression "(wchar32)uVar3" ( (type_descriptor "wchar32" type_identifier) ) identifier)))) )) ;) })) (return_statement "return (long)local_28 - (long)param_2;" return (binary_expression "(long)local_28 - (long)param_2" (cast_expression "(long)local_28" ( (type_descriptor "long" (sized_type_specifier "long" long)) ) identifier) - (cast_expression "(long)param_2" ( (type_descriptor "long" (sized_type_specifier "long" long)) ) identifier)) ;) })))
(translation_unit "long FUN_002f5f60(long param_1,undefined8 param_2,long param_3,undefined8 param_4,long param_5)\n\n{\n  uint uVar1;\n  uint uVar2;\n  ulong uVar3;\n  undefined4 local_2c;\n  long local_28;\n  undefined8 local_20;\n  \n  local_2c = *(undefined4 *)(param_1 + 0x18);\n  uVar2 = (uint)*(undefined8 *)(param_1 + 0x10);\n  local_28 = param_3;\n  local_20 = param_4;\n  FUN_002f5bf0(&local_28,&local_2c);\n  if (0xfffe < uVar2) {\n    uVar2 = 0xffff;\n  }\n  uVar3 = (ulong)uVar2;\n  if (param_5 != 0) {\n    do {\n      param_5 = param_5 + -1;\n      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);\n    } while (param_5 != 0 && uVar1 <= (uint)uVar3);\n  }\n  return local_28 - param_3;\n}\n\n" (function_definition "long FUN_002f5f60(long param_1,undefined8 param_2,long param_3,undefined8 param_4,long param_5)\n\n{\n  uint uVar1;\n  uint uVar2;\n  ulong uVar3;\n  undefined4 local_2c;\n  long local_28;\n  undefined8 local_20;\n  \n  local_2c = *(undefined4 *)(param_1 + 0x18);\n  uVar2 = (uint)*(undefined8 *)(param_1 + 0x10);\n  local_28 = param_3;\n  local_20 = param_4;\n  FUN_002f5bf0(&local_28,&local_2c);\n  if (0xfffe < uVar2) {\n    uVar2 = 0xffff;\n  }\n  uVar3 = (ulong)uVar2;\n  if (param_5 != 0) {\n    do {\n      param_5 = param_5 + -1;\n      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);\n    } while (param_5 != 0 && uVar1 <= (uint)uVar3);\n  }\n  return local_28 - param_3;\n}" (sized_type_specifier "long" long) (function_declarator "FUN_002f5f60(long param_1,undefined8 param_2,long param_3,undefined8 param_4,long param_5)" identifier (parameter_list "(long param_1,undefined8 param_2,long param_3,undefined8 param_4,long param_5)" ( (parameter_declaration "long param_1" (sized_type_specifier "long" long) identifier) , (parameter_declaration "undefined8 param_2" type_identifier identifier) , (parameter_declaration "long param_3" (sized_type_specifier "long" long) identifier) , (parameter_declaration "undefined8 param_4" type_identifier identifier) , (parameter_declaration "long param_5" (sized_type_specifier "long" long) identifier) ))) (compound_statement "{\n  uint uVar1;\n  uint uVar2;\n  ulong uVar3;\n  undefined4 local_2c;\n  long local_28;\n  undefined8 local_20;\n  \n  local_2c = *(undefined4 *)(param_1 + 0x18);\n  uVar2 = (uint)*(undefined8 *)(param_1 + 0x10);\n  local_28 = param_3;\n  local_20 = param_4;\n  FUN_002f5bf0(&local_28,&local_2c);\n  if (0xfffe < uVar2) {\n    uVar2 = 0xffff;\n  }\n  uVar3 = (ulong)uVar2;\n  if (param_5 != 0) {\n    do {\n      param_5 = param_5 + -1;\n      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);\n    } while (param_5 != 0 && uVar1 <= (uint)uVar3);\n  }\n  return local_28 - param_3;\n}" { (declaration "uint uVar1;" type_identifier identifier ;) (declaration "uint uVar2;" type_identifier identifier ;) (declaration "ulong uVar3;" type_identifier identifier ;) (declaration "undefined4 local_2c;" type_identifier identifier ;) (declaration "long local_28;" (sized_type_specifier "long" long) identifier ;) (declaration "undefined8 local_20;" type_identifier identifier ;) (expression_statement "local_2c = *(undefined4 *)(param_1 + 0x18);" (assignment_expression "local_2c = *(undefined4 *)(param_1 + 0x18)" identifier = (pointer_expression "*(undefined4 *)(param_1 + 0x18)" * (cast_expression "(undefined4 *)(param_1 + 0x18)" ( (type_descriptor "undefined4 *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(param_1 + 0x18)" ( (binary_expression "param_1 + 0x18" identifier + number_literal) ))))) ;) (expression_statement "uVar2 = (uint)*(undefined8 *)(param_1 + 0x10);" (assignment_expression "uVar2 = (uint)*(undefined8 *)(param_1 + 0x10)" identifier = (binary_expression "(uint)*(undefined8 *)(param_1 + 0x10)" (parenthesized_expression "(uint)" ( identifier )) * (cast_expression "(undefined8 *)(param_1 + 0x10)" ( (type_descriptor "undefined8 *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(param_1 + 0x10)" ( (binary_expression "param_1 + 0x10" identifier + number_literal) ))))) ;) (expression_statement "local_28 = param_3;" (assignment_expression "local_28 = param_3" identifier = identifier) ;) (expression_statement "local_20 = param_4;" (assignment_expression "local_20 = param_4" identifier = identifier) ;) (expression_statement "FUN_002f5bf0(&local_28,&local_2c);" (call_expression "FUN_002f5bf0(&local_28,&local_2c)" identifier (argument_list "(&local_28,&local_2c)" ( (pointer_expression "&local_28" & identifier) , (pointer_expression "&local_2c" & identifier) ))) ;) (if_statement "if (0xfffe < uVar2) {\n    uVar2 = 0xffff;\n  }" if (parenthesized_expression "(0xfffe < uVar2)" ( (binary_expression "0xfffe < uVar2" number_literal < identifier) )) (compound_statement "{\n    uVar2 = 0xffff;\n  }" { (expression_statement "uVar2 = 0xffff;" (assignment_expression "uVar2 = 0xffff" identifier = number_literal) ;) })) (expression_statement "uVar3 = (ulong)uVar2;" (assignment_expression "uVar3 = (ulong)uVar2" identifier = (cast_expression "(ulong)uVar2" ( (type_descriptor "ulong" type_identifier) ) identifier)) ;) (if_statement "if (param_5 != 0) {\n    do {\n      param_5 = param_5 + -1;\n      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);\n    } while (param_5 != 0 && uVar1 <= (uint)uVar3);\n  }" if (parenthesized_expression "(param_5 != 0)" ( (binary_expression "param_5 != 0" identifier != number_literal) )) (compound_statement "{\n    do {\n      param_5 = param_5 + -1;\n      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);\n    } while (param_5 != 0 && uVar1 <= (uint)uVar3);\n  }" { (do_statement "do {\n      param_5 = param_5 + -1;\n      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);\n    } while (param_5 != 0 && uVar1 <= (uint)uVar3);" do (compound_statement "{\n      param_5 = param_5 + -1;\n      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);\n    }" { (expression_statement "param_5 = param_5 + -1;" (assignment_expression "param_5 = param_5 + -1" identifier = (binary_expression "param_5 + -1" identifier + number_literal)) ;) (expression_statement "uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);" (assignment_expression "uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c)" identifier = (call_expression "FUN_002f54f0(&local_28,uVar2,local_2c)" identifier (argument_list "(&local_28,uVar2,local_2c)" ( (pointer_expression "&local_28" & identifier) , identifier , identifier )))) ;) }) while (parenthesized_expression "(param_5 != 0 && uVar1 <= (uint)uVar3)" ( (binary_expression "param_5 != 0 && uVar1 <= (uint)uVar3" (binary_expression "param_5 != 0" identifier != number_literal) && (binary_expression "uVar1 <= (uint)uVar3" identifier <= (cast_expression "(uint)uVar3" ( (type_descriptor "uint" type_identifier) ) identifier))) )) ;) })) (return_statement "return local_28 - param_3;" return (binary_expression "local_28 - param_3" identifier - identifier) ;) })))
(translation_unit (function_definition (sized_type_specifier long) (function_declarator IDENT (parameter_list ( (parameter_declaration (sized_type_specifier long) IDENT) , (parameter_declaration TYPE IDENT) , (parameter_declaration (sized_type_specifier long) IDENT) , (parameter_declaration TYPE IDENT) , (parameter_declaration (sized_type_specifier long) IDENT) ))) (compound_statement { (declaration TYPE IDENT ;) (declaration TYPE IDENT ;) (declaration TYPE IDENT ;) (declaration TYPE IDENT ;) (declaration (sized_type_specifier long) IDENT ;) (declaration TYPE IDENT ;) (expression_statement (assignment_expression IDENT = (pointer_expression * (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (parenthesized_expression ( (binary_expression IDENT + LIT) ))))) ;) (expression_statement (assignment_expression IDENT = (binary_expression (parenthesized_expression ( IDENT )) * (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (parenthesized_expression ( (binary_expression IDENT + LIT) ))))) ;) (expression_statement (assignment_expression IDENT = IDENT) ;) (expression_statement (assignment_expression IDENT = IDENT) ;) (expression_statement (call_expression IDENT (argument_list ( (pointer_expression & IDENT) , (pointer_expression & IDENT) ))) ;) (if_statement if (parenthesized_expression ( (binary_expression LIT < IDENT) )) (compound_statement { (expression_statement (assignment_expression IDENT = LIT) ;) })) (expression_statement (assignment_expression IDENT = (cast_expression ( (type_descriptor TYPE) ) IDENT)) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT != LIT) )) (compound_statement { (do_statement do (compound_statement { (expression_statement (assignment_expression IDENT = (binary_expression IDENT + LIT)) ;) (expression_statement (assignment_expression IDENT = (call_expression IDENT (argument_list ( (pointer_expression & IDENT) , IDENT , IDENT )))) ;) }) while (parenthesized_expression ( (binary_expression (binary_expression IDENT != LIT) && (binary_expression IDENT <= (cast_expression ( (type_descriptor TYPE) ) IDENT))) )) ;) })) (return_statement return (binary_expression IDENT - IDENT) ;) })))
(function_definition "long FUN_002f5f60(long param_1,undefined8 param_2,long param_3,undefined8 param_4,long param_5)\n\n{\n  uint uVar1;\n  uint uVar2;\n  ulong uVar3;\n  undefined4 local_2c;\n  long local_28;\n  undefined8 local_20;\n  \n  local_2c = *(undefined4 *)(param_1 + 0x18);\n  uVar2 = (uint)*(undefined8 *)(param_1 + 0x10);\n  local_28 = param_3;\n  local_20 = param_4;\n  FUN_002f5bf0(&local_28,&local_2c);\n  if (0xfffe < uVar2) {\n    uVar2 = 0xffff;\n  }\n  uVar3 = (ulong)uVar2;\n  if (param_5 != 0) {\n    do {\n      param_5 = param_5 + -1;\n      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);\n    } while (param_5 != 0 && uVar1 <= (uint)uVar3);\n  }\n  return local_28 - param_3;\n}" (sized_type_specifier "long" (long "long")) (function_declarator "FUN_002f5f60(long param_1,undefined8 param_2,long param_3,undefined8 param_4,long param_5)" (identifier "FUN_002f5f60") (parameter_list "(long param_1,undefined8 param_2,long param_3,undefined8 param_4,long param_5)" (( "(") (parameter_declaration "long param_1" (sized_type_specifier "long" (long "long")) (identifier "param_1")) (, ",") (parameter_declaration "undefined8 param_2" (type_identifier "undefined8") (identifier "param_2")) (, ",") (parameter_declaration "long param_3" (sized_type_specifier "long" (long "long")) (identifier "param_3")) (, ",") (parameter_declaration "undefined8 param_4" (type_identifier "undefined8") (identifier "param_4")) (, ",") (parameter_declaration "long param_5" (sized_type_specifier "long" (long "long")) (identifier "param_5")) () ")"))) (compound_statement "{\n  uint uVar1;\n  uint uVar2;\n  ulong uVar3;\n  undefined4 local_2c;\n  long local_28;\n  undefined8 local_20;\n  \n  local_2c = *(undefined4 *)(param_1 + 0x18);\n  uVar2 = (uint)*(undefined8 *)(param_1 + 0x10);\n  local_28 = param_3;\n  local_20 = param_4;\n  FUN_002f5bf0(&local_28,&local_2c);\n  if (0xfffe < uVar2) {\n    uVar2 = 0xffff;\n  }\n  uVar3 = (ulong)uVar2;\n  if (param_5 != 0) {\n    do {\n      param_5 = param_5 + -1;\n      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);\n    } while (param_5 != 0 && uVar1 <= (uint)uVar3);\n  }\n  return local_28 - param_3;\n}" ({ "{") (declaration "uint uVar1;" (type_identifier "uint") (identifier "uVar1") (; ";")) (declaration "uint uVar2;" (type_identifier "uint") (identifier "uVar2") (; ";")) (declaration "ulong uVar3;" (type_identifier "ulong") (identifier "uVar3") (; ";")) (declaration "undefined4 local_2c;" (type_identifier "undefined4") (identifier "local_2c") (; ";")) (declaration "long local_28;" (sized_type_specifier "long" (long "long")) (identifier "local_28") (; ";")) (declaration "undefined8 local_20;" (type_identifier "undefined8") (identifier "local_20") (; ";")) (expression_statement "local_2c = *(undefined4 *)(param_1 + 0x18);" (assignment_expression "local_2c = *(undefined4 *)(param_1 + 0x18)" (identifier "local_2c") (= "=") (pointer_expression "*(undefined4 *)(param_1 + 0x18)" (* "*") (cast_expression "(undefined4 *)(param_1 + 0x18)" (( "(") (type_descriptor "undefined4 *" (type_identifier "undefined4") (abstract_pointer_declarator "*" (* "*"))) () ")") (parenthesized_expression "(param_1 + 0x18)" (( "(") (binary_expression "param_1 + 0x18" (identifier "param_1") (+ "+") (number_literal "0x18")) () ")"))))) (; ";")) (expression_statement "uVar2 = (uint)*(undefined8 *)(param_1 + 0x10);" (assignment_expression "uVar2 = (uint)*(undefined8 *)(param_1 + 0x10)" (identifier "uVar2") (= "=") (binary_expression "(uint)*(undefined8 *)(param_1 + 0x10)" (parenthesized_expression "(uint)" (( "(") (identifier "uint") () ")")) (* "*") (cast_expression "(undefined8 *)(param_1 + 0x10)" (( "(") (type_descriptor "undefined8 *" (type_identifier "undefined8") (abstract_pointer_declarator "*" (* "*"))) () ")") (parenthesized_expression "(param_1 + 0x10)" (( "(") (binary_expression "param_1 + 0x10" (identifier "param_1") (+ "+") (number_literal "0x10")) () ")"))))) (; ";")) (expression_statement "local_28 = param_3;" (assignment_expression "local_28 = param_3" (identifier "local_28") (= "=") (identifier "param_3")) (; ";")) (expression_statement "local_20 = param_4;" (assignment_expression "local_20 = param_4" (identifier "local_20") (= "=") (identifier "param_4")) (; ";")) (expression_statement "FUN_002f5bf0(&local_28,&local_2c);" (call_expression "FUN_002f5bf0(&local_28,&local_2c)" (identifier "FUN_002f5bf0") (argument_list "(&local_28,&local_2c)" (( "(") (pointer_expression "&local_28" (& "&") (identifier "local_28")) (, ",") (pointer_expression "&local_2c" (& "&") (identifier "local_2c")) () ")"))) (; ";")) (if_statement "if (0xfffe < uVar2) {\n    uVar2 = 0xffff;\n  }" (if "if") (parenthesized_expression "(0xfffe < uVar2)" (( "(") (binary_expression "0xfffe < uVar2" (number_literal "0xfffe") (< "<") (identifier "uVar2")) () ")")) (compound_statement "{\n    uVar2 = 0xffff;\n  }" ({ "{") (expression_statement "uVar2 = 0xffff;" (assignment_expression "uVar2 = 0xffff" (identifier "uVar2") (= "=") (number_literal "0xffff")) (; ";")) (} "}"))) (expression_statement "uVar3 = (ulong)uVar2;" (assignment_expression "uVar3 = (ulong)uVar2" (identifier "uVar3") (= "=") (cast_expression "(ulong)uVar2" (( "(") (type_descriptor "ulong" (type_identifier "ulong")) () ")") (identifier "uVar2"))) (; ";")) (if_statement "if (param_5 != 0) {\n    do {\n      param_5 = param_5 + -1;\n      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);\n    } while (param_5 != 0 && uVar1 <= (uint)uVar3);\n  }" (if "if") (parenthesized_expression "(param_5 != 0)" (( "(") (binary_expression "param_5 != 0" (identifier "param_5") (!= "!=") (number_literal "0")) () ")")) (compound_statement "{\n    do {\n      param_5 = param_5 + -1;\n      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);\n    } while (param_5 != 0 && uVar1 <= (uint)uVar3);\n  }" ({ "{") (do_statement "do {\n      param_5 = param_5 + -1;\n      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);\n    } while (param_5 != 0 && uVar1 <= (uint)uVar3);" (do "do") (compound_statement "{\n      param_5 = param_5 + -1;\n      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);\n    }" ({ "{") (expression_statement "param_5 = param_5 + -1;" (assignment_expression "param_5 = param_5 + -1" (identifier "param_5") (= "=") (binary_expression "param_5 + -1" (identifier "param_5") (+ "+") (number_literal "-1"))) (; ";")) (expression_statement "uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);" (assignment_expression "uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c)" (identifier "uVar1") (= "=") (call_expression "FUN_002f54f0(&local_28,uVar2,local_2c)" (identifier "FUN_002f54f0") (argument_list "(&local_28,uVar2,local_2c)" (( "(") (pointer_expression "&local_28" (& "&") (identifier "local_28")) (, ",") (identifier "uVar2") (, ",") (identifier "local_2c") () ")")))) (; ";")) (} "}")) (while "while") (parenthesized_expression "(param_5 != 0 && uVar1 <= (uint)uVar3)" (( "(") (binary_expression "param_5 != 0 && uVar1 <= (uint)uVar3" (binary_expression "param_5 != 0" (identifier "param_5") (!= "!=") (number_literal "0")) (&& "&&") (binary_expression "uVar1 <= (uint)uVar3" (identifier "uVar1") (<= "<=") (cast_expression "(uint)uVar3" (( "(") (type_descriptor "uint" (type_identifier "uint")) () ")") (identifier "uVar3")))) () ")")) (; ";")) (} "}"))) (return_statement "return local_28 - param_3;" (return "return") (binary_expression "local_28 - param_3" (identifier "local_28") (- "-") (identifier "param_3")) (; ";")) (} "}")))

/* std::__codecvt_utf16_base<char16_t>::do_length(__mbstate_t&, char const*, char const*, unsigned
   long) const */

long __thiscall
std::type_1<char16_t>::function_1
          (type_1<char16_t> *var_1,type_2 *param_1,char *param_2,char *param_3,
          type_3 var_3)

{
  type_4 wVar1;
  type_5 var_2;
  type_3 uVar3;
  type_6 local_2c;
  char *local_28;
  char *local_20;
  
  local_2c = *(type_6 *)(var_1 + 0x18);
  var_2 = (type_5)*(type_7 *)(var_1 + 0x10);
  local_28 = param_2;
  local_20 = param_3;
  (anonymous_namespace)::read_utf16_bom<false>((type_8 *)&local_28,(type_9 *)&local_2c);
  if (0xfffe < var_2) {
    var_2 = 0xffff;
  }
  uVar3 = (type_3)var_2;
  if (var_3 != 0) {
    do {
      var_3 = var_3 - 1;
      wVar1 = (anonymous_namespace)::read_utf16_code_point<false>((type_8 *)&local_28,var_2,local_2c)
      ;
    } while (var_3 != 0 && (type_5)wVar1 <= (type_5)(type_4)uVar3);
  }
  return (long)local_28 - (long)param_2;
}


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

long MASKED(long param_1,undefined8 param_2,long param_3,undefined8 param_4,long param_5)

{
  uint uVar1;
  uint uVar2;
  ulong uVar3;
  undefined4 local_2c;
  long local_28;
  undefined8 local_20;
  
  local_2c = *(undefined4 *)(param_1 + 0x18);
  uVar2 = (uint)*(undefined8 *)(param_1 + 0x10);
  local_28 = param_3;
  local_20 = param_4;
  FUN_002f5bf0(&local_28,&local_2c);
  if (0xfffe < uVar2) {
    uVar2 = 0xffff;
  }
  uVar3 = (ulong)uVar2;
  if (param_5 != 0) {
    do {
      param_5 = param_5 + -1;
      uVar1 = FUN_002f54f0(&local_28,uVar2,local_2c);
    } while (param_5 != 0 && uVar1 <= (uint)uVar3);
  }
  return local_28 - param_3;
}

