// File: /workspace/github_cpp_makefile_star2_O3/IHorvalds[P]RomAna/./processing/InflexEngineCore.cpp
// Function: InflexEngine::search(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int&)
int32_t InflexEngine::search(std::string str, int32_t& lastPos) {
// Good for tests: if str is a rootWord returns the pointer where it was saved. Otherwise, the pointer of its rootword.
  int32_t ptr, pos, encoding;
  bool toCheck;
  ptr = 0;
  for (pos = 0; pos < str.size();) {
    // Get the encoding
    encoding = (pos == str.size() - 1) ? romanian::encode(str[pos]) : romanian::diacriticEncode(str[pos], str[pos + 1]);
    
    toCheck = (staticTrieAccess(ptr)->configuration != fullBits) ? bitOp::getBit(staticTrieAccess(ptr)->configuration, encoding) : staticTrieAccess(ptr)->sons[encoding];
    if (!toCheck) {
      lastPos = pos;
      return -ptr;
    }
    ptr = staticTrieAccess(ptr)->sons[staticTrieAccess(ptr)->configuration != fullBits ? bitOp::orderOfBit(staticTrieAccess(ptr)->configuration, encoding) : encoding];
    pos += 1 + romanian::isDiacritic(str[pos]);
  }
  return (staticTrieAccess(ptr)->code & 1) ? ptr : (staticTrieAccess(ptr)->code / 2);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x8(%rsi), %rax
testq %rax, %rax
je 0x3baf
movq %rdx, 0x8(%rsp)
xorl %r15d, %r15d
xorl %ebp, %ebp
xorl %edx, %edx
movq %rsi, 0x10(%rsp)
decq %rax
movq (%rsi), %rcx
movsbl (%rcx,%r15), %edi
cmpq %r15, %rax
movl %edx, 0x4(%rsp)
jne 0x3ac2
callq 0x33a0
movl %eax, %r12d
addl $-0x61, %r12d
cmpl $0x1a, %r12d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovael %eax, %r12d
jmp 0x3ad5
movl %edx, %eax
movzbl 0x1(%rcx,%rax), %esi
movzbl %dil, %edi
callq 0x4316
movl %eax, %r12d
movq %rbx, %rdi
movl %ebp, %esi
callq 0x383c
movl 0x8(%rax), %r14d
movl 0x24(%rbx), %r13d
movq %rbx, %rdi
movl %ebp, %esi
callq 0x383c
cmpl %r13d, %r14d
jne 0x3b02
movq 0xc(%rax), %rax
movslq %r12d, %rcx
movl (%rax,%rcx,4), %eax
jmp 0x3b0e
movl 0x8(%rax), %ecx
xorl %eax, %eax
btl %r12d, %ecx
setb %al
testl %eax, %eax
je 0x3bd0
movq %rbx, %rdi
movl %ebp, %esi
callq 0x383c
movq 0xc(%rax), %r14
movq %rbx, %rdi
movl %ebp, %esi
callq 0x383c
movl 0x8(%rax), %eax
cmpl 0x24(%rbx), %eax
je 0x3b4e
movq %rbx, %rdi
movl %ebp, %esi
callq 0x383c
movl 0x8(%rax), %edi
movl %r12d, %esi
callq 0x42b1
movl %eax, %r12d
movl %r12d, %eax
movl (%r14,%rax,4), %ebp
movq 0x10(%rsp), %rsi
movq (%rsi), %rax
movb (%rax,%r15), %al
movl $0x2, %r15d
cmpb $-0x3c, %al
movl 0x4(%rsp), %r8d
je 0x3b9a
xorl %edx, %edx
leaq 0x84c7(%rip), %rdi      # 0xc040
movq %rdx, %rcx
cmpq $0x9, %rdx
je 0x3b8c
leaq 0x1(%rcx), %rdx
cmpb %al, 0x2(%rdi,%rcx,2)
jne 0x3b79
cmpq $0x9, %rcx
movl $0x0, %r15d
adcl $0x1, %r15d
addl %r8d, %r15d
movq 0x8(%rsi), %rax
movl %r15d, %edx
cmpq %r15, %rax
ja 0x3a93
jmp 0x3bb1
xorl %ebp, %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x383c
testb $0x1, (%rax)
jne 0x3bdd
movq %rbx, %rdi
movl %ebp, %esi
callq 0x383c
movl (%rax), %ebp
shrl %ebp
jmp 0x3bdd
movq 0x8(%rsp), %rax
movl 0x4(%rsp), %ecx
movl %ecx, (%rax)
negl %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq