// File: /workspace/github_c_makefile_star2_O1/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, 0x1c(%rsp)
movq %rdi, %r14
leaq 0x30(%rsp), %rbx
movl $0x1, %esi
movq %rbx, %rdx
callq 0x9559
movq %rax, 0x20(%rsp)
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
movl $0x2, %esi
callq 0x9559
movq %rax, %r15
movl $0x1, %r12d
movl $0x1, %edx
movq %r14, 0x8(%rsp)
movq %r14, %rdi
movl $0x3, %esi
callq 0x9769
movq (%rbx), %rcx
testq %rax, %rax
jns 0x15df6
movq %rax, %rdx
negq %rdx
cmpq %rdx, %rcx
jae 0x15df0
xorl %eax, %eax
jmp 0x15df6
addq %rcx, %rax
incq %rax
testq %rax, %rax
je 0x15e0a
incq %rcx
movq %rax, %r12
cmpq %rcx, %rax
ja 0x1600b
movq %r15, 0x28(%rsp)
cmpl $0x0, 0x1c(%rsp)
je 0x15f2c
movq 0x8(%rsp), %rdi
movl $0x4, %esi
callq 0x7bb6
testl %eax, %eax
je 0x15ee6
movq 0x20(%rsp), %rax
leaq (%rax,%r12), %rbx
decq %rbx
movq 0x10(%rsp), %r14
testq %r14, %r14
je 0x15ead
movq 0x30(%rsp), %rbp
subq %r12, %rbp
incq %rbp
cmpq %rbp, %r14
ja 0x15eab
decq %r14
subq %r14, %rbp
je 0x15eab
movq 0x28(%rsp), %r15
movsbl (%r15), %eax
movl %eax, 0x4(%rsp)
incq %r15
movq %rbx, %rdi
movl 0x4(%rsp), %esi
movq %rbp, %rdx
callq 0x6270
testq %rax, %rax
je 0x15eab
movq %rax, %r13
leaq 0x1(%rax), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x63f0
testl %eax, %eax
je 0x1602e
addq %rbx, %rbp
movq %r12, %rbx
subq %r12, %rbp
jne 0x15e6f
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x1600b
subq 0x20(%rsp), %rbx
leaq 0x1(%rbx), %rsi
movq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x7d87
addq 0x10(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7d87
movl $0x2, %ebp
jmp 0x1601a
movq 0x10(%rsp), %r15
xorl %ebp, %ebp
leaq 0xb983(%rip), %rbx      # 0x21877
movq 0x28(%rsp), %rax
leaq (%rax,%rbp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x6440
testq %rax, %rax
jne 0x15f2c
movq %rax, %r14
movq %r13, %rdi
callq 0x6170
addq %rax, %rbp
incq %rbp
cmpq %r15, %rbp
jbe 0x15ef4
testq %r14, %r14
je 0x15e31
movq 0x28(%rsp), %rdx
movb (%rdx), %al
movb %al, 0x4(%rsp)
cmpb $0x5e, %al
jne 0x15f43
incq %rdx
decq 0x10(%rsp)
leaq 0x38(%rsp), %rsi
movq 0x8(%rsp), %rax
movq %rax, 0x20(%rsi)
movl $0xc8, (%rsi)
movq 0x20(%rsp), %rcx
movq %rcx, 0x8(%rsi)
movq 0x30(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x10(%rsi)
movq 0x10(%rsp), %rax
movq %rdx, %r13
addq %rdx, %rax
movq %rax, 0x18(%rsi)
leaq -0x1(%rcx), %r15
leaq (%r15,%r12), %r14
movl $0x0, 0x60(%rsp)
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x16036
movq %rax, %rbx
testq %rax, %rax
je 0x15ff1
cmpl $0x0, 0x1c(%rsp)
je 0x15fdf
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x7d87
movq %rbx, %rsi
subq 0x20(%rsp), %rsi
movq %rbp, %rdi
callq 0x7d87
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1648e
movl %eax, %ebp
addl $0x2, %ebp
jmp 0x15ff1
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x1648e
movl %eax, %ebp
testq %rbx, %rbx
jne 0x1601a
cmpb $0x5e, 0x4(%rsp)
je 0x1600b
incq %r12
cmpq 0x48(%rsp), %r14
jb 0x15f7f
movq 0x8(%rsp), %rdi
callq 0x7d5e
movl $0x1, %ebp
movl %ebp, %eax
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rbx
jmp 0x15ead