// File: /workspace/github_c_makefile_star2_O0/tylerneylon[P]APIsWithLua/lua/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);
  lua_Integer init = posrelat(luaL_optinteger(L, 3, 1), ls);
  if (init < 1) init = 1;
  else if (init > (lua_Integer)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 - (size_t)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 */
    }
    prepstate(&ms, L, s, ls, p, lp);
    do {
      const char *res;
      reprepstate(&ms);
      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
movq %rsp, %rbp
subq $0x290, %rsp            # imm = 0x290
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq -0x20(%rbp), %rdx
callq 0x20390
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movl $0x2, %esi
leaq -0x28(%rbp), %rdx
callq 0x20390
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movl $0x3, %esi
movl $0x1, %edx
callq 0x205e0
movq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x2de20
movq %rax, -0x40(%rbp)
cmpq $0x1, -0x40(%rbp)
jge 0x2df22
movq $0x1, -0x40(%rbp)
jmp 0x2df4a
movq -0x40(%rbp), %rax
movq -0x20(%rbp), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jle 0x2df48
movq -0x10(%rbp), %rdi
callq 0x6b60
movl $0x1, -0x4(%rbp)
jmp 0x2e152
jmp 0x2df4a
cmpl $0x0, -0x14(%rbp)
je 0x2dfea
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x6770
cmpl $0x0, %eax
jne 0x2df79
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x2e160
cmpl $0x0, %eax
je 0x2dfea
movq -0x30(%rbp), %rdi
addq -0x40(%rbp), %rdi
addq $-0x1, %rdi
movq -0x20(%rbp), %rsi
subq -0x40(%rbp), %rsi
addq $0x1, %rsi
movq -0x38(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x2e1d0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x2dfe5
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x30(%rbp), %rax
subq %rax, %rsi
addq $0x1, %rsi
callq 0x6be0
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x30(%rbp), %rax
subq %rax, %rsi
addq -0x28(%rbp), %rsi
callq 0x6be0
movl $0x2, -0x4(%rbp)
jmp 0x2e152
jmp 0x2e142
movq -0x30(%rbp), %rax
addq -0x40(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x278(%rbp)
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5e, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x27c(%rbp)
cmpl $0x0, -0x27c(%rbp)
je 0x2e036
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %r8
movq -0x28(%rbp), %r9
leaq -0x270(%rbp), %rdi
callq 0x2e2d0
leaq -0x270(%rbp), %rdi
callq 0x2e330
movq -0x278(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x270(%rbp), %rdi
callq 0x2e350
movq %rax, -0x288(%rbp)
cmpq $0x0, %rax
je 0x2e0f8
cmpl $0x0, -0x14(%rbp)
je 0x2e0d9
movq -0x10(%rbp), %rdi
movq -0x278(%rbp), %rsi
movq -0x30(%rbp), %rax
subq %rax, %rsi
addq $0x1, %rsi
callq 0x6be0
movq -0x10(%rbp), %rdi
movq -0x288(%rbp), %rsi
movq -0x30(%rbp), %rax
subq %rax, %rsi
callq 0x6be0
leaq -0x270(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x2e730
addl $0x2, %eax
movl %eax, -0x4(%rbp)
jmp 0x2e152
movq -0x278(%rbp), %rsi
movq -0x288(%rbp), %rdx
leaq -0x270(%rbp), %rdi
callq 0x2e730
movl %eax, -0x4(%rbp)
jmp 0x2e152
jmp 0x2e0fa
movq -0x278(%rbp), %rcx
movq %rcx, %rax
addq $0x1, %rax
movq %rax, -0x278(%rbp)
xorl %eax, %eax
cmpq -0x268(%rbp), %rcx
movb %al, -0x289(%rbp)
jae 0x2e132
cmpl $0x0, -0x27c(%rbp)
setne %al
xorb $-0x1, %al
movb %al, -0x289(%rbp)
movb -0x289(%rbp), %al
testb $0x1, %al
jne 0x2e056
jmp 0x2e142
movq -0x10(%rbp), %rdi
callq 0x6b60
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x290, %rsp            # imm = 0x290
popq %rbp
retq
nop