#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 */

/* Variables and functions */
scalar_t__ atoi(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strtol(char *, int /*<<< orphan*/ *, int);
int getNumber(char *inputNumberInString) {
  int ret = 0;
  if (inputNumberInString[0] == '0' && inputNumberInString[1] == 'x') {
    int length = strlen(inputNumberInString);
    char newString[length];
    strcpy(newString, inputNumberInString + 2);
    ret = (int)strtol(newString, NULL, 16);
  } else if (inputNumberInString[0] == '0' && inputNumberInString[1] == 'b') {
    int length = strlen(inputNumberInString);
    char newString[length];
    strcpy(newString, inputNumberInString + 2);
    ret = (int)strtol(newString, NULL, 2);
  } else {
    ret = (int)atoi(inputNumberInString);
  }
  return ret;
}


x86 assembly (clang, -O0):
<getNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    11d4 <getNumber+0x94>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x78,%eax
jne    11d4 <getNumber+0x94>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x40(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
add    $0x2,%rsi
call   1030 <strcpy@plt>
mov    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1050 <strtol@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
jmp    1266 <getNumber+0x126>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    1255 <getNumber+0x115>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x62,%eax
jne    1255 <getNumber+0x115>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x48(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rsi
add    $0x2,%rsi
call   1030 <strcpy@plt>
mov    -0x48(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x2,%edx
call   1050 <strtol@plt>
mov    %eax,-0xc(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
jmp    1261 <getNumber+0x121>
mov    -0x8(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0xc(%rbp)
jmp    1266 <getNumber+0x126>
mov    -0xc(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNumber>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
cmpb   $0x30,(%rdi)
jne    1196 <getNumber+0x56>
mov    0x1(%rbx),%al
cmp    $0x62,%al
je     11a0 <getNumber+0x60>
cmp    $0x78,%al
jne    1196 <getNumber+0x56>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rsp,%r15
mov    %eax,%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
add    $0x2,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x10,%edx
jmp    11d7 <getNumber+0x97>
mov    %rbx,%rdi
call   1060 <atoi@plt>
jmp    11df <getNumber+0x9f>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rsp,%r15
mov    %eax,%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
add    $0x2,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1050 <strtol@plt>
mov    %r15,%rsp
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getNumber(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
store i8* %0, i8** %2
store i32 0, i32* %3
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 48
br i1 %14, label %15, label %34
15: ; preds = %1
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 120
br i1 %20, label %21, label %34
21: ; preds = %15
%22 = load i8*, i8** %2
%23 = call i32 @strlen(i8* %22)
store i32 %23, i32* %4
%24 = load i32, i32* %4
%25 = zext i32 %24 to i64
%26 = call i8* @llvm.stacksave()
store i8* %26, i8** %5
%27 = alloca i8, i64 %25
store i64 %25, i64* %6
%28 = load i8*, i8** %2
%29 = getelementptr inbounds i8, i8* %28, i64 2
%30 = call i32 @strcpy(i8* %27, i8* %29)
%31 = call i64 @strtol(i8* %27, i32* null, i32 16)
%32 = trunc i64 %31 to i32
store i32 %32, i32* %3
%33 = load i8*, i8** %5
br label %64
34: ; preds = %15, %1
%35 = load i8*, i8** %2
%36 = getelementptr inbounds i8, i8* %35, i64 0
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 48
br i1 %39, label %40, label %59
40: ; preds = %34
%41 = load i8*, i8** %2
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 98
br i1 %45, label %46, label %59
46: ; preds = %40
%47 = load i8*, i8** %2
%48 = call i32 @strlen(i8* %47)
store i32 %48, i32* %7
%49 = load i32, i32* %7
%50 = zext i32 %49 to i64
%51 = call i8* @llvm.stacksave()
store i8* %51, i8** %8
%52 = alloca i8, i64 %50
store i64 %50, i64* %9
%53 = load i8*, i8** %2
%54 = getelementptr inbounds i8, i8* %53, i64 2
%55 = call i32 @strcpy(i8* %52, i8* %54)
%56 = call i64 @strtol(i8* %52, i32* null, i32 2)
%57 = trunc i64 %56 to i32
store i32 %57, i32* %3
%58 = load i8*, i8** %8
br label %63
59: ; preds = %40, %34
%60 = load i8*, i8** %2
%61 = call i64 @atoi(i8* %60)
%62 = trunc i64 %61 to i32
store i32 %62, i32* %3
br label %63
63: ; preds = %59, %46
br label %64
64: ; preds = %63, %21
%65 = load i32, i32* %3
ret i32 %65
}

LLVM IR (-O2):
define i32 @getNumber(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 48
br i1 %3, label %4, label %23
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
switch i8 %6, label %23 [
i8 120, label %7
i8 98, label %15
]
7: ; preds = %4
%8 = tail call i32 @strlen(i8* %0)
%9 = zext i32 %8 to i64
%10 = tail call i8* @llvm.stacksave()
%11 = alloca i8, i64 %9
%12 = getelementptr inbounds i8, i8* %0, i64 2
%13 = call i32 @strcpy(i8* %11, i8* %12)
%14 = call i64 @strtol(i8* nocapture %11, i32* null, i32 16)
br label %25
15: ; preds = %4
%16 = tail call i32 @strlen(i8* %0)
%17 = zext i32 %16 to i64
%18 = tail call i8* @llvm.stacksave()
%19 = alloca i8, i64 %17
%20 = getelementptr inbounds i8, i8* %0, i64 2
%21 = call i32 @strcpy(i8* %19, i8* %20)
%22 = call i64 @strtol(i8* nocapture %19, i32* null, i32 2)
br label %25
23: ; preds = %4, %1
%24 = tail call i64 @atoi(i8* %0)
br label %25
25: ; preds = %15, %23, %7
%26 = phi i64 [ %14, %7 ], [ %22, %15 ], [ %24, %23 ]
%27 = trunc i64 %26 to i32
ret i32 %27
}