#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();
scalar_t__ islower(char);
int /*<<< orphan*/ printf(char *);
int main(void) {
  char ch;
  printf("Give me a letter of the alphabet, and I will give an animal "
         "name\nbeginning with that letter.\n");
  printf("Please type in a letter; type # to end my act.\n");
  while ((ch = getchar()) != '#') {
    if ('\n' == ch)
      continue;
    if (islower(ch))
      switch (ch) {
      case 'a':
        printf("argali, a wild sheep of Asia\n");
        break;
      case 'b':
        printf("babirusa, a wild pig of Malay\n");
        break;
      case 'c':
        printf("coati, racoonlike mammal\n");
        break;
      case 'd':
        printf("desman, aquatic, molelike critter\n");
        break;
      case 'e':
        printf("echidna, the spiny anteater\n");
        break;
      case 'f':
        printf("fisher, brownish marten\n");
        break;
      default:
        printf("That's a stumper!\n");
      }
    else
      printf("I recognize only lowercase letters.\n");
    while (getchar() != '\n')
      continue;
    printf("Please type another letter or a #.\n");
  }
  printf("Bye!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed2(%rip),%rdi
call   1040 <printf@plt>
lea    0xf24(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0x23,%eax
je     1271 <main+0x141>
movsbl -0x5(%rbp),%ecx
mov    $0xa,%eax
cmp    %ecx,%eax
jne    1183 <main+0x53>
jmp    1157 <main+0x27>
movsbl -0x5(%rbp),%edi
call   1030 <islower@plt>
cmp    $0x0,%rax
je     1237 <main+0x107>
movsbl -0x5(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x5,%eax
ja     1226 <main+0xf6>
mov    -0x10(%rbp),%rax
lea    0xe49(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xedf(%rip),%rdi
call   1040 <printf@plt>
jmp    1232 <main+0x102>
lea    0xeec(%rip),%rdi
call   1040 <printf@plt>
jmp    1232 <main+0x102>
lea    0xefa(%rip),%rdi
call   1040 <printf@plt>
jmp    1232 <main+0x102>
lea    0xf03(%rip),%rdi
call   1040 <printf@plt>
jmp    1232 <main+0x102>
lea    0xf15(%rip),%rdi
call   1040 <printf@plt>
jmp    1232 <main+0x102>
lea    0xf21(%rip),%rdi
call   1040 <printf@plt>
jmp    1232 <main+0x102>
lea    0xf29(%rip),%rdi
call   1040 <printf@plt>
jmp    1243 <main+0x113>
lea    0xf2b(%rip),%rdi
call   1040 <printf@plt>
jmp    1248 <main+0x118>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1260 <main+0x130>
jmp    1248 <main+0x118>
lea    0xf27(%rip),%rdi
call   1040 <printf@plt>
jmp    1157 <main+0x27>
lea    0xf3a(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xec0(%rip),%rdi
call   1040 <puts@plt>
lea    0xf11(%rip),%rdi
lea    0xf3e(%rip),%r14
lea    0xf5b(%rip),%r15
lea    0x1021(%rip),%r12
lea    0x102c(%rip),%r13
call   1040 <puts@plt>
nopl   (%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     1170 <main+0x40>
cmp    $0x23,%al
je     11c0 <main+0x90>
movsbl %al,%ebx
mov    %ebx,%edi
call   1030 <islower@plt>
mov    %r14,%rdi
test   %rax,%rax
je     11a7 <main+0x77>
add    $0xffffff9f,%ebx
mov    %r12,%rdi
cmp    $0x5,%ebx
ja     11a7 <main+0x77>
movslq %ebx,%rax
movslq 0x0(%r13,%rax,4),%rdi
add    %r13,%rdi
call   1040 <puts@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    11b0 <main+0x80>
mov    %r15,%rdi
jmp    1168 <main+0x38>
lea    0xec5(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [94 x i8] c"Give me a letter of the alphabet, and I will give an animal name\0Abeginning with that letter.\0A\00"
@.str.1 = [48 x i8] c"Please type in a letter; type # to end my act.\0A\00"
@.str.2 = [30 x i8] c"argali, a wild sheep of Asia\0A\00"
@.str.3 = [31 x i8] c"babirusa, a wild pig of Malay\0A\00"
@.str.4 = [26 x i8] c"coati, racoonlike mammal\0A\00"
@.str.5 = [35 x i8] c"desman, aquatic, molelike critter\0A\00"
@.str.6 = [29 x i8] c"echidna, the spiny anteater\0A\00"
@.str.7 = [25 x i8] c"fisher, brownish marten\0A\00"
@.str.8 = [19 x i8] c"That's a stumper!\0A\00"
@.str.9 = [37 x i8] c"I recognize only lowercase letters.\0A\00"
@.str.10 = [36 x i8] c"Please type another letter or a #.\0A\00"
@.str.11 = [6 x i8] c"Bye!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
br label %5
5: ; preds = %44, %13, %0
%6 = call signext i8 (...) @getchar()
store i8 %6, i8* %2
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 35
br i1 %8, label %9, label %46
9: ; preds = %5
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
%12 = icmp eq i32 10, %11
br i1 %12, label %13, label %14
13: ; preds = %9
br label %5
14: ; preds = %9
%15 = load i8, i8* %2
%16 = call i64 @islower(i8 signext %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %36
18: ; preds = %14
%19 = load i8, i8* %2
%20 = sext i8 %19 to i32
switch i32 %20, label %33 [
i32 97, label %21
i32 98, label %23
i32 99, label %25
i32 100, label %27
i32 101, label %29
i32 102, label %31
]
21: ; preds = %18
%22 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %35
23: ; preds = %18
%24 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %35
25: ; preds = %18
%26 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %35
27: ; preds = %18
%28 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
br label %35
29: ; preds = %18
%30 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
br label %35
31: ; preds = %18
%32 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
br label %35
33: ; preds = %18
%34 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
br label %35
35: ; preds = %33, %31, %29, %27, %25, %23, %21
br label %38
36: ; preds = %14
%37 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.9, i64 0, i64 0))
br label %38
38: ; preds = %36, %35
br label %39
39: ; preds = %43, %38
%40 = call signext i8 (...) @getchar()
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 10
br i1 %42, label %43, label %44
43: ; preds = %39
br label %39
44: ; preds = %39
%45 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0))
br label %5
46: ; preds = %5
%47 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [93 x i8] c"Give me a letter of the alphabet, and I will give an animal name\0Abeginning with that letter.\00"
@str.12 = [47 x i8] c"Please type in a letter; type # to end my act.\00"
@str.13 = [5 x i8] c"Bye!\00"
@str.14 = [36 x i8] c"I recognize only lowercase letters.\00"
@str.15 = [35 x i8] c"Please type another letter or a #.\00"
@str.16 = [24 x i8] c"fisher, brownish marten\00"
@str.17 = [28 x i8] c"echidna, the spiny anteater\00"
@str.18 = [34 x i8] c"desman, aquatic, molelike critter\00"
@str.19 = [25 x i8] c"coati, racoonlike mammal\00"
@str.20 = [30 x i8] c"babirusa, a wild pig of Malay\00"
@str.21 = [29 x i8] c"argali, a wild sheep of Asia\00"
@str.22 = [18 x i8] c"That's a stumper!\00"
@reltable.main = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([29 x i8]* @str.21 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([30 x i8]* @str.20 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @str.19 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([34 x i8]* @str.18 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @str.17 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @str.16 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32)]
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([93 x i8], [93 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %21, %0
%3 = phi i8* [ getelementptr inbounds ([47 x i8], [47 x i8]* @str.12, i64 0, i64 0), %0 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @str.15, i64 0, i64 0), %21 ]
%4 = tail call i32 @puts(i8* dereferenceable(1) %3)
br label %5
5: ; preds = %2, %5
%6 = tail call signext i8 (...) @getchar()
switch i8 %6, label %7 [
i8 35, label %24
i8 10, label %5
]
7: ; preds = %5
%8 = sext i8 %6 to i32
%9 = tail call i64 @islower(i8 signext %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %18, label %11
11: ; preds = %7
%12 = add nsw i32 %8, -97
%13 = icmp ult i32 %12, 6
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = sext i32 %12 to i64
%16 = shl i64 %15, 2
%17 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.main to i8*), i64 %16)
br label %18
18: ; preds = %11, %14, %7
%19 = phi i8* [ getelementptr inbounds ([36 x i8], [36 x i8]* @str.14, i64 0, i64 0), %7 ], [ %17, %14 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.22, i64 0, i64 0), %11 ]
%20 = tail call i32 @puts(i8* dereferenceable(1) %19)
br label %21
21: ; preds = %21, %18
%22 = tail call signext i8 (...) @getchar()
%23 = icmp eq i8 %22, 10
br i1 %23, label %2, label %21
24: ; preds = %5
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.13, i64 0, i64 0))
ret i32 0
}