// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movl %esi, %r13d
movq %rdi, %r14
leaq 0x28(%rsp), %rbx
movl $0x1, %esi
movq %rbx, %rdx
callq 0x14fff
movq %rax, %rbp
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
movl $0x2, %esi
callq 0x14fff
movq %rax, %r15
movl $0x1, %r12d
movl $0x1, %edx
movq %r14, %rdi
movl $0x3, %esi
callq 0x1518f
movq (%rbx), %rcx
testq %rax, %rax
jns 0x1e540
movq %rax, %rdx
negq %rdx
cmpq %rdx, %rcx
jb 0x1e558
addq %rcx, %rax
incq %rax
testq %rax, %rax
jle 0x1e558
incq %rcx
movq %rax, %r12
cmpq %rcx, %rax
jle 0x1e558
movq %r14, %rdi
jmp 0x1e6e1
testl %r13d, %r13d
movq %rbp, (%rsp)
movl %r13d, 0x18(%rsp)
je 0x1e654
movq %r15, 0x20(%rsp)
movq %r14, %rdi
movl $0x4, %esi
callq 0x6333
movq 0x10(%rsp), %rcx
testl %eax, %eax
movq %rcx, %rbp
jne 0x1e5c5
xorl %r15d, %r15d
leaq 0x5ff1(%rip), %r13      # 0x24583
movq 0x20(%rsp), %rax
leaq (%rax,%r15), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x53c0
testq %rax, %rax
jne 0x1e65e
movq %rbx, %rdi
callq 0x5140
addq %rax, %r15
incq %r15
movq %rbp, %rcx
cmpq %rbp, %r15
jbe 0x1e592
movq (%rsp), %r13
addq %r12, %r13
decq %r13
testq %rcx, %rcx
je 0x1e74e
movq %r14, 0x8(%rsp)
movq 0x28(%rsp), %r14
subq %r12, %r14
incq %r14
cmpq %r14, %rcx
ja 0x1e6dc
decq %rbp
movq %rbp, 0x18(%rsp)
subq %rbp, %r14
je 0x1e6dc
movq 0x20(%rsp), %r15
movsbl (%r15), %r12d
incq %r15
movq %r13, %rdi
movl %r12d, %esi
movq %r14, %rdx
callq 0x5220
testq %rax, %rax
je 0x1e6dc
movq %rax, %rbp
leaq 0x1(%rax), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movq 0x18(%rsp), %rdx
callq 0x5380
testl %eax, %eax
je 0x1e746
addq %r13, %r14
movq %rbx, %r13
subq %rbx, %r14
jne 0x1e60e
jmp 0x1e6dc
movq %rbp, %rax
movq 0x10(%rsp), %rbp
jmp 0x1e667
movq 0x20(%rsp), %r15
movq (%rsp), %rax
movb (%r15), %bl
cmpb $0x5e, %bl
jne 0x1e67a
incq %r15
decq %rbp
movq %rbp, 0x10(%rsp)
leaq 0x30(%rsp), %rdx
movq %r14, 0x8(%rsp)
movq %r14, 0x18(%rdx)
movl $0xc8, 0x20(%rdx)
movq %rax, %rcx
movq %rax, (%rdx)
movq 0x28(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x8(%rdx)
movq %r15, %r14
addq %r15, %rbp
movq %rbp, 0x10(%rdx)
leaq -0x1(%rcx), %r15
leaq (%r15,%r12), %rbp
movb $0x0, 0x54(%rsp)
leaq 0x30(%rsp), %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x1e785
testq %rax, %rax
jne 0x1e6f0
cmpb $0x5e, %bl
je 0x1e6dc
incq %r12
cmpq 0x38(%rsp), %rbp
jb 0x1e6af
movq 0x8(%rsp), %rdi
callq 0x64cd
movl $0x1, %eax
jmp 0x1e773
movq %rax, %r13
cmpl $0x0, 0x18(%rsp)
je 0x1e72c
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x64f6
subq (%rsp), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x64f6
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1eb8a
addl $0x2, %eax
jmp 0x1e773
movq (%rsp), %rax
leaq (%rax,%r12), %rsi
decq %rsi
leaq 0x30(%rsp), %rdi
movq %r13, %rdx
callq 0x1eb8a
jmp 0x1e773
movq %rbp, %r13
movq 0x8(%rsp), %r14
subq (%rsp), %r13
leaq 0x1(%r13), %rsi
movq %r14, %rdi
callq 0x64f6
addq 0x10(%rsp), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x64f6
movl $0x2, %eax
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq