// File: /workspace/github_c_makefile_star2_O2/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, 0x14(%rsp)
movq %rdi, %rbp
pushq $0x1
popq %r14
leaq 0x30(%rsp), %rbx
movl %r14d, %esi
movq %rbx, %rdx
callq 0x9264
movq %rax, %r13
pushq $0x2
popq %rsi
leaq 0x28(%rsp), %rdx
movq %rbp, %rdi
callq 0x9264
movq %rax, %r15
pushq $0x3
popq %rsi
pushq $0x1
popq %r12
movq %rbp, %rdi
movq %r12, %rdx
callq 0x9456
movq (%rbx), %rcx
testq %rax, %rax
jns 0x14a53
movq %rax, %rdx
negq %rdx
cmpq %rdx, %rcx
jb 0x14a70
addq %rcx, %rax
incq %rax
testq %rax, %rax
je 0x14a70
incq %rcx
movq %rax, %r12
cmpq %rcx, %rax
jbe 0x14a70
movq %rbp, %rdi
callq 0x7acb
jmp 0x14c87
cmpl $0x0, 0x14(%rsp)
movq %r13, 0x8(%rsp)
je 0x14b64
movq %r15, 0x20(%rsp)
pushq $0x4
popq %rsi
movq %rbp, %rdi
callq 0x7943
movq 0x28(%rsp), %rcx
testl %eax, %eax
movq %rcx, %r14
jne 0x14ad9
xorl %r15d, %r15d
leaq 0xadb1(%rip), %r13      # 0x1f857
movq 0x20(%rsp), %rax
leaq (%rax,%r15), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x6430
testq %rax, %rax
jne 0x14b6b
movq %rbx, %rdi
callq 0x6170
addq %rax, %r15
incq %r15
movq %r14, %rcx
cmpq %r14, %r15
jbe 0x14aa6
movq 0x8(%rsp), %r13
addq %r12, %r13
decq %r13
testq %rcx, %rcx
je 0x14c62
movq %rbp, 0x18(%rsp)
movq 0x30(%rsp), %rbp
subq %r12, %rbp
incq %rbp
cmpq %rbp, %rcx
ja 0x14bea
decq %r14
movq %r14, %r15
subq %r14, %rbp
movq 0x20(%rsp), %r12
incq %r12
testq %rbp, %rbp
je 0x14bea
movq 0x20(%rsp), %rax
movsbl (%rax), %esi
movq %r13, %rdi
movq %rbp, %rdx
callq 0x6260
testq %rax, %rax
je 0x14bea
movq %rax, %r14
leaq 0x1(%rax), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x63e0
testl %eax, %eax
je 0x14c5a
addq %r13, %rbp
subq %rbx, %rbp
movq %rbx, %r13
jmp 0x14b17
movq 0x28(%rsp), %rcx
jmp 0x14b78
movq 0x20(%rsp), %r15
movq %r14, %rcx
movq 0x8(%rsp), %r13
movb (%r15), %bl
cmpb $0x5e, %bl
jne 0x14b8b
incq %r15
decq %rcx
movq %rcx, 0x28(%rsp)
leaq 0x38(%rsp), %rdx
movq %rbp, 0x18(%rsp)
movq %rbp, 0x20(%rdx)
movl $0xc8, (%rdx)
movq %r13, 0x8(%rdx)
movq 0x30(%rsp), %rax
addq %r13, %rax
movq %rax, 0x10(%rdx)
movq %r15, %r14
addq %r15, %rcx
movq %rcx, 0x18(%rdx)
leaq -0x1(%r13), %r15
leaq (%r15,%r12), %rbp
andl $0x0, 0x60(%rsp)
leaq 0x38(%rsp), %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x14c9c
testq %rax, %rax
jne 0x14bfb
cmpb $0x5e, %bl
je 0x14bea
incq %r12
cmpq 0x48(%rsp), %rbp
jb 0x14bbd
movq 0x18(%rsp), %rdi
callq 0x7acb
pushq $0x1
jmp 0x14c85
movq %rax, %r13
cmpl $0x0, 0x14(%rsp)
je 0x14c3c
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x7af1
subq 0x8(%rsp), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x7af1
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x15077
movl %eax, %r14d
addl $0x2, %r14d
jmp 0x14c87
movq 0x8(%rsp), %rax
leaq (%rax,%r12), %rsi
decq %rsi
leaq 0x38(%rsp), %rdi
movq %r13, %rdx
callq 0x15077
movl %eax, %r14d
jmp 0x14c87
movq %r14, %r13
movq 0x18(%rsp), %rbp
subq 0x8(%rsp), %r13
leaq 0x1(%r13), %rsi
movq %rbp, %rdi
callq 0x7af1
addq 0x28(%rsp), %r13
movq %rbp, %rdi
movq %r13, %rsi
callq 0x7af1
pushq $0x2
popq %r14
movl %r14d, %eax
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq