#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 *, int *);
void main(void) {
  int weekday;
  printf("enter a weekday number: \n");
  scanf("%d", &weekday);
  switch (weekday) {
  case 0:
    printf("monday");
    break;
  case 1:
    printf("tuesday");
    break;
  case 2:
    printf("wednesday");
    break;
  case 3:
    printf("thursday");
    break;
  case 4:
    printf("friday");
    break;
  case 5:
    printf("saturday");
    break;
  case 6:
    printf("sunday");
    break;
  default:
    printf("enter valid input");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeed(%rip),%rdi
call   1030 <printf@plt>
lea    0xefb(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x6,%rax
ja     11e0 <main+0xc0>
mov    -0x10(%rbp),%rax
lea    0xea0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xec9(%rip),%rdi
call   1030 <printf@plt>
jmp    11ec <main+0xcc>
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
jmp    11ec <main+0xcc>
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
jmp    11ec <main+0xcc>
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
jmp    11ec <main+0xcc>
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
jmp    11ec <main+0xcc>
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
jmp    11ec <main+0xcc>
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
jmp    11ec <main+0xcc>
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf16(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
movslq 0x4(%rsp),%rax
cmp    $0x6,%rax
ja     1169 <main+0x39>
lea    0xf08(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    1170 <main+0x40>
lea    0xecc(%rip),%rdi
call   1040 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [26 x i8] c"enter a weekday number: \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [7 x i8] c"monday\00"
@.str.3 = [8 x i8] c"tuesday\00"
@.str.4 = [10 x i8] c"wednesday\00"
@.str.5 = [9 x i8] c"thursday\00"
@.str.6 = [7 x i8] c"friday\00"
@.str.7 = [9 x i8] c"saturday\00"
@.str.8 = [7 x i8] c"sunday\00"
@.str.9 = [18 x i8] c"enter valid input\00"
define void @main() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 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), i32* %1)
%4 = load i32, i32* %1
switch i32 %4, label %19 [
i32 0, label %5
i32 1, label %7
i32 2, label %9
i32 3, label %11
i32 4, label %13
i32 5, label %15
i32 6, label %17
]
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %21
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %21
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %21
11: ; preds = %0
%12 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %21
13: ; preds = %0
%14 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %21
15: ; preds = %0
%16 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
br label %21
17: ; preds = %0
%18 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
br label %21
19: ; preds = %0
%20 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
br label %21
21: ; preds = %19, %17, %15, %13, %11, %9, %7, %5
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [7 x i8] c"monday\00"
@.str.3 = [8 x i8] c"tuesday\00"
@.str.4 = [10 x i8] c"wednesday\00"
@.str.5 = [9 x i8] c"thursday\00"
@.str.6 = [7 x i8] c"friday\00"
@.str.7 = [9 x i8] c"saturday\00"
@.str.8 = [7 x i8] c"sunday\00"
@.str.9 = [18 x i8] c"enter valid input\00"
@str = [25 x i8] c"enter a weekday number: \00"
@reltable.main = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.4 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.6 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.7 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.8 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32)]
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 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), i32* %1)
%5 = load i32, i32* %1
%6 = icmp ult i32 %5, 7
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = sext i32 %5 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.main to i8*), i64 %9)
br label %11
11: ; preds = %0, %7
%12 = phi i8* [ %10, %7 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), %0 ]
%13 = call i32 @printf(i8* dereferenceable(1) %12)
ret void
}