// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq 0x58(%rsp), %rdi
movl $0x2, %esi
callq 0x9350
cmpl $0x0, %eax
jg 0x2d26f
movq 0x58(%rsp), %rdi
movl $0x1, %esi
leaq 0x54(%rsp), %rdx
callq 0x9810
movsd %xmm0, 0x48(%rsp)
cmpl $0x0, 0x54(%rsp)
je 0x2d25b
movq 0x58(%rsp), %rdi
movsd 0x48(%rsp), %xmm0
callq 0x9e20
movl $0x1, 0x64(%rsp)
jmp 0x2d4bb
movq 0x58(%rsp), %rdi
movl $0x1, %esi
callq 0xce50
jmp 0x2d4a9
movq 0x58(%rsp), %rdi
movl $0x1, %esi
leaq 0x40(%rsp), %rdx
callq 0xcd00
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
addq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x58(%rsp), %rdi
movl $0x2, %esi
callq 0xcf40
movl %eax, 0x2c(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x2, %eax
cmpl 0x2c(%rsp), %eax
jg 0x2d2ca
movb $0x1, %al
cmpl $0x24, 0x2c(%rsp)
movb %al, 0x1b(%rsp)
jle 0x2d2ea
movq 0x58(%rsp), %rdi
movl $0x2, %esi
leaq 0xa17f(%rip), %rdx      # 0x3745a
callq 0xc3a0
cmpl $0x0, %eax
setne %al
movb %al, 0x1b(%rsp)
movb 0x1b(%rsp), %al
movq 0x38(%rsp), %rdi
leaq 0xa172(%rip), %rsi      # 0x3746c
callq 0x7230
addq 0x38(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x2d32e
movq 0x38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x38(%rsp)
movl $0x1, 0x28(%rsp)
jmp 0x2d34b
movq 0x38(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2b, %eax
jne 0x2d349
movq 0x38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x38(%rsp)
jmp 0x2d34b
callq 0x75c0
movq (%rax), %rax
movq 0x38(%rsp), %rcx
movzbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x2d4a7
xorps %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
callq 0x75c0
movq (%rax), %rax
movq 0x38(%rsp), %rcx
movzbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x2d3a9
movq 0x38(%rsp), %rax
movsbl (%rax), %eax
subl $0x30, %eax
movl %eax, 0x14(%rsp)
jmp 0x2d3c0
movq 0x38(%rsp), %rax
movzbl (%rax), %edi
callq 0x70d0
subl $0x41, %eax
addl $0xa, %eax
movl %eax, 0x14(%rsp)
movl 0x14(%rsp), %eax
movl %eax, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
cmpl 0x2c(%rsp), %eax
jl 0x2d3d4
jmp 0x2d425
movsd 0x20(%rsp), %xmm0
cvtsi2sdl 0x2c(%rsp), %xmm2
cvtsi2sdl 0x1c(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x38(%rsp)
callq 0x75c0
movq (%rax), %rax
movq 0x38(%rsp), %rcx
movzbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x2d377
movq 0x38(%rsp), %rdi
leaq 0xa03b(%rip), %rsi      # 0x3746c
callq 0x7230
addq 0x38(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
jne 0x2d4a5
movq 0x58(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpl $0x0, 0x28(%rsp)
je 0x2d481
movsd 0x20(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, (%rsp)
jmp 0x2d48c
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rsp)
movq 0x8(%rsp), %rdi
movsd (%rsp), %xmm0
callq 0x9e20
movl $0x1, 0x64(%rsp)
jmp 0x2d4bb
jmp 0x2d4a7
jmp 0x2d4a9
movq 0x58(%rsp), %rdi
callq 0x9df0
movl $0x1, 0x64(%rsp)
movl 0x64(%rsp), %eax
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)