// File: /workspace/github_c_makefile_star2_O1/tylerneylon[P]APIsWithLua/lua/lbaselib.c
// Function: luaB_tonumber
static int luaB_tonumber (lua_State *L) {
  if (lua_isnoneornil(L, 2)) {  /* standard conversion? */
    luaL_checkany(L, 1);
    if (lua_type(L, 1) == LUA_TNUMBER) {  /* already a number? */
      lua_settop(L, 1);  /* yes; return it */
      return 1;
    }
    else {
      size_t l;
      const char *s = lua_tolstring(L, 1, &l);
      if (s != NULL && lua_stringtonumber(L, s) == l + 1)
        return 1;  /* successful conversion to number */
      /* else not a number */
    }
  }
  else {
    size_t l;
    const char *s;
    lua_Integer n = 0;  /* to avoid warnings */
    lua_Integer base = luaL_checkinteger(L, 2);
    luaL_checktype(L, 1, LUA_TSTRING);  /* no numbers as strings */
    s = lua_tolstring(L, 1, &l);
    luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
    if (b_str2int(s, (int)base, &n) == s + l) {
      lua_pushinteger(L, n);
      return 1;
    }  /* else not a number */
  }  /* else not a number */
  lua_pushnil(L);  /* not a number */
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movl $0x2, %esi
callq 0x5f7f
movq %rbx, %rdi
testl %eax, %eax
jle 0x18854
movl $0x2, %esi
callq 0x1465a
movq %rax, %r15
movq %rbx, %rdi
movl $0x1, %esi
movl $0x4, %edx
callq 0x1456f
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x6249
movq %rax, %r12
movq %rax, %r14
leaq -0x2(%r15), %rax
cmpq $0x23, %rax
jb 0x18783
leaq 0xa451(%rip), %rdx      # 0x22bc7
movq %rbx, %rdi
movl $0x2, %esi
callq 0x13ea8
leaq 0xa44f(%rip), %rsi      # 0x22bd9
movq %r14, %rdi
callq 0x5200
movb (%r14,%rax), %r13b
leal -0x2b(%r13), %ecx
andb $-0x3, %cl
cmpb $0x1, %cl
adcq %rax, %r12
callq 0x5540
movq (%rax), %rbp
movzbl (%r12), %eax
movq $0x0, (%rsp)
testb $0x8, (%rbp,%rax,2)
movl $0x0, %eax
je 0x188bc
movq %r13, 0x20(%rsp)
movq %r14, 0x10(%rsp)
movq %rbx, 0x18(%rsp)
movslq %r15d, %r14
movq $0x0, (%rsp)
xorl %r13d, %r13d
movzbl (%r12), %ebx
testb $0x8, 0x1(%rbp,%rbx,2)
jne 0x18801
callq 0x5030
movq (%rax), %rax
movl (%rax,%rbx,4), %eax
addl $-0x37, %eax
jmp 0x18807
movsbl %bl, %eax
addl $-0x30, %eax
cmpl %r15d, %eax
jge 0x188b0
movq %r13, %rcx
imulq %r14, %rcx
movslq %eax, %r13
addq %rcx, %r13
movzbl 0x1(%r12), %eax
incq %r12
testb $0x8, (%rbp,%rax,2)
jne 0x187e5
leaq 0xa3a5(%rip), %rsi      # 0x22bd9
movq %r12, %rdi
callq 0x5200
addq %r12, %rax
movq %r13, %rcx
negq %rcx
cmpb $0x2d, 0x20(%rsp)
cmovneq %r13, %rcx
movq %rcx, (%rsp)
jmp 0x188b2
movl $0x1, %esi
callq 0x145a3
movq %rbx, %rdi
movl $0x1, %esi
callq 0x5f7f
cmpl $0x3, %eax
jne 0x1887f
movq %rbx, %rdi
movl $0x1, %esi
callq 0x5d51
jmp 0x188df
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x6249
testq %rax, %rax
je 0x188c9
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6163
movq 0x8(%rsp), %rcx
incq %rcx
cmpq %rcx, %rax
jne 0x188c9
jmp 0x188df
xorl %eax, %eax
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %r14
movq 0x8(%rsp), %rcx
addq %r14, %rcx
cmpq %rcx, %rax
je 0x188d3
movq %rbx, %rdi
callq 0x63bd
jmp 0x188df
movq %rbx, %rdi
movq (%rsp), %rsi
callq 0x63e6
movl $0x1, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq