#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*/ puts(char *);
int /*<<< orphan*/ read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ sscanf(char *, char *, unsigned int *);
scalar_t__ strncmp(char *, char *, int);
int main() {
  char swch;
  char test[100] = {0};
  unsigned int val;
  read(0, &swch, 1);
  read(0, test, 80);
  if (swch == 'x') {
    sscanf(test, "%07x", &val);
    if (val == 0xaaaa) {
      if (strncmp(test, "0x", 2) == 0) {
        puts("0x worked");
      } else if (strncmp(test, "+0x", 3) == 0) {
        puts("+0x worked");
      } else if (test[0] == '+') {
        puts("base +16 worked");
      } else {
        puts("base 16 worked");
      }
    } else if (val == -0xcdcd) {
      if (strncmp(test, "-0x", 3) == 0) {
        puts("-0x worked");
      } else if (test[0] == '-') {
        puts("base -16 worked");
      } else {
        puts("shouldn't happen");
      }
    } else {
      puts("Nope x");
    }
  } else if (swch == 'u') {
    sscanf(test, "%u", &val);
    if (val == 0xaaaa) {
      if (test[0] == '0' && test[1] != 'x') {
        puts("base 8 worked");
      } else if (test[0] == '+' && test[1] == '0' && test[2] != 'x') {
        puts("base +8 worked");
      } else if (test[0] == '+' && test[1] != '0') {
        puts("base +10 worked");
      } else {
        puts("base 10 worked");
      }
    } else if (val == -0xcdcd) {
      if (test[0] == '-' && test[1] == '0' && test[2] != 'x') {
        puts("base -8 worked");
      } else if (test[0] == '-' && test[1] != '0') {
        puts("base -10 worked");
      } else {
        puts("shouldn't happen");
      }
    } else {
      puts("Nope u");
    }
  } else {
    puts("No switch");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
xor    %edi,%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
lea    -0x70(%rbp),%rsi
xor    %edi,%edi
mov    $0x50,%edx
call   1060 <read@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x78,%eax
jne    12e0 <main+0x190>
lea    -0x70(%rbp),%rdi
lea    0xe56(%rip),%rsi
lea    -0x74(%rbp),%rdx
call   1070 <sscanf@plt>
cmpl   $0xaaaa,-0x74(%rbp)
jne    1259 <main+0x109>
lea    -0x70(%rbp),%rdi
lea    0xe3b(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11f0 <main+0xa0>
lea    0xe24(%rip),%rdi
call   1040 <puts@plt>
jmp    1254 <main+0x104>
lea    -0x70(%rbp),%rdi
lea    0xe0a(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1220 <main+0xd0>
lea    0xdf3(%rip),%rdi
call   1040 <puts@plt>
jmp    124f <main+0xff>
movsbl -0x70(%rbp),%eax
cmp    $0x2b,%eax
jne    123e <main+0xee>
lea    0xde0(%rip),%rdi
call   1040 <puts@plt>
jmp    124a <main+0xfa>
lea    0xddf(%rip),%rdi
call   1040 <puts@plt>
jmp    124f <main+0xff>
jmp    1254 <main+0x104>
jmp    12db <main+0x18b>
cmpl   $0xffff3233,-0x74(%rbp)
jne    12ca <main+0x17a>
lea    -0x70(%rbp),%rdi
lea    0xdc2(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1296 <main+0x146>
lea    0xdab(%rip),%rdi
call   1040 <puts@plt>
jmp    12c5 <main+0x175>
movsbl -0x70(%rbp),%eax
cmp    $0x2d,%eax
jne    12b4 <main+0x164>
lea    0xd98(%rip),%rdi
call   1040 <puts@plt>
jmp    12c0 <main+0x170>
lea    0xd97(%rip),%rdi
call   1040 <puts@plt>
jmp    12c5 <main+0x175>
jmp    12d6 <main+0x186>
lea    0xd92(%rip),%rdi
call   1040 <puts@plt>
jmp    12db <main+0x18b>
jmp    1464 <main+0x314>
movsbl -0x5(%rbp),%eax
cmp    $0x75,%eax
jne    1453 <main+0x303>
lea    -0x70(%rbp),%rdi
lea    0xd72(%rip),%rsi
lea    -0x74(%rbp),%rdx
call   1070 <sscanf@plt>
cmpl   $0xaaaa,-0x74(%rbp)
jne    13b7 <main+0x267>
movsbl -0x70(%rbp),%eax
cmp    $0x30,%eax
jne    1339 <main+0x1e9>
movsbl -0x6f(%rbp),%eax
cmp    $0x78,%eax
je     1339 <main+0x1e9>
lea    0xd3e(%rip),%rdi
call   1040 <puts@plt>
jmp    13b2 <main+0x262>
movsbl -0x70(%rbp),%eax
cmp    $0x2b,%eax
jne    1371 <main+0x221>
movsbl -0x6f(%rbp),%eax
cmp    $0x30,%eax
jne    1371 <main+0x221>
movsbl -0x6e(%rbp),%eax
cmp    $0x78,%eax
je     1371 <main+0x221>
lea    0xd14(%rip),%rdi
call   1040 <puts@plt>
jmp    13ad <main+0x25d>
movsbl -0x70(%rbp),%eax
cmp    $0x2b,%eax
jne    139c <main+0x24c>
movsbl -0x6f(%rbp),%eax
cmp    $0x30,%eax
je     139c <main+0x24c>
lea    0xcf8(%rip),%rdi
call   1040 <puts@plt>
jmp    13a8 <main+0x258>
lea    0xcf7(%rip),%rdi
call   1040 <puts@plt>
jmp    13ad <main+0x25d>
jmp    13b2 <main+0x262>
jmp    144e <main+0x2fe>
cmpl   $0xffff3233,-0x74(%rbp)
jne    143d <main+0x2ed>
movsbl -0x70(%rbp),%eax
cmp    $0x2d,%eax
jne    13fc <main+0x2ac>
movsbl -0x6f(%rbp),%eax
cmp    $0x30,%eax
jne    13fc <main+0x2ac>
movsbl -0x6e(%rbp),%eax
cmp    $0x78,%eax
je     13fc <main+0x2ac>
lea    0xcb7(%rip),%rdi
call   1040 <puts@plt>
jmp    1438 <main+0x2e8>
movsbl -0x70(%rbp),%eax
cmp    $0x2d,%eax
jne    1427 <main+0x2d7>
movsbl -0x6f(%rbp),%eax
cmp    $0x30,%eax
je     1427 <main+0x2d7>
lea    0xc9b(%rip),%rdi
call   1040 <puts@plt>
jmp    1433 <main+0x2e3>
lea    0xc24(%rip),%rdi
call   1040 <puts@plt>
jmp    1438 <main+0x2e8>
jmp    1449 <main+0x2f9>
lea    0xc84(%rip),%rdi
call   1040 <puts@plt>
jmp    144e <main+0x2fe>
jmp    145f <main+0x30f>
lea    0xc75(%rip),%rdi
call   1040 <puts@plt>
jmp    1464 <main+0x314>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x78,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
lea    0xb(%rsp),%rsi
xor    %edi,%edi
mov    $0x1,%edx
call   1050 <read@plt>
lea    0x10(%rsp),%rsi
xor    %edi,%edi
mov    $0x50,%edx
call   1050 <read@plt>
mov    0xb(%rsp),%al
cmp    $0x75,%al
je     1228 <main+0xe8>
cmp    $0x78,%al
jne    1279 <main+0x139>
lea    0xe56(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
call   1060 <sscanf@plt>
mov    0xc(%rsp),%eax
cmp    $0xffff3233,%eax
je     1285 <main+0x145>
cmp    $0xaaaa,%eax
jne    12b7 <main+0x177>
lea    0xe2c(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1321 <main+0x1e1>
lea    0xe0c(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1345 <main+0x205>
cmpb   $0x2b,0x10(%rsp)
jne    134e <main+0x20e>
lea    0xdf1(%rip),%rdi
jmp    135e <main+0x21e>
lea    0xe3b(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
call   1060 <sscanf@plt>
mov    0xc(%rsp),%eax
cmp    $0xffff3233,%eax
je     12c3 <main+0x183>
cmp    $0xaaaa,%eax
jne    12e4 <main+0x1a4>
mov    0x10(%rsp),%cl
mov    0x11(%rsp),%al
cmp    $0x30,%cl
jne    12ed <main+0x1ad>
cmp    $0x78,%al
je     12ed <main+0x1ad>
lea    0xdf9(%rip),%rdi
jmp    135e <main+0x21e>
lea    0xe4f(%rip),%rdi
jmp    135e <main+0x21e>
lea    0xda7(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     132a <main+0x1ea>
cmpb   $0x2d,0x10(%rsp)
jne    1318 <main+0x1d8>
lea    0xd90(%rip),%rdi
jmp    135e <main+0x21e>
lea    0xda5(%rip),%rdi
jmp    135e <main+0x21e>
mov    0x10(%rsp),%cl
mov    0x11(%rsp),%al
cmp    $0x2d,%cl
jne    1306 <main+0x1c6>
cmp    $0x30,%al
jne    1306 <main+0x1c6>
cmpb   $0x78,0x12(%rsp)
je     1306 <main+0x1c6>
lea    0xdc7(%rip),%rdi
jmp    135e <main+0x21e>
lea    0xddd(%rip),%rdi
jmp    135e <main+0x21e>
cmp    $0x2b,%cl
jne    1333 <main+0x1f3>
cmp    $0x30,%al
jne    1333 <main+0x1f3>
cmpb   $0x78,0x12(%rsp)
je     1333 <main+0x1f3>
lea    0xd77(%rip),%rdi
jmp    135e <main+0x21e>
cmp    $0x2d,%cl
jne    1318 <main+0x1d8>
cmp    $0x30,%al
je     1318 <main+0x1d8>
lea    0xda2(%rip),%rdi
jmp    135e <main+0x21e>
lea    0xd33(%rip),%rdi
jmp    135e <main+0x21e>
lea    0xce2(%rip),%rdi
jmp    135e <main+0x21e>
lea    0xd06(%rip),%rdi
jmp    135e <main+0x21e>
cmp    $0x2b,%cl
jne    1357 <main+0x217>
cmp    $0x30,%al
je     1357 <main+0x217>
lea    0xd47(%rip),%rdi
jmp    135e <main+0x21e>
lea    0xcbd(%rip),%rdi
jmp    135e <main+0x21e>
lea    0xccf(%rip),%rdi
jmp    135e <main+0x21e>
lea    0xd3c(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x78,%rsp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%07x\00"
@.str.1 = [3 x i8] c"0x\00"
@.str.2 = [10 x i8] c"0x worked\00"
@.str.3 = [4 x i8] c"+0x\00"
@.str.4 = [11 x i8] c"+0x worked\00"
@.str.5 = [16 x i8] c"base +16 worked\00"
@.str.6 = [15 x i8] c"base 16 worked\00"
@.str.7 = [4 x i8] c"-0x\00"
@.str.8 = [11 x i8] c"-0x worked\00"
@.str.9 = [16 x i8] c"base -16 worked\00"
@.str.10 = [17 x i8] c"shouldn't happen\00"
@.str.11 = [7 x i8] c"Nope x\00"
@.str.12 = [3 x i8] c"%u\00"
@.str.13 = [14 x i8] c"base 8 worked\00"
@.str.14 = [15 x i8] c"base +8 worked\00"
@.str.15 = [16 x i8] c"base +10 worked\00"
@.str.16 = [15 x i8] c"base 10 worked\00"
@.str.17 = [15 x i8] c"base -8 worked\00"
@.str.18 = [16 x i8] c"base -10 worked\00"
@.str.19 = [7 x i8] c"Nope u\00"
@.str.20 = [10 x i8] c"No switch\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [100 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [100 x i8]* %3 to i8*
%6 = call i32 @read(i32 0, i8* %2, i32 1)
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = call i32 @read(i32 0, i8* %7, i32 80)
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 120
br i1 %11, label %12, label %65
12: ; preds = %0
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%14 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %4)
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 43690
br i1 %16, label %17, label %41
17: ; preds = %12
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%19 = call i64 @strncmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @puts(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %40
23: ; preds = %17
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%25 = call i64 @strncmp(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = call i32 @puts(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %39
29: ; preds = %23
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 43
br i1 %33, label %34, label %36
34: ; preds = %29
%35 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
br label %38
36: ; preds = %29
%37 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %38
38: ; preds = %36, %34
br label %39
39: ; preds = %38, %27
br label %40
40: ; preds = %39, %21
br label %64
41: ; preds = %12
%42 = load i32, i32* %4
%43 = icmp eq i32 %42, -52685
br i1 %43, label %44, label %61
44: ; preds = %41
%45 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%46 = call i64 @strncmp(i8* %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 3)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = call i32 @puts(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
br label %60
50: ; preds = %44
%51 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 45
br i1 %54, label %55, label %57
55: ; preds = %50
%56 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
br label %59
57: ; preds = %50
%58 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
br label %59
59: ; preds = %57, %55
br label %60
60: ; preds = %59, %48
br label %63
61: ; preds = %41
%62 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
br label %63
63: ; preds = %61, %60
br label %64
64: ; preds = %63, %40
br label %163
65: ; preds = %0
%66 = load i8, i8* %2
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 117
br i1 %68, label %69, label %160
69: ; preds = %65
%70 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%71 = call i32 @sscanf(i8* %70, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i32* %4)
%72 = load i32, i32* %4
%73 = icmp eq i32 %72, 43690
br i1 %73, label %74, label %120
74: ; preds = %69
%75 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 48
br i1 %78, label %79, label %86
79: ; preds = %74
%80 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 1
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = icmp ne i32 %82, 120
br i1 %83, label %84, label %86
84: ; preds = %79
%85 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0))
br label %119
86: ; preds = %79, %74
%87 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = icmp eq i32 %89, 43
br i1 %90, label %91, label %103
91: ; preds = %86
%92 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 1
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = icmp eq i32 %94, 48
br i1 %95, label %96, label %103
96: ; preds = %91
%97 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 2
%98 = load i8, i8* %97
%99 = sext i8 %98 to i32
%100 = icmp ne i32 %99, 120
br i1 %100, label %101, label %103
101: ; preds = %96
%102 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.14, i64 0, i64 0))
br label %118
103: ; preds = %96, %91, %86
%104 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%105 = load i8, i8* %104
%106 = sext i8 %105 to i32
%107 = icmp eq i32 %106, 43
br i1 %107, label %108, label %115
108: ; preds = %103
%109 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 1
%110 = load i8, i8* %109
%111 = sext i8 %110 to i32
%112 = icmp ne i32 %111, 48
br i1 %112, label %113, label %115
113: ; preds = %108
%114 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.15, i64 0, i64 0))
br label %117
115: ; preds = %108, %103
%116 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.16, i64 0, i64 0))
br label %117
117: ; preds = %115, %113
br label %118
118: ; preds = %117, %101
br label %119
119: ; preds = %118, %84
br label %159
120: ; preds = %69
%121 = load i32, i32* %4
%122 = icmp eq i32 %121, -52685
br i1 %122, label %123, label %156
123: ; preds = %120
%124 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%125 = load i8, i8* %124
%126 = sext i8 %125 to i32
%127 = icmp eq i32 %126, 45
br i1 %127, label %128, label %140
128: ; preds = %123
%129 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 1
%130 = load i8, i8* %129
%131 = sext i8 %130 to i32
%132 = icmp eq i32 %131, 48
br i1 %132, label %133, label %140
133: ; preds = %128
%134 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 2
%135 = load i8, i8* %134
%136 = sext i8 %135 to i32
%137 = icmp ne i32 %136, 120
br i1 %137, label %138, label %140
138: ; preds = %133
%139 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.17, i64 0, i64 0))
br label %155
140: ; preds = %133, %128, %123
%141 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%142 = load i8, i8* %141
%143 = sext i8 %142 to i32
%144 = icmp eq i32 %143, 45
br i1 %144, label %145, label %152
145: ; preds = %140
%146 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 1
%147 = load i8, i8* %146
%148 = sext i8 %147 to i32
%149 = icmp ne i32 %148, 48
br i1 %149, label %150, label %152
150: ; preds = %145
%151 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.18, i64 0, i64 0))
br label %154
152: ; preds = %145, %140
%153 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
br label %154
154: ; preds = %152, %150
br label %155
155: ; preds = %154, %138
br label %158
156: ; preds = %120
%157 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0))
br label %158
158: ; preds = %156, %155
br label %159
159: ; preds = %158, %119
br label %162
160: ; preds = %65
%161 = call i32 @puts(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.20, i64 0, i64 0))
br label %162
162: ; preds = %160, %159
br label %163
163: ; preds = %162, %64
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%07x\00"
@.str.1 = [3 x i8] c"0x\00"
@.str.2 = [10 x i8] c"0x worked\00"
@.str.3 = [4 x i8] c"+0x\00"
@.str.4 = [11 x i8] c"+0x worked\00"
@.str.5 = [16 x i8] c"base +16 worked\00"
@.str.6 = [15 x i8] c"base 16 worked\00"
@.str.7 = [4 x i8] c"-0x\00"
@.str.8 = [11 x i8] c"-0x worked\00"
@.str.9 = [16 x i8] c"base -16 worked\00"
@.str.10 = [17 x i8] c"shouldn't happen\00"
@.str.11 = [7 x i8] c"Nope x\00"
@.str.12 = [3 x i8] c"%u\00"
@.str.13 = [14 x i8] c"base 8 worked\00"
@.str.14 = [15 x i8] c"base +8 worked\00"
@.str.15 = [16 x i8] c"base +10 worked\00"
@.str.16 = [15 x i8] c"base 10 worked\00"
@.str.17 = [15 x i8] c"base -8 worked\00"
@.str.18 = [16 x i8] c"base -10 worked\00"
@.str.19 = [7 x i8] c"Nope u\00"
@.str.20 = [10 x i8] c"No switch\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = bitcast i32* %3 to i8*
%6 = call i32 @read(i32 0, i8* %1, i32 1)
%7 = call i32 @read(i32 0, i8* %4, i32 80)
%8 = load i8, i8* %1
switch i8 %8, label %94 [
i8 120, label %9
i8 117, label %43
]
9: ; preds = %0
%10 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
switch i32 %11, label %41 [
i32 43690, label %12
i32 -52685, label %29
]
12: ; preds = %9
%13 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %96
17: ; preds = %12
%18 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %96
22: ; preds = %17
%23 = load i8, i8* %4
%24 = icmp eq i8 %23, 43
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
br label %96
27: ; preds = %22
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %96
29: ; preds = %9
%30 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 3)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
br label %96
34: ; preds = %29
%35 = load i8, i8* %4
%36 = icmp eq i8 %35, 45
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
br label %96
39: ; preds = %34
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
br label %96
41: ; preds = %9
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
br label %96
43: ; preds = %0
%44 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i32* %3)
%45 = load i32, i32* %3
switch i32 %45, label %92 [
i32 43690, label %46
i32 -52685, label %72
]
46: ; preds = %43
%47 = load i8, i8* %4
%48 = icmp eq i8 %47, 48
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 1
%50 = load i8, i8* %49
%51 = icmp ne i8 %50, 120
%52 = select i1 %48, i1 %51, i1 false
br i1 %52, label %53, label %55
53: ; preds = %46
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0))
br label %96
55: ; preds = %46
%56 = icmp eq i8 %47, 43
%57 = icmp eq i8 %50, 48
%58 = select i1 %56, i1 %57, i1 false
%59 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 2
%60 = load i8, i8* %59
%61 = icmp ne i8 %60, 120
%62 = select i1 %58, i1 %61, i1 false
br i1 %62, label %63, label %65
63: ; preds = %55
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.14, i64 0, i64 0))
br label %96
65: ; preds = %55
%66 = icmp ne i8 %50, 48
%67 = select i1 %56, i1 %66, i1 false
br i1 %67, label %68, label %70
68: ; preds = %65
%69 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.15, i64 0, i64 0))
br label %96
70: ; preds = %65
%71 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.16, i64 0, i64 0))
br label %96
72: ; preds = %43
%73 = load i8, i8* %4
%74 = icmp eq i8 %73, 45
%75 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 1
%76 = load i8, i8* %75
%77 = icmp eq i8 %76, 48
%78 = select i1 %74, i1 %77, i1 false
%79 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 2
%80 = load i8, i8* %79
%81 = icmp ne i8 %80, 120
%82 = select i1 %78, i1 %81, i1 false
br i1 %82, label %83, label %85
83: ; preds = %72
%84 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.17, i64 0, i64 0))
br label %96
85: ; preds = %72
%86 = icmp ne i8 %76, 48
%87 = select i1 %74, i1 %86, i1 false
br i1 %87, label %88, label %90
88: ; preds = %85
%89 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.18, i64 0, i64 0))
br label %96
90: ; preds = %85
%91 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
br label %96
92: ; preds = %43
%93 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0))
br label %96
94: ; preds = %0
%95 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.20, i64 0, i64 0))
br label %96
96: ; preds = %94, %92, %88, %90, %83, %53, %68, %70, %63, %20, %27, %25, %15, %32, %39, %37, %41
ret i32 0
}