// File: /workspace/github_c_makefile_star2_O1/bhk[P]tooltree/lua/../opensource/lua-5.2.3/src/lbaselib.c
// Function: luaB_tonumber
static int luaB_tonumber (lua_State *L) {
  if (lua_isnoneornil(L, 2)) {  /* standard conversion */
    int isnum;
    lua_Number n = lua_tonumberx(L, 1, &isnum);
    if (isnum) {
      lua_pushnumber(L, n);
      return 1;
    }  /* else not a number; must be something */
    luaL_checkany(L, 1);
  }
  else {
    size_t l;
    const char *s = luaL_checklstring(L, 1, &l);
    const char *e = s + l;  /* end point for 's' */
    int base = luaL_checkint(L, 2);
    int neg = 0;
    luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
    s += strspn(s, SPACECHARS);  /* skip initial spaces */
    if (*s == '-') { s++; neg = 1; }  /* handle signal */
    else if (*s == '+') s++;
    if (isalnum((unsigned char)*s)) {
      lua_Number n = 0;
      do {
        int digit = (isdigit((unsigned char)*s)) ? *s - '0'
                       : toupper((unsigned char)*s) - 'A' + 10;
        if (digit >= base) break;  /* invalid numeral; force a fail */
        n = n * (lua_Number)base + (lua_Number)digit;
        s++;
      } while (isalnum((unsigned char)*s));
      s += strspn(s, SPACECHARS);  /* skip trailing spaces */
      if (s == e) {  /* no invalid trailing characters? */
        lua_pushnumber(L, (neg) ? -n : 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 $0x38, %rsp
movq %rdi, %rbx
movl $0x2, %esi
callq 0x7889
testl %eax, %eax
jle 0x1b502
leaq 0x30(%rsp), %r15
movq %rbx, %rdi
movl $0x1, %esi
movq %r15, %rdx
callq 0x9559
movq %rax, %r14
movq (%r15), %r12
addq %rax, %r12
movq %rbx, %rdi
movl $0x2, %esi
callq 0x96d4
movq %rax, %r15
addl $-0x2, %eax
cmpl $0x23, %eax
jb 0x1b432
leaq 0x6d53(%rip), %rdx      # 0x22178
movq %rbx, %rdi
movl $0x2, %esi
callq 0x8f3e
leaq 0x6d51(%rip), %rsi      # 0x2218a
movq %r14, %rdi
callq 0x6240
movb (%r14,%rax), %cl
movq %rcx, 0x18(%rsp)
addl $-0x2b, %ecx
andb $-0x3, %cl
cmpb $0x1, %cl
adcq %rax, %r14
callq 0x65f0
movq (%rax), %rbp
movzbl (%r14), %eax
testb $0x8, (%rbp,%rax,2)
je 0x1b536
cvtsi2sd %r15d, %xmm0
movsd %xmm0, 0x20(%rsp)
xorpd %xmm1, %xmm1
movzbl (%r14), %r13d
testb $0x8, 0x1(%rbp,%r13,2)
jne 0x1b4a3
movapd %xmm1, (%rsp)
callq 0x6030
movapd (%rsp), %xmm1
movq (%rax), %rax
movl (%rax,%r13,4), %eax
addl $-0x37, %eax
jmp 0x1b4aa
movsbl %r13b, %eax
addl $-0x30, %eax
xorl %ecx, %ecx
cmpl %r15d, %eax
setl %cl
addq %rcx, %r14
cmpl %r15d, %eax
jge 0x1b4cb
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x20(%rsp), %xmm1
addsd %xmm0, %xmm1
jge 0x1b4d8
movzbl (%r14), %eax
testb $0x8, (%rbp,%rax,2)
jne 0x1b47c
movapd %xmm1, (%rsp)
leaq 0x6ca6(%rip), %rsi      # 0x2218a
movq %r14, %rdi
callq 0x6240
addq %r14, %rax
cmpq %r12, %rax
jne 0x1b536
cmpb $0x2d, 0x18(%rsp)
je 0x1b552
movapd (%rsp), %xmm0
jmp 0x1b55f
leaq 0x2c(%rsp), %r14
movq %rbx, %rdi
movl $0x1, %esi
movq %r14, %rdx
callq 0x7ad5
movl (%r14), %ebp
movq %rbx, %rdi
testl %ebp, %ebp
je 0x1b528
callq 0x7d72
jmp 0x1b532
movl $0x1, %esi
callq 0x961d
testl %ebp, %ebp
jne 0x1b53e
movq %rbx, %rdi
callq 0x7d5e
movl $0x1, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movapd (%rsp), %xmm0
xorpd 0x5a41(%rip), %xmm0     # 0x20fa0
movq %rbx, %rdi
callq 0x7d72
jmp 0x1b53e