// File: /workspace/github_c_makefile_star2_O3/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, %r14
movl $0x2, %esi
callq 0x608f
movq %r14, %rdi
testl %eax, %eax
jle 0x193b9
movl $0x2, %esi
callq 0x15124
movq %rax, %r15
movq %r14, %rdi
movl $0x1, %esi
movl $0x4, %edx
callq 0x15039
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
movl $0x1, %esi
callq 0x6359
movq %rax, %r12
movq %rax, %r13
leaq -0x2(%r15), %rax
cmpq $0x23, %rax
jb 0x192e5
leaq 0xa97f(%rip), %rdx      # 0x23c57
movq %r14, %rdi
movl $0x2, %esi
callq 0x1497c
leaq 0xa97d(%rip), %rsi      # 0x23c69
movq %r13, %rdi
callq 0x51f0
movb (%r13,%rax), %cl
movq %rcx, 0x20(%rsp)
addl $-0x2b, %ecx
andb $-0x3, %cl
cmpb $0x1, %cl
adcq %rax, %r12
callq 0x5530
movq (%rax), %rbp
movzbl (%r12), %ebx
movzwl (%rbp,%rbx,2), %ecx
movq $0x0, (%rsp)
movl $0x0, %eax
testb $0x8, %cl
je 0x19421
movq %r13, 0x10(%rsp)
movq %r14, 0x18(%rsp)
movslq %r15d, %r14
movq $0x0, (%rsp)
xorl %r13d, %r13d
btl $0xb, %ecx
jb 0x19363
callq 0x5030
movq (%rax), %rax
movzbl %bl, %ecx
movl (%rax,%rcx,4), %eax
addl $-0x37, %eax
jmp 0x19369
movsbl %bl, %eax
addl $-0x30, %eax
cmpl %r15d, %eax
jge 0x19415
movq %r13, %rcx
imulq %r14, %rcx
movslq %eax, %r13
addq %rcx, %r13
movzbl 0x1(%r12), %ebx
incq %r12
movzwl (%rbp,%rbx,2), %ecx
testb $0x8, %cl
jne 0x1934a
leaq 0xa8d0(%rip), %rsi      # 0x23c69
movq %r12, %rdi
callq 0x51f0
addq %r12, %rax
movq %r13, %rcx
negq %rcx
cmpb $0x2d, 0x20(%rsp)
cmovneq %r13, %rcx
movq %rcx, (%rsp)
jmp 0x19417
movl $0x1, %esi
callq 0x1506d
movq %r14, %rdi
movl $0x1, %esi
callq 0x608f
cmpl $0x3, %eax
jne 0x193e4
movq %r14, %rdi
movl $0x1, %esi
callq 0x5d4d
jmp 0x19444
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
movl $0x1, %esi
callq 0x6359
testq %rax, %rax
je 0x1942e
movq %r14, %rdi
movq %rax, %rsi
callq 0x626f
movq 0x8(%rsp), %rcx
incq %rcx
cmpq %rcx, %rax
jne 0x1942e
jmp 0x19444
xorl %eax, %eax
movq 0x18(%rsp), %r14
movq 0x10(%rsp), %r13
movq 0x8(%rsp), %rcx
addq %r13, %rcx
cmpq %rcx, %rax
je 0x19438
movq %r14, %rdi
callq 0x64cd
jmp 0x19444
movq %r14, %rdi
movq (%rsp), %rsi
callq 0x64f6
movl $0x1, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq