// File: /workspace/github_c_makefile_star2_O1/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 $0x268, %rsp            # imm = 0x268
movl %esi, 0x24(%rsp)
movq %rdi, %r14
leaq 0x38(%rsp), %rbx
movl $0x1, %esi
movq %rbx, %rdx
callq 0x14535
movq %rax, 0x28(%rsp)
leaq 0x18(%rsp), %rdx
movq %r14, %rdi
movl $0x2, %esi
callq 0x14535
movq %rax, %r15
movl $0x1, %r12d
movl $0x1, %edx
movq %r14, 0x10(%rsp)
movq %r14, %rdi
movl $0x3, %esi
callq 0x146c5
movq (%rbx), %rcx
testq %rax, %rax
jns 0x1d9a0
movq %rax, %rdx
negq %rdx
cmpq %rdx, %rcx
jae 0x1d99a
xorl %eax, %eax
jmp 0x1d9a0
addq %rcx, %rax
incq %rax
testq %rax, %rax
jle 0x1d9b4
incq %rcx
movq %rax, %r12
cmpq %rcx, %rax
jg 0x1dbb2
movq %r15, 0x30(%rsp)
cmpl $0x0, 0x24(%rsp)
je 0x1dad6
movq 0x10(%rsp), %rdi
movl $0x4, %esi
callq 0x6223
testl %eax, %eax
je 0x1da90
movq 0x28(%rsp), %rax
leaq (%rax,%r12), %rbx
decq %rbx
movq 0x18(%rsp), %r14
testq %r14, %r14
je 0x1da57
movq 0x38(%rsp), %rbp
subq %r12, %rbp
incq %rbp
cmpq %rbp, %r14
ja 0x1da55
decq %r14
subq %r14, %rbp
je 0x1da55
movq 0x30(%rsp), %r15
movsbl (%r15), %eax
movl %eax, 0xc(%rsp)
incq %r15
movq %rbx, %rdi
movl 0xc(%rsp), %esi
movq %rbp, %rdx
callq 0x5230
testq %rax, %rax
je 0x1da55
movq %rax, %r13
leaq 0x1(%rax), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x5390
testl %eax, %eax
je 0x1dbd5
addq %rbx, %rbp
movq %r12, %rbx
subq %r12, %rbp
jne 0x1da19
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x1dbb2
subq 0x28(%rsp), %rbx
leaq 0x1(%rbx), %rsi
movq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x63e6
addq 0x18(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x63e6
movl $0x2, %ebp
jmp 0x1dbc1
movq 0x18(%rsp), %r15
xorl %ebp, %ebp
leaq 0x5a2d(%rip), %rbx      # 0x234cb
movq 0x30(%rsp), %rax
leaq (%rax,%rbp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x53d0
testq %rax, %rax
jne 0x1dad6
movq %rax, %r14
movq %r13, %rdi
callq 0x5150
addq %rax, %rbp
incq %rbp
cmpq %r15, %rbp
jbe 0x1da9e
testq %r14, %r14
je 0x1d9db
movq 0x30(%rsp), %rdx
movb (%rdx), %al
movb %al, 0xc(%rsp)
cmpb $0x5e, %al
jne 0x1daed
incq %rdx
decq 0x18(%rsp)
leaq 0x40(%rsp), %rsi
movq 0x10(%rsp), %rax
movq %rax, 0x18(%rsi)
movl $0xc8, 0x20(%rsi)
movq 0x28(%rsp), %rcx
movq %rcx, (%rsi)
movq 0x38(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x8(%rsi)
movq 0x18(%rsp), %rax
movq %rdx, %r13
addq %rdx, %rax
movq %rax, 0x10(%rsi)
leaq -0x1(%rcx), %r15
leaq (%r15,%r12), %r14
movb $0x0, 0x64(%rsp)
leaq 0x40(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x1dbdd
movq %rax, %rbx
testq %rax, %rax
je 0x1db98
cmpl $0x0, 0x24(%rsp)
je 0x1db86
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x63e6
movq %rbx, %rsi
subq 0x28(%rsp), %rsi
movq %rbp, %rdi
callq 0x63e6
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1e03a
movl %eax, %ebp
addl $0x2, %ebp
jmp 0x1db98
leaq 0x40(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x1e03a
movl %eax, %ebp
testq %rbx, %rbx
jne 0x1dbc1
cmpb $0x5e, 0xc(%rsp)
je 0x1dbb2
incq %r12
cmpq 0x48(%rsp), %r14
jb 0x1db29
movq 0x10(%rsp), %rdi
callq 0x63bd
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 0x1da57