// File: /workspace/github_c_makefile_star2_O2/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 $0x48, %rsp
movq %rdi, %rbx
pushq $0x2
popq %rsi
callq 0x7624
pushq $0x1
popq %rsi
testl %eax, %eax
jle 0x197e5
leaq 0x40(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rdx
callq 0x9264
movq %rax, %r14
movq (%r15), %r13
addq %rax, %r13
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x93db
movq %rax, %r15
addl $-0x2, %eax
cmpl $0x23, %eax
jb 0x196ea
leaq 0x6a89(%rip), %rdx      # 0x20168
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x8c84
leaq 0x6a89(%rip), %rsi      # 0x2017a
movq %r14, %rdi
callq 0x6230
movb (%r14,%rax), %cl
movq %rcx, 0x30(%rsp)
addl $-0x2b, %ecx
andb $-0x3, %cl
cmpb $0x1, %cl
adcq %rax, %r14
callq 0x65e0
movq (%rax), %rbp
movzbl (%r14), %r12d
movzwl (%rbp,%r12,2), %eax
testb $0x8, %al
je 0x19810
movq %r13, 0x28(%rsp)
cvtsi2sd %r15d, %xmm3
xorpd %xmm2, %xmm2
movsd %xmm3, 0x10(%rsp)
movapd %xmm2, %xmm1
btl $0xb, %eax
jb 0x1976e
movsd %xmm1, 0x8(%rsp)
callq 0x6030
movsd 0x10(%rsp), %xmm3
movsd 0x8(%rsp), %xmm1
movq (%rax), %rax
movzbl %r12b, %ecx
movl (%rax,%rcx,4), %r13d
addl $-0x37, %r13d
jmp 0x19776
movsbl %r12b, %r13d
addl $-0x30, %r13d
cvtsi2sd %r13d, %xmm0
movapd %xmm1, %xmm2
mulsd %xmm3, %xmm2
addsd %xmm0, %xmm2
cmpl %r15d, %r13d
jge 0x1979e
movzbl 0x1(%r14), %r12d
incq %r14
movzwl (%rbp,%r12,2), %eax
testb $0x8, %al
jne 0x1973c
movapd %xmm2, 0x10(%rsp)
movsd %xmm1, 0x8(%rsp)
leaq 0x69c9(%rip), %rsi      # 0x2017a
movq %r14, %rdi
callq 0x6230
addq %r14, %rax
cmpq 0x28(%rsp), %rax
jne 0x19810
cmpl %r15d, %r13d
movapd 0x10(%rsp), %xmm0
jl 0x197d4
movsd 0x8(%rsp), %xmm0
cmpb $0x2d, 0x30(%rsp)
jne 0x197fb
xorpd 0x578d(%rip), %xmm0     # 0x1ef70
jmp 0x197fb
leaq 0x3c(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rdx
callq 0x785f
cmpl $0x0, (%r14)
je 0x19805
movq %rbx, %rdi
callq 0x7adc
jmp 0x19818
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x9331
movq %rbx, %rdi
callq 0x7acb
pushq $0x1
popq %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq