#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 myChar;
  printf("Print a character: ");
  scanf("%c", myChar);
  switch (myChar) {
  case 'A':
    printf("Hello.\n");
    break;
  case 'B':
    printf("Happy Birthday.\n");
    break;
  case 'C':
    printf("Welcome.\n");
    break;
  default:
    printf("Not a recognized character.");
    break;
  };
  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>
movsbl -0x5(%rbp),%esi
lea    0xece(%rip),%rdi
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x41,%eax
je     1182 <main+0x62>
jmp    1160 <main+0x40>
mov    -0xc(%rbp),%eax
sub    $0x42,%eax
je     1193 <main+0x73>
jmp    1171 <main+0x51>
mov    -0xc(%rbp),%eax
sub    $0x43,%eax
je     11a4 <main+0x84>
jmp    11b5 <main+0x95>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
jmp    11c1 <main+0xa1>
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
jmp    11c1 <main+0xa1>
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
jmp    11c1 <main+0xa1>
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
xor    %esi,%esi
call   1040 <scanf@plt>
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Print a character: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [8 x i8] c"Hello.\0A\00"
@.str.3 = [17 x i8] c"Happy Birthday.\0A\00"
@.str.4 = [10 x i8] c"Welcome.\0A\00"
@.str.5 = [28 x i8] c"Not a recognized character.\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 = load i8, i8* %2
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %4)
%6 = load i8, i8* %2
%7 = sext i8 %6 to i32
switch i32 %7, label %14 [
i32 65, label %8
i32 66, label %10
i32 67, label %12
]
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %16
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %16
12: ; preds = %0
%13 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %16
14: ; preds = %0
%15 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %16
16: ; preds = %14, %12, %10, %8
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Print a character: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.5 = [28 x i8] c"Not a recognized 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 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext undef)
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}