#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 binToInt(char const *);
int decToInt(char const *);
int hexToInt(char const *);
int octToInt(char const *);
char *skipBlank(char const *);
int strToInt(const char *src) {
  const char *p = skipBlank(src);
  unsigned chr, chr2;
  int value;
  int sign = 1;
  chr = *p;
  if (chr == '-') {
    sign = -1;
    ++p;
    chr = *p;
  } else if (chr == '+') {
    ++p;
    chr = *p;
  }
  if (chr < '0' || chr > '9') {
    return 0;
  }
  chr2 = *(p + 1);
  if (chr == '0') {
    switch (chr2) {
    case 'x':
    case 'X':
      return hexToInt(p + 2) * sign;
    case 'o':
    case 'O':
      return octToInt(p + 2) * sign;
    case 'b':
    case 'B':
      return binToInt(p + 2) * sign;
    default:
      return decToInt(p) * sign;
    }
  } else {
    return decToInt(p) * sign;
  }
}


x86 assembly (clang, -O0):
<strToInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <skipBlank@plt>
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x2d,-0x1c(%rbp)
jne    11a6 <strToInt+0x56>
movl   $0xffffffff,-0x28(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
jmp    11cb <strToInt+0x7b>
cmpl   $0x2b,-0x1c(%rbp)
jne    11c6 <strToInt+0x76>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
jmp    11cb <strToInt+0x7b>
cmpl   $0x30,-0x1c(%rbp)
jb     11df <strToInt+0x8f>
cmpl   $0x39,-0x1c(%rbp)
jbe    11eb <strToInt+0x9b>
movl   $0x0,-0x4(%rbp)
jmp    12d9 <strToInt+0x189>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x30,-0x1c(%rbp)
jne    12c9 <strToInt+0x179>
mov    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x42,%eax
je     129b <strToInt+0x14b>
jmp    1214 <strToInt+0xc4>
mov    -0x2c(%rbp),%eax
sub    $0x4f,%eax
je     1282 <strToInt+0x132>
jmp    1225 <strToInt+0xd5>
mov    -0x2c(%rbp),%eax
sub    $0x58,%eax
je     1269 <strToInt+0x119>
jmp    1236 <strToInt+0xe6>
mov    -0x2c(%rbp),%eax
sub    $0x62,%eax
je     129b <strToInt+0x14b>
jmp    1247 <strToInt+0xf7>
mov    -0x2c(%rbp),%eax
sub    $0x6f,%eax
je     1282 <strToInt+0x132>
jmp    1258 <strToInt+0x108>
mov    -0x2c(%rbp),%eax
sub    $0x78,%eax
jne    12b4 <strToInt+0x164>
jmp    1269 <strToInt+0x119>
mov    -0x18(%rbp),%rdi
add    $0x2,%rdi
call   1040 <hexToInt@plt>
imul   -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12d9 <strToInt+0x189>
mov    -0x18(%rbp),%rdi
add    $0x2,%rdi
call   1050 <octToInt@plt>
imul   -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12d9 <strToInt+0x189>
mov    -0x18(%rbp),%rdi
add    $0x2,%rdi
call   1030 <binToInt@plt>
imul   -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12d9 <strToInt+0x189>
mov    -0x18(%rbp),%rdi
call   1060 <decToInt@plt>
imul   -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12d9 <strToInt+0x189>
mov    -0x18(%rbp),%rdi
call   1060 <decToInt@plt>
imul   -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strToInt>:
push   %rbx
call   1070 <skipBlank@plt>
mov    (%rax),%dl
cmp    $0x2d,%dl
je     116e <strToInt+0x1e>
mov    $0x1,%ebx
cmp    $0x2b,%dl
jne    117a <strToInt+0x2a>
mov    $0x1,%ebx
jmp    1173 <strToInt+0x23>
mov    $0xffffffff,%ebx
mov    0x1(%rax),%dl
add    $0x1,%rax
lea    -0x3a(%rdx),%esi
xor    %ecx,%ecx
cmp    $0xf6,%sil
jb     11fd <strToInt+0xad>
cmp    $0x30,%dl
jne    11d4 <strToInt+0x84>
movsbl 0x1(%rax),%ecx
add    $0xffffffbe,%ecx
cmp    $0x36,%ecx
ja     11d4 <strToInt+0x84>
movabs $0x100000001,%rdx
bt     %rcx,%rdx
jb     11de <strToInt+0x8e>
movabs $0x200000002000,%rdx
bt     %rcx,%rdx
jb     11ec <strToInt+0x9c>
movabs $0x40000000400000,%rdx
bt     %rcx,%rdx
jae    11d4 <strToInt+0x84>
add    $0x2,%rax
mov    %rax,%rdi
call   1040 <hexToInt@plt>
jmp    11f8 <strToInt+0xa8>
mov    %rax,%rdi
call   1060 <decToInt@plt>
jmp    11f8 <strToInt+0xa8>
add    $0x2,%rax
mov    %rax,%rdi
call   1030 <binToInt@plt>
jmp    11f8 <strToInt+0xa8>
add    $0x2,%rax
mov    %rax,%rdi
call   1050 <octToInt@plt>
mov    %eax,%ecx
imul   %ebx,%ecx
mov    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @strToInt(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
%9 = load i8*, i8** %3
%10 = call i8* @skipBlank(i8* %9)
store i8* %10, i8** %4
store i32 1, i32* %8
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 45
br i1 %15, label %16, label %22
16: ; preds = %1
store i32 -1, i32* %8
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %4
%19 = load i8*, i8** %4
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
store i32 %21, i32* %5
br label %32
22: ; preds = %1
%23 = load i32, i32* %5
%24 = icmp eq i32 %23, 43
br i1 %24, label %25, label %31
25: ; preds = %22
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %4
%28 = load i8*, i8** %4
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
store i32 %30, i32* %5
br label %31
31: ; preds = %25, %22
br label %32
32: ; preds = %31, %16
%33 = load i32, i32* %5
%34 = icmp ult i32 %33, 48
br i1 %34, label %38, label %35
35: ; preds = %32
%36 = load i32, i32* %5
%37 = icmp ugt i32 %36, 57
br i1 %37, label %38, label %39
38: ; preds = %35, %32
store i32 0, i32* %2
br label %76
39: ; preds = %35
%40 = load i8*, i8** %4
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
store i32 %43, i32* %6
%44 = load i32, i32* %5
%45 = icmp eq i32 %44, 48
br i1 %45, label %46, label %71
46: ; preds = %39
%47 = load i32, i32* %6
switch i32 %47, label %66 [
i32 120, label %48
i32 88, label %48
i32 111, label %54
i32 79, label %54
i32 98, label %60
i32 66, label %60
]
48: ; preds = %46, %46
%49 = load i8*, i8** %4
%50 = getelementptr inbounds i8, i8* %49, i64 2
%51 = call i32 @hexToInt(i8* %50)
%52 = load i32, i32* %8
%53 = mul nsw i32 %51, %52
store i32 %53, i32* %2
br label %76
54: ; preds = %46, %46
%55 = load i8*, i8** %4
%56 = getelementptr inbounds i8, i8* %55, i64 2
%57 = call i32 @octToInt(i8* %56)
%58 = load i32, i32* %8
%59 = mul nsw i32 %57, %58
store i32 %59, i32* %2
br label %76
60: ; preds = %46, %46
%61 = load i8*, i8** %4
%62 = getelementptr inbounds i8, i8* %61, i64 2
%63 = call i32 @binToInt(i8* %62)
%64 = load i32, i32* %8
%65 = mul nsw i32 %63, %64
store i32 %65, i32* %2
br label %76
66: ; preds = %46
%67 = load i8*, i8** %4
%68 = call i32 @decToInt(i8* %67)
%69 = load i32, i32* %8
%70 = mul nsw i32 %68, %69
store i32 %70, i32* %2
br label %76
71: ; preds = %39
%72 = load i8*, i8** %4
%73 = call i32 @decToInt(i8* %72)
%74 = load i32, i32* %8
%75 = mul nsw i32 %73, %74
store i32 %75, i32* %2
br label %76
76: ; preds = %71, %66, %60, %54, %48, %38
%77 = load i32, i32* %2
ret i32 %77
}

LLVM IR (-O2):
define i32 @strToInt(i8* %0) {
%2 = tail call i8* @skipBlank(i8* %0)
%3 = load i8, i8* %2
switch i8 %3, label %9 [
i8 45, label %5
i8 43, label %4
]
4: ; preds = %1
br label %5
5: ; preds = %1, %4
%6 = phi i32 [ 1, %4 ], [ -1, %1 ]
%7 = getelementptr inbounds i8, i8* %2, i64 1
%8 = load i8, i8* %7
br label %9
9: ; preds = %5, %1
%10 = phi i8 [ %3, %1 ], [ %8, %5 ]
%11 = phi i8* [ %2, %1 ], [ %7, %5 ]
%12 = phi i32 [ 1, %1 ], [ %6, %5 ]
%13 = add i8 %10, -58
%14 = icmp ult i8 %13, -10
br i1 %14, label %39, label %15
15: ; preds = %9
%16 = icmp eq i8 %10, 48
br i1 %16, label %17, label %36
17: ; preds = %15
%18 = getelementptr inbounds i8, i8* %11, i64 1
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
switch i32 %20, label %33 [
i32 120, label %21
i32 88, label %21
i32 111, label %25
i32 79, label %25
i32 98, label %29
i32 66, label %29
]
21: ; preds = %17, %17
%22 = getelementptr inbounds i8, i8* %11, i64 2
%23 = tail call i32 @hexToInt(i8* %22)
%24 = mul nsw i32 %23, %12
br label %39
25: ; preds = %17, %17
%26 = getelementptr inbounds i8, i8* %11, i64 2
%27 = tail call i32 @octToInt(i8* %26)
%28 = mul nsw i32 %27, %12
br label %39
29: ; preds = %17, %17
%30 = getelementptr inbounds i8, i8* %11, i64 2
%31 = tail call i32 @binToInt(i8* %30)
%32 = mul nsw i32 %31, %12
br label %39
33: ; preds = %17
%34 = tail call i32 @decToInt(i8* %11)
%35 = mul nsw i32 %34, %12
br label %39
36: ; preds = %15
%37 = tail call i32 @decToInt(i8* %11)
%38 = mul nsw i32 %37, %12
br label %39
39: ; preds = %9, %36, %33, %29, %25, %21
%40 = phi i32 [ %35, %33 ], [ %32, %29 ], [ %28, %25 ], [ %24, %21 ], [ %38, %36 ], [ 0, %9 ]
ret i32 %40
}