// File: /workspace/github_cpp_makefile_star2_O1/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 0x3bb3
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 0x3ac6
callq 0x33a0
movl %eax, %r12d
addl $-0x61, %r12d
cmpl $0x1a, %r12d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovael %eax, %r12d
jmp 0x3ad9
movl %edx, %eax
movzbl 0x1(%rcx,%rax), %esi
movzbl %dil, %edi
callq 0x433a
movl %eax, %r12d
movq %rbx, %rdi
movl %ebp, %esi
callq 0x384c
movl 0x8(%rax), %r14d
movl 0x24(%rbx), %r13d
movq %rbx, %rdi
movl %ebp, %esi
callq 0x384c
cmpl %r13d, %r14d
jne 0x3b06
movq 0xc(%rax), %rax
movslq %r12d, %rcx
movl (%rax,%rcx,4), %eax
jmp 0x3b12
movl 0x8(%rax), %ecx
xorl %eax, %eax
btl %r12d, %ecx
setb %al
testl %eax, %eax
je 0x3bd4
movq %rbx, %rdi
movl %ebp, %esi
callq 0x384c
movq 0xc(%rax), %r14
movq %rbx, %rdi
movl %ebp, %esi
callq 0x384c
movl 0x8(%rax), %eax
cmpl 0x24(%rbx), %eax
je 0x3b52
movq %rbx, %rdi
movl %ebp, %esi
callq 0x384c
movl 0x8(%rax), %edi
movl %r12d, %esi
callq 0x42d5
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 0x3b9e
xorl %edx, %edx
leaq 0x84c3(%rip), %rdi      # 0xc040
movq %rdx, %rcx
cmpq $0x9, %rdx
je 0x3b90
leaq 0x1(%rcx), %rdx
cmpb %al, 0x2(%rdi,%rcx,2)
jne 0x3b7d
cmpq $0x9, %rcx
movl $0x0, %r15d
adcl $0x1, %r15d
addl %r8d, %r15d
movq 0x8(%rsi), %rax
movl %r15d, %edx
cmpq %r15, %rax
ja 0x3a97
jmp 0x3bb5
xorl %ebp, %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x384c
testb $0x1, (%rax)
jne 0x3be1
movq %rbx, %rdi
movl %ebp, %esi
callq 0x384c
movl (%rax), %ebp
shrl %ebp
jmp 0x3be1
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