// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/lua-5.1.5/src/lstrlib.c
// Function: str_find_aux
static int str_find_aux (lua_State *L, int find) {
  size_t l1, l2;
  const char *s = luaL_checklstring(L, 1, &l1);
  const char *p = luaL_checklstring(L, 2, &l2);
  ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1;
  if (init < 0) init = 0;
  else if ((size_t)(init) > l1) init = (ptrdiff_t)l1;
  if (find && (lua_toboolean(L, 4) ||  /* explicit request? */
      strpbrk(p, SPECIALS) == NULL)) {  /* or no special characters? */
    /* do a plain search */
    const char *s2 = lmemfind(s+init, l1-init, p, l2);
    if (s2) {
      lua_pushinteger(L, s2-s+1);
      lua_pushinteger(L, s2-s+l2);
      return 2;
    }
  }
  else {
    MatchState ms;
    int anchor = (*p == '^') ? (p++, 1) : 0;
    const char *s1=s+init;
    ms.L = L;
    ms.src_init = s;
    ms.src_end = s+l1;
    do {
      const char *res;
      ms.level = 0;
      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, %rbx
leaq 0x30(%rsp), %r14
movl $0x1, %esi
movq %r14, %rdx
callq 0x5b1b3
movq %rax, 0x18(%rsp)
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
movl $0x2, %esi
callq 0x5b1b3
movq %rax, %rbp
movl $0x1, %edx
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
movl $0x3, %esi
callq 0x5b45e
movq (%r14), %r12
leaq 0x1(%r12), %rcx
movq %rax, %rdx
sarq $0x3f, %rdx
andq %rcx, %rdx
addq %rax, %rdx
xorl %eax, %eax
testq %rdx, %rdx
movl $0x0, %r15d
cmovgq %rdx, %r15
decq %r15
cmpq %r12, %r15
cmovaeq %r12, %r15
testq %rdx, %rdx
cmovleq %rax, %r15
movl %r13d, 0xc(%rsp)
testl %r13d, %r13d
je 0x6d298
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rbx
movq 0x18(%rax), %rax
addq $0x30, %rax
cmpq %rbx, %rax
jb 0x6d267
leaq 0x804a9(%rip), %rax     # 0xed710
movl 0x8(%rax), %ecx
testl %ecx, %ecx
je 0x6d280
cmpl $0x1, %ecx
jne 0x6d390
cmpl $0x0, (%rax)
jne 0x6d390
leaq 0x81ad4(%rip), %rsi     # 0xeed5b
movq %rbp, %rdi
callq 0xbb20
testq %rax, %rax
je 0x6d390
movq %rbp, %r13
movb (%rbp), %bl
xorl %eax, %eax
cmpb $0x5e, %bl
sete %al
addq %rax, %r13
movq 0x18(%rsp), %rcx
leaq (%rcx,%r15), %r14
leaq 0x38(%rsp), %rdx
movq 0x10(%rsp), %rax
movq %rax, 0x10(%rdx)
movq %rcx, (%rdx)
addq %rcx, %r12
movq %r12, 0x8(%rdx)
incq %r15
movl $0x0, 0x50(%rsp)
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x6d498
movq %rax, %rbp
testq %rax, %rax
je 0x6d364
cmpl $0x0, 0xc(%rsp)
je 0x6d351
movq 0x10(%rsp), %rdx
movq 0x10(%rdx), %rax
xorps %xmm0, %xmm0
cvtsi2sd %r15, %xmm0
movsd %xmm0, (%rax)
movl $0x3, %esi
movl %esi, 0x8(%rax)
movq 0x10(%rdx), %rax
leaq 0x10(%rax), %rcx
movq %rcx, 0x10(%rdx)
movq %rbp, %rcx
subq 0x18(%rsp), %rcx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
movsd %xmm0, 0x10(%rax)
movl %esi, 0x18(%rax)
addq $0x10, 0x10(%rdx)
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x6d8d2
movl %eax, %r12d
addl $0x2, %r12d
jmp 0x6d364
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x6d8d2
movl %eax, %r12d
testq %rbp, %rbp
jne 0x6d483
cmpb $0x5e, %bl
je 0x6d465
leaq 0x1(%r14), %rax
incq %r15
cmpq 0x40(%rsp), %r14
movq %rax, %r14
jb 0x6d2cd
jmp 0x6d465
movq 0x18(%rsp), %rax
leaq (%rax,%r15), %r13
movq 0x28(%rsp), %rax
testq %rax, %rax
je 0x6d413
subq %r15, %r12
cmpq %r12, %rax
ja 0x6d406
decq %rax
subq %rax, %r12
je 0x6d406
movq %rax, %r15
movq %rbx, 0x20(%rsp)
movq %rbp, %rbx
movsbl (%rbp), %eax
movl %eax, 0xc(%rsp)
incq %rbx
movq %r13, %rdi
movl 0xc(%rsp), %esi
movq %r12, %rdx
callq 0xb710
testq %rax, %rax
je 0x6d401
movq %rax, %rbp
leaq 0x1(%rax), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xb6b0
testl %eax, %eax
je 0x6d40b
addq %r13, %r12
movq %r14, %r13
subq %r14, %r12
jne 0x6d3c9
xorl %r13d, %r13d
jmp 0x6d40e
xorl %r13d, %r13d
jmp 0x6d413
movq %rbp, %r13
movq 0x20(%rsp), %rbx
testq %r13, %r13
je 0x6d465
subq 0x18(%rsp), %r13
leaq 0x1(%r13), %rax
cvtsi2sd %rax, %xmm0
movsd %xmm0, (%rbx)
movl $0x3, %eax
movl %eax, 0x8(%rbx)
movq 0x10(%rsp), %rsi
movq 0x10(%rsi), %rcx
leaq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rsi)
addq 0x28(%rsp), %r13
xorps %xmm0, %xmm0
cvtsi2sd %r13, %xmm0
movsd %xmm0, 0x10(%rcx)
movl %eax, 0x18(%rcx)
addq $0x10, 0x10(%rsi)
movl $0x2, %r12d
jmp 0x6d483
movq 0x10(%rsp), %rcx
movq 0x10(%rcx), %rax
movl $0x0, 0x8(%rax)
addq $0x10, %rax
movq %rax, 0x10(%rcx)
movl $0x1, %r12d
movl %r12d, %eax
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq