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

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

{
  long lVar1;
  int iVar2;
  ulong uVar3;
  bool bVar4;
  
  if (param_3 <= *(ulong *)(this + 8)) {
    uVar3 = *(ulong *)(this + 8) - param_3;
    lVar1 = *(long *)this;
    if (uVar3 <= param_2) {
      param_2 = uVar3;
    }
    do {
      if (param_3 == 0) {
        return param_2;
      }
      iVar2 = memcmp((void *)(lVar1 + param_2),param_1,param_3);
      if (iVar2 == 0) {
        return param_2;
      }
      bVar4 = param_2 != 0;
      param_2 = param_2 - 1;
    } while (bVar4);
  }
  return 0xffffffffffffffff;
}



ulong FUN_002e3420(long *param_1,void *param_2,ulong param_3,size_t param_4)

{
  long lVar1;
  int iVar2;
  ulong uVar3;
  bool bVar4;
  
  if (param_4 <= (ulong)param_1[1]) {
    uVar3 = param_1[1] - param_4;
    lVar1 = *param_1;
    if (uVar3 <= param_3) {
      param_3 = uVar3;
    }
    do {
      if (param_4 == 0) {
        return param_3;
      }
      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);
      if (iVar2 == 0) {
        return param_3;
      }
      bVar4 = param_3 != 0;
      param_3 = param_3 - 1;
    } while (bVar4);
  }
  return 0xffffffffffffffff;
}


PUSH R13
PUSH R12
PUSH RBP
PUSH RBX
MOV RBX,-0x1
SUB RSP,0x8
MOV RAX,qword ptr [RDI + 0x8]
CMP RCX,RAX
JA 0x002e347a
SUB RAX,RCX
MOV RBP,RCX
MOV R12,RSI
MOV R13,qword ptr [RDI]
CMP RAX,RDX
CMOVBE RDX,RAX
MOV RBX,RDX
TEST RBP,RBP
JZ 0x002e347a
LEA RDI,[R13 + RBX*0x1]
MOV RDX,RBP
MOV RSI,R12
CALL 0x00147840
TEST EAX,EAX
JZ 0x002e347a
LEA RAX,[RBX + -0x1]
TEST RBX,RBX
JZ 0x002e3490
MOV RBX,RAX
TEST RBP,RBP
JNZ 0x002e3455
ADD RSP,0x8
MOV RAX,RBX
POP RBX
POP RBP
POP R12
POP R13
RET
MOV RBX,-0x1
JMP 0x002e347a
(translation_unit "ulong FUN_002e3420(long *param_1,void *param_2,ulong param_3,size_t param_4)\n\n{\n  long lVar1;\n  int iVar2;\n  ulong uVar3;\n  bool bVar4;\n  \n  if (param_4 <= (ulong)param_1[1]) {\n    uVar3 = param_1[1] - param_4;\n    lVar1 = *param_1;\n    if (uVar3 <= param_3) {\n      param_3 = uVar3;\n    }\n    do {\n      if (param_4 == 0) {\n        return param_3;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);\n      if (iVar2 == 0) {\n        return param_3;\n      }\n      bVar4 = param_3 != 0;\n      param_3 = param_3 - 1;\n    } while (bVar4);\n  }\n  return 0xffffffffffffffff;\n}\n\n" (function_definition "ulong FUN_002e3420(long *param_1,void *param_2,ulong param_3,size_t param_4)\n\n{\n  long lVar1;\n  int iVar2;\n  ulong uVar3;\n  bool bVar4;\n  \n  if (param_4 <= (ulong)param_1[1]) {\n    uVar3 = param_1[1] - param_4;\n    lVar1 = *param_1;\n    if (uVar3 <= param_3) {\n      param_3 = uVar3;\n    }\n    do {\n      if (param_4 == 0) {\n        return param_3;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);\n      if (iVar2 == 0) {\n        return param_3;\n      }\n      bVar4 = param_3 != 0;\n      param_3 = param_3 - 1;\n    } while (bVar4);\n  }\n  return 0xffffffffffffffff;\n}" type_identifier (function_declarator "FUN_002e3420(long *param_1,void *param_2,ulong param_3,size_t param_4)" identifier (parameter_list "(long *param_1,void *param_2,ulong param_3,size_t param_4)" ( (parameter_declaration "long *param_1" (sized_type_specifier "long" long) (pointer_declarator "*param_1" * identifier)) , (parameter_declaration "void *param_2" primitive_type (pointer_declarator "*param_2" * identifier)) , (parameter_declaration "ulong param_3" type_identifier identifier) , (parameter_declaration "size_t param_4" primitive_type identifier) ))) (compound_statement "{\n  long lVar1;\n  int iVar2;\n  ulong uVar3;\n  bool bVar4;\n  \n  if (param_4 <= (ulong)param_1[1]) {\n    uVar3 = param_1[1] - param_4;\n    lVar1 = *param_1;\n    if (uVar3 <= param_3) {\n      param_3 = uVar3;\n    }\n    do {\n      if (param_4 == 0) {\n        return param_3;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);\n      if (iVar2 == 0) {\n        return param_3;\n      }\n      bVar4 = param_3 != 0;\n      param_3 = param_3 - 1;\n    } while (bVar4);\n  }\n  return 0xffffffffffffffff;\n}" { (declaration "long lVar1;" (sized_type_specifier "long" long) identifier ;) (declaration "int iVar2;" primitive_type identifier ;) (declaration "ulong uVar3;" type_identifier identifier ;) (declaration "bool bVar4;" primitive_type identifier ;) (if_statement "if (param_4 <= (ulong)param_1[1]) {\n    uVar3 = param_1[1] - param_4;\n    lVar1 = *param_1;\n    if (uVar3 <= param_3) {\n      param_3 = uVar3;\n    }\n    do {\n      if (param_4 == 0) {\n        return param_3;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);\n      if (iVar2 == 0) {\n        return param_3;\n      }\n      bVar4 = param_3 != 0;\n      param_3 = param_3 - 1;\n    } while (bVar4);\n  }" if (parenthesized_expression "(param_4 <= (ulong)param_1[1])" ( (binary_expression "param_4 <= (ulong)param_1[1]" identifier <= (cast_expression "(ulong)param_1[1]" ( (type_descriptor "ulong" type_identifier) ) (subscript_expression "param_1[1]" identifier [ number_literal ]))) )) (compound_statement "{\n    uVar3 = param_1[1] - param_4;\n    lVar1 = *param_1;\n    if (uVar3 <= param_3) {\n      param_3 = uVar3;\n    }\n    do {\n      if (param_4 == 0) {\n        return param_3;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);\n      if (iVar2 == 0) {\n        return param_3;\n      }\n      bVar4 = param_3 != 0;\n      param_3 = param_3 - 1;\n    } while (bVar4);\n  }" { (expression_statement "uVar3 = param_1[1] - param_4;" (assignment_expression "uVar3 = param_1[1] - param_4" identifier = (binary_expression "param_1[1] - param_4" (subscript_expression "param_1[1]" identifier [ number_literal ]) - identifier)) ;) (expression_statement "lVar1 = *param_1;" (assignment_expression "lVar1 = *param_1" identifier = (pointer_expression "*param_1" * identifier)) ;) (if_statement "if (uVar3 <= param_3) {\n      param_3 = uVar3;\n    }" if (parenthesized_expression "(uVar3 <= param_3)" ( (binary_expression "uVar3 <= param_3" identifier <= identifier) )) (compound_statement "{\n      param_3 = uVar3;\n    }" { (expression_statement "param_3 = uVar3;" (assignment_expression "param_3 = uVar3" identifier = identifier) ;) })) (do_statement "do {\n      if (param_4 == 0) {\n        return param_3;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);\n      if (iVar2 == 0) {\n        return param_3;\n      }\n      bVar4 = param_3 != 0;\n      param_3 = param_3 - 1;\n    } while (bVar4);" do (compound_statement "{\n      if (param_4 == 0) {\n        return param_3;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);\n      if (iVar2 == 0) {\n        return param_3;\n      }\n      bVar4 = param_3 != 0;\n      param_3 = param_3 - 1;\n    }" { (if_statement "if (param_4 == 0) {\n        return param_3;\n      }" if (parenthesized_expression "(param_4 == 0)" ( (binary_expression "param_4 == 0" identifier == number_literal) )) (compound_statement "{\n        return param_3;\n      }" { (return_statement "return param_3;" return identifier ;) })) (expression_statement "iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);" (assignment_expression "iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4)" identifier = (call_expression "memcmp((void *)(lVar1 + param_3),param_2,param_4)" identifier (argument_list "((void *)(lVar1 + param_3),param_2,param_4)" ( (cast_expression "(void *)(lVar1 + param_3)" ( (type_descriptor "void *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(lVar1 + param_3)" ( (binary_expression "lVar1 + param_3" identifier + identifier) ))) , identifier , identifier )))) ;) (if_statement "if (iVar2 == 0) {\n        return param_3;\n      }" if (parenthesized_expression "(iVar2 == 0)" ( (binary_expression "iVar2 == 0" identifier == number_literal) )) (compound_statement "{\n        return param_3;\n      }" { (return_statement "return param_3;" return identifier ;) })) (expression_statement "bVar4 = param_3 != 0;" (assignment_expression "bVar4 = param_3 != 0" identifier = (binary_expression "param_3 != 0" identifier != number_literal)) ;) (expression_statement "param_3 = param_3 - 1;" (assignment_expression "param_3 = param_3 - 1" identifier = (binary_expression "param_3 - 1" identifier - number_literal)) ;) }) while (parenthesized_expression "(bVar4)" ( identifier )) ;) })) (return_statement "return 0xffffffffffffffff;" return number_literal ;) })))
(translation_unit "/* std::string::rfind(char const*, unsigned long, unsigned long) const */\n\nulong __thiscall std::string::rfind(string *this,char *param_1,ulong param_2,ulong param_3)\n\n{\n  long lVar1;\n  int iVar2;\n  ulong uVar3;\n  bool bVar4;\n  \n  if (param_3 <= *(ulong *)(this + 8)) {\n    uVar3 = *(ulong *)(this + 8) - param_3;\n    lVar1 = *(long *)this;\n    if (uVar3 <= param_2) {\n      param_2 = uVar3;\n    }\n    do {\n      if (param_3 == 0) {\n        return param_2;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_2),param_1,param_3);\n      if (iVar2 == 0) {\n        return param_2;\n      }\n      bVar4 = param_2 != 0;\n      param_2 = param_2 - 1;\n    } while (bVar4);\n  }\n  return 0xffffffffffffffff;\n}\n\n" comment (function_definition "ulong __thiscall std::string::rfind(string *this,char *param_1,ulong param_2,ulong param_3)\n\n{\n  long lVar1;\n  int iVar2;\n  ulong uVar3;\n  bool bVar4;\n  \n  if (param_3 <= *(ulong *)(this + 8)) {\n    uVar3 = *(ulong *)(this + 8) - param_3;\n    lVar1 = *(long *)this;\n    if (uVar3 <= param_2) {\n      param_2 = uVar3;\n    }\n    do {\n      if (param_3 == 0) {\n        return param_2;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_2),param_1,param_3);\n      if (iVar2 == 0) {\n        return param_2;\n      }\n      bVar4 = param_2 != 0;\n      param_2 = param_2 - 1;\n    } while (bVar4);\n  }\n  return 0xffffffffffffffff;\n}" type_identifier (ms_call_modifier "__thiscall" __thiscall) (ERROR "std::string::" identifier : : identifier : :) (function_declarator "rfind(string *this,char *param_1,ulong param_2,ulong param_3)" identifier (parameter_list "(string *this,char *param_1,ulong param_2,ulong param_3)" ( (parameter_declaration "string *this" type_identifier (pointer_declarator "*this" * identifier)) , (parameter_declaration "char *param_1" primitive_type (pointer_declarator "*param_1" * identifier)) , (parameter_declaration "ulong param_2" type_identifier identifier) , (parameter_declaration "ulong param_3" type_identifier identifier) ))) (compound_statement "{\n  long lVar1;\n  int iVar2;\n  ulong uVar3;\n  bool bVar4;\n  \n  if (param_3 <= *(ulong *)(this + 8)) {\n    uVar3 = *(ulong *)(this + 8) - param_3;\n    lVar1 = *(long *)this;\n    if (uVar3 <= param_2) {\n      param_2 = uVar3;\n    }\n    do {\n      if (param_3 == 0) {\n        return param_2;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_2),param_1,param_3);\n      if (iVar2 == 0) {\n        return param_2;\n      }\n      bVar4 = param_2 != 0;\n      param_2 = param_2 - 1;\n    } while (bVar4);\n  }\n  return 0xffffffffffffffff;\n}" { (declaration "long lVar1;" (sized_type_specifier "long" long) identifier ;) (declaration "int iVar2;" primitive_type identifier ;) (declaration "ulong uVar3;" type_identifier identifier ;) (declaration "bool bVar4;" primitive_type identifier ;) (if_statement "if (param_3 <= *(ulong *)(this + 8)) {\n    uVar3 = *(ulong *)(this + 8) - param_3;\n    lVar1 = *(long *)this;\n    if (uVar3 <= param_2) {\n      param_2 = uVar3;\n    }\n    do {\n      if (param_3 == 0) {\n        return param_2;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_2),param_1,param_3);\n      if (iVar2 == 0) {\n        return param_2;\n      }\n      bVar4 = param_2 != 0;\n      param_2 = param_2 - 1;\n    } while (bVar4);\n  }" if (parenthesized_expression "(param_3 <= *(ulong *)(this + 8))" ( (binary_expression "param_3 <= *(ulong *)(this + 8)" identifier <= (pointer_expression "*(ulong *)(this + 8)" * (cast_expression "(ulong *)(this + 8)" ( (type_descriptor "ulong *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(this + 8)" ( (binary_expression "this + 8" identifier + number_literal) ))))) )) (compound_statement "{\n    uVar3 = *(ulong *)(this + 8) - param_3;\n    lVar1 = *(long *)this;\n    if (uVar3 <= param_2) {\n      param_2 = uVar3;\n    }\n    do {\n      if (param_3 == 0) {\n        return param_2;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_2),param_1,param_3);\n      if (iVar2 == 0) {\n        return param_2;\n      }\n      bVar4 = param_2 != 0;\n      param_2 = param_2 - 1;\n    } while (bVar4);\n  }" { (expression_statement "uVar3 = *(ulong *)(this + 8) - param_3;" (assignment_expression "uVar3 = *(ulong *)(this + 8) - param_3" identifier = (binary_expression "*(ulong *)(this + 8) - param_3" (pointer_expression "*(ulong *)(this + 8)" * (cast_expression "(ulong *)(this + 8)" ( (type_descriptor "ulong *" type_identifier (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(this + 8)" ( (binary_expression "this + 8" identifier + number_literal) )))) - 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))) ;) (if_statement "if (uVar3 <= param_2) {\n      param_2 = uVar3;\n    }" if (parenthesized_expression "(uVar3 <= param_2)" ( (binary_expression "uVar3 <= param_2" identifier <= identifier) )) (compound_statement "{\n      param_2 = uVar3;\n    }" { (expression_statement "param_2 = uVar3;" (assignment_expression "param_2 = uVar3" identifier = identifier) ;) })) (do_statement "do {\n      if (param_3 == 0) {\n        return param_2;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_2),param_1,param_3);\n      if (iVar2 == 0) {\n        return param_2;\n      }\n      bVar4 = param_2 != 0;\n      param_2 = param_2 - 1;\n    } while (bVar4);" do (compound_statement "{\n      if (param_3 == 0) {\n        return param_2;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_2),param_1,param_3);\n      if (iVar2 == 0) {\n        return param_2;\n      }\n      bVar4 = param_2 != 0;\n      param_2 = param_2 - 1;\n    }" { (if_statement "if (param_3 == 0) {\n        return param_2;\n      }" if (parenthesized_expression "(param_3 == 0)" ( (binary_expression "param_3 == 0" identifier == number_literal) )) (compound_statement "{\n        return param_2;\n      }" { (return_statement "return param_2;" return identifier ;) })) (expression_statement "iVar2 = memcmp((void *)(lVar1 + param_2),param_1,param_3);" (assignment_expression "iVar2 = memcmp((void *)(lVar1 + param_2),param_1,param_3)" identifier = (call_expression "memcmp((void *)(lVar1 + param_2),param_1,param_3)" identifier (argument_list "((void *)(lVar1 + param_2),param_1,param_3)" ( (cast_expression "(void *)(lVar1 + param_2)" ( (type_descriptor "void *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(lVar1 + param_2)" ( (binary_expression "lVar1 + param_2" identifier + identifier) ))) , identifier , identifier )))) ;) (if_statement "if (iVar2 == 0) {\n        return param_2;\n      }" if (parenthesized_expression "(iVar2 == 0)" ( (binary_expression "iVar2 == 0" identifier == number_literal) )) (compound_statement "{\n        return param_2;\n      }" { (return_statement "return param_2;" return identifier ;) })) (expression_statement "bVar4 = param_2 != 0;" (assignment_expression "bVar4 = param_2 != 0" identifier = (binary_expression "param_2 != 0" identifier != number_literal)) ;) (expression_statement "param_2 = param_2 - 1;" (assignment_expression "param_2 = param_2 - 1" identifier = (binary_expression "param_2 - 1" identifier - number_literal)) ;) }) while (parenthesized_expression "(bVar4)" ( identifier )) ;) })) (return_statement "return 0xffffffffffffffff;" return number_literal ;) })))
(translation_unit "ulong FUN_002e3420(long *param_1,void *param_2,ulong param_3,size_t param_4)\n\n{\n  long lVar1;\n  int iVar2;\n  ulong uVar3;\n  bool bVar4;\n  \n  if (param_4 <= (ulong)param_1[1]) {\n    uVar3 = param_1[1] - param_4;\n    lVar1 = *param_1;\n    if (uVar3 <= param_3) {\n      param_3 = uVar3;\n    }\n    do {\n      if (param_4 == 0) {\n        return param_3;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);\n      if (iVar2 == 0) {\n        return param_3;\n      }\n      bVar4 = param_3 != 0;\n      param_3 = param_3 - 1;\n    } while (bVar4);\n  }\n  return 0xffffffffffffffff;\n}\n\n" (function_definition "ulong FUN_002e3420(long *param_1,void *param_2,ulong param_3,size_t param_4)\n\n{\n  long lVar1;\n  int iVar2;\n  ulong uVar3;\n  bool bVar4;\n  \n  if (param_4 <= (ulong)param_1[1]) {\n    uVar3 = param_1[1] - param_4;\n    lVar1 = *param_1;\n    if (uVar3 <= param_3) {\n      param_3 = uVar3;\n    }\n    do {\n      if (param_4 == 0) {\n        return param_3;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);\n      if (iVar2 == 0) {\n        return param_3;\n      }\n      bVar4 = param_3 != 0;\n      param_3 = param_3 - 1;\n    } while (bVar4);\n  }\n  return 0xffffffffffffffff;\n}" type_identifier (function_declarator "FUN_002e3420(long *param_1,void *param_2,ulong param_3,size_t param_4)" identifier (parameter_list "(long *param_1,void *param_2,ulong param_3,size_t param_4)" ( (parameter_declaration "long *param_1" (sized_type_specifier "long" long) (pointer_declarator "*param_1" * identifier)) , (parameter_declaration "void *param_2" primitive_type (pointer_declarator "*param_2" * identifier)) , (parameter_declaration "ulong param_3" type_identifier identifier) , (parameter_declaration "size_t param_4" primitive_type identifier) ))) (compound_statement "{\n  long lVar1;\n  int iVar2;\n  ulong uVar3;\n  bool bVar4;\n  \n  if (param_4 <= (ulong)param_1[1]) {\n    uVar3 = param_1[1] - param_4;\n    lVar1 = *param_1;\n    if (uVar3 <= param_3) {\n      param_3 = uVar3;\n    }\n    do {\n      if (param_4 == 0) {\n        return param_3;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);\n      if (iVar2 == 0) {\n        return param_3;\n      }\n      bVar4 = param_3 != 0;\n      param_3 = param_3 - 1;\n    } while (bVar4);\n  }\n  return 0xffffffffffffffff;\n}" { (declaration "long lVar1;" (sized_type_specifier "long" long) identifier ;) (declaration "int iVar2;" primitive_type identifier ;) (declaration "ulong uVar3;" type_identifier identifier ;) (declaration "bool bVar4;" primitive_type identifier ;) (if_statement "if (param_4 <= (ulong)param_1[1]) {\n    uVar3 = param_1[1] - param_4;\n    lVar1 = *param_1;\n    if (uVar3 <= param_3) {\n      param_3 = uVar3;\n    }\n    do {\n      if (param_4 == 0) {\n        return param_3;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);\n      if (iVar2 == 0) {\n        return param_3;\n      }\n      bVar4 = param_3 != 0;\n      param_3 = param_3 - 1;\n    } while (bVar4);\n  }" if (parenthesized_expression "(param_4 <= (ulong)param_1[1])" ( (binary_expression "param_4 <= (ulong)param_1[1]" identifier <= (cast_expression "(ulong)param_1[1]" ( (type_descriptor "ulong" type_identifier) ) (subscript_expression "param_1[1]" identifier [ number_literal ]))) )) (compound_statement "{\n    uVar3 = param_1[1] - param_4;\n    lVar1 = *param_1;\n    if (uVar3 <= param_3) {\n      param_3 = uVar3;\n    }\n    do {\n      if (param_4 == 0) {\n        return param_3;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);\n      if (iVar2 == 0) {\n        return param_3;\n      }\n      bVar4 = param_3 != 0;\n      param_3 = param_3 - 1;\n    } while (bVar4);\n  }" { (expression_statement "uVar3 = param_1[1] - param_4;" (assignment_expression "uVar3 = param_1[1] - param_4" identifier = (binary_expression "param_1[1] - param_4" (subscript_expression "param_1[1]" identifier [ number_literal ]) - identifier)) ;) (expression_statement "lVar1 = *param_1;" (assignment_expression "lVar1 = *param_1" identifier = (pointer_expression "*param_1" * identifier)) ;) (if_statement "if (uVar3 <= param_3) {\n      param_3 = uVar3;\n    }" if (parenthesized_expression "(uVar3 <= param_3)" ( (binary_expression "uVar3 <= param_3" identifier <= identifier) )) (compound_statement "{\n      param_3 = uVar3;\n    }" { (expression_statement "param_3 = uVar3;" (assignment_expression "param_3 = uVar3" identifier = identifier) ;) })) (do_statement "do {\n      if (param_4 == 0) {\n        return param_3;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);\n      if (iVar2 == 0) {\n        return param_3;\n      }\n      bVar4 = param_3 != 0;\n      param_3 = param_3 - 1;\n    } while (bVar4);" do (compound_statement "{\n      if (param_4 == 0) {\n        return param_3;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);\n      if (iVar2 == 0) {\n        return param_3;\n      }\n      bVar4 = param_3 != 0;\n      param_3 = param_3 - 1;\n    }" { (if_statement "if (param_4 == 0) {\n        return param_3;\n      }" if (parenthesized_expression "(param_4 == 0)" ( (binary_expression "param_4 == 0" identifier == number_literal) )) (compound_statement "{\n        return param_3;\n      }" { (return_statement "return param_3;" return identifier ;) })) (expression_statement "iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);" (assignment_expression "iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4)" identifier = (call_expression "memcmp((void *)(lVar1 + param_3),param_2,param_4)" identifier (argument_list "((void *)(lVar1 + param_3),param_2,param_4)" ( (cast_expression "(void *)(lVar1 + param_3)" ( (type_descriptor "void *" primitive_type (abstract_pointer_declarator "*" *)) ) (parenthesized_expression "(lVar1 + param_3)" ( (binary_expression "lVar1 + param_3" identifier + identifier) ))) , identifier , identifier )))) ;) (if_statement "if (iVar2 == 0) {\n        return param_3;\n      }" if (parenthesized_expression "(iVar2 == 0)" ( (binary_expression "iVar2 == 0" identifier == number_literal) )) (compound_statement "{\n        return param_3;\n      }" { (return_statement "return param_3;" return identifier ;) })) (expression_statement "bVar4 = param_3 != 0;" (assignment_expression "bVar4 = param_3 != 0" identifier = (binary_expression "param_3 != 0" identifier != number_literal)) ;) (expression_statement "param_3 = param_3 - 1;" (assignment_expression "param_3 = param_3 - 1" identifier = (binary_expression "param_3 - 1" identifier - number_literal)) ;) }) while (parenthesized_expression "(bVar4)" ( identifier )) ;) })) (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 (sized_type_specifier long) IDENT ;) (declaration TYPE IDENT ;) (declaration TYPE IDENT ;) (declaration TYPE IDENT ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT <= (cast_expression ( (type_descriptor TYPE) ) (subscript_expression IDENT [ LIT ]))) )) (compound_statement { (expression_statement (assignment_expression IDENT = (binary_expression (subscript_expression IDENT [ LIT ]) - IDENT)) ;) (expression_statement (assignment_expression IDENT = (pointer_expression * IDENT)) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT <= IDENT) )) (compound_statement { (expression_statement (assignment_expression IDENT = IDENT) ;) })) (do_statement do (compound_statement { (if_statement if (parenthesized_expression ( (binary_expression IDENT == LIT) )) (compound_statement { (return_statement return IDENT ;) })) (expression_statement (assignment_expression IDENT = (call_expression IDENT (argument_list ( (cast_expression ( (type_descriptor TYPE (abstract_pointer_declarator *)) ) (parenthesized_expression ( (binary_expression IDENT + IDENT) ))) , IDENT , IDENT )))) ;) (if_statement if (parenthesized_expression ( (binary_expression IDENT == LIT) )) (compound_statement { (return_statement return IDENT ;) })) (expression_statement (assignment_expression IDENT = (binary_expression IDENT != LIT)) ;) (expression_statement (assignment_expression IDENT = (binary_expression IDENT - LIT)) ;) }) while (parenthesized_expression ( IDENT )) ;) })) (return_statement return LIT ;) })))
(function_definition "ulong FUN_002e3420(long *param_1,void *param_2,ulong param_3,size_t param_4)\n\n{\n  long lVar1;\n  int iVar2;\n  ulong uVar3;\n  bool bVar4;\n  \n  if (param_4 <= (ulong)param_1[1]) {\n    uVar3 = param_1[1] - param_4;\n    lVar1 = *param_1;\n    if (uVar3 <= param_3) {\n      param_3 = uVar3;\n    }\n    do {\n      if (param_4 == 0) {\n        return param_3;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);\n      if (iVar2 == 0) {\n        return param_3;\n      }\n      bVar4 = param_3 != 0;\n      param_3 = param_3 - 1;\n    } while (bVar4);\n  }\n  return 0xffffffffffffffff;\n}" (type_identifier "ulong") (function_declarator "FUN_002e3420(long *param_1,void *param_2,ulong param_3,size_t param_4)" (identifier "FUN_002e3420") (parameter_list "(long *param_1,void *param_2,ulong param_3,size_t param_4)" (( "(") (parameter_declaration "long *param_1" (sized_type_specifier "long" (long "long")) (pointer_declarator "*param_1" (* "*") (identifier "param_1"))) (, ",") (parameter_declaration "void *param_2" (primitive_type "void") (pointer_declarator "*param_2" (* "*") (identifier "param_2"))) (, ",") (parameter_declaration "ulong param_3" (type_identifier "ulong") (identifier "param_3")) (, ",") (parameter_declaration "size_t param_4" (primitive_type "size_t") (identifier "param_4")) () ")"))) (compound_statement "{\n  long lVar1;\n  int iVar2;\n  ulong uVar3;\n  bool bVar4;\n  \n  if (param_4 <= (ulong)param_1[1]) {\n    uVar3 = param_1[1] - param_4;\n    lVar1 = *param_1;\n    if (uVar3 <= param_3) {\n      param_3 = uVar3;\n    }\n    do {\n      if (param_4 == 0) {\n        return param_3;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);\n      if (iVar2 == 0) {\n        return param_3;\n      }\n      bVar4 = param_3 != 0;\n      param_3 = param_3 - 1;\n    } while (bVar4);\n  }\n  return 0xffffffffffffffff;\n}" ({ "{") (declaration "long lVar1;" (sized_type_specifier "long" (long "long")) (identifier "lVar1") (; ";")) (declaration "int iVar2;" (primitive_type "int") (identifier "iVar2") (; ";")) (declaration "ulong uVar3;" (type_identifier "ulong") (identifier "uVar3") (; ";")) (declaration "bool bVar4;" (primitive_type "bool") (identifier "bVar4") (; ";")) (if_statement "if (param_4 <= (ulong)param_1[1]) {\n    uVar3 = param_1[1] - param_4;\n    lVar1 = *param_1;\n    if (uVar3 <= param_3) {\n      param_3 = uVar3;\n    }\n    do {\n      if (param_4 == 0) {\n        return param_3;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);\n      if (iVar2 == 0) {\n        return param_3;\n      }\n      bVar4 = param_3 != 0;\n      param_3 = param_3 - 1;\n    } while (bVar4);\n  }" (if "if") (parenthesized_expression "(param_4 <= (ulong)param_1[1])" (( "(") (binary_expression "param_4 <= (ulong)param_1[1]" (identifier "param_4") (<= "<=") (cast_expression "(ulong)param_1[1]" (( "(") (type_descriptor "ulong" (type_identifier "ulong")) () ")") (subscript_expression "param_1[1]" (identifier "param_1") ([ "[") (number_literal "1") (] "]")))) () ")")) (compound_statement "{\n    uVar3 = param_1[1] - param_4;\n    lVar1 = *param_1;\n    if (uVar3 <= param_3) {\n      param_3 = uVar3;\n    }\n    do {\n      if (param_4 == 0) {\n        return param_3;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);\n      if (iVar2 == 0) {\n        return param_3;\n      }\n      bVar4 = param_3 != 0;\n      param_3 = param_3 - 1;\n    } while (bVar4);\n  }" ({ "{") (expression_statement "uVar3 = param_1[1] - param_4;" (assignment_expression "uVar3 = param_1[1] - param_4" (identifier "uVar3") (= "=") (binary_expression "param_1[1] - param_4" (subscript_expression "param_1[1]" (identifier "param_1") ([ "[") (number_literal "1") (] "]")) (- "-") (identifier "param_4"))) (; ";")) (expression_statement "lVar1 = *param_1;" (assignment_expression "lVar1 = *param_1" (identifier "lVar1") (= "=") (pointer_expression "*param_1" (* "*") (identifier "param_1"))) (; ";")) (if_statement "if (uVar3 <= param_3) {\n      param_3 = uVar3;\n    }" (if "if") (parenthesized_expression "(uVar3 <= param_3)" (( "(") (binary_expression "uVar3 <= param_3" (identifier "uVar3") (<= "<=") (identifier "param_3")) () ")")) (compound_statement "{\n      param_3 = uVar3;\n    }" ({ "{") (expression_statement "param_3 = uVar3;" (assignment_expression "param_3 = uVar3" (identifier "param_3") (= "=") (identifier "uVar3")) (; ";")) (} "}"))) (do_statement "do {\n      if (param_4 == 0) {\n        return param_3;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);\n      if (iVar2 == 0) {\n        return param_3;\n      }\n      bVar4 = param_3 != 0;\n      param_3 = param_3 - 1;\n    } while (bVar4);" (do "do") (compound_statement "{\n      if (param_4 == 0) {\n        return param_3;\n      }\n      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);\n      if (iVar2 == 0) {\n        return param_3;\n      }\n      bVar4 = param_3 != 0;\n      param_3 = param_3 - 1;\n    }" ({ "{") (if_statement "if (param_4 == 0) {\n        return param_3;\n      }" (if "if") (parenthesized_expression "(param_4 == 0)" (( "(") (binary_expression "param_4 == 0" (identifier "param_4") (== "==") (number_literal "0")) () ")")) (compound_statement "{\n        return param_3;\n      }" ({ "{") (return_statement "return param_3;" (return "return") (identifier "param_3") (; ";")) (} "}"))) (expression_statement "iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);" (assignment_expression "iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4)" (identifier "iVar2") (= "=") (call_expression "memcmp((void *)(lVar1 + param_3),param_2,param_4)" (identifier "memcmp") (argument_list "((void *)(lVar1 + param_3),param_2,param_4)" (( "(") (cast_expression "(void *)(lVar1 + param_3)" (( "(") (type_descriptor "void *" (primitive_type "void") (abstract_pointer_declarator "*" (* "*"))) () ")") (parenthesized_expression "(lVar1 + param_3)" (( "(") (binary_expression "lVar1 + param_3" (identifier "lVar1") (+ "+") (identifier "param_3")) () ")"))) (, ",") (identifier "param_2") (, ",") (identifier "param_4") () ")")))) (; ";")) (if_statement "if (iVar2 == 0) {\n        return param_3;\n      }" (if "if") (parenthesized_expression "(iVar2 == 0)" (( "(") (binary_expression "iVar2 == 0" (identifier "iVar2") (== "==") (number_literal "0")) () ")")) (compound_statement "{\n        return param_3;\n      }" ({ "{") (return_statement "return param_3;" (return "return") (identifier "param_3") (; ";")) (} "}"))) (expression_statement "bVar4 = param_3 != 0;" (assignment_expression "bVar4 = param_3 != 0" (identifier "bVar4") (= "=") (binary_expression "param_3 != 0" (identifier "param_3") (!= "!=") (number_literal "0"))) (; ";")) (expression_statement "param_3 = param_3 - 1;" (assignment_expression "param_3 = param_3 - 1" (identifier "param_3") (= "=") (binary_expression "param_3 - 1" (identifier "param_3") (- "-") (number_literal "1"))) (; ";")) (} "}")) (while "while") (parenthesized_expression "(bVar4)" (( "(") (identifier "bVar4") () ")")) (; ";")) (} "}"))) (return_statement "return 0xffffffffffffffff;" (return "return") (number_literal "0xffffffffffffffff") (; ";")) (} "}")))

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

type_1 __thiscall std::type_2::function_1(type_2 *var_2,char *param_1,type_1 var_4,type_1 var_1)

{
  long var_6;
  int var_7;
  type_1 var_3;
  bool bVar4;
  
  if (var_1 <= *(type_1 *)(var_2 + 8)) {
    var_3 = *(type_1 *)(var_2 + 8) - var_1;
    var_6 = *(long *)var_2;
    if (var_3 <= var_4) {
      var_4 = var_3;
    }
    do {
      if (var_1 == 0) {
        return var_4;
      }
      var_7 = var_5((void *)(var_6 + var_4),param_1,var_1);
      if (var_7 == 0) {
        return var_4;
      }
      bVar4 = var_4 != 0;
      var_4 = var_4 - 1;
    } while (bVar4);
  }
  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: (primitive_type) declarator: (pointer_declarator declarator: (identifier))) (parameter_declaration type: (type_identifier) declarator: (identifier)) (parameter_declaration type: (primitive_type) declarator: (identifier)))) body: (compound_statement (declaration type: (sized_type_specifier) declarator: (identifier)) (declaration type: (primitive_type) declarator: (identifier)) (declaration type: (type_identifier) declarator: (identifier)) (declaration type: (primitive_type) declarator: (identifier)) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (cast_expression type: (type_descriptor type: (type_identifier)) value: (subscript_expression argument: (identifier) index: (number_literal))))) consequence: (compound_statement (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (subscript_expression argument: (identifier) index: (number_literal)) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (pointer_expression argument: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (compound_statement (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (do_statement body: (compound_statement (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (number_literal))) consequence: (compound_statement (return_statement (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (call_expression function: (identifier) arguments: (argument_list (cast_expression type: (type_descriptor type: (primitive_type) declarator: (abstract_pointer_declarator)) value: (parenthesized_expression (binary_expression left: (identifier) right: (identifier)))) (identifier) (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (number_literal))) consequence: (compound_statement (return_statement (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (number_literal)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (number_literal))))) condition: (parenthesized_expression (identifier))))) (return_statement (number_literal)))))

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

{
  long lVar1;
  int iVar2;
  ulong uVar3;
  bool bVar4;
  
  if (param_4 <= (ulong)param_1[1]) {
    uVar3 = param_1[1] - param_4;
    lVar1 = *param_1;
    if (uVar3 <= param_3) {
      param_3 = uVar3;
    }
    do {
      if (param_4 == 0) {
        return param_3;
      }
      iVar2 = memcmp((void *)(lVar1 + param_3),param_2,param_4);
      if (iVar2 == 0) {
        return param_3;
      }
      bVar4 = param_3 != 0;
      param_3 = param_3 - 1;
    } while (bVar4);
  }
  return 0xffffffffffffffff;
}

