#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int int32_t;

/* Variables and functions */
int /*<<< orphan*/ debug_print(char *, int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ is_token_number(char const *);
int /*<<< orphan*/ stdout;
int strlen(char const *);
scalar_t__ strncmp(char const *, char *, int);
int32_t conv_token_number(const char *token, int resolution) {
  debug_print("n", stdout, "Converting token to number\n");
  debug_print("n", stdout, "TOKEN -> %s\n", token);
  debug_print("n", stdout, "RESOLUTION = (%d)\n", resolution);
  int base = 10;
  int cur_sign = 1;
  if (!is_token_number(token))
    return (int32_t)0;
  if (strncmp(token, "-", 1) == 0) {
    token += 1;
    cur_sign = -1;
  } else if (strncmp(token, "+", 1) == 0) {
    token += 1;
    cur_sign = 1;
  }
  if (strncmp(token, "0b", 2) == 0) {
    token += 2;
    base = 2;
  } else if (strncmp(token, "0o", 2) == 0) {
    token += 2;
    base = 8;
  } else if (strncmp(token, "0d", 2) == 0) {
    token += 2;
    base = 10;
  } else if (strncmp(token, "0x", 2) == 0) {
    token += 2;
    base = 16;
  }
  debug_print("n", stdout, "\nBase Number Found: %d\n", base);
  debug_print("n", stdout, "Expected Sign = (%d)\n", cur_sign);
  int32_t result = 0;
  int32_t base_pow = 1;
  int32_t tokval = 0;
  for (int i = 0; i < (int)strlen(token); i++) {
    switch (token[strlen(token) - 1 - i]) {
    case '0':
      tokval = 0;
      break;
    case '1':
      tokval = 1;
      break;
    case '2':
      tokval = 2;
      break;
    case '3':
      tokval = 3;
      break;
    case '4':
      tokval = 4;
      break;
    case '5':
      tokval = 5;
      break;
    case '6':
      tokval = 6;
      break;
    case '7':
      tokval = 7;
      break;
    case '8':
      tokval = 8;
      break;
    case '9':
      tokval = 9;
      break;
    case 'a':
    case 'A':
      tokval = 10;
      break;
    case 'b':
    case 'B':
      tokval = 11;
      break;
    case 'c':
    case 'C':
      tokval = 12;
      break;
    case 'd':
    case 'D':
      tokval = 13;
      break;
    case 'e':
    case 'E':
      tokval = 14;
      break;
    case 'f':
    case 'F':
      tokval = 15;
      break;
    case '_':
    default:
      continue;
      break;
    }
    result += (base_pow * tokval);
    base_pow *= base;
  }
  result *= cur_sign;
  debug_print("n", stdout, "\nFull Number = %d\n", result);
  base_pow = 1;
  base = 2;
  int32_t mask = 0;
  for (int i = 0; i < resolution; i++) {
    mask += (base_pow * 1);
    base_pow *= base;
  }
  debug_print("n", stdout, "Mask Generated = %x\n", mask);
  debug_print("n", stdout, "Final Result: %d\n", result & mask);
  debug_print("n", stdout, "Final Result: %x\n\n\n", result & mask);
  return result & mask;
}


x86 assembly (clang, -O0):
<conv_token_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%esi
lea    0xf7d(%rip),%rdi
lea    0xf78(%rip),%rdx
mov    $0x0,%al
call   1060 <debug_print@plt>
mov    0x2e6c(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rcx
lea    0xf5b(%rip),%rdi
lea    0xf72(%rip),%rdx
mov    $0x0,%al
call   1060 <debug_print@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%esi
mov    -0x14(%rbp),%ecx
lea    0xf3a(%rip),%rdi
lea    0xf5e(%rip),%rdx
mov    $0x0,%al
call   1060 <debug_print@plt>
movl   $0xa,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <is_token_number@plt>
cmp    $0x0,%eax
jne    11dc <conv_token_number+0x9c>
movl   $0x0,-0x4(%rbp)
jmp    15c9 <conv_token_number+0x489>
mov    -0x10(%rbp),%rdi
lea    0xf33(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1213 <conv_token_number+0xd3>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
jmp    124a <conv_token_number+0x10a>
mov    -0x10(%rbp),%rdi
lea    0xefe(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1245 <conv_token_number+0x105>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
jmp    124a <conv_token_number+0x10a>
mov    -0x10(%rbp),%rdi
lea    0xec9(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1281 <conv_token_number+0x141>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
movl   $0x2,-0x18(%rbp)
jmp    1330 <conv_token_number+0x1f0>
mov    -0x10(%rbp),%rdi
lea    0xe95(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12b8 <conv_token_number+0x178>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
movl   $0x8,-0x18(%rbp)
jmp    132b <conv_token_number+0x1eb>
mov    -0x10(%rbp),%rdi
lea    0xe61(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12ef <conv_token_number+0x1af>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
movl   $0xa,-0x18(%rbp)
jmp    1326 <conv_token_number+0x1e6>
mov    -0x10(%rbp),%rdi
lea    0xe2d(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1321 <conv_token_number+0x1e1>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
movl   $0x10,-0x18(%rbp)
jmp    1326 <conv_token_number+0x1e6>
jmp    132b <conv_token_number+0x1eb>
jmp    1330 <conv_token_number+0x1f0>
mov    0x2ca9(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%ecx
lea    0xd99(%rip),%rdi
lea    0xde0(%rip),%rdx
mov    $0x0,%al
call   1060 <debug_print@plt>
mov    0x2c88(%rip),%rax
mov    (%rax),%esi
mov    -0x1c(%rbp),%ecx
lea    0xd78(%rip),%rdi
lea    0xdd7(%rip),%rdx
mov    $0x0,%al
call   1060 <debug_print@plt>
movl   $0x0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cmp    %ecx,%eax
jge    14e0 <conv_token_number+0x3a0>
mov    -0x10(%rbp),%rdi
mov    %rdi,-0x48(%rbp)
call   1040 <strlen@plt>
mov    %eax,%edx
mov    -0x48(%rbp),%rax
mov    -0x2c(%rbp),%ecx
not    %ecx
add    %edx,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
add    $0xffffffd0,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x36,%eax
ja     14b6 <conv_token_number+0x376>
mov    -0x40(%rbp),%rax
lea    0xc18(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x28(%rbp)
jmp    14bb <conv_token_number+0x37b>
movl   $0x1,-0x28(%rbp)
jmp    14bb <conv_token_number+0x37b>
movl   $0x2,-0x28(%rbp)
jmp    14bb <conv_token_number+0x37b>
movl   $0x3,-0x28(%rbp)
jmp    14bb <conv_token_number+0x37b>
movl   $0x4,-0x28(%rbp)
jmp    14bb <conv_token_number+0x37b>
movl   $0x5,-0x28(%rbp)
jmp    14bb <conv_token_number+0x37b>
movl   $0x6,-0x28(%rbp)
jmp    14bb <conv_token_number+0x37b>
movl   $0x7,-0x28(%rbp)
jmp    14bb <conv_token_number+0x37b>
movl   $0x8,-0x28(%rbp)
jmp    14bb <conv_token_number+0x37b>
movl   $0x9,-0x28(%rbp)
jmp    14bb <conv_token_number+0x37b>
movl   $0xa,-0x28(%rbp)
jmp    14bb <conv_token_number+0x37b>
movl   $0xb,-0x28(%rbp)
jmp    14bb <conv_token_number+0x37b>
movl   $0xc,-0x28(%rbp)
jmp    14bb <conv_token_number+0x37b>
movl   $0xd,-0x28(%rbp)
jmp    14bb <conv_token_number+0x37b>
movl   $0xe,-0x28(%rbp)
jmp    14bb <conv_token_number+0x37b>
movl   $0xf,-0x28(%rbp)
jmp    14bb <conv_token_number+0x37b>
jmp    14b6 <conv_token_number+0x376>
jmp    14d2 <conv_token_number+0x392>
mov    -0x24(%rbp),%eax
imul   -0x28(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    138e <conv_token_number+0x24e>
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2aef(%rip),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%ecx
lea    0xbdf(%rip),%rdi
lea    0xc54(%rip),%rdx
mov    $0x0,%al
call   1060 <debug_print@plt>
movl   $0x1,-0x24(%rbp)
movl   $0x2,-0x18(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1557 <conv_token_number+0x417>
mov    -0x24(%rbp),%eax
shl    $0x0,%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1527 <conv_token_number+0x3e7>
mov    0x2a82(%rip),%rax
mov    (%rax),%esi
mov    -0x30(%rbp),%ecx
lea    0xb72(%rip),%rdi
lea    0xbfa(%rip),%rdx
mov    $0x0,%al
call   1060 <debug_print@plt>
mov    0x2a61(%rip),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%ecx
and    -0x30(%rbp),%ecx
lea    0xb4e(%rip),%rdi
lea    0xbeb(%rip),%rdx
mov    $0x0,%al
call   1060 <debug_print@plt>
mov    0x2a3d(%rip),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%ecx
and    -0x30(%rbp),%ecx
lea    0xb2a(%rip),%rdi
lea    0xbd9(%rip),%rdx
mov    $0x0,%al
call   1060 <debug_print@plt>
mov    -0x20(%rbp),%eax
and    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conv_token_number>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
mov    0x2e85(%rip),%r15
mov    (%r15),%esi
lea    0xe9b(%rip),%rbp
lea    0xe96(%rip),%rdx
xor    %r12d,%r12d
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <debug_print@plt>
mov    (%r15),%esi
lea    0xe9b(%rip),%rdx
mov    %rbp,%rdi
mov    %rbx,%rcx
xor    %eax,%eax
call   1060 <debug_print@plt>
mov    (%r15),%esi
lea    0xe91(%rip),%rdx
mov    %rbp,%rdi
mov    %r14d,%ecx
xor    %eax,%eax
call   1060 <debug_print@plt>
mov    %rbx,%rdi
call   1050 <is_token_number@plt>
test   %eax,%eax
je     1467 <conv_token_number+0x327>
lea    0xe80(%rip),%rsi
mov    $0x1,%r13d
mov    %rbx,%rdi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11f4 <conv_token_number+0xb4>
lea    0xe63(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
call   1030 <strncmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
jmp    11ff <conv_token_number+0xbf>
mov    $0xffffffff,%r13d
mov    $0x1,%ecx
add    %rcx,%rbx
lea    0xe39(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     127c <conv_token_number+0x13c>
lea    0xe23(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1287 <conv_token_number+0x147>
lea    0xe0d(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1292 <conv_token_number+0x152>
lea    0xdf7(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
lea    (%rbx,%rcx,2),%rbx
mov    $0x10,%eax
mov    $0xa,%ecx
cmove  %eax,%ecx
jmp    129b <conv_token_number+0x15b>
add    $0x2,%rbx
mov    $0x2,%ecx
jmp    129b <conv_token_number+0x15b>
add    $0x2,%rbx
mov    $0x8,%ecx
jmp    129b <conv_token_number+0x15b>
add    $0x2,%rbx
mov    $0xa,%ecx
mov    (%r15),%esi
lea    0xd5b(%rip),%r12
lea    0xda2(%rip),%rdx
xor    %ebp,%ebp
mov    %r12,%rdi
mov    %ecx,0x14(%rsp)
xor    %eax,%eax
call   1060 <debug_print@plt>
mov    (%r15),%esi
lea    0xda0(%rip),%rdx
mov    %r12,%rdi
mov    %r13d,0x10(%rsp)
mov    %r13d,%ecx
xor    %eax,%eax
call   1060 <debug_print@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
movl   $0x0,0xc(%rsp)
test   %eax,%eax
jle    136e <conv_token_number+0x22e>
mov    $0x1,%r15d
xor    %r13d,%r13d
mov    $0xffffffff,%r12d
movl   $0x0,0xc(%rsp)
jmp    1325 <conv_token_number+0x1e5>
nopl   0x0(%rax)
add    $0x1,%r13d
mov    %rbx,%rdi
call   1040 <strlen@plt>
add    $0xffffffff,%r12d
cmp    %eax,%r13d
jge    136e <conv_token_number+0x22e>
mov    %rbx,%rdi
call   1040 <strlen@plt>
add    %r12d,%eax
cltq
movsbl (%rbx,%rax,1),%eax
lea    -0x30(%rax),%ecx
cmp    $0x36,%ecx
ja     1310 <conv_token_number+0x1d0>
movabs $0x7e0000007e03ff,%rdx
bt     %rcx,%rdx
jae    1310 <conv_token_number+0x1d0>
cltq
lea    0xd75(%rip),%rcx
mov    -0xc0(%rcx,%rax,4),%eax
imul   %r15d,%eax
add    %eax,0xc(%rsp)
imul   0x14(%rsp),%r15d
jmp    1310 <conv_token_number+0x1d0>
mov    0xc(%rsp),%r12d
imul   0x10(%rsp),%r12d
mov    0x2c60(%rip),%r15
mov    (%r15),%esi
lea    0xc76(%rip),%rdi
lea    0xceb(%rip),%rdx
mov    %r12d,%ecx
xor    %eax,%eax
call   1060 <debug_print@plt>
test   %r14d,%r14d
jle    1419 <conv_token_number+0x2d9>
lea    -0x1(%r14),%ecx
mov    %r14d,%eax
and    $0x7,%eax
cmp    $0x7,%ecx
jae    13b8 <conv_token_number+0x278>
mov    $0x1,%ecx
xor    %ebp,%ebp
jmp    1401 <conv_token_number+0x2c1>
and    $0xfffffff8,%r14d
mov    $0x1,%ecx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    %ecx,%ebp
lea    0x0(%rbp,%rcx,2),%edx
lea    (%rdx,%rcx,4),%edx
lea    (%rdx,%rcx,8),%edx
mov    %ecx,%esi
shl    $0x4,%esi
add    %edx,%esi
mov    %ecx,%edx
shl    $0x5,%edx
add    %esi,%edx
mov    %ecx,%esi
shl    $0x6,%esi
add    %edx,%esi
mov    %ecx,%ebp
shl    $0x7,%ebp
add    %esi,%ebp
shl    $0x8,%ecx
add    $0xfffffff8,%r14d
jne    13d0 <conv_token_number+0x290>
test   %eax,%eax
je     1419 <conv_token_number+0x2d9>
cs nopw 0x0(%rax,%rax,1)
nop
add    %ecx,%ebp
add    %ecx,%ecx
add    $0xffffffff,%eax
jne    1410 <conv_token_number+0x2d0>
mov    (%r15),%esi
lea    0xbdd(%rip),%rbx
lea    0xc65(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%ecx
xor    %eax,%eax
call   1060 <debug_print@plt>
mov    (%r15),%esi
and    %ebp,%r12d
lea    0xc61(%rip),%rdx
mov    %rbx,%rdi
mov    %r12d,%ecx
xor    %eax,%eax
call   1060 <debug_print@plt>
mov    (%r15),%esi
lea    0xc5c(%rip),%rdx
mov    %rbx,%rdi
mov    %r12d,%ecx
xor    %eax,%eax
call   1060 <debug_print@plt>
mov    %r12d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"n\00"
@stdout = global i32 0
@.str.1 = [28 x i8] c"Converting token to number\0A\00"
@.str.2 = [13 x i8] c"TOKEN -> %s\0A\00"
@.str.3 = [19 x i8] c"RESOLUTION = (%d)\0A\00"
@.str.4 = [2 x i8] c"-\00"
@.str.5 = [2 x i8] c"+\00"
@.str.6 = [3 x i8] c"0b\00"
@.str.7 = [3 x i8] c"0o\00"
@.str.8 = [3 x i8] c"0d\00"
@.str.9 = [3 x i8] c"0x\00"
@.str.10 = [24 x i8] c"\0ABase Number Found: %d\0A\00"
@.str.11 = [22 x i8] c"Expected Sign = (%d)\0A\00"
@.str.12 = [19 x i8] c"\0AFull Number = %d\0A\00"
@.str.13 = [21 x i8] c"Mask Generated = %x\0A\00"
@.str.14 = [18 x i8] c"Final Result: %d\0A\00"
@.str.15 = [20 x i8] c"Final Result: %x\0A\0A\0A\00"
define i32 @conv_token_number(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%14 = load i32, i32* @stdout
%15 = call i32 (i8*, i32, i8*, ...) @debug_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %14, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @stdout
%17 = load i8*, i8** %4
%18 = call i32 (i8*, i32, i8*, ...) @debug_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @stdout
%20 = load i32, i32* %5
%21 = call i32 (i8*, i32, i8*, ...) @debug_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %19, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %20)
store i32 10, i32* %6
store i32 1, i32* %7
%22 = load i8*, i8** %4
%23 = call i32 @is_token_number(i8* %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %2
store i32 0, i32* %3
br label %164
26: ; preds = %2
%27 = load i8*, i8** %4
%28 = call i64 @strncmp(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 1
store i8* %32, i8** %4
store i32 -1, i32* %7
br label %41
33: ; preds = %26
%34 = load i8*, i8** %4
%35 = call i64 @strncmp(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i64 1
store i8* %39, i8** %4
store i32 1, i32* %7
br label %40
40: ; preds = %37, %33
br label %41
41: ; preds = %40, %30
%42 = load i8*, i8** %4
%43 = call i64 @strncmp(i8* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 2)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load i8*, i8** %4
%47 = getelementptr inbounds i8, i8* %46, i64 2
store i8* %47, i8** %4
store i32 2, i32* %6
br label %72
48: ; preds = %41
%49 = load i8*, i8** %4
%50 = call i64 @strncmp(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 2)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %48
%53 = load i8*, i8** %4
%54 = getelementptr inbounds i8, i8* %53, i64 2
store i8* %54, i8** %4
store i32 8, i32* %6
br label %71
55: ; preds = %48
%56 = load i8*, i8** %4
%57 = call i64 @strncmp(i8* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 2)
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %55
%60 = load i8*, i8** %4
%61 = getelementptr inbounds i8, i8* %60, i64 2
store i8* %61, i8** %4
store i32 10, i32* %6
br label %70
62: ; preds = %55
%63 = load i8*, i8** %4
%64 = call i64 @strncmp(i8* %63, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 2)
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %62
%67 = load i8*, i8** %4
%68 = getelementptr inbounds i8, i8* %67, i64 2
store i8* %68, i8** %4
store i32 16, i32* %6
br label %69
69: ; preds = %66, %62
br label %70
70: ; preds = %69, %59
br label %71
71: ; preds = %70, %52
br label %72
72: ; preds = %71, %45
%73 = load i32, i32* @stdout
%74 = load i32, i32* %6
%75 = call i32 (i8*, i32, i8*, ...) @debug_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %73, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i32 %74)
%76 = load i32, i32* @stdout
%77 = load i32, i32* %7
%78 = call i32 (i8*, i32, i8*, ...) @debug_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %76, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i32 %77)
store i32 0, i32* %8
store i32 1, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
br label %79
79: ; preds = %122, %72
%80 = load i32, i32* %11
%81 = load i8*, i8** %4
%82 = call i32 @strlen(i8* %81)
%83 = icmp slt i32 %80, %82
br i1 %83, label %84, label %125
84: ; preds = %79
%85 = load i8*, i8** %4
%86 = load i8*, i8** %4
%87 = call i32 @strlen(i8* %86)
%88 = sub nsw i32 %87, 1
%89 = load i32, i32* %11
%90 = sub nsw i32 %88, %89
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i8, i8* %85, i64 %91
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
switch i32 %94, label %112 [
i32 48, label %95
i32 49, label %96
i32 50, label %97
i32 51, label %98
i32 52, label %99
i32 53, label %100
i32 54, label %101
i32 55, label %102
i32 56, label %103
i32 57, label %104
i32 97, label %105
i32 65, label %105
i32 98, label %106
i32 66, label %106
i32 99, label %107
i32 67, label %107
i32 100, label %108
i32 68, label %108
i32 101, label %109
i32 69, label %109
i32 102, label %110
i32 70, label %110
i32 95, label %111
]
95: ; preds = %84
store i32 0, i32* %10
br label %113
96: ; preds = %84
store i32 1, i32* %10
br label %113
97: ; preds = %84
store i32 2, i32* %10
br label %113
98: ; preds = %84
store i32 3, i32* %10
br label %113
99: ; preds = %84
store i32 4, i32* %10
br label %113
100: ; preds = %84
store i32 5, i32* %10
br label %113
101: ; preds = %84
store i32 6, i32* %10
br label %113
102: ; preds = %84
store i32 7, i32* %10
br label %113
103: ; preds = %84
store i32 8, i32* %10
br label %113
104: ; preds = %84
store i32 9, i32* %10
br label %113
105: ; preds = %84, %84
store i32 10, i32* %10
br label %113
106: ; preds = %84, %84
store i32 11, i32* %10
br label %113
107: ; preds = %84, %84
store i32 12, i32* %10
br label %113
108: ; preds = %84, %84
store i32 13, i32* %10
br label %113
109: ; preds = %84, %84
store i32 14, i32* %10
br label %113
110: ; preds = %84, %84
store i32 15, i32* %10
br label %113
111: ; preds = %84
br label %112
112: ; preds = %84, %111
br label %122
113: ; preds = %110, %109, %108, %107, %106, %105, %104, %103, %102, %101, %100, %99, %98, %97, %96, %95
%114 = load i32, i32* %9
%115 = load i32, i32* %10
%116 = mul nsw i32 %114, %115
%117 = load i32, i32* %8
%118 = add nsw i32 %117, %116
store i32 %118, i32* %8
%119 = load i32, i32* %6
%120 = load i32, i32* %9
%121 = mul nsw i32 %120, %119
store i32 %121, i32* %9
br label %122
122: ; preds = %113, %112
%123 = load i32, i32* %11
%124 = add nsw i32 %123, 1
store i32 %124, i32* %11
br label %79
125: ; preds = %79
%126 = load i32, i32* %7
%127 = load i32, i32* %8
%128 = mul nsw i32 %127, %126
store i32 %128, i32* %8
%129 = load i32, i32* @stdout
%130 = load i32, i32* %8
%131 = call i32 (i8*, i32, i8*, ...) @debug_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %129, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), i32 %130)
store i32 1, i32* %9
store i32 2, i32* %6
store i32 0, i32* %12
store i32 0, i32* %13
br label %132
132: ; preds = %144, %125
%133 = load i32, i32* %13
%134 = load i32, i32* %5
%135 = icmp slt i32 %133, %134
br i1 %135, label %136, label %147
136: ; preds = %132
%137 = load i32, i32* %9
%138 = mul nsw i32 %137, 1
%139 = load i32, i32* %12
%140 = add nsw i32 %139, %138
store i32 %140, i32* %12
%141 = load i32, i32* %6
%142 = load i32, i32* %9
%143 = mul nsw i32 %142, %141
store i32 %143, i32* %9
br label %144
144: ; preds = %136
%145 = load i32, i32* %13
%146 = add nsw i32 %145, 1
store i32 %146, i32* %13
br label %132
147: ; preds = %132
%148 = load i32, i32* @stdout
%149 = load i32, i32* %12
%150 = call i32 (i8*, i32, i8*, ...) @debug_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %148, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.13, i64 0, i64 0), i32 %149)
%151 = load i32, i32* @stdout
%152 = load i32, i32* %8
%153 = load i32, i32* %12
%154 = and i32 %152, %153
%155 = call i32 (i8*, i32, i8*, ...) @debug_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %151, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), i32 %154)
%156 = load i32, i32* @stdout
%157 = load i32, i32* %8
%158 = load i32, i32* %12
%159 = and i32 %157, %158
%160 = call i32 (i8*, i32, i8*, ...) @debug_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %156, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.15, i64 0, i64 0), i32 %159)
%161 = load i32, i32* %8
%162 = load i32, i32* %12
%163 = and i32 %161, %162
store i32 %163, i32* %3
br label %164
164: ; preds = %147, %25
%165 = load i32, i32* %3
ret i32 %165
}

LLVM IR (-O2):
@.str = [2 x i8] c"n\00"
@stdout = global i32 0
@.str.1 = [28 x i8] c"Converting token to number\0A\00"
@.str.2 = [13 x i8] c"TOKEN -> %s\0A\00"
@.str.3 = [19 x i8] c"RESOLUTION = (%d)\0A\00"
@.str.4 = [2 x i8] c"-\00"
@.str.5 = [2 x i8] c"+\00"
@.str.6 = [3 x i8] c"0b\00"
@.str.7 = [3 x i8] c"0o\00"
@.str.8 = [3 x i8] c"0d\00"
@.str.9 = [3 x i8] c"0x\00"
@.str.10 = [24 x i8] c"\0ABase Number Found: %d\0A\00"
@.str.11 = [22 x i8] c"Expected Sign = (%d)\0A\00"
@.str.12 = [19 x i8] c"\0AFull Number = %d\0A\00"
@.str.13 = [21 x i8] c"Mask Generated = %x\0A\00"
@.str.14 = [18 x i8] c"Final Result: %d\0A\00"
@.str.15 = [20 x i8] c"Final Result: %x\0A\0A\0A\00"
@switch.table.conv_token_number = [55 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15]
define i32 @conv_token_number(i8* %0, i32 %1) {
%3 = load i32, i32* @stdout
%4 = tail call i32 (i8*, i32, i8*, ...) @debug_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %3, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%5 = load i32, i32* @stdout
%6 = tail call i32 (i8*, i32, i8*, ...) @debug_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %5, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%7 = load i32, i32* @stdout
%8 = tail call i32 (i8*, i32, i8*, ...) @debug_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %7, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %1)
%9 = tail call i32 @is_token_number(i8* %0)
%10 = icmp eq i32 %9, 0
br i1 %10, label %138, label %11
11: ; preds = %2
%12 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %11
%15 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1)
%16 = icmp eq i64 %15, 0
%17 = zext i1 %16 to i64
br label %18
18: ; preds = %11, %14
%19 = phi i64 [ %17, %14 ], [ 1, %11 ]
%20 = phi i32 [ 1, %14 ], [ -1, %11 ]
%21 = getelementptr i8, i8* %0, i64 %19
%22 = tail call i64 @strncmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 2)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %18
%25 = getelementptr inbounds i8, i8* %21, i64 2
br label %42
26: ; preds = %18
%27 = tail call i64 @strncmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 2)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = getelementptr inbounds i8, i8* %21, i64 2
br label %42
31: ; preds = %26
%32 = tail call i64 @strncmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 2)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = getelementptr inbounds i8, i8* %21, i64 2
br label %42
36: ; preds = %31
%37 = tail call i64 @strncmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 2)
%38 = icmp eq i64 %37, 0
%39 = select i1 %38, i64 2, i64 0
%40 = getelementptr i8, i8* %21, i64 %39
%41 = select i1 %38, i32 16, i32 10
br label %42
42: ; preds = %36, %29, %34, %24
%43 = phi i8* [ %25, %24 ], [ %30, %29 ], [ %35, %34 ], [ %40, %36 ]
%44 = phi i32 [ 2, %24 ], [ 8, %29 ], [ 10, %34 ], [ %41, %36 ]
%45 = load i32, i32* @stdout
%46 = tail call i32 (i8*, i32, i8*, ...) @debug_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %45, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i32 %44)
%47 = load i32, i32* @stdout
%48 = tail call i32 (i8*, i32, i8*, ...) @debug_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %47, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i32 %20)
%49 = tail call i32 @strlen(i8* %43)
%50 = icmp sgt i32 %49, 0
br i1 %50, label %63, label %51
51: ; preds = %88, %42
%52 = phi i32 [ 0, %42 ], [ %89, %88 ]
%53 = mul nsw i32 %52, %20
%54 = load i32, i32* @stdout
%55 = tail call i32 (i8*, i32, i8*, ...) @debug_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %54, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), i32 %53)
%56 = icmp sgt i32 %1, 0
br i1 %56, label %57, label %107
57: ; preds = %51
%58 = add i32 %1, -1
%59 = and i32 %1, 7
%60 = icmp ult i32 %58, 7
br i1 %60, label %94, label %61
61: ; preds = %57
%62 = and i32 %1, -8
br label %116
63: ; preds = %42, %88
%64 = phi i32 [ %91, %88 ], [ 0, %42 ]
%65 = phi i32 [ %90, %88 ], [ 1, %42 ]
%66 = phi i32 [ %89, %88 ], [ 0, %42 ]
%67 = tail call i32 @strlen(i8* %43)
%68 = xor i32 %64, -1
%69 = add i32 %67, %68
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %43, i64 %70
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = add nsw i32 %73, -48
%75 = icmp ult i32 %74, 55
br i1 %75, label %76, label %88
76: ; preds = %63
%77 = zext i32 %74 to i64
%78 = lshr i64 35465847073801215, %77
%79 = and i64 %78, 1
%80 = icmp eq i64 %79, 0
br i1 %80, label %88, label %81
81: ; preds = %76
%82 = sext i32 %74 to i64
%83 = getelementptr inbounds [55 x i32], [55 x i32]* @switch.table.conv_token_number, i64 0, i64 %82
%84 = load i32, i32* %83
%85 = mul nsw i32 %84, %65
%86 = add nsw i32 %85, %66
%87 = mul nsw i32 %65, %44
br label %88
88: ; preds = %76, %63, %81
%89 = phi i32 [ %66, %63 ], [ %86, %81 ], [ %66, %76 ]
%90 = phi i32 [ %65, %63 ], [ %87, %81 ], [ %65, %76 ]
%91 = add nuw nsw i32 %64, 1
%92 = tail call i32 @strlen(i8* %43)
%93 = icmp slt i32 %91, %92
br i1 %93, label %63, label %51
94: ; preds = %116, %57
%95 = phi i32 [ undef, %57 ], [ %134, %116 ]
%96 = phi i32 [ 0, %57 ], [ %134, %116 ]
%97 = phi i32 [ 1, %57 ], [ %135, %116 ]
%98 = icmp eq i32 %59, 0
br i1 %98, label %107, label %99
99: ; preds = %94, %99
%100 = phi i32 [ %103, %99 ], [ %96, %94 ]
%101 = phi i32 [ %104, %99 ], [ %97, %94 ]
%102 = phi i32 [ %105, %99 ], [ 0, %94 ]
%103 = add nuw nsw i32 %100, %101
%104 = shl nsw i32 %101, 1
%105 = add i32 %102, 1
%106 = icmp eq i32 %105, %59
br i1 %106, label %107, label %99
107: ; preds = %94, %99, %51
%108 = phi i32 [ 0, %51 ], [ %95, %94 ], [ %103, %99 ]
%109 = load i32, i32* @stdout
%110 = tail call i32 (i8*, i32, i8*, ...) @debug_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %109, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.13, i64 0, i64 0), i32 %108)
%111 = load i32, i32* @stdout
%112 = and i32 %108, %53
%113 = tail call i32 (i8*, i32, i8*, ...) @debug_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %111, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), i32 %112)
%114 = load i32, i32* @stdout
%115 = tail call i32 (i8*, i32, i8*, ...) @debug_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %114, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.15, i64 0, i64 0), i32 %112)
br label %138
116: ; preds = %116, %61
%117 = phi i32 [ 0, %61 ], [ %134, %116 ]
%118 = phi i32 [ 1, %61 ], [ %135, %116 ]
%119 = phi i32 [ 0, %61 ], [ %136, %116 ]
%120 = add nuw nsw i32 %117, %118
%121 = shl nsw i32 %118, 1
%122 = add nuw nsw i32 %120, %121
%123 = shl nsw i32 %118, 2
%124 = add nuw nsw i32 %122, %123
%125 = shl nsw i32 %118, 3
%126 = add nuw nsw i32 %124, %125
%127 = shl nsw i32 %118, 4
%128 = add nuw nsw i32 %126, %127
%129 = shl nsw i32 %118, 5
%130 = add nuw nsw i32 %128, %129
%131 = shl nsw i32 %118, 6
%132 = add nuw nsw i32 %130, %131
%133 = shl nsw i32 %118, 7
%134 = add nuw nsw i32 %132, %133
%135 = shl nsw i32 %118, 8
%136 = add i32 %119, 8
%137 = icmp eq i32 %136, %62
br i1 %137, label %94, label %116
138: ; preds = %2, %107
%139 = phi i32 [ %112, %107 ], [ 0, %2 ]
ret i32 %139
}