#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 */
int /*<<< orphan*/ sscanf(char *, char *, int *);
int get_int(char *str) {
  int value;
  switch (str[0]) {
  case '$':
    sscanf(str + 1, "%x", &value);
    return value;
  case '\'':
    return str[1];
  case '0':
    switch (str[1]) {
    case 'x':
    case 'X':
      sscanf(str + 2, "%x", &value);
      return value;
    case 'o':
    case 'O':
      sscanf(str + 2, "%o", &value);
      return value;
    }
  default:
    sscanf(str, "%d", &value);
  }
  return value;
}


x86 assembly (clang, -O0):
<get_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x18(%rbp)
sub    $0x24,%eax
je     1156 <get_int+0x46>
jmp    1134 <get_int+0x24>
mov    -0x18(%rbp),%eax
sub    $0x27,%eax
je     1179 <get_int+0x69>
jmp    1145 <get_int+0x35>
mov    -0x18(%rbp),%eax
sub    $0x30,%eax
je     1189 <get_int+0x79>
jmp    1220 <get_int+0x110>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
lea    0xe9b(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1030 <sscanf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    123a <get_int+0x12a>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    123a <get_int+0x12a>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x4f,%eax
je     11f8 <get_int+0xe8>
jmp    11a2 <get_int+0x92>
mov    -0x1c(%rbp),%eax
sub    $0x58,%eax
je     11d5 <get_int+0xc5>
jmp    11b3 <get_int+0xa3>
mov    -0x1c(%rbp),%eax
sub    $0x6f,%eax
je     11f8 <get_int+0xe8>
jmp    11c4 <get_int+0xb4>
mov    -0x1c(%rbp),%eax
sub    $0x78,%eax
jne    121b <get_int+0x10b>
jmp    11d5 <get_int+0xc5>
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
lea    0xe1c(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1030 <sscanf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    123a <get_int+0x12a>
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
lea    0xdfc(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1030 <sscanf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    123a <get_int+0x12a>
jmp    1220 <get_int+0x110>
mov    -0x10(%rbp),%rdi
lea    0xddb(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1030 <sscanf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_int>:
push   %rax
movsbl (%rdi),%eax
cmp    $0x30,%eax
je     1130 <get_int+0x20>
cmp    $0x27,%eax
je     114c <get_int+0x3c>
cmp    $0x24,%eax
jne    1143 <get_int+0x33>
add    $0x1,%rdi
lea    0xed2(%rip),%rsi
jmp    1174 <get_int+0x64>
movsbl 0x1(%rdi),%eax
cmp    $0x6e,%eax
jg     1152 <get_int+0x42>
cmp    $0x4f,%eax
je     1169 <get_int+0x59>
cmp    $0x58,%eax
je     115c <get_int+0x4c>
lea    0xebc(%rip),%rsi
jmp    1174 <get_int+0x64>
movsbl 0x1(%rdi),%eax
pop    %rcx
ret
cmp    $0x6f,%eax
je     1169 <get_int+0x59>
cmp    $0x78,%eax
jne    1143 <get_int+0x33>
add    $0x2,%rdi
lea    0xe99(%rip),%rsi
jmp    1174 <get_int+0x64>
add    $0x2,%rdi
lea    0xe8f(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1030 <sscanf@plt>
mov    0x4(%rsp),%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%x\00"
@.str.1 = [3 x i8] c"%o\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @get_int(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
switch i32 %8, label %35 [
i32 36, label %9
i32 39, label %14
i32 48, label %19
]
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%13 = load i32, i32* %4
store i32 %13, i32* %2
br label %40
14: ; preds = %1
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
store i32 %18, i32* %2
br label %40
19: ; preds = %1
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
switch i32 %23, label %34 [
i32 120, label %24
i32 88, label %24
i32 111, label %29
i32 79, label %29
]
24: ; preds = %19, %19
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i64 2
%27 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%28 = load i32, i32* %4
store i32 %28, i32* %2
br label %40
29: ; preds = %19, %19
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i64 2
%32 = call i32 @sscanf(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%33 = load i32, i32* %4
store i32 %33, i32* %2
br label %40
34: ; preds = %19
br label %35
35: ; preds = %1, %34
%36 = load i8*, i8** %3
%37 = call i32 @sscanf(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
br label %38
38: ; preds = %35
%39 = load i32, i32* %4
store i32 %39, i32* %2
br label %40
40: ; preds = %38, %29, %24, %14, %9
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
@.str = [3 x i8] c"%x\00"
@.str.1 = [3 x i8] c"%o\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @get_int(i8* nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = load i8, i8* %0
%5 = sext i8 %4 to i32
switch i32 %5, label %26 [
i32 36, label %6
i32 39, label %10
i32 48, label %14
]
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
br label %29
10: ; preds = %1
%11 = getelementptr inbounds i8, i8* %0, i64 1
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
br label %29
14: ; preds = %1
%15 = getelementptr inbounds i8, i8* %0, i64 1
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
switch i32 %17, label %26 [
i32 120, label %18
i32 88, label %18
i32 111, label %22
i32 79, label %22
]
18: ; preds = %14, %14
%19 = getelementptr inbounds i8, i8* %0, i64 2
%20 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%21 = load i32, i32* %2
br label %29
22: ; preds = %14, %14
%23 = getelementptr inbounds i8, i8* %0, i64 2
%24 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%25 = load i32, i32* %2
br label %29
26: ; preds = %14, %1
%27 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%28 = load i32, i32* %2
br label %29
29: ; preds = %26, %22, %18, %10, %6
%30 = phi i32 [ %28, %26 ], [ %25, %22 ], [ %21, %18 ], [ %13, %10 ], [ %9, %6 ]
ret i32 %30
}