// File: /workspace/github_c_makefile_star2_O2/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, 0xc(%rsp)
movq %rdi, %rbp
pushq $0x1
popq %r14
leaq 0x28(%rsp), %rbx
movl %r14d, %esi
movq %rbx, %rdx
callq 0x13131
movq %rax, %r13
pushq $0x2
popq %rsi
leaq 0x20(%rsp), %rdx
movq %rbp, %rdi
callq 0x13131
movq %rax, %r15
pushq $0x3
popq %rsi
pushq $0x1
popq %r12
movq %rbp, %rdi
movq %r12, %rdx
callq 0x132b0
movq (%rbx), %rcx
testq %rax, %rax
jns 0x1bd17
movq %rax, %rdx
negq %rdx
cmpq %rdx, %rcx
jb 0x1bd34
addq %rcx, %rax
incq %rax
testq %rax, %rax
jle 0x1bd34
incq %rcx
movq %rax, %r12
cmpq %rcx, %rax
jle 0x1bd34
movq %rbp, %rdi
callq 0x6135
jmp 0x1bf45
cmpl $0x0, 0xc(%rsp)
movq %r13, (%rsp)
je 0x1be26
movq %r15, 0x18(%rsp)
pushq $0x4
popq %rsi
movq %rbp, %rdi
callq 0x5fa6
movq 0x20(%rsp), %rcx
testl %eax, %eax
movq %rcx, %r14
jne 0x1bd9c
xorl %r15d, %r15d
leaq 0x5882(%rip), %r13      # 0x215eb
movq 0x18(%rsp), %rax
leaq (%rax,%r15), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x53b0
testq %rax, %rax
jne 0x1be2d
movq %rbx, %rdi
callq 0x5140
addq %rax, %r15
incq %r15
movq %r14, %rcx
cmpq %r14, %r15
jbe 0x1bd69
movq (%rsp), %r13
addq %r12, %r13
decq %r13
testq %rcx, %rcx
je 0x1bf21
movq %rbp, 0x10(%rsp)
movq 0x28(%rsp), %rbp
subq %r12, %rbp
incq %rbp
cmpq %rbp, %rcx
ja 0x1beab
decq %r14
movq %r14, %r15
subq %r14, %rbp
movq 0x18(%rsp), %r12
incq %r12
testq %rbp, %rbp
je 0x1beab
movq 0x18(%rsp), %rax
movsbl (%rax), %esi
movq %r13, %rdi
movq %rbp, %rdx
callq 0x5210
testq %rax, %rax
je 0x1beab
movq %rax, %r14
leaq 0x1(%rax), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x5370
testl %eax, %eax
je 0x1bf19
addq %r13, %rbp
subq %rbx, %rbp
movq %rbx, %r13
jmp 0x1bdd9
movq 0x20(%rsp), %rcx
jmp 0x1be39
movq 0x18(%rsp), %r15
movq %r14, %rcx
movq (%rsp), %r13
movb (%r15), %bl
cmpb $0x5e, %bl
jne 0x1be4c
incq %r15
decq %rcx
movq %rcx, 0x20(%rsp)
leaq 0x30(%rsp), %rdx
movq %rbp, 0x10(%rsp)
movq %rbp, 0x18(%rdx)
movl $0xc8, 0x20(%rdx)
movq %r13, (%rdx)
movq 0x28(%rsp), %rax
addq %r13, %rax
movq %rax, 0x8(%rdx)
movq %r15, %r14
addq %r15, %rcx
movq %rcx, 0x10(%rdx)
leaq -0x1(%r13), %r15
leaq (%r15,%r12), %rbp
movb $0x0, 0x54(%rsp)
leaq 0x30(%rsp), %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x1bf5a
testq %rax, %rax
jne 0x1bebc
cmpb $0x5e, %bl
je 0x1beab
incq %r12
cmpq 0x38(%rsp), %rbp
jb 0x1be7e
movq 0x10(%rsp), %rdi
callq 0x6135
pushq $0x1
jmp 0x1bf43
movq %rax, %r13
cmpl $0x0, 0xc(%rsp)
je 0x1befc
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x615b
subq (%rsp), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x615b
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1c33a
movl %eax, %r14d
addl $0x2, %r14d
jmp 0x1bf45
movq (%rsp), %rax
leaq (%rax,%r12), %rsi
decq %rsi
leaq 0x30(%rsp), %rdi
movq %r13, %rdx
callq 0x1c33a
movl %eax, %r14d
jmp 0x1bf45
movq %r14, %r13
movq 0x10(%rsp), %rbp
subq (%rsp), %r13
leaq 0x1(%r13), %rsi
movq %rbp, %rdi
callq 0x615b
addq 0x20(%rsp), %r13
movq %rbp, %rdi
movq %r13, %rsi
callq 0x615b
pushq $0x2
popq %r14
movl %r14d, %eax
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq