#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(int argc, char const *argv[]) {
  char ch;
  printf("Give me a letter of the alphabet, and I will give ");
  printf("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("argali, b wild sheep of Asia \n");
        break;
      case 'c':
        printf("argali, c wild sheep of Asia \n");
        break;
      case 'd':
        printf("argali, d wild sheep of Asia \n");
        break;
      case 'e':
        printf("argali, e wild sheep of Asia \n");
        break;
      case 'f':
        printf("argali, f wild sheep of Asia \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");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xecb(%rip),%rdi
call   1040 <printf@plt>
lea    0xef2(%rip),%rdi
call   1040 <printf@plt>
lea    0xf13(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
cmp    $0x23,%eax
je     1284 <main+0x154>
movsbl -0x11(%rbp),%ecx
mov    $0xa,%eax
cmp    %ecx,%eax
jne    1196 <main+0x66>
jmp    116a <main+0x3a>
movsbl -0x11(%rbp),%edi
call   1030 <islower@plt>
cmp    $0x0,%rax
je     124a <main+0x11a>
movsbl -0x11(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x5,%eax
ja     1239 <main+0x109>
mov    -0x20(%rbp),%rax
lea    0xe36(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xecf(%rip),%rdi
call   1040 <printf@plt>
jmp    1245 <main+0x115>
lea    0xedd(%rip),%rdi
call   1040 <printf@plt>
jmp    1245 <main+0x115>
lea    0xeeb(%rip),%rdi
call   1040 <printf@plt>
jmp    1245 <main+0x115>
lea    0xef9(%rip),%rdi
call   1040 <printf@plt>
jmp    1245 <main+0x115>
lea    0xf07(%rip),%rdi
call   1040 <printf@plt>
jmp    1245 <main+0x115>
lea    0xf15(%rip),%rdi
call   1040 <printf@plt>
jmp    1245 <main+0x115>
lea    0xf23(%rip),%rdi
call   1040 <printf@plt>
jmp    1256 <main+0x126>
lea    0xf26(%rip),%rdi
call   1040 <printf@plt>
jmp    125b <main+0x12b>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1273 <main+0x143>
jmp    125b <main+0x12b>
lea    0xf22(%rip),%rdi
call   1040 <printf@plt>
jmp    116a <main+0x3a>
lea    0xf35(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xeb0(%rip),%rdi
call   1050 <printf@plt>
lea    0xedb(%rip),%rdi
call   1040 <puts@plt>
lea    0xefb(%rip),%rdi
lea    0xf24(%rip),%r14
lea    0xf41(%rip),%r15
lea    0x1011(%rip),%r12
lea    0x1020(%rip),%r13
call   1040 <puts@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%al
je     1190 <main+0x50>
cmp    $0x23,%al
je     11e0 <main+0xa0>
movsbl %al,%ebx
mov    %ebx,%edi
call   1030 <islower@plt>
mov    %r14,%rdi
test   %rax,%rax
je     11c7 <main+0x87>
add    $0xffffff9f,%ebx
mov    %r12,%rdi
cmp    $0x5,%ebx
ja     11c7 <main+0x87>
movslq %ebx,%rax
movslq 0x0(%r13,%rax,4),%rdi
add    %r13,%rdi
call   1040 <puts@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%al
jne    11d0 <main+0x90>
mov    %r15,%rdi
jmp    1184 <main+0x44>
lea    0xe4c(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [51 x i8] c"Give me a letter of the alphabet, and I will give \00"
@.str.12 = [4 x i8] c"Bye\00"
@str = [44 x i8] c"an animal name\0Abeginning with that letter. \00"
@str.13 = [48 x i8] c"Please type in a letter: type # to end my act. \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 = [30 x i8] c"argali, f wild sheep of Asia \00"
@str.17 = [30 x i8] c"argali, e wild sheep of Asia \00"
@str.18 = [30 x i8] c"argali, d wild sheep of Asia \00"
@str.19 = [30 x i8] c"argali, c wild sheep of Asia \00"
@str.20 = [30 x i8] c"argali, b wild sheep of Asia \00"
@str.21 = [30 x i8] c"argali, a wild sheep of Asia \00"
@str.22 = [19 x i8] c"That 's a stumper!\00"
@reltable.main = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([30 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 ([30 x i8]* @str.19 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([30 x i8]* @str.18 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([30 x i8]* @str.17 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([30 x i8]* @str.16 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32)]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
br label %5
5: ; preds = %24, %2
%6 = phi i8* [ getelementptr inbounds ([48 x i8], [48 x i8]* @str.13, i64 0, i64 0), %2 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @str.15, i64 0, i64 0), %24 ]
%7 = tail call i32 @puts(i8* dereferenceable(1) %6)
br label %8
8: ; preds = %5, %8
%9 = tail call signext i8 (...) @getchar()
switch i8 %9, label %10 [
i8 35, label %27
i8 10, label %8
]
10: ; preds = %8
%11 = sext i8 %9 to i32
%12 = tail call i64 @islower(i8 signext %9)
%13 = icmp eq i64 %12, 0
br i1 %13, label %21, label %14
14: ; preds = %10
%15 = add nsw i32 %11, -97
%16 = icmp ult i32 %15, 6
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = sext i32 %15 to i64
%19 = shl i64 %18, 2
%20 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.main to i8*), i64 %19)
br label %21
21: ; preds = %14, %17, %10
%22 = phi i8* [ getelementptr inbounds ([36 x i8], [36 x i8]* @str.14, i64 0, i64 0), %10 ], [ %20, %17 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.22, i64 0, i64 0), %14 ]
%23 = tail call i32 @puts(i8* dereferenceable(1) %22)
br label %24
24: ; preds = %24, %21
%25 = tail call signext i8 (...) @getchar()
%26 = icmp eq i8 %25, 10
br i1 %26, label %5, label %24
27: ; preds = %8
%28 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
ret i32 0
}