#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 getc(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int main() {
  printf("Enter a character: ");
  int c = getc(stdin);
  printf("\n");
  switch (c) {
  case 'a':
    printf("You entered a!\n");
    break;
  case 'b':
    printf("You entered b!\n");
    break;
  default:
    printf("Invalid character!\n");
    break;
  }
  if (c == 'a') {
    printf("You entered a!\n");
  } else if (c == 'b') {
    printf("You entered b!\n");
  } else {
    printf("Invalid character!\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
mov    0x2ea6(%rip),%rax
mov    (%rax),%edi
call   1040 <getc@plt>
mov    %eax,-0x8(%rbp)
lea    0xecf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x61,%eax
je     117d <main+0x5d>
jmp    116c <main+0x4c>
mov    -0xc(%rbp),%eax
sub    $0x62,%eax
je     118e <main+0x6e>
jmp    119f <main+0x7f>
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
jmp    11ab <main+0x8b>
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
jmp    11ab <main+0x8b>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x61,-0x8(%rbp)
jne    11c6 <main+0xa6>
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
jmp    11f2 <main+0xd2>
cmpl   $0x62,-0x8(%rbp)
jne    11e1 <main+0xc1>
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
jmp    11ed <main+0xcd>
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
jmp    11f2 <main+0xd2>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xeb8(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
call   1060 <getc@plt>
mov    %eax,%ebx
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    $0x61,%ebx
je     117a <main+0x3a>
cmp    $0x62,%ebx
jne    1183 <main+0x43>
lea    0xe9c(%rip),%rbx
jmp    118a <main+0x4a>
lea    0xea2(%rip),%rbx
jmp    118a <main+0x4a>
lea    0xea8(%rip),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter a character: \00"
@stdin = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [16 x i8] c"You entered a!\0A\00"
@.str.3 = [16 x i8] c"You entered b!\0A\00"
@.str.4 = [20 x i8] c"Invalid character!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32 @getc(i32 %4)
store i32 %5, i32* %2
%6 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* %2
switch i32 %7, label %12 [
i32 97, label %8
i32 98, label %10
]
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %14
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %14
12: ; preds = %0
%13 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %14
14: ; preds = %12, %10, %8
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 97
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %27
19: ; preds = %14
%20 = load i32, i32* %2
%21 = icmp eq i32 %20, 98
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %26
24: ; preds = %19
%25 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %26
26: ; preds = %24, %22
br label %27
27: ; preds = %26, %17
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter a character: \00"
@stdin = global i32 0
@str.6 = [15 x i8] c"You entered b!\00"
@str.8 = [15 x i8] c"You entered a!\00"
@str.9 = [19 x i8] c"Invalid character!\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%2 = load i32, i32* @stdin
%3 = tail call i32 @getc(i32 %2)
%4 = tail call i32 @putchar(i32 10)
switch i32 %3, label %6 [
i32 97, label %7
i32 98, label %5
]
5: ; preds = %0
br label %7
6: ; preds = %0
br label %7
7: ; preds = %0, %5, %6
%8 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.6, i64 0, i64 0), %5 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.9, i64 0, i64 0), %6 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.8, i64 0, i64 0), %0 ]
%9 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.6, i64 0, i64 0), %5 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.9, i64 0, i64 0), %6 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.8, i64 0, i64 0), %0 ]
%10 = tail call i32 @puts(i8* dereferenceable(1) %8)
%11 = tail call i32 @puts(i8* dereferenceable(1) %9)
ret i32 0
}