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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
call   1050 <getc@plt>
mov    %eax,-0x8(%rbp)
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x61,%eax
je     118d <main+0x5d>
jmp    117c <main+0x4c>
mov    -0xc(%rbp),%eax
sub    $0x62,%eax
je     1199 <main+0x69>
jmp    11aa <main+0x7a>
lea    0xe82(%rip),%rdi
call   1030 <puts@plt>
lea    0xe82(%rip),%rdi
call   1030 <puts@plt>
jmp    11b6 <main+0x86>
lea    0xe7d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xeb6(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
call   1060 <getc@plt>
mov    %eax,%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xeb0(%rip),%rbx
cmp    $0x62,%ebp
je     118f <main+0x4f>
cmp    $0x61,%ebp
jne    1188 <main+0x48>
lea    0xe93(%rip),%rdi
call   1040 <puts@plt>
jmp    118f <main+0x4f>
lea    0xe9d(%rip),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
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 = [12 x i8] c"Stuff for a\00"
@.str.3 = [12 x i8] c"Stuff for b\00"
@.str.4 = [26 x i8] c"Stuff for everything else\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 @puts(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %0, %8
%11 = call i32 @puts(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %14
12: ; preds = %0
%13 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %14
14: ; preds = %12, %10
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter a character: \00"
@stdin = global i32 0
@.str.2 = [12 x i8] c"Stuff for a\00"
@.str.3 = [12 x i8] c"Stuff for b\00"
@.str.4 = [26 x i8] c"Stuff for everything else\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 %7 [
i32 97, label %5
i32 98, label %8
]
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %8
7: ; preds = %0
br label %8
8: ; preds = %5, %0, %7
%9 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), %7 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), %0 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), %5 ]
%10 = tail call i32 @puts(i8* dereferenceable(1) %9)
ret i32 0
}