// File: /workspace/github_c_makefile_star2_O3/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
movl $0x2, %esi
callq 0x7992
testl %eax, %eax
jle 0x1b542
leaq 0x40(%rsp), %r15
movq %rbx, %rdi
movl $0x1, %esi
movq %r15, %rdx
callq 0x9690
movq %rax, %r14
movq (%r15), %r13
addq %rax, %r13
movq %rbx, %rdi
movl $0x2, %esi
callq 0x980b
movq %rax, %r15
addl $-0x2, %eax
cmpl $0x23, %eax
jb 0x1b444
leaq 0x6d41(%rip), %rdx      # 0x22178
movq %rbx, %rdi
movl $0x2, %esi
callq 0x905e
leaq 0x6d3f(%rip), %rsi      # 0x2218a
movq %r14, %rdi
callq 0x6240
movb (%r14,%rax), %cl
movq %rcx, 0x30(%rsp)
addl $-0x2b, %ecx
andb $-0x3, %cl
cmpb $0x1, %cl
adcq %rax, %r14
callq 0x65f0
movq (%rax), %rbp
movzbl (%r14), %r12d
movzwl (%rbp,%r12,2), %eax
testb $0x8, %al
je 0x1b574
movq %r13, 0x28(%rsp)
cvtsi2sd %r15d, %xmm3
xorpd %xmm2, %xmm2
movsd %xmm3, 0x10(%rsp)
movapd %xmm2, %xmm1
btl $0xb, %eax
jb 0x1b4c8
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 0x1b4d0
movsbl %r12b, %r13d
addl $-0x30, %r13d
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
movapd %xmm1, %xmm2
mulsd %xmm3, %xmm2
addsd %xmm0, %xmm2
cmpl %r15d, %r13d
jge 0x1b4fb
movzbl 0x1(%r14), %r12d
incq %r14
movzwl (%rbp,%r12,2), %eax
testb $0x8, %al
jne 0x1b496
movapd %xmm2, 0x10(%rsp)
movsd %xmm1, 0x8(%rsp)
leaq 0x6c7c(%rip), %rsi      # 0x2218a
movq %r14, %rdi
callq 0x6240
addq %r14, %rax
cmpq 0x28(%rsp), %rax
jne 0x1b574
cmpl %r15d, %r13d
movapd 0x10(%rsp), %xmm0
jl 0x1b531
movsd 0x8(%rsp), %xmm0
cmpb $0x2d, 0x30(%rsp)
jne 0x1b55d
xorpd 0x5a60(%rip), %xmm0     # 0x20fa0
jmp 0x1b55d
leaq 0x3c(%rsp), %r14
movq %rbx, %rdi
movl $0x1, %esi
movq %r14, %rdx
callq 0x7be3
cmpl $0x0, (%r14)
je 0x1b567
movq %rbx, %rdi
callq 0x7e80
jmp 0x1b57c
movq %rbx, %rdi
movl $0x1, %esi
callq 0x9754
movq %rbx, %rdi
callq 0x7e6c
movl $0x1, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq