// File: /workspace/github_c_makefile_star2_O3/bhk[P]tooltree/lua/../opensource/lua-5.2.3/src/lstrlib.c
// Function: str_find_aux
static int str_find_aux (lua_State *L, int find) {
  size_t ls, lp;
  const char *s = luaL_checklstring(L, 1, &ls);
  const char *p = luaL_checklstring(L, 2, &lp);
  size_t init = posrelat(luaL_optinteger(L, 3, 1), ls);
  if (init < 1) init = 1;
  else if (init > ls + 1) {  /* start after string's end? */
    lua_pushnil(L);  /* cannot find anything */
    return 1;
  }
  /* explicit request or no special characters? */
  if (find && (lua_toboolean(L, 4) || nospecials(p, lp))) {
    /* do a plain search */
    const char *s2 = lmemfind(s + init - 1, ls - init + 1, p, lp);
    if (s2) {
      lua_pushinteger(L, s2 - s + 1);
      lua_pushinteger(L, s2 - s + lp);
      return 2;
    }
  }
  else {
    MatchState ms;
    const char *s1 = s + init - 1;
    int anchor = (*p == '^');
    if (anchor) {
      p++; lp--;  /* skip anchor character */
    }
    ms.L = L;
    ms.matchdepth = MAXCCALLS;
    ms.src_init = s;
    ms.src_end = s + ls;
    ms.p_end = p + lp;
    do {
      const char *res;
      ms.level = 0;
      lua_assert(ms.matchdepth == MAXCCALLS);
      if ((res=match(&ms, s1, p)) != NULL) {
        if (find) {
          lua_pushinteger(L, s1 - s + 1);  /* start */
          lua_pushinteger(L, res - s);   /* end */
          return push_captures(&ms, NULL, 0) + 2;
        }
        else
          return push_captures(&ms, s1, res);
      }
    } while (s1++ < ms.src_end && !anchor);
  }
  lua_pushnil(L);  /* not found */
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movl %esi, %r13d
movq %rdi, %r14
leaq 0x30(%rsp), %rbx
movl $0x1, %esi
movq %rbx, %rdx
callq 0x9690
movq %rax, %rbp
leaq 0x18(%rsp), %rdx
movq %r14, %rdi
movl $0x2, %esi
callq 0x9690
movq %rax, %r15
movl $0x1, %r12d
movl $0x1, %edx
movq %r14, %rdi
movl $0x3, %esi
callq 0x98a0
movq (%rbx), %rcx
testq %rax, %rax
jns 0x15f1e
movq %rax, %rdx
negq %rdx
cmpq %rdx, %rcx
jb 0x15f36
addq %rcx, %rax
incq %rax
testq %rax, %rax
je 0x15f36
incq %rcx
movq %rax, %r12
cmpq %rcx, %rax
jbe 0x15f36
movq %r14, %rdi
jmp 0x160c5
testl %r13d, %r13d
movq %rbp, 0x8(%rsp)
movl %r13d, 0x20(%rsp)
je 0x16034
movq %r15, 0x28(%rsp)
movq %r14, %rdi
movl $0x4, %esi
callq 0x7cc4
movq 0x18(%rsp), %rcx
testl %eax, %eax
movq %rcx, %rbp
jne 0x15fa4
xorl %r15d, %r15d
leaq 0xb8fe(%rip), %r13      # 0x2186f
movq 0x28(%rsp), %rax
leaq (%rax,%r15), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x6440
testq %rax, %rax
jne 0x1603e
movq %rbx, %rdi
callq 0x6170
addq %rax, %r15
incq %r15
movq %rbp, %rcx
cmpq %rbp, %r15
jbe 0x15f71
movq 0x8(%rsp), %r13
addq %r12, %r13
decq %r13
testq %rcx, %rcx
je 0x16134
movq %r14, 0x10(%rsp)
movq 0x30(%rsp), %r14
subq %r12, %r14
incq %r14
cmpq %r14, %rcx
ja 0x160c0
decq %rbp
movq %rbp, 0x20(%rsp)
subq %rbp, %r14
je 0x160c0
movq 0x28(%rsp), %r15
movsbl (%r15), %r12d
incq %r15
movq %r13, %rdi
movl %r12d, %esi
movq %r14, %rdx
callq 0x6270
testq %rax, %rax
je 0x160c0
movq %rax, %rbp
leaq 0x1(%rax), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movq 0x20(%rsp), %rdx
callq 0x63f0
testl %eax, %eax
je 0x1612c
addq %r13, %r14
movq %rbx, %r13
subq %rbx, %r14
jne 0x15fee
jmp 0x160c0
movq %rbp, %rax
movq 0x18(%rsp), %rbp
jmp 0x16048
movq 0x28(%rsp), %r15
movq 0x8(%rsp), %rax
movb (%r15), %bl
cmpb $0x5e, %bl
jne 0x1605b
incq %r15
decq %rbp
movq %rbp, 0x18(%rsp)
leaq 0x38(%rsp), %rdx
movq %r14, 0x10(%rsp)
movq %r14, 0x20(%rdx)
movl $0xc8, (%rdx)
movq %rax, %rcx
movq %rax, 0x8(%rdx)
movq 0x30(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x10(%rdx)
movq %r15, %r14
addq %r15, %rbp
movq %rbp, 0x18(%rdx)
leaq -0x1(%rcx), %r15
leaq (%r15,%r12), %rbp
movl $0x0, 0x60(%rsp)
leaq 0x38(%rsp), %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x1616c
testq %rax, %rax
jne 0x160d4
cmpb $0x5e, %bl
je 0x160c0
incq %r12
cmpq 0x48(%rsp), %rbp
jb 0x16090
movq 0x10(%rsp), %rdi
callq 0x7e6c
movl $0x1, %eax
jmp 0x1615a
movq %rax, %r13
cmpl $0x0, 0x20(%rsp)
je 0x16111
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x7e95
subq 0x8(%rsp), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x7e95
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1656c
addl $0x2, %eax
jmp 0x1615a
movq 0x8(%rsp), %rax
leaq (%rax,%r12), %rsi
decq %rsi
leaq 0x38(%rsp), %rdi
movq %r13, %rdx
callq 0x1656c
jmp 0x1615a
movq %rbp, %r13
movq 0x10(%rsp), %r14
subq 0x8(%rsp), %r13
leaq 0x1(%r13), %rsi
movq %r14, %rdi
callq 0x7e95
addq 0x18(%rsp), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x7e95
movl $0x2, %eax
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq