#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 */
char getchar();
int /*<<< orphan*/ printf(char *);
void main() {
  char letter;
  printf("Please input the first leter of someday\n");
  while ((letter = getchar()) != 'Y') {
    switch (letter) {
    case 'S':
      printf("Please input the second letter\n");
      if ((letter = getchar()) == 'a')
        printf("Saturday\n");
      else if ((letter = getchar()) == 'u')
        printf("Sunday\n");
      else
        printf("data error!\n");
      break;
    case 'T':
      printf("Please input the second letter\n");
      if ('h' == (letter = getchar()))
        printf("Thursday\n");
      else if ('u' == (letter = getchar()))
        printf("Tuesday\n");
      else
        printf("data error\n");
      break;
    case 'M':
      printf("Monday\n");
      break;
    case 'W':
      printf("Wednesday\n");
      break;
    case 'F':
      printf("Friday\n");
      break;
    default:
      printf("data error!\n");
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xf19(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x1(%rbp)
movsbl %al,%eax
cmp    $0x59,%eax
je     12a0 <main+0x180>
movsbl -0x1(%rbp),%eax
add    $0xffffffba,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x11,%eax
ja     128f <main+0x16f>
mov    -0x10(%rbp),%rax
lea    0xe95(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xef6(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x1(%rbp)
movsbl %al,%eax
cmp    $0x61,%eax
jne    11a7 <main+0x87>
lea    0xef4(%rip),%rdi
call   1030 <printf@plt>
jmp    11df <main+0xbf>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x1(%rbp)
movsbl %al,%eax
cmp    $0x75,%eax
jne    11ce <main+0xae>
lea    0xed7(%rip),%rdi
call   1030 <printf@plt>
jmp    11da <main+0xba>
lea    0xece(%rip),%rdi
call   1030 <printf@plt>
jmp    11df <main+0xbf>
jmp    129b <main+0x17b>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x1(%rbp)
movsbl %al,%ecx
mov    $0x68,%eax
cmp    %ecx,%eax
jne    121b <main+0xfb>
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
jmp    1257 <main+0x137>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x1(%rbp)
movsbl %al,%ecx
mov    $0x75,%eax
cmp    %ecx,%eax
jne    1246 <main+0x126>
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
jmp    1252 <main+0x132>
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
jmp    1257 <main+0x137>
jmp    129b <main+0x17b>
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
jmp    129b <main+0x17b>
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
jmp    129b <main+0x17b>
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
jmp    129b <main+0x17b>
lea    0xe0d(%rip),%rdi
call   1030 <printf@plt>
jmp    1134 <main+0x14>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf16(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0x59,%al
jne    1151 <main+0x31>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xf29(%rip),%r12
lea    0xf74(%rip),%r15
lea    0xe9a(%rip),%rbx
lea    0xf37(%rip),%r14
lea    0xf27(%rip),%r13
lea    0xefc(%rip),%rbp
jmp    1193 <main+0x73>
nopl   (%rax)
mov    %r15,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0x59,%al
je     1142 <main+0x22>
movsbl %al,%eax
add    $0xffffffba,%eax
cmp    $0x11,%eax
ja     1180 <main+0x60>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
mov    %r12,%rdi
jmp    *%rax
lea    0xebf(%rip),%rdi
jmp    1183 <main+0x63>
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
lea    0xf01(%rip),%rdi
cmp    $0x61,%al
je     1183 <main+0x63>
xor    %eax,%eax
call   1040 <getchar@plt>
lea    0xee8(%rip),%rdi
cmp    $0x75,%al
jne    1180 <main+0x60>
jmp    1183 <main+0x63>
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %r13,%rdi
cmp    $0x68,%al
je     1183 <main+0x63>
xor    %eax,%eax
call   1040 <getchar@plt>
lea    0xe8e(%rip),%rdi
cmp    $0x75,%al
je     1183 <main+0x63>
lea    0xe74(%rip),%rdi
jmp    1183 <main+0x63>
mov    %rbp,%rdi
jmp    1183 <main+0x63>

LLVM IR (-O0):
@.str = [41 x i8] c"Please input the first leter of someday\0A\00"
@.str.1 = [32 x i8] c"Please input the second letter\0A\00"
@.str.2 = [10 x i8] c"Saturday\0A\00"
@.str.3 = [8 x i8] c"Sunday\0A\00"
@.str.4 = [13 x i8] c"data error!\0A\00"
@.str.5 = [10 x i8] c"Thursday\0A\00"
@.str.6 = [9 x i8] c"Tuesday\0A\00"
@.str.7 = [12 x i8] c"data error\0A\00"
@.str.8 = [8 x i8] c"Monday\0A\00"
@.str.9 = [11 x i8] c"Wednesday\0A\00"
@.str.10 = [8 x i8] c"Friday\0A\00"
define void @main() {
%1 = alloca i8
%2 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %3
3: ; preds = %52, %0
%4 = call signext i8 (...) @getchar()
store i8 %4, i8* %1
%5 = sext i8 %4 to i32
%6 = icmp ne i32 %5, 89
br i1 %6, label %7, label %53
7: ; preds = %3
%8 = load i8, i8* %1
%9 = sext i8 %8 to i32
switch i32 %9, label %50 [
i32 83, label %10
i32 84, label %27
i32 77, label %44
i32 87, label %46
i32 70, label %48
]
10: ; preds = %7
%11 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%12 = call signext i8 (...) @getchar()
store i8 %12, i8* %1
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 97
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %26
17: ; preds = %10
%18 = call signext i8 (...) @getchar()
store i8 %18, i8* %1
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 117
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %25
23: ; preds = %17
%24 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %25
25: ; preds = %23, %21
br label %26
26: ; preds = %25, %15
br label %52
27: ; preds = %7
%28 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%29 = call signext i8 (...) @getchar()
store i8 %29, i8* %1
%30 = sext i8 %29 to i32
%31 = icmp eq i32 104, %30
br i1 %31, label %32, label %34
32: ; preds = %27
%33 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %43
34: ; preds = %27
%35 = call signext i8 (...) @getchar()
store i8 %35, i8* %1
%36 = sext i8 %35 to i32
%37 = icmp eq i32 117, %36
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %42
40: ; preds = %34
%41 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
br label %42
42: ; preds = %40, %38
br label %43
43: ; preds = %42, %32
br label %52
44: ; preds = %7
%45 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
br label %52
46: ; preds = %7
%47 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
br label %52
48: ; preds = %7
%49 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
br label %52
50: ; preds = %7
%51 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %52
52: ; preds = %50, %48, %46, %44, %43, %26
br label %3
53: ; preds = %3
ret void
}

LLVM IR (-O2):
@str = [40 x i8] c"Please input the first leter of someday\00"
@str.11 = [7 x i8] c"Friday\00"
@str.12 = [10 x i8] c"Wednesday\00"
@str.13 = [7 x i8] c"Monday\00"
@str.15 = [11 x i8] c"data error\00"
@str.16 = [8 x i8] c"Tuesday\00"
@str.17 = [9 x i8] c"Thursday\00"
@str.18 = [31 x i8] c"Please input the second letter\00"
@str.20 = [7 x i8] c"Sunday\00"
@str.21 = [9 x i8] c"Saturday\00"
@str.22 = [12 x i8] c"data error!\00"
define void @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%2 = tail call signext i8 (...) @getchar()
%3 = icmp eq i8 %2, 89
br i1 %3, label %31, label %4
4: ; preds = %0, %26
%5 = phi i8 [ %29, %26 ], [ %2, %0 ]
%6 = sext i8 %5 to i32
switch i32 %6, label %25 [
i32 83, label %7
i32 84, label %15
i32 77, label %26
i32 87, label %23
i32 70, label %24
]
7: ; preds = %4
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.18, i64 0, i64 0))
%9 = tail call signext i8 (...) @getchar()
%10 = icmp eq i8 %9, 97
br i1 %10, label %26, label %11
11: ; preds = %7
%12 = tail call signext i8 (...) @getchar()
%13 = icmp eq i8 %12, 117
%14 = select i1 %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.20, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str.22, i64 0, i64 0)
br label %26
15: ; preds = %4
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.18, i64 0, i64 0))
%17 = tail call signext i8 (...) @getchar()
%18 = icmp eq i8 %17, 104
br i1 %18, label %26, label %19
19: ; preds = %15
%20 = tail call signext i8 (...) @getchar()
%21 = icmp eq i8 %20, 117
%22 = select i1 %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str.16, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @str.15, i64 0, i64 0)
br label %26
23: ; preds = %4
br label %26
24: ; preds = %4
br label %26
25: ; preds = %4
br label %26
26: ; preds = %4, %19, %15, %11, %7, %25, %24, %23
%27 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.22, i64 0, i64 0), %25 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.11, i64 0, i64 0), %24 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.12, i64 0, i64 0), %23 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.21, i64 0, i64 0), %7 ], [ %14, %11 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.17, i64 0, i64 0), %15 ], [ %22, %19 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.13, i64 0, i64 0), %4 ]
%28 = tail call i32 @puts(i8* dereferenceable(1) %27)
%29 = tail call signext i8 (...) @getchar()
%30 = icmp eq i8 %29, 89
br i1 %30, label %31, label %4
31: ; preds = %26, %0
ret void
}