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

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

{
  wchar_t __c;
  long lVar1;
  ulong uVar2;
  int iVar3;
  wchar_t *pwVar4;
  ulong uVar5;
  size_t __n;
  
  lVar1 = *(long *)this;
  uVar2 = *(ulong *)(lVar1 + -0x18);
  if (param_3 == 0) {
    uVar5 = 0xffffffffffffffff;
    if (param_2 <= uVar2) {
      uVar5 = param_2;
    }
    return uVar5;
  }
  if ((param_2 < uVar2) && (param_3 <= uVar2 - param_2)) {
    __n = (uVar2 - param_2) + (1 - param_3);
    if (__n != 0) {
      __c = *param_1;
      pwVar4 = (wchar_t *)(lVar1 + param_2 * 4);
      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {
        iVar3 = wmemcmp(pwVar4,param_1,param_3);
        if (iVar3 == 0) {
          return (long)pwVar4 - lVar1 >> 2;
        }
        pwVar4 = pwVar4 + 1;
        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;
        if (uVar5 < param_3) {
          return 0xffffffffffffffff;
        }
        __n = uVar5 + (1 - param_3);
        if (__n == 0) {
          return 0xffffffffffffffff;
        }
      }
    }
  }
  return 0xffffffffffffffff;
}



ulong FUN_0031cd40(long *param_1,wchar_t *param_2,ulong param_3,ulong param_4)

{
  wchar_t __c;
  long lVar1;
  ulong uVar2;
  int iVar3;
  wchar_t *pwVar4;
  ulong uVar5;
  size_t __n;
  
  lVar1 = *param_1;
  uVar2 = *(ulong *)(lVar1 + -0x18);
  if (param_4 == 0) {
    uVar5 = 0xffffffffffffffff;
    if (param_3 <= uVar2) {
      uVar5 = param_3;
    }
    return uVar5;
  }
  if ((param_3 < uVar2) && (param_4 <= uVar2 - param_3)) {
    __n = (uVar2 - param_3) + (1 - param_4);
    if (__n != 0) {
      __c = *param_2;
      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);
      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {
        iVar3 = wmemcmp(pwVar4,param_2,param_4);
        if (iVar3 == 0) {
          return (long)pwVar4 - lVar1 >> 2;
        }
        pwVar4 = pwVar4 + 1;
        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;
        if (uVar5 < param_4) {
          return 0xffffffffffffffff;
        }
        __n = uVar5 + (1 - param_4);
        if (__n == 0) {
          return 0xffffffffffffffff;
        }
      }
    }
  }
  return 0xffffffffffffffff;
}


PUSH R15
PUSH R14
PUSH R13
PUSH R12
PUSH RBP
PUSH RBX
SUB RSP,0x18
MOV R13,qword ptr [RDI]
MOV R9,qword ptr [R13 + -0x18]
TEST RCX,RCX
JZ 0x0031cdf8
MOV RAX,-0x1
CMP R9,RDX
JBE 0x0031cde3
MOV R8,R9
SUB R8,RDX
CMP RCX,R8
JA 0x0031cde3
MOV EBP,0x1
SUB RBP,RCX
ADD R8,RBP
JZ 0x0031cde3
LEA RAX,[R13 + R9*0x4]
MOV R14D,dword ptr [RSI]
MOV RBX,RCX
MOV R12,RSI
MOV qword ptr [RSP + 0x8],RAX
LEA RDI,[R13 + RDX*0x4]
MOV RDX,R8
MOV ESI,R14D
CALL 0x001444d0
MOV R15,RAX
TEST RAX,RAX
JZ 0x0031cddc
MOV RDX,RBX
MOV RSI,R12
MOV RDI,RAX
CALL 0x00144260
TEST EAX,EAX
JZ 0x0031ce18
MOV RDX,qword ptr [RSP + 0x8]
LEA RDI,[R15 + 0x4]
SUB RDX,RDI
SAR RDX,0x2
CMP RBX,RDX
JA 0x0031cddc
ADD RDX,RBP
MOV R8,RDX
JNZ 0x0031cd9a
MOV RAX,-0x1
ADD RSP,0x18
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET
CMP R9,RDX
MOV RAX,-0x1
CMOVNC RAX,RDX
ADD RSP,0x18
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET
MOV RAX,R15
SUB RAX,R13
SAR RAX,0x2
JMP 0x0031cde3
(translation_unit "ulong FUN_0031cd40(long *param_1,wchar_t *param_2,ulong param_3,ulong param_4)\n\n{\n  wchar_t __c;\n  long lVar1;\n  ulong uVar2;\n  int iVar3;\n  wchar_t *pwVar4;\n  ulong uVar5;\n  size_t __n;\n  \n  lVar1 = *param_1;\n  uVar2 = *(ulong *)(lVar1 + -0x18);\n  if (param_4 == 0) {\n    uVar5 = 0xffffffffffffffff;\n    if (param_3 <= uVar2) {\n      uVar5 = param_3;\n    }\n    return uVar5;\n  }\n  if ((param_3 < uVar2) && (param_4 <= uVar2 - param_3)) {\n    __n = (uVar2 - param_3) + (1 - param_4);\n    if (__n != 0) {\n      __c = *param_2;\n      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }\n  }\n  return 0xffffffffffffffff;\n}\n\n" (function_definition "ulong FUN_0031cd40(long *param_1,wchar_t *param_2,ulong param_3,ulong param_4)\n\n{\n  wchar_t __c;\n  long lVar1;\n  ulong uVar2;\n  int iVar3;\n  wchar_t *pwVar4;\n  ulong uVar5;\n  size_t __n;\n  \n  lVar1 = *param_1;\n  uVar2 = *(ulong *)(lVar1 + -0x18);\n  if (param_4 == 0) {\n    uVar5 = 0xffffffffffffffff;\n    if (param_3 <= uVar2) {\n      uVar5 = param_3;\n    }\n    return uVar5;\n  }\n  if ((param_3 < uVar2) && (param_4 <= uVar2 - param_3)) {\n    __n = (uVar2 - param_3) + (1 - param_4);\n    if (__n != 0) {\n      __c = *param_2;\n      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }\n  }\n  return 0xffffffffffffffff;\n}" type_identifier (function_declarator "FUN_0031cd40(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 __c;\n  long lVar1;\n  ulong uVar2;\n  int iVar3;\n  wchar_t *pwVar4;\n  ulong uVar5;\n  size_t __n;\n  \n  lVar1 = *param_1;\n  uVar2 = *(ulong *)(lVar1 + -0x18);\n  if (param_4 == 0) {\n    uVar5 = 0xffffffffffffffff;\n    if (param_3 <= uVar2) {\n      uVar5 = param_3;\n    }\n    return uVar5;\n  }\n  if ((param_3 < uVar2) && (param_4 <= uVar2 - param_3)) {\n    __n = (uVar2 - param_3) + (1 - param_4);\n    if (__n != 0) {\n      __c = *param_2;\n      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }\n  }\n  return 0xffffffffffffffff;\n}" { (declaration "wchar_t __c;" type_identifier identifier ;) (declaration "long lVar1;" (sized_type_specifier "long" long) identifier ;) (declaration "ulong uVar2;" type_identifier identifier ;) (declaration "int iVar3;" primitive_type identifier ;) (declaration "wchar_t *pwVar4;" type_identifier (pointer_declarator "*pwVar4" * identifier) ;) (declaration "ulong uVar5;" type_identifier identifier ;) (declaration "size_t __n;" primitive_type identifier ;) (expression_statement "lVar1 = *param_1;" (assignment_expression "lVar1 = *param_1" identifier = (pointer_expression "*param_1" * identifier)) ;) (expression_statement "uVar2 = *(ulong *)(lVar1 + -0x18);" (assignment_expression "uVar2 = *(ulong *)(lVar1 + -0x18)" identifier = (pointer_expression "*(ulong *)(lVar1 + -0x18)" * (cast_expression "(ulong *)(lVar1 + -0x18)" ( (type_descriptor "ulong *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(lVar1 + -0x18)" ( (binary_expression "lVar1 + -0x18" identifier + number_literal) ))))) ;) (if_statement "if (param_4 == 0) {\n    uVar5 = 0xffffffffffffffff;\n    if (param_3 <= uVar2) {\n      uVar5 = param_3;\n    }\n    return uVar5;\n  }" if (parenthesized_expression "(param_4 == 0)" ( (binary_expression "param_4 == 0" identifier == number_literal) )) (compound_statement "{\n    uVar5 = 0xffffffffffffffff;\n    if (param_3 <= uVar2) {\n      uVar5 = param_3;\n    }\n    return uVar5;\n  }" { (expression_statement "uVar5 = 0xffffffffffffffff;" (assignment_expression "uVar5 = 0xffffffffffffffff" identifier = number_literal) ;) (if_statement "if (param_3 <= uVar2) {\n      uVar5 = param_3;\n    }" if (parenthesized_expression "(param_3 <= uVar2)" ( (binary_expression "param_3 <= uVar2" identifier <= identifier) )) (compound_statement "{\n      uVar5 = param_3;\n    }" { (expression_statement "uVar5 = param_3;" (assignment_expression "uVar5 = param_3" identifier = identifier) ;) })) (return_statement "return uVar5;" return identifier ;) })) (if_statement "if ((param_3 < uVar2) && (param_4 <= uVar2 - param_3)) {\n    __n = (uVar2 - param_3) + (1 - param_4);\n    if (__n != 0) {\n      __c = *param_2;\n      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }\n  }" if (parenthesized_expression "((param_3 < uVar2) && (param_4 <= uVar2 - param_3))" ( (binary_expression "(param_3 < uVar2) && (param_4 <= uVar2 - param_3)" (parenthesized_expression "(param_3 < uVar2)" ( (binary_expression "param_3 < uVar2" identifier < identifier) )) && (parenthesized_expression "(param_4 <= uVar2 - param_3)" ( (binary_expression "param_4 <= uVar2 - param_3" identifier <= (binary_expression "uVar2 - param_3" identifier - identifier)) ))) )) (compound_statement "{\n    __n = (uVar2 - param_3) + (1 - param_4);\n    if (__n != 0) {\n      __c = *param_2;\n      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }\n  }" { (expression_statement "__n = (uVar2 - param_3) + (1 - param_4);" (assignment_expression "__n = (uVar2 - param_3) + (1 - param_4)" identifier = (binary_expression "(uVar2 - param_3) + (1 - param_4)" (parenthesized_expression "(uVar2 - param_3)" ( (binary_expression "uVar2 - param_3" identifier - identifier) )) + (parenthesized_expression "(1 - param_4)" ( (binary_expression "1 - param_4" number_literal - identifier) )))) ;) (if_statement "if (__n != 0) {\n      __c = *param_2;\n      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }" if (parenthesized_expression "(__n != 0)" ( (binary_expression "__n != 0" identifier != number_literal) )) (compound_statement "{\n      __c = *param_2;\n      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }" { (expression_statement "__c = *param_2;" (assignment_expression "__c = *param_2" identifier = (pointer_expression "*param_2" * identifier)) ;) (expression_statement "pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);" (assignment_expression "pwVar4 = (wchar_t *)(lVar1 + param_3 * 4)" identifier = (cast_expression "(wchar_t *)(lVar1 + param_3 * 4)" ( (type_descriptor "wchar_t *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(lVar1 + param_3 * 4)" ( (binary_expression "lVar1 + param_3 * 4" identifier + (binary_expression "param_3 * 4" identifier * number_literal)) )))) ;) (while_statement "while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }" while (parenthesized_expression "(pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0)" ( (comma_expression "pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0" (assignment_expression "pwVar4 = wmemchr(pwVar4,__c,__n)" identifier = (call_expression "wmemchr(pwVar4,__c,__n)" identifier (argument_list "(pwVar4,__c,__n)" ( identifier , identifier , identifier )))) , (binary_expression "pwVar4 != (wchar_t *)0x0" identifier != (cast_expression "(wchar_t *)0x0" ( (type_descriptor "wchar_t *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal))) )) (compound_statement "{\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }" { (expression_statement "iVar3 = wmemcmp(pwVar4,param_2,param_4);" (assignment_expression "iVar3 = wmemcmp(pwVar4,param_2,param_4)" identifier = (call_expression "wmemcmp(pwVar4,param_2,param_4)" identifier (argument_list "(pwVar4,param_2,param_4)" ( identifier , identifier , identifier )))) ;) (if_statement "if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }" if (parenthesized_expression "(iVar3 == 0)" ( (binary_expression "iVar3 == 0" identifier == number_literal) )) (compound_statement "{\n          return (long)pwVar4 - lVar1 >> 2;\n        }" { (return_statement "return (long)pwVar4 - lVar1 >> 2;" return (binary_expression "(long)pwVar4 - lVar1 >> 2" (binary_expression "(long)pwVar4 - lVar1" (cast_expression "(long)pwVar4" ( (type_descriptor "long" (sized_type_specifier "long" long)) ) identifier) - identifier) >> number_literal) ;) })) (expression_statement "pwVar4 = pwVar4 + 1;" (assignment_expression "pwVar4 = pwVar4 + 1" identifier = (binary_expression "pwVar4 + 1" identifier + number_literal)) ;) (expression_statement "uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;" (assignment_expression "uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2" identifier = (binary_expression "(long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2" (cast_expression "(long)((lVar1 + uVar2 * 4) - (long)pwVar4)" ( (type_descriptor "long" (sized_type_specifier "long" long)) ) (parenthesized_expression "((lVar1 + uVar2 * 4) - (long)pwVar4)" ( (binary_expression "(lVar1 + uVar2 * 4) - (long)pwVar4" (parenthesized_expression "(lVar1 + uVar2 * 4)" ( (binary_expression "lVar1 + uVar2 * 4" identifier + (binary_expression "uVar2 * 4" identifier * number_literal)) )) - (cast_expression "(long)pwVar4" ( (type_descriptor "long" (sized_type_specifier "long" long)) ) identifier)) ))) >> number_literal)) ;) (if_statement "if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }" if (parenthesized_expression "(uVar5 < param_4)" ( (binary_expression "uVar5 < param_4" identifier < identifier) )) (compound_statement "{\n          return 0xffffffffffffffff;\n        }" { (return_statement "return 0xffffffffffffffff;" return number_literal ;) })) (expression_statement "__n = uVar5 + (1 - param_4);" (assignment_expression "__n = uVar5 + (1 - param_4)" identifier = (binary_expression "uVar5 + (1 - param_4)" identifier + (parenthesized_expression "(1 - param_4)" ( (binary_expression "1 - param_4" number_literal - identifier) )))) ;) (if_statement "if (__n == 0) {\n          return 0xffffffffffffffff;\n        }" if (parenthesized_expression "(__n == 0)" ( (binary_expression "__n == 0" identifier == number_literal) )) (compound_statement "{\n          return 0xffffffffffffffff;\n        }" { (return_statement "return 0xffffffffffffffff;" return number_literal ;) })) })) })) })) (return_statement "return 0xffffffffffffffff;" return number_literal ;) })))
(translation_unit "/* std::wstring::find(wchar_t const*, unsigned long, unsigned long) const */\n\nulong __thiscall std::wstring::find(wstring *this,wchar_t *param_1,ulong param_2,ulong param_3)\n\n{\n  wchar_t __c;\n  long lVar1;\n  ulong uVar2;\n  int iVar3;\n  wchar_t *pwVar4;\n  ulong uVar5;\n  size_t __n;\n  \n  lVar1 = *(long *)this;\n  uVar2 = *(ulong *)(lVar1 + -0x18);\n  if (param_3 == 0) {\n    uVar5 = 0xffffffffffffffff;\n    if (param_2 <= uVar2) {\n      uVar5 = param_2;\n    }\n    return uVar5;\n  }\n  if ((param_2 < uVar2) && (param_3 <= uVar2 - param_2)) {\n    __n = (uVar2 - param_2) + (1 - param_3);\n    if (__n != 0) {\n      __c = *param_1;\n      pwVar4 = (wchar_t *)(lVar1 + param_2 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_1,param_3);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_3) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_3);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }\n  }\n  return 0xffffffffffffffff;\n}\n\n" comment (function_definition "ulong __thiscall std::wstring::find(wstring *this,wchar_t *param_1,ulong param_2,ulong param_3)\n\n{\n  wchar_t __c;\n  long lVar1;\n  ulong uVar2;\n  int iVar3;\n  wchar_t *pwVar4;\n  ulong uVar5;\n  size_t __n;\n  \n  lVar1 = *(long *)this;\n  uVar2 = *(ulong *)(lVar1 + -0x18);\n  if (param_3 == 0) {\n    uVar5 = 0xffffffffffffffff;\n    if (param_2 <= uVar2) {\n      uVar5 = param_2;\n    }\n    return uVar5;\n  }\n  if ((param_2 < uVar2) && (param_3 <= uVar2 - param_2)) {\n    __n = (uVar2 - param_2) + (1 - param_3);\n    if (__n != 0) {\n      __c = *param_1;\n      pwVar4 = (wchar_t *)(lVar1 + param_2 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_1,param_3);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_3) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_3);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }\n  }\n  return 0xffffffffffffffff;\n}" type_identifier (ms_call_modifier "__thiscall" __thiscall) (ERROR "std::wstring::" identifier : : identifier : :) (function_declarator "find(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 __c;\n  long lVar1;\n  ulong uVar2;\n  int iVar3;\n  wchar_t *pwVar4;\n  ulong uVar5;\n  size_t __n;\n  \n  lVar1 = *(long *)this;\n  uVar2 = *(ulong *)(lVar1 + -0x18);\n  if (param_3 == 0) {\n    uVar5 = 0xffffffffffffffff;\n    if (param_2 <= uVar2) {\n      uVar5 = param_2;\n    }\n    return uVar5;\n  }\n  if ((param_2 < uVar2) && (param_3 <= uVar2 - param_2)) {\n    __n = (uVar2 - param_2) + (1 - param_3);\n    if (__n != 0) {\n      __c = *param_1;\n      pwVar4 = (wchar_t *)(lVar1 + param_2 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_1,param_3);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_3) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_3);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }\n  }\n  return 0xffffffffffffffff;\n}" { (declaration "wchar_t __c;" type_identifier identifier ;) (declaration "long lVar1;" (sized_type_specifier "long" long) identifier ;) (declaration "ulong uVar2;" type_identifier identifier ;) (declaration "int iVar3;" primitive_type identifier ;) (declaration "wchar_t *pwVar4;" type_identifier (pointer_declarator "*pwVar4" * identifier) ;) (declaration "ulong uVar5;" type_identifier identifier ;) (declaration "size_t __n;" primitive_type identifier ;) (expression_statement "lVar1 = *(long *)this;" (assignment_expression "lVar1 = *(long *)this" identifier = (pointer_expression "*(long *)this" * (cast_expression "(long *)this" ( (type_descriptor "long *" (sized_type_specifier "long" long) (abstract_pointer_declarator "*" *)) ) identifier))) ;) (expression_statement "uVar2 = *(ulong *)(lVar1 + -0x18);" (assignment_expression "uVar2 = *(ulong *)(lVar1 + -0x18)" identifier = (pointer_expression "*(ulong *)(lVar1 + -0x18)" * (cast_expression "(ulong *)(lVar1 + -0x18)" ( (type_descriptor "ulong *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(lVar1 + -0x18)" ( (binary_expression "lVar1 + -0x18" identifier + number_literal) ))))) ;) (if_statement "if (param_3 == 0) {\n    uVar5 = 0xffffffffffffffff;\n    if (param_2 <= uVar2) {\n      uVar5 = param_2;\n    }\n    return uVar5;\n  }" if (parenthesized_expression "(param_3 == 0)" ( (binary_expression "param_3 == 0" identifier == number_literal) )) (compound_statement "{\n    uVar5 = 0xffffffffffffffff;\n    if (param_2 <= uVar2) {\n      uVar5 = param_2;\n    }\n    return uVar5;\n  }" { (expression_statement "uVar5 = 0xffffffffffffffff;" (assignment_expression "uVar5 = 0xffffffffffffffff" identifier = number_literal) ;) (if_statement "if (param_2 <= uVar2) {\n      uVar5 = param_2;\n    }" if (parenthesized_expression "(param_2 <= uVar2)" ( (binary_expression "param_2 <= uVar2" identifier <= identifier) )) (compound_statement "{\n      uVar5 = param_2;\n    }" { (expression_statement "uVar5 = param_2;" (assignment_expression "uVar5 = param_2" identifier = identifier) ;) })) (return_statement "return uVar5;" return identifier ;) })) (if_statement "if ((param_2 < uVar2) && (param_3 <= uVar2 - param_2)) {\n    __n = (uVar2 - param_2) + (1 - param_3);\n    if (__n != 0) {\n      __c = *param_1;\n      pwVar4 = (wchar_t *)(lVar1 + param_2 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_1,param_3);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_3) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_3);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }\n  }" if (parenthesized_expression "((param_2 < uVar2) && (param_3 <= uVar2 - param_2))" ( (binary_expression "(param_2 < uVar2) && (param_3 <= uVar2 - param_2)" (parenthesized_expression "(param_2 < uVar2)" ( (binary_expression "param_2 < uVar2" identifier < identifier) )) && (parenthesized_expression "(param_3 <= uVar2 - param_2)" ( (binary_expression "param_3 <= uVar2 - param_2" identifier <= (binary_expression "uVar2 - param_2" identifier - identifier)) ))) )) (compound_statement "{\n    __n = (uVar2 - param_2) + (1 - param_3);\n    if (__n != 0) {\n      __c = *param_1;\n      pwVar4 = (wchar_t *)(lVar1 + param_2 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_1,param_3);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_3) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_3);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }\n  }" { (expression_statement "__n = (uVar2 - param_2) + (1 - param_3);" (assignment_expression "__n = (uVar2 - param_2) + (1 - param_3)" identifier = (binary_expression "(uVar2 - param_2) + (1 - param_3)" (parenthesized_expression "(uVar2 - param_2)" ( (binary_expression "uVar2 - param_2" identifier - identifier) )) + (parenthesized_expression "(1 - param_3)" ( (binary_expression "1 - param_3" number_literal - identifier) )))) ;) (if_statement "if (__n != 0) {\n      __c = *param_1;\n      pwVar4 = (wchar_t *)(lVar1 + param_2 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_1,param_3);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_3) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_3);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }" if (parenthesized_expression "(__n != 0)" ( (binary_expression "__n != 0" identifier != number_literal) )) (compound_statement "{\n      __c = *param_1;\n      pwVar4 = (wchar_t *)(lVar1 + param_2 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_1,param_3);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_3) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_3);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }" { (expression_statement "__c = *param_1;" (assignment_expression "__c = *param_1" identifier = (pointer_expression "*param_1" * identifier)) ;) (expression_statement "pwVar4 = (wchar_t *)(lVar1 + param_2 * 4);" (assignment_expression "pwVar4 = (wchar_t *)(lVar1 + param_2 * 4)" identifier = (cast_expression "(wchar_t *)(lVar1 + param_2 * 4)" ( (type_descriptor "wchar_t *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(lVar1 + param_2 * 4)" ( (binary_expression "lVar1 + param_2 * 4" identifier + (binary_expression "param_2 * 4" identifier * number_literal)) )))) ;) (while_statement "while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_1,param_3);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_3) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_3);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }" while (parenthesized_expression "(pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0)" ( (comma_expression "pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0" (assignment_expression "pwVar4 = wmemchr(pwVar4,__c,__n)" identifier = (call_expression "wmemchr(pwVar4,__c,__n)" identifier (argument_list "(pwVar4,__c,__n)" ( identifier , identifier , identifier )))) , (binary_expression "pwVar4 != (wchar_t *)0x0" identifier != (cast_expression "(wchar_t *)0x0" ( (type_descriptor "wchar_t *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal))) )) (compound_statement "{\n        iVar3 = wmemcmp(pwVar4,param_1,param_3);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_3) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_3);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }" { (expression_statement "iVar3 = wmemcmp(pwVar4,param_1,param_3);" (assignment_expression "iVar3 = wmemcmp(pwVar4,param_1,param_3)" identifier = (call_expression "wmemcmp(pwVar4,param_1,param_3)" identifier (argument_list "(pwVar4,param_1,param_3)" ( identifier , identifier , identifier )))) ;) (if_statement "if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }" if (parenthesized_expression "(iVar3 == 0)" ( (binary_expression "iVar3 == 0" identifier == number_literal) )) (compound_statement "{\n          return (long)pwVar4 - lVar1 >> 2;\n        }" { (return_statement "return (long)pwVar4 - lVar1 >> 2;" return (binary_expression "(long)pwVar4 - lVar1 >> 2" (binary_expression "(long)pwVar4 - lVar1" (cast_expression "(long)pwVar4" ( (type_descriptor "long" (sized_type_specifier "long" long)) ) identifier) - identifier) >> number_literal) ;) })) (expression_statement "pwVar4 = pwVar4 + 1;" (assignment_expression "pwVar4 = pwVar4 + 1" identifier = (binary_expression "pwVar4 + 1" identifier + number_literal)) ;) (expression_statement "uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;" (assignment_expression "uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2" identifier = (binary_expression "(long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2" (cast_expression "(long)((lVar1 + uVar2 * 4) - (long)pwVar4)" ( (type_descriptor "long" (sized_type_specifier "long" long)) ) (parenthesized_expression "((lVar1 + uVar2 * 4) - (long)pwVar4)" ( (binary_expression "(lVar1 + uVar2 * 4) - (long)pwVar4" (parenthesized_expression "(lVar1 + uVar2 * 4)" ( (binary_expression "lVar1 + uVar2 * 4" identifier + (binary_expression "uVar2 * 4" identifier * number_literal)) )) - (cast_expression "(long)pwVar4" ( (type_descriptor "long" (sized_type_specifier "long" long)) ) identifier)) ))) >> number_literal)) ;) (if_statement "if (uVar5 < param_3) {\n          return 0xffffffffffffffff;\n        }" if (parenthesized_expression "(uVar5 < param_3)" ( (binary_expression "uVar5 < param_3" identifier < identifier) )) (compound_statement "{\n          return 0xffffffffffffffff;\n        }" { (return_statement "return 0xffffffffffffffff;" return number_literal ;) })) (expression_statement "__n = uVar5 + (1 - param_3);" (assignment_expression "__n = uVar5 + (1 - param_3)" identifier = (binary_expression "uVar5 + (1 - param_3)" identifier + (parenthesized_expression "(1 - param_3)" ( (binary_expression "1 - param_3" number_literal - identifier) )))) ;) (if_statement "if (__n == 0) {\n          return 0xffffffffffffffff;\n        }" if (parenthesized_expression "(__n == 0)" ( (binary_expression "__n == 0" identifier == number_literal) )) (compound_statement "{\n          return 0xffffffffffffffff;\n        }" { (return_statement "return 0xffffffffffffffff;" return number_literal ;) })) })) })) })) (return_statement "return 0xffffffffffffffff;" return number_literal ;) })))
(translation_unit "ulong FUN_0031cd40(long *param_1,wchar_t *param_2,ulong param_3,ulong param_4)\n\n{\n  wchar_t __c;\n  long lVar1;\n  ulong uVar2;\n  int iVar3;\n  wchar_t *pwVar4;\n  ulong uVar5;\n  size_t __n;\n  \n  lVar1 = *param_1;\n  uVar2 = *(ulong *)(lVar1 + -0x18);\n  if (param_4 == 0) {\n    uVar5 = 0xffffffffffffffff;\n    if (param_3 <= uVar2) {\n      uVar5 = param_3;\n    }\n    return uVar5;\n  }\n  if ((param_3 < uVar2) && (param_4 <= uVar2 - param_3)) {\n    __n = (uVar2 - param_3) + (1 - param_4);\n    if (__n != 0) {\n      __c = *param_2;\n      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }\n  }\n  return 0xffffffffffffffff;\n}\n\n" (function_definition "ulong FUN_0031cd40(long *param_1,wchar_t *param_2,ulong param_3,ulong param_4)\n\n{\n  wchar_t __c;\n  long lVar1;\n  ulong uVar2;\n  int iVar3;\n  wchar_t *pwVar4;\n  ulong uVar5;\n  size_t __n;\n  \n  lVar1 = *param_1;\n  uVar2 = *(ulong *)(lVar1 + -0x18);\n  if (param_4 == 0) {\n    uVar5 = 0xffffffffffffffff;\n    if (param_3 <= uVar2) {\n      uVar5 = param_3;\n    }\n    return uVar5;\n  }\n  if ((param_3 < uVar2) && (param_4 <= uVar2 - param_3)) {\n    __n = (uVar2 - param_3) + (1 - param_4);\n    if (__n != 0) {\n      __c = *param_2;\n      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }\n  }\n  return 0xffffffffffffffff;\n}" type_identifier (function_declarator "FUN_0031cd40(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 __c;\n  long lVar1;\n  ulong uVar2;\n  int iVar3;\n  wchar_t *pwVar4;\n  ulong uVar5;\n  size_t __n;\n  \n  lVar1 = *param_1;\n  uVar2 = *(ulong *)(lVar1 + -0x18);\n  if (param_4 == 0) {\n    uVar5 = 0xffffffffffffffff;\n    if (param_3 <= uVar2) {\n      uVar5 = param_3;\n    }\n    return uVar5;\n  }\n  if ((param_3 < uVar2) && (param_4 <= uVar2 - param_3)) {\n    __n = (uVar2 - param_3) + (1 - param_4);\n    if (__n != 0) {\n      __c = *param_2;\n      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }\n  }\n  return 0xffffffffffffffff;\n}" { (declaration "wchar_t __c;" type_identifier identifier ;) (declaration "long lVar1;" (sized_type_specifier "long" long) identifier ;) (declaration "ulong uVar2;" type_identifier identifier ;) (declaration "int iVar3;" primitive_type identifier ;) (declaration "wchar_t *pwVar4;" type_identifier (pointer_declarator "*pwVar4" * identifier) ;) (declaration "ulong uVar5;" type_identifier identifier ;) (declaration "size_t __n;" primitive_type identifier ;) (expression_statement "lVar1 = *param_1;" (assignment_expression "lVar1 = *param_1" identifier = (pointer_expression "*param_1" * identifier)) ;) (expression_statement "uVar2 = *(ulong *)(lVar1 + -0x18);" (assignment_expression "uVar2 = *(ulong *)(lVar1 + -0x18)" identifier = (pointer_expression "*(ulong *)(lVar1 + -0x18)" * (cast_expression "(ulong *)(lVar1 + -0x18)" ( (type_descriptor "ulong *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(lVar1 + -0x18)" ( (binary_expression "lVar1 + -0x18" identifier + number_literal) ))))) ;) (if_statement "if (param_4 == 0) {\n    uVar5 = 0xffffffffffffffff;\n    if (param_3 <= uVar2) {\n      uVar5 = param_3;\n    }\n    return uVar5;\n  }" if (parenthesized_expression "(param_4 == 0)" ( (binary_expression "param_4 == 0" identifier == number_literal) )) (compound_statement "{\n    uVar5 = 0xffffffffffffffff;\n    if (param_3 <= uVar2) {\n      uVar5 = param_3;\n    }\n    return uVar5;\n  }" { (expression_statement "uVar5 = 0xffffffffffffffff;" (assignment_expression "uVar5 = 0xffffffffffffffff" identifier = number_literal) ;) (if_statement "if (param_3 <= uVar2) {\n      uVar5 = param_3;\n    }" if (parenthesized_expression "(param_3 <= uVar2)" ( (binary_expression "param_3 <= uVar2" identifier <= identifier) )) (compound_statement "{\n      uVar5 = param_3;\n    }" { (expression_statement "uVar5 = param_3;" (assignment_expression "uVar5 = param_3" identifier = identifier) ;) })) (return_statement "return uVar5;" return identifier ;) })) (if_statement "if ((param_3 < uVar2) && (param_4 <= uVar2 - param_3)) {\n    __n = (uVar2 - param_3) + (1 - param_4);\n    if (__n != 0) {\n      __c = *param_2;\n      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }\n  }" if (parenthesized_expression "((param_3 < uVar2) && (param_4 <= uVar2 - param_3))" ( (binary_expression "(param_3 < uVar2) && (param_4 <= uVar2 - param_3)" (parenthesized_expression "(param_3 < uVar2)" ( (binary_expression "param_3 < uVar2" identifier < identifier) )) && (parenthesized_expression "(param_4 <= uVar2 - param_3)" ( (binary_expression "param_4 <= uVar2 - param_3" identifier <= (binary_expression "uVar2 - param_3" identifier - identifier)) ))) )) (compound_statement "{\n    __n = (uVar2 - param_3) + (1 - param_4);\n    if (__n != 0) {\n      __c = *param_2;\n      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }\n  }" { (expression_statement "__n = (uVar2 - param_3) + (1 - param_4);" (assignment_expression "__n = (uVar2 - param_3) + (1 - param_4)" identifier = (binary_expression "(uVar2 - param_3) + (1 - param_4)" (parenthesized_expression "(uVar2 - param_3)" ( (binary_expression "uVar2 - param_3" identifier - identifier) )) + (parenthesized_expression "(1 - param_4)" ( (binary_expression "1 - param_4" number_literal - identifier) )))) ;) (if_statement "if (__n != 0) {\n      __c = *param_2;\n      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }" if (parenthesized_expression "(__n != 0)" ( (binary_expression "__n != 0" identifier != number_literal) )) (compound_statement "{\n      __c = *param_2;\n      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }" { (expression_statement "__c = *param_2;" (assignment_expression "__c = *param_2" identifier = (pointer_expression "*param_2" * identifier)) ;) (expression_statement "pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);" (assignment_expression "pwVar4 = (wchar_t *)(lVar1 + param_3 * 4)" identifier = (cast_expression "(wchar_t *)(lVar1 + param_3 * 4)" ( (type_descriptor "wchar_t *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(lVar1 + param_3 * 4)" ( (binary_expression "lVar1 + param_3 * 4" identifier + (binary_expression "param_3 * 4" identifier * number_literal)) )))) ;) (while_statement "while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }" while (parenthesized_expression "(pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0)" ( (comma_expression "pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0" (assignment_expression "pwVar4 = wmemchr(pwVar4,__c,__n)" identifier = (call_expression "wmemchr(pwVar4,__c,__n)" identifier (argument_list "(pwVar4,__c,__n)" ( identifier , identifier , identifier )))) , (binary_expression "pwVar4 != (wchar_t *)0x0" identifier != (cast_expression "(wchar_t *)0x0" ( (type_descriptor "wchar_t *" type_identifier (abstract_pointer_declarator "*" *)) ) number_literal))) )) (compound_statement "{\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }" { (expression_statement "iVar3 = wmemcmp(pwVar4,param_2,param_4);" (assignment_expression "iVar3 = wmemcmp(pwVar4,param_2,param_4)" identifier = (call_expression "wmemcmp(pwVar4,param_2,param_4)" identifier (argument_list "(pwVar4,param_2,param_4)" ( identifier , identifier , identifier )))) ;) (if_statement "if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }" if (parenthesized_expression "(iVar3 == 0)" ( (binary_expression "iVar3 == 0" identifier == number_literal) )) (compound_statement "{\n          return (long)pwVar4 - lVar1 >> 2;\n        }" { (return_statement "return (long)pwVar4 - lVar1 >> 2;" return (binary_expression "(long)pwVar4 - lVar1 >> 2" (binary_expression "(long)pwVar4 - lVar1" (cast_expression "(long)pwVar4" ( (type_descriptor "long" (sized_type_specifier "long" long)) ) identifier) - identifier) >> number_literal) ;) })) (expression_statement "pwVar4 = pwVar4 + 1;" (assignment_expression "pwVar4 = pwVar4 + 1" identifier = (binary_expression "pwVar4 + 1" identifier + number_literal)) ;) (expression_statement "uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;" (assignment_expression "uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2" identifier = (binary_expression "(long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2" (cast_expression "(long)((lVar1 + uVar2 * 4) - (long)pwVar4)" ( (type_descriptor "long" (sized_type_specifier "long" long)) ) (parenthesized_expression "((lVar1 + uVar2 * 4) - (long)pwVar4)" ( (binary_expression "(lVar1 + uVar2 * 4) - (long)pwVar4" (parenthesized_expression "(lVar1 + uVar2 * 4)" ( (binary_expression "lVar1 + uVar2 * 4" identifier + (binary_expression "uVar2 * 4" identifier * number_literal)) )) - (cast_expression "(long)pwVar4" ( (type_descriptor "long" (sized_type_specifier "long" long)) ) identifier)) ))) >> number_literal)) ;) (if_statement "if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }" if (parenthesized_expression "(uVar5 < param_4)" ( (binary_expression "uVar5 < param_4" identifier < identifier) )) (compound_statement "{\n          return 0xffffffffffffffff;\n        }" { (return_statement "return 0xffffffffffffffff;" return number_literal ;) })) (expression_statement "__n = uVar5 + (1 - param_4);" (assignment_expression "__n = uVar5 + (1 - param_4)" identifier = (binary_expression "uVar5 + (1 - param_4)" identifier + (parenthesized_expression "(1 - param_4)" ( (binary_expression "1 - param_4" number_literal - identifier) )))) ;) (if_statement "if (__n == 0) {\n          return 0xffffffffffffffff;\n        }" if (parenthesized_expression "(__n == 0)" ( (binary_expression "__n == 0" identifier == number_literal) )) (compound_statement "{\n          return 0xffffffffffffffff;\n        }" { (return_statement "return 0xffffffffffffffff;" return number_literal ;) })) })) })) })) (return_statement "return 0xffffffffffffffff;" return number_literal ;) })))
(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 IDENT ;) (declaration (sized_type_specifier long) IDENT ;) (declaration TYPE IDENT ;) (declaration TYPE IDENT ;) (declaration TYPE (pointer_declarator * IDENT) ;) (declaration TYPE IDENT ;) (declaration TYPE IDENT ;) (expression_statement (assignment_expression IDENT = (pointer_expression * IDENT)) ;) (expression_statement (assignment_expression IDENT = (pointer_expression * (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (parenthesized_expression ( (binary_expression IDENT + LIT) ))))) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT == LIT) )) (compound_statement { (expression_statement (assignment_expression IDENT = LIT) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT <= IDENT) )) (compound_statement { (expression_statement (assignment_expression IDENT = IDENT) ;) })) (return_statement return IDENT ;) })) (if_statement if (parenthesized_expression ( (binary_expression (parenthesized_expression ( (binary_expression IDENT < IDENT) )) && (parenthesized_expression ( (binary_expression IDENT <= (binary_expression IDENT - IDENT)) ))) )) (compound_statement { (expression_statement (assignment_expression IDENT = (binary_expression (parenthesized_expression ( (binary_expression IDENT - IDENT) )) + (parenthesized_expression ( (binary_expression LIT - IDENT) )))) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT != LIT) )) (compound_statement { (expression_statement (assignment_expression IDENT = (pointer_expression * IDENT)) ;) (expression_statement (assignment_expression IDENT = (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (parenthesized_expression ( (binary_expression IDENT + (binary_expression IDENT * LIT)) )))) ;) (while_statement while (parenthesized_expression ( (comma_expression (assignment_expression IDENT = (call_expression IDENT (argument_list ( IDENT , IDENT , IDENT )))) , (binary_expression IDENT != (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) LIT))) )) (compound_statement { (expression_statement (assignment_expression IDENT = (call_expression IDENT (argument_list ( IDENT , IDENT , IDENT )))) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT == LIT) )) (compound_statement { (return_statement return (binary_expression (binary_expression (cast_expression ( (type_descriptor (sized_type_specifier long)) ) IDENT) - IDENT) >> LIT) ;) })) (expression_statement (assignment_expression IDENT = (binary_expression IDENT + LIT)) ;) (expression_statement (assignment_expression IDENT = (binary_expression (cast_expression ( (type_descriptor (sized_type_specifier long)) ) (parenthesized_expression ( (binary_expression (parenthesized_expression ( (binary_expression IDENT + (binary_expression IDENT * LIT)) )) - (cast_expression ( (type_descriptor (sized_type_specifier long)) ) IDENT)) ))) >> LIT)) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT < IDENT) )) (compound_statement { (return_statement return LIT ;) })) (expression_statement (assignment_expression IDENT = (binary_expression IDENT + (parenthesized_expression ( (binary_expression LIT - IDENT) )))) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT == LIT) )) (compound_statement { (return_statement return LIT ;) })) })) })) })) (return_statement return LIT ;) })))
(function_definition "ulong FUN_0031cd40(long *param_1,wchar_t *param_2,ulong param_3,ulong param_4)\n\n{\n  wchar_t __c;\n  long lVar1;\n  ulong uVar2;\n  int iVar3;\n  wchar_t *pwVar4;\n  ulong uVar5;\n  size_t __n;\n  \n  lVar1 = *param_1;\n  uVar2 = *(ulong *)(lVar1 + -0x18);\n  if (param_4 == 0) {\n    uVar5 = 0xffffffffffffffff;\n    if (param_3 <= uVar2) {\n      uVar5 = param_3;\n    }\n    return uVar5;\n  }\n  if ((param_3 < uVar2) && (param_4 <= uVar2 - param_3)) {\n    __n = (uVar2 - param_3) + (1 - param_4);\n    if (__n != 0) {\n      __c = *param_2;\n      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }\n  }\n  return 0xffffffffffffffff;\n}" (type_identifier "ulong") (function_declarator "FUN_0031cd40(long *param_1,wchar_t *param_2,ulong param_3,ulong param_4)" (identifier "FUN_0031cd40") (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 __c;\n  long lVar1;\n  ulong uVar2;\n  int iVar3;\n  wchar_t *pwVar4;\n  ulong uVar5;\n  size_t __n;\n  \n  lVar1 = *param_1;\n  uVar2 = *(ulong *)(lVar1 + -0x18);\n  if (param_4 == 0) {\n    uVar5 = 0xffffffffffffffff;\n    if (param_3 <= uVar2) {\n      uVar5 = param_3;\n    }\n    return uVar5;\n  }\n  if ((param_3 < uVar2) && (param_4 <= uVar2 - param_3)) {\n    __n = (uVar2 - param_3) + (1 - param_4);\n    if (__n != 0) {\n      __c = *param_2;\n      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }\n  }\n  return 0xffffffffffffffff;\n}" ({ "{") (declaration "wchar_t __c;" (type_identifier "wchar_t") (identifier "__c") (; ";")) (declaration "long lVar1;" (sized_type_specifier "long" (long "long")) (identifier "lVar1") (; ";")) (declaration "ulong uVar2;" (type_identifier "ulong") (identifier "uVar2") (; ";")) (declaration "int iVar3;" (primitive_type "int") (identifier "iVar3") (; ";")) (declaration "wchar_t *pwVar4;" (type_identifier "wchar_t") (pointer_declarator "*pwVar4" (* "*") (identifier "pwVar4")) (; ";")) (declaration "ulong uVar5;" (type_identifier "ulong") (identifier "uVar5") (; ";")) (declaration "size_t __n;" (primitive_type "size_t") (identifier "__n") (; ";")) (expression_statement "lVar1 = *param_1;" (assignment_expression "lVar1 = *param_1" (identifier "lVar1") (= "=") (pointer_expression "*param_1" (* "*") (identifier "param_1"))) (; ";")) (expression_statement "uVar2 = *(ulong *)(lVar1 + -0x18);" (assignment_expression "uVar2 = *(ulong *)(lVar1 + -0x18)" (identifier "uVar2") (= "=") (pointer_expression "*(ulong *)(lVar1 + -0x18)" (* "*") (cast_expression "(ulong *)(lVar1 + -0x18)" (( "(") (type_descriptor "ulong *" (type_identifier "ulong") (abstract_pointer_declarator "*" (* "*"))) () ")") (parenthesized_expression "(lVar1 + -0x18)" (( "(") (binary_expression "lVar1 + -0x18" (identifier "lVar1") (+ "+") (number_literal "-0x18")) () ")"))))) (; ";")) (if_statement "if (param_4 == 0) {\n    uVar5 = 0xffffffffffffffff;\n    if (param_3 <= uVar2) {\n      uVar5 = param_3;\n    }\n    return uVar5;\n  }" (if "if") (parenthesized_expression "(param_4 == 0)" (( "(") (binary_expression "param_4 == 0" (identifier "param_4") (== "==") (number_literal "0")) () ")")) (compound_statement "{\n    uVar5 = 0xffffffffffffffff;\n    if (param_3 <= uVar2) {\n      uVar5 = param_3;\n    }\n    return uVar5;\n  }" ({ "{") (expression_statement "uVar5 = 0xffffffffffffffff;" (assignment_expression "uVar5 = 0xffffffffffffffff" (identifier "uVar5") (= "=") (number_literal "0xffffffffffffffff")) (; ";")) (if_statement "if (param_3 <= uVar2) {\n      uVar5 = param_3;\n    }" (if "if") (parenthesized_expression "(param_3 <= uVar2)" (( "(") (binary_expression "param_3 <= uVar2" (identifier "param_3") (<= "<=") (identifier "uVar2")) () ")")) (compound_statement "{\n      uVar5 = param_3;\n    }" ({ "{") (expression_statement "uVar5 = param_3;" (assignment_expression "uVar5 = param_3" (identifier "uVar5") (= "=") (identifier "param_3")) (; ";")) (} "}"))) (return_statement "return uVar5;" (return "return") (identifier "uVar5") (; ";")) (} "}"))) (if_statement "if ((param_3 < uVar2) && (param_4 <= uVar2 - param_3)) {\n    __n = (uVar2 - param_3) + (1 - param_4);\n    if (__n != 0) {\n      __c = *param_2;\n      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }\n  }" (if "if") (parenthesized_expression "((param_3 < uVar2) && (param_4 <= uVar2 - param_3))" (( "(") (binary_expression "(param_3 < uVar2) && (param_4 <= uVar2 - param_3)" (parenthesized_expression "(param_3 < uVar2)" (( "(") (binary_expression "param_3 < uVar2" (identifier "param_3") (< "<") (identifier "uVar2")) () ")")) (&& "&&") (parenthesized_expression "(param_4 <= uVar2 - param_3)" (( "(") (binary_expression "param_4 <= uVar2 - param_3" (identifier "param_4") (<= "<=") (binary_expression "uVar2 - param_3" (identifier "uVar2") (- "-") (identifier "param_3"))) () ")"))) () ")")) (compound_statement "{\n    __n = (uVar2 - param_3) + (1 - param_4);\n    if (__n != 0) {\n      __c = *param_2;\n      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }\n  }" ({ "{") (expression_statement "__n = (uVar2 - param_3) + (1 - param_4);" (assignment_expression "__n = (uVar2 - param_3) + (1 - param_4)" (identifier "__n") (= "=") (binary_expression "(uVar2 - param_3) + (1 - param_4)" (parenthesized_expression "(uVar2 - param_3)" (( "(") (binary_expression "uVar2 - param_3" (identifier "uVar2") (- "-") (identifier "param_3")) () ")")) (+ "+") (parenthesized_expression "(1 - param_4)" (( "(") (binary_expression "1 - param_4" (number_literal "1") (- "-") (identifier "param_4")) () ")")))) (; ";")) (if_statement "if (__n != 0) {\n      __c = *param_2;\n      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }" (if "if") (parenthesized_expression "(__n != 0)" (( "(") (binary_expression "__n != 0" (identifier "__n") (!= "!=") (number_literal "0")) () ")")) (compound_statement "{\n      __c = *param_2;\n      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);\n      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }\n    }" ({ "{") (expression_statement "__c = *param_2;" (assignment_expression "__c = *param_2" (identifier "__c") (= "=") (pointer_expression "*param_2" (* "*") (identifier "param_2"))) (; ";")) (expression_statement "pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);" (assignment_expression "pwVar4 = (wchar_t *)(lVar1 + param_3 * 4)" (identifier "pwVar4") (= "=") (cast_expression "(wchar_t *)(lVar1 + param_3 * 4)" (( "(") (type_descriptor "wchar_t *" (type_identifier "wchar_t") (abstract_pointer_declarator "*" (* "*"))) () ")") (parenthesized_expression "(lVar1 + param_3 * 4)" (( "(") (binary_expression "lVar1 + param_3 * 4" (identifier "lVar1") (+ "+") (binary_expression "param_3 * 4" (identifier "param_3") (* "*") (number_literal "4"))) () ")")))) (; ";")) (while_statement "while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }" (while "while") (parenthesized_expression "(pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0)" (( "(") (comma_expression "pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0" (assignment_expression "pwVar4 = wmemchr(pwVar4,__c,__n)" (identifier "pwVar4") (= "=") (call_expression "wmemchr(pwVar4,__c,__n)" (identifier "wmemchr") (argument_list "(pwVar4,__c,__n)" (( "(") (identifier "pwVar4") (, ",") (identifier "__c") (, ",") (identifier "__n") () ")")))) (, ",") (binary_expression "pwVar4 != (wchar_t *)0x0" (identifier "pwVar4") (!= "!=") (cast_expression "(wchar_t *)0x0" (( "(") (type_descriptor "wchar_t *" (type_identifier "wchar_t") (abstract_pointer_declarator "*" (* "*"))) () ")") (number_literal "0x0")))) () ")")) (compound_statement "{\n        iVar3 = wmemcmp(pwVar4,param_2,param_4);\n        if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }\n        pwVar4 = pwVar4 + 1;\n        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;\n        if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }\n        __n = uVar5 + (1 - param_4);\n        if (__n == 0) {\n          return 0xffffffffffffffff;\n        }\n      }" ({ "{") (expression_statement "iVar3 = wmemcmp(pwVar4,param_2,param_4);" (assignment_expression "iVar3 = wmemcmp(pwVar4,param_2,param_4)" (identifier "iVar3") (= "=") (call_expression "wmemcmp(pwVar4,param_2,param_4)" (identifier "wmemcmp") (argument_list "(pwVar4,param_2,param_4)" (( "(") (identifier "pwVar4") (, ",") (identifier "param_2") (, ",") (identifier "param_4") () ")")))) (; ";")) (if_statement "if (iVar3 == 0) {\n          return (long)pwVar4 - lVar1 >> 2;\n        }" (if "if") (parenthesized_expression "(iVar3 == 0)" (( "(") (binary_expression "iVar3 == 0" (identifier "iVar3") (== "==") (number_literal "0")) () ")")) (compound_statement "{\n          return (long)pwVar4 - lVar1 >> 2;\n        }" ({ "{") (return_statement "return (long)pwVar4 - lVar1 >> 2;" (return "return") (binary_expression "(long)pwVar4 - lVar1 >> 2" (binary_expression "(long)pwVar4 - lVar1" (cast_expression "(long)pwVar4" (( "(") (type_descriptor "long" (sized_type_specifier "long" (long "long"))) () ")") (identifier "pwVar4")) (- "-") (identifier "lVar1")) (>> ">>") (number_literal "2")) (; ";")) (} "}"))) (expression_statement "pwVar4 = pwVar4 + 1;" (assignment_expression "pwVar4 = pwVar4 + 1" (identifier "pwVar4") (= "=") (binary_expression "pwVar4 + 1" (identifier "pwVar4") (+ "+") (number_literal "1"))) (; ";")) (expression_statement "uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;" (assignment_expression "uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2" (identifier "uVar5") (= "=") (binary_expression "(long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2" (cast_expression "(long)((lVar1 + uVar2 * 4) - (long)pwVar4)" (( "(") (type_descriptor "long" (sized_type_specifier "long" (long "long"))) () ")") (parenthesized_expression "((lVar1 + uVar2 * 4) - (long)pwVar4)" (( "(") (binary_expression "(lVar1 + uVar2 * 4) - (long)pwVar4" (parenthesized_expression "(lVar1 + uVar2 * 4)" (( "(") (binary_expression "lVar1 + uVar2 * 4" (identifier "lVar1") (+ "+") (binary_expression "uVar2 * 4" (identifier "uVar2") (* "*") (number_literal "4"))) () ")")) (- "-") (cast_expression "(long)pwVar4" (( "(") (type_descriptor "long" (sized_type_specifier "long" (long "long"))) () ")") (identifier "pwVar4"))) () ")"))) (>> ">>") (number_literal "2"))) (; ";")) (if_statement "if (uVar5 < param_4) {\n          return 0xffffffffffffffff;\n        }" (if "if") (parenthesized_expression "(uVar5 < param_4)" (( "(") (binary_expression "uVar5 < param_4" (identifier "uVar5") (< "<") (identifier "param_4")) () ")")) (compound_statement "{\n          return 0xffffffffffffffff;\n        }" ({ "{") (return_statement "return 0xffffffffffffffff;" (return "return") (number_literal "0xffffffffffffffff") (; ";")) (} "}"))) (expression_statement "__n = uVar5 + (1 - param_4);" (assignment_expression "__n = uVar5 + (1 - param_4)" (identifier "__n") (= "=") (binary_expression "uVar5 + (1 - param_4)" (identifier "uVar5") (+ "+") (parenthesized_expression "(1 - param_4)" (( "(") (binary_expression "1 - param_4" (number_literal "1") (- "-") (identifier "param_4")) () ")")))) (; ";")) (if_statement "if (__n == 0) {\n          return 0xffffffffffffffff;\n        }" (if "if") (parenthesized_expression "(__n == 0)" (( "(") (binary_expression "__n == 0" (identifier "__n") (== "==") (number_literal "0")) () ")")) (compound_statement "{\n          return 0xffffffffffffffff;\n        }" ({ "{") (return_statement "return 0xffffffffffffffff;" (return "return") (number_literal "0xffffffffffffffff") (; ";")) (} "}"))) (} "}"))) (} "}"))) (} "}"))) (return_statement "return 0xffffffffffffffff;" (return "return") (number_literal "0xffffffffffffffff") (; ";")) (} "}")))

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

type_1 __thiscall std::type_2::function_1(type_2 *this,type_3 *param_1,type_1 var_3,type_1 var_2)

{
  type_3 __c;
  long var_1;
  type_1 var_4;
  int var_9;
  type_3 *var_7;
  type_1 var_10;
  size_t var_5;
  
  var_1 = *(long *)this;
  var_4 = *(type_1 *)(var_1 + -0x18);
  if (var_2 == 0) {
    var_10 = 0xffffffffffffffff;
    if (var_3 <= var_4) {
      var_10 = var_3;
    }
    return var_10;
  }
  if ((var_3 < var_4) && (var_2 <= var_4 - var_3)) {
    var_5 = (var_4 - var_3) + (1 - var_2);
    if (var_5 != 0) {
      __c = *param_1;
      var_7 = (type_3 *)(var_1 + var_3 * 4);
      while (var_7 = var_6(var_7,__c,var_5), var_7 != (type_3 *)0x0) {
        var_9 = var_8(var_7,param_1,var_2);
        if (var_9 == 0) {
          return (long)var_7 - var_1 >> 2;
        }
        var_7 = var_7 + 1;
        var_10 = (long)((var_1 + var_4 * 4) - (long)var_7) >> 2;
        if (var_10 < var_2) {
          return 0xffffffffffffffff;
        }
        var_5 = var_10 + (1 - var_2);
        if (var_5 == 0) {
          return 0xffffffffffffffff;
        }
      }
    }
  }
  return 0xffffffffffffffff;
}


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

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

{
  wchar_t __c;
  long lVar1;
  ulong uVar2;
  int iVar3;
  wchar_t *pwVar4;
  ulong uVar5;
  size_t __n;
  
  lVar1 = *param_1;
  uVar2 = *(ulong *)(lVar1 + -0x18);
  if (param_4 == 0) {
    uVar5 = 0xffffffffffffffff;
    if (param_3 <= uVar2) {
      uVar5 = param_3;
    }
    return uVar5;
  }
  if ((param_3 < uVar2) && (param_4 <= uVar2 - param_3)) {
    __n = (uVar2 - param_3) + (1 - param_4);
    if (__n != 0) {
      __c = *param_2;
      pwVar4 = (wchar_t *)(lVar1 + param_3 * 4);
      while (pwVar4 = wmemchr(pwVar4,__c,__n), pwVar4 != (wchar_t *)0x0) {
        iVar3 = wmemcmp(pwVar4,param_2,param_4);
        if (iVar3 == 0) {
          return (long)pwVar4 - lVar1 >> 2;
        }
        pwVar4 = pwVar4 + 1;
        uVar5 = (long)((lVar1 + uVar2 * 4) - (long)pwVar4) >> 2;
        if (uVar5 < param_4) {
          return 0xffffffffffffffff;
        }
        __n = uVar5 + (1 - param_4);
        if (__n == 0) {
          return 0xffffffffffffffff;
        }
      }
    }
  }
  return 0xffffffffffffffff;
}

