#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*/ flushall();
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
main() {
  char num1;
  printf("\t\tWelcome to your student timetable!\n");
  printf("\t\tPlease choose a day by typing the letter beside the day:\n");
  printf("(a)\tMonday\n");
  printf("(b)\tTuesday\n");
  printf("(c)\tWednesday\n");
  printf("(d)\tThursday\n");
  printf("(e)\tFriday\n");
  scanf("%c", &num1);
  flushall();
  switch (num1) {
  case 'a': {
    printf("Mon");
    break;
  }
  case 'b': {
    printf("Tues");
    break;
  }
  case 'c': {
    printf("Wed");
    break;
  }
  case 'd': {
    printf("Thurs");
    break;
  }
  case 'e': {
    printf("Fri");
    break;
  }
  default: {
    printf("Not a choice, please try again..");
  }
  }
  getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
lea    0xf08(%rip),%rdi
call   1030 <printf@plt>
lea    0xf08(%rip),%rdi
call   1030 <printf@plt>
lea    0xf09(%rip),%rdi
call   1030 <printf@plt>
lea    0xf0c(%rip),%rdi
call   1030 <printf@plt>
lea    0xf0e(%rip),%rdi
call   1030 <printf@plt>
lea    0xf0e(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1040 <flushall@plt>
movsbl -0x5(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x4,%eax
ja     1239 <main+0xf9>
mov    -0x10(%rbp),%rax
lea    0xe25(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
jmp    1245 <main+0x105>
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
jmp    1245 <main+0x105>
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
jmp    1245 <main+0x105>
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
jmp    1245 <main+0x105>
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
jmp    1245 <main+0x105>
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
lea    0xefc(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2b(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2a(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2a(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2c(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe54(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <flushall@plt>
movsbq 0x7(%rsp),%rax
add    $0xffffffffffffff9f,%rax
cmp    $0x4,%eax
ja     11dc <main+0x8c>
lea    0xf05(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    11e3 <main+0x93>
lea    0xe37(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"\09\09Welcome to your student timetable!\0A\00"
@.str.1 = [60 x i8] c"\09\09Please choose a day by typing the letter beside the day:\0A\00"
@.str.2 = [12 x i8] c"(a)\09Monday\0A\00"
@.str.3 = [13 x i8] c"(b)\09Tuesday\0A\00"
@.str.4 = [15 x i8] c"(c)\09Wednesday\0A\00"
@.str.5 = [14 x i8] c"(d)\09Thursday\0A\00"
@.str.6 = [12 x i8] c"(e)\09Friday\0A\00"
@.str.7 = [3 x i8] c"%c\00"
@.str.8 = [4 x i8] c"Mon\00"
@.str.9 = [5 x i8] c"Tues\00"
@.str.10 = [4 x i8] c"Wed\00"
@.str.11 = [6 x i8] c"Thurs\00"
@.str.12 = [4 x i8] c"Fri\00"
@.str.13 = [33 x i8] c"Not a choice, please try again..\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %2)
%11 = call i32 (...) @flushall()
%12 = load i8, i8* %2
%13 = sext i8 %12 to i32
switch i32 %13, label %24 [
i32 97, label %14
i32 98, label %16
i32 99, label %18
i32 100, label %20
i32 101, label %22
]
14: ; preds = %0
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
br label %26
16: ; preds = %0
%17 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %26
18: ; preds = %0
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
br label %26
20: ; preds = %0
%21 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
br label %26
22: ; preds = %0
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
br label %26
24: ; preds = %0
%25 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.13, i64 0, i64 0))
br label %26
26: ; preds = %24, %22, %20, %18, %16, %14
%27 = call i32 (...) @getchar()
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@.str.7 = [3 x i8] c"%c\00"
@.str.8 = [4 x i8] c"Mon\00"
@.str.9 = [5 x i8] c"Tues\00"
@.str.10 = [4 x i8] c"Wed\00"
@.str.11 = [6 x i8] c"Thurs\00"
@.str.12 = [4 x i8] c"Fri\00"
@.str.13 = [33 x i8] c"Not a choice, please try again..\00"
@str = [37 x i8] c"\09\09Welcome to your student timetable!\00"
@str.14 = [59 x i8] c"\09\09Please choose a day by typing the letter beside the day:\00"
@str.15 = [11 x i8] c"(a)\09Monday\00"
@str.16 = [12 x i8] c"(b)\09Tuesday\00"
@str.17 = [14 x i8] c"(c)\09Wednesday\00"
@str.18 = [13 x i8] c"(d)\09Thursday\00"
@str.19 = [11 x i8] c"(e)\09Friday\00"
@reltable.main = [5 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.8 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.9 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.10 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.11 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.12 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32)]
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.14, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.15, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.16, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.17, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.18, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.19, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %1)
%10 = call i32 (...) @flushall()
%11 = load i8, i8* %1
%12 = sext i8 %11 to i32
%13 = add nsw i32 %12, -97
%14 = icmp ult i32 %13, 5
br i1 %14, label %15, label %19
15: ; preds = %0
%16 = sext i32 %13 to i64
%17 = shl i64 %16, 2
%18 = call i8* @llvm.load.relative.i64(i8* bitcast ([5 x i32]* @reltable.main to i8*), i64 %17)
br label %19
19: ; preds = %0, %15
%20 = phi i8* [ %18, %15 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.13, i64 0, i64 0), %0 ]
%21 = call i32 @printf(i8* dereferenceable(1) %20)
%22 = call i32 (...) @getchar()
ret i32 0
}