// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x298, %rsp            # imm = 0x298
movq %rdi, 0x288(%rsp)
movl %esi, 0x284(%rsp)
movq 0x288(%rsp), %rdi
movl $0x1, %esi
leaq 0x278(%rsp), %rdx
callq 0xcd00
movq %rax, 0x268(%rsp)
movq 0x288(%rsp), %rdi
movl $0x2, %esi
leaq 0x270(%rsp), %rdx
callq 0xcd00
movq %rax, 0x260(%rsp)
movq 0x288(%rsp), %rdi
movl $0x3, %esi
movl $0x1, %edx
callq 0xcfe0
movq %rax, %rdi
movq 0x278(%rsp), %rsi
callq 0x21f60
movq %rax, 0x258(%rsp)
cmpq $0x1, 0x258(%rsp)
jae 0x220a2
movq $0x1, 0x258(%rsp)
jmp 0x220da
movq 0x258(%rsp), %rax
movq 0x278(%rsp), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jbe 0x220d8
movq 0x288(%rsp), %rdi
callq 0x9df0
movl $0x1, 0x294(%rsp)
jmp 0x22380
jmp 0x220da
cmpl $0x0, 0x284(%rsp)
je 0x221ce
movq 0x288(%rsp), %rdi
movl $0x4, %esi
callq 0x9a10
cmpl $0x0, %eax
jne 0x2211d
movq 0x260(%rsp), %rdi
movq 0x270(%rsp), %rsi
callq 0x22390
cmpl $0x0, %eax
je 0x221ce
movq 0x268(%rsp), %rdi
addq 0x258(%rsp), %rdi
addq $-0x1, %rdi
movq 0x278(%rsp), %rsi
subq 0x258(%rsp), %rsi
addq $0x1, %rsi
movq 0x260(%rsp), %rdx
movq 0x270(%rsp), %rcx
callq 0x22410
movq %rax, 0x250(%rsp)
cmpq $0x0, 0x250(%rsp)
je 0x221c9
movq 0x288(%rsp), %rdi
movq 0x250(%rsp), %rsi
movq 0x268(%rsp), %rax
subq %rax, %rsi
addq $0x1, %rsi
callq 0x9e70
movq 0x288(%rsp), %rdi
movq 0x250(%rsp), %rsi
movq 0x268(%rsp), %rax
subq %rax, %rsi
addq 0x270(%rsp), %rsi
callq 0x9e70
movl $0x2, 0x294(%rsp)
jmp 0x22380
jmp 0x22368
movq 0x268(%rsp), %rax
addq 0x258(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x18(%rsp)
movq 0x260(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x5e, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x14(%rsp)
cmpl $0x0, 0x14(%rsp)
je 0x22230
movq 0x260(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x260(%rsp)
movq 0x270(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x270(%rsp)
movq 0x288(%rsp), %rax
movq %rax, 0x40(%rsp)
movl $0xc8, 0x20(%rsp)
movq 0x268(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x268(%rsp), %rax
addq 0x278(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x260(%rsp), %rax
addq 0x270(%rsp), %rax
movq %rax, 0x38(%rsp)
movl $0x0, 0x48(%rsp)
movq 0x18(%rsp), %rsi
movq 0x260(%rsp), %rdx
leaq 0x20(%rsp), %rdi
callq 0x22530
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x2232c
cmpl $0x0, 0x284(%rsp)
je 0x2230f
movq 0x288(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x268(%rsp), %rax
subq %rax, %rsi
addq $0x1, %rsi
callq 0x9e70
movq 0x288(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x268(%rsp), %rax
subq %rax, %rsi
callq 0x9e70
leaq 0x20(%rsp), %rdi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x22970
addl $0x2, %eax
movl %eax, 0x294(%rsp)
jmp 0x22380
movq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0x20(%rsp), %rdi
callq 0x22970
movl %eax, 0x294(%rsp)
jmp 0x22380
jmp 0x2232e
movq 0x18(%rsp), %rcx
movq %rcx, %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
xorl %eax, %eax
cmpq 0x30(%rsp), %rcx
movb %al, 0x7(%rsp)
jae 0x2235a
cmpl $0x0, 0x14(%rsp)
setne %al
xorb $-0x1, %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x2227c
jmp 0x22368
movq 0x288(%rsp), %rdi
callq 0x9df0
movl $0x1, 0x294(%rsp)
movl 0x294(%rsp), %eax
addq $0x298, %rsp            # imm = 0x298
retq
nop