#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*/ scanf(char *, unsigned int *);
int main() {
  char swch;
  char test[100] = {0};
  unsigned int val;
  read(0, &swch, 1);
  if (swch == 'x') {
    scanf("%07x", &val);
    if (val == 0xaaaa) {
      puts("%%07x");
    } else if (val == -0xcdcd) {
      puts("%%07x and negative numbers");
    } else {
      puts("nope 0");
    }
  } else if (swch == 'd') {
    scanf("%d", &val);
    if (val == 133337) {
      puts("%%d");
    } else if (val == -1337) {
      puts("%%d and negative numbers");
    } else {
      puts("nope 1");
    }
  } else if (swch == 'u') {
    scanf("%u", &val);
    if (val == 0xaaaa) {
      puts("%%u");
    } else if (val == -0xcdcd) {
      puts("%%u and negative numbers");
    } else {
      puts("nope 2");
    }
  } else {
    puts("Unsupported 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   1040 <memset@plt>
xor    %edi,%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1050 <read@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x78,%eax
jne    11e1 <main+0xa1>
lea    0xe7b(%rip),%rdi
lea    -0x74(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0xaaaa,-0x74(%rbp)
jne    11ad <main+0x6d>
lea    0xe5d(%rip),%rdi
call   1030 <puts@plt>
jmp    11dc <main+0x9c>
cmpl   $0xffff3233,-0x74(%rbp)
jne    11cb <main+0x8b>
lea    0xe45(%rip),%rdi
call   1030 <puts@plt>
jmp    11d7 <main+0x97>
lea    0xe4f(%rip),%rdi
call   1030 <puts@plt>
jmp    11dc <main+0x9c>
jmp    12d5 <main+0x195>
movsbl -0x5(%rbp),%eax
cmp    $0x64,%eax
jne    1250 <main+0x110>
lea    0xe34(%rip),%rdi
lea    -0x74(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x208d9,-0x74(%rbp)
jne    121c <main+0xdc>
lea    0xe16(%rip),%rdi
call   1030 <puts@plt>
jmp    124b <main+0x10b>
cmpl   $0xfffffac7,-0x74(%rbp)
jne    123a <main+0xfa>
lea    0xdfc(%rip),%rdi
call   1030 <puts@plt>
jmp    1246 <main+0x106>
lea    0xe04(%rip),%rdi
call   1030 <puts@plt>
jmp    124b <main+0x10b>
jmp    12d0 <main+0x190>
movsbl -0x5(%rbp),%eax
cmp    $0x75,%eax
jne    12bf <main+0x17f>
lea    0xde9(%rip),%rdi
lea    -0x74(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0xaaaa,-0x74(%rbp)
jne    128b <main+0x14b>
lea    0xdcb(%rip),%rdi
call   1030 <puts@plt>
jmp    12ba <main+0x17a>
cmpl   $0xffff3233,-0x74(%rbp)
jne    12a9 <main+0x169>
lea    0xdb1(%rip),%rdi
call   1030 <puts@plt>
jmp    12b5 <main+0x175>
lea    0xdb9(%rip),%rdi
call   1030 <puts@plt>
jmp    12ba <main+0x17a>
jmp    12cb <main+0x18b>
lea    0xdaa(%rip),%rdi
call   1030 <puts@plt>
jmp    12d0 <main+0x190>
jmp    12d5 <main+0x195>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0x3(%rsp),%rsi
xor    %edi,%edi
mov    $0x1,%edx
call   1040 <read@plt>
mov    0x3(%rsp),%al
cmp    $0x64,%al
je     1185 <main+0x55>
cmp    $0x75,%al
je     11b1 <main+0x81>
cmp    $0x78,%al
jne    11dd <main+0xad>
lea    0xea4(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0xffff3233,%eax
je     11e6 <main+0xb6>
cmp    $0xaaaa,%eax
jne    11ef <main+0xbf>
lea    0xe80(%rip),%rdi
jmp    121a <main+0xea>
lea    0xe9d(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0xfffffac7,%eax
je     11f8 <main+0xc8>
cmp    $0x208d9,%eax
jne    1201 <main+0xd1>
lea    0xe79(%rip),%rdi
jmp    121a <main+0xea>
lea    0xe95(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0xffff3233,%eax
je     120a <main+0xda>
cmp    $0xaaaa,%eax
jne    1213 <main+0xe3>
lea    0xe71(%rip),%rdi
jmp    121a <main+0xea>
lea    0xe8c(%rip),%rdi
jmp    121a <main+0xea>
lea    0xe19(%rip),%rdi
jmp    121a <main+0xea>
lea    0xe2b(%rip),%rdi
jmp    121a <main+0xea>
lea    0xe2d(%rip),%rdi
jmp    121a <main+0xea>
lea    0xe3d(%rip),%rdi
jmp    121a <main+0xea>
lea    0xe3f(%rip),%rdi
jmp    121a <main+0xea>
lea    0xe4f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%07x\00"
@.str.1 = [6 x i8] c"%%07x\00"
@.str.2 = [27 x i8] c"%%07x and negative numbers\00"
@.str.3 = [7 x i8] c"nope 0\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [4 x i8] c"%%d\00"
@.str.6 = [25 x i8] c"%%d and negative numbers\00"
@.str.7 = [7 x i8] c"nope 1\00"
@.str.8 = [3 x i8] c"%u\00"
@.str.9 = [4 x i8] c"%%u\00"
@.str.10 = [25 x i8] c"%%u and negative numbers\00"
@.str.11 = [7 x i8] c"nope 2\00"
@.str.12 = [19 x i8] c"Unsupported 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 = load i8, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 120
br i1 %9, label %10, label %25
10: ; preds = %0
%11 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %4)
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 43690
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %24
16: ; preds = %10
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, -52685
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %23
21: ; preds = %16
%22 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
br label %24
24: ; preds = %23, %14
br label %67
25: ; preds = %0
%26 = load i8, i8* %2
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 100
br i1 %28, label %29, label %44
29: ; preds = %25
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%31 = load i32, i32* %4
%32 = icmp eq i32 %31, 133337
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = call i32 @puts(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %43
35: ; preds = %29
%36 = load i32, i32* %4
%37 = icmp eq i32 %36, -1337
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
br label %42
40: ; preds = %35
%41 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %42
42: ; preds = %40, %38
br label %43
43: ; preds = %42, %33
br label %66
44: ; preds = %25
%45 = load i8, i8* %2
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 117
br i1 %47, label %48, label %63
48: ; preds = %44
%49 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %4)
%50 = load i32, i32* %4
%51 = icmp eq i32 %50, 43690
br i1 %51, label %52, label %54
52: ; preds = %48
%53 = call i32 @puts(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
br label %62
54: ; preds = %48
%55 = load i32, i32* %4
%56 = icmp eq i32 %55, -52685
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0))
br label %61
59: ; preds = %54
%60 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
br label %61
61: ; preds = %59, %57
br label %62
62: ; preds = %61, %52
br label %65
63: ; preds = %44
%64 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
br label %65
65: ; preds = %63, %62
br label %66
66: ; preds = %65, %43
br label %67
67: ; preds = %66, %24
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%07x\00"
@.str.1 = [6 x i8] c"%%07x\00"
@.str.2 = [27 x i8] c"%%07x and negative numbers\00"
@.str.3 = [7 x i8] c"nope 0\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [4 x i8] c"%%d\00"
@.str.6 = [25 x i8] c"%%d and negative numbers\00"
@.str.7 = [7 x i8] c"nope 1\00"
@.str.8 = [3 x i8] c"%u\00"
@.str.9 = [4 x i8] c"%%u\00"
@.str.10 = [25 x i8] c"%%u and negative numbers\00"
@.str.11 = [7 x i8] c"nope 2\00"
@.str.12 = [19 x i8] c"Unsupported switch\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @read(i32 0, i8* %1, i32 1)
%5 = load i8, i8* %1
switch i8 %5, label %33 [
i8 120, label %6
i8 100, label %15
i8 117, label %24
]
6: ; preds = %0
%7 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
switch i32 %8, label %13 [
i32 43690, label %9
i32 -52685, label %11
]
9: ; preds = %6
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %35
11: ; preds = %6
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %35
13: ; preds = %6
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %35
15: ; preds = %0
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%17 = load i32, i32* %2
switch i32 %17, label %22 [
i32 133337, label %18
i32 -1337, label %20
]
18: ; preds = %15
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %35
20: ; preds = %15
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
br label %35
22: ; preds = %15
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %35
24: ; preds = %0
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %2)
%26 = load i32, i32* %2
switch i32 %26, label %31 [
i32 43690, label %27
i32 -52685, label %29
]
27: ; preds = %24
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
br label %35
29: ; preds = %24
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0))
br label %35
31: ; preds = %24
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
br label %35
33: ; preds = %0
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
br label %35
35: ; preds = %20, %22, %18, %27, %31, %29, %33, %9, %13, %11
ret i32 0
}