#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char ch;
  printf("Enter a character: ");
  scanf("%c", &ch);
  if (ch == '+')
    printf("You typed a plus sign.\n");
  else if (ch == '-')
    printf("You typed a minus sign.\n");
  else if (ch == ' ')
    printf("You typed a space.\n");
  else if (ch == '!')
    printf("You typed a bang.\n");
  else
    printf("You typed something else.\n");
  switch (ch) {
  case '+':
    printf("You typed a plus sign.\n");
    break;
  case '-':
    printf("You typed a minus sign.\n");
    break;
  case ' ':
    printf("You typed a space.\n");
    break;
  case '!':
    printf("You typed a bang.\n");
    break;
  default:
    printf("You typed something else.\n");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xf02(%rip),%rdi
call   1030 <printf@plt>
lea    0xf0a(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x2b,%eax
jne    1169 <main+0x49>
lea    0xef0(%rip),%rdi
call   1030 <printf@plt>
jmp    11de <main+0xbe>
movsbl -0x5(%rbp),%eax
cmp    $0x2d,%eax
jne    1187 <main+0x67>
lea    0xeea(%rip),%rdi
call   1030 <printf@plt>
jmp    11d9 <main+0xb9>
movsbl -0x5(%rbp),%eax
cmp    $0x20,%eax
jne    11a5 <main+0x85>
lea    0xee5(%rip),%rdi
call   1030 <printf@plt>
jmp    11d4 <main+0xb4>
movsbl -0x5(%rbp),%eax
cmp    $0x21,%eax
jne    11c3 <main+0xa3>
lea    0xedb(%rip),%rdi
call   1030 <printf@plt>
jmp    11cf <main+0xaf>
lea    0xedd(%rip),%rdi
call   1030 <printf@plt>
jmp    11d4 <main+0xb4>
jmp    11d9 <main+0xb9>
jmp    11de <main+0xbe>
movsbl -0x5(%rbp),%eax
add    $0xffffffe0,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0xd,%eax
ja     124c <main+0x12c>
mov    -0x10(%rbp),%rax
lea    0xe01(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe40(%rip),%rdi
call   1030 <printf@plt>
jmp    1258 <main+0x138>
lea    0xe47(%rip),%rdi
call   1030 <printf@plt>
jmp    1258 <main+0x138>
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
jmp    1258 <main+0x138>
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
jmp    1258 <main+0x138>
lea    0xe54(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xf34(%rip),%rdi
call   1040 <printf@plt>
lea    0xf3c(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xf85(%rip),%rbx
mov    0xf(%rsp),%al
add    $0xe0,%al
cmp    $0xd,%al
ja     118b <main+0x5b>
movzbl %al,%eax
lea    0xe93(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
mov    %rbx,%rdi
jmp    *%rax
lea    0xf33(%rip),%rdi
jmp    119b <main+0x6b>
lea    0xf18(%rip),%rdi
jmp    119b <main+0x6b>
lea    0xef5(%rip),%rdi
jmp    119b <main+0x6b>
lea    0xf2b(%rip),%rdi
call   1030 <puts@plt>
movsbl 0xf(%rsp),%eax
add    $0xffffffe0,%eax
cmp    $0xd,%eax
ja     11cf <main+0x9f>
lea    0xe84(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeef(%rip),%rbx
jmp    11df <main+0xaf>
lea    0xed4(%rip),%rbx
jmp    11df <main+0xaf>
lea    0xeb1(%rip),%rbx
jmp    11df <main+0xaf>
lea    0xee7(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter a character: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [24 x i8] c"You typed a plus sign.\0A\00"
@.str.3 = [25 x i8] c"You typed a minus sign.\0A\00"
@.str.4 = [20 x i8] c"You typed a space.\0A\00"
@.str.5 = [19 x i8] c"You typed a bang.\0A\00"
@.str.6 = [27 x i8] c"You typed something else.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = load i8, i8* %2
%6 = sext i8 %5 to i32
%7 = icmp eq i32 %6, 43
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %33
10: ; preds = %0
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 45
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %32
16: ; preds = %10
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 32
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %31
22: ; preds = %16
%23 = load i8, i8* %2
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 33
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %30
28: ; preds = %22
%29 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
br label %30
30: ; preds = %28, %26
br label %31
31: ; preds = %30, %20
br label %32
32: ; preds = %31, %14
br label %33
33: ; preds = %32, %8
%34 = load i8, i8* %2
%35 = sext i8 %34 to i32
switch i32 %35, label %44 [
i32 43, label %36
i32 45, label %38
i32 32, label %40
i32 33, label %42
]
36: ; preds = %33
%37 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %46
38: ; preds = %33
%39 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %46
40: ; preds = %33
%41 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %46
42: ; preds = %33
%43 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %46
44: ; preds = %33
%45 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
br label %46
46: ; preds = %44, %42, %40, %38, %36
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter a character: \00"
@.str.1 = [3 x i8] c"%c\00"
@str.11 = [26 x i8] c"You typed something else.\00"
@str.12 = [18 x i8] c"You typed a bang.\00"
@str.13 = [19 x i8] c"You typed a space.\00"
@str.14 = [24 x i8] c"You typed a minus sign.\00"
@str.15 = [23 x i8] c"You typed a plus sign.\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%4 = load i8, i8* %1
switch i8 %4, label %8 [
i8 43, label %9
i8 45, label %5
i8 32, label %6
i8 33, label %7
]
5: ; preds = %0
br label %9
6: ; preds = %0
br label %9
7: ; preds = %0
br label %9
8: ; preds = %0
br label %9
9: ; preds = %0, %5, %7, %8, %6
%10 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.14, i64 0, i64 0), %5 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.12, i64 0, i64 0), %7 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @str.11, i64 0, i64 0), %8 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.13, i64 0, i64 0), %6 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.15, i64 0, i64 0), %0 ]
%11 = call i32 @puts(i8* dereferenceable(1) %10)
%12 = load i8, i8* %1
%13 = sext i8 %12 to i32
switch i32 %13, label %17 [
i32 43, label %18
i32 45, label %14
i32 32, label %15
i32 33, label %16
]
14: ; preds = %9
br label %18
15: ; preds = %9
br label %18
16: ; preds = %9
br label %18
17: ; preds = %9
br label %18
18: ; preds = %9, %17, %16, %15, %14
%19 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @str.11, i64 0, i64 0), %17 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.12, i64 0, i64 0), %16 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.13, i64 0, i64 0), %15 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.14, i64 0, i64 0), %14 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.15, i64 0, i64 0), %9 ]
%20 = call i32 @puts(i8* dereferenceable(1) %19)
ret i32 0
}