#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() {
  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("babirusa, a wild pig of Malay\n");
        break;
      case 'c':
        printf("coati, racoonlike mammal\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");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
lea    0xee1(%rip),%rdi
call   1040 <printf@plt>
lea    0xf02(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0x23,%eax
je     1257 <main+0x127>
movsbl -0x5(%rbp),%ecx
mov    $0xa,%eax
cmp    %ecx,%eax
jne    118f <main+0x5f>
jmp    1163 <main+0x33>
movsbl -0x5(%rbp),%edi
call   1030 <islower@plt>
cmp    $0x0,%rax
je     121d <main+0xed>
movsbl -0x5(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x61,%eax
je     11d9 <main+0xa9>
jmp    11b7 <main+0x87>
mov    -0xc(%rbp),%eax
sub    $0x62,%eax
je     11ea <main+0xba>
jmp    11c8 <main+0x98>
mov    -0xc(%rbp),%eax
sub    $0x63,%eax
je     11fb <main+0xcb>
jmp    120c <main+0xdc>
lea    0xeb0(%rip),%rdi
call   1040 <printf@plt>
jmp    1218 <main+0xe8>
lea    0xebd(%rip),%rdi
call   1040 <printf@plt>
jmp    1218 <main+0xe8>
lea    0xecb(%rip),%rdi
call   1040 <printf@plt>
jmp    1218 <main+0xe8>
lea    0xed4(%rip),%rdi
call   1040 <printf@plt>
jmp    1229 <main+0xf9>
lea    0xed6(%rip),%rdi
call   1040 <printf@plt>
jmp    122e <main+0xfe>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1246 <main+0x116>
jmp    122e <main+0xfe>
lea    0xed2(%rip),%rdi
call   1040 <printf@plt>
jmp    1163 <main+0x33>
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    0xeb0(%rip),%rdi
call   1050 <printf@plt>
lea    0xed7(%rip),%rdi
call   1040 <puts@plt>
lea    0xef7(%rip),%rdi
lea    0xf1f(%rip),%r14
lea    0xf3c(%rip),%r15
lea    0xfac(%rip),%r12
lea    0xfb8(%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    $0x2,%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>
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 = [48 x i8] c"Please type in a letter ;type # to end my act.\0A\00"
@.str.3 = [30 x i8] c"argali, a wild sheep of Asia\0A\00"
@.str.4 = [31 x i8] c"babirusa, a wild pig of Malay\0A\00"
@.str.5 = [26 x i8] c"coati, racoonlike mammal\0A\00"
@.str.6 = [19 x i8] c"That's a stumper!\0A\00"
@.str.7 = [37 x i8] c"I recognize only lowercase letters.\0A\00"
@.str.8 = [36 x i8] c"Please type another letter or a #.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
br label %6
6: ; preds = %39, %14, %0
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 35
br i1 %9, label %10, label %41
10: ; preds = %6
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = icmp eq i32 10, %12
br i1 %13, label %14, label %15
14: ; preds = %10
br label %6
15: ; preds = %10
%16 = load i8, i8* %2
%17 = call i64 @islower(i8 signext %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %31
19: ; preds = %15
%20 = load i8, i8* %2
%21 = sext i8 %20 to i32
switch i32 %21, label %28 [
i32 97, label %22
i32 98, label %24
i32 99, label %26
]
22: ; preds = %19
%23 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
br label %30
24: ; preds = %19
%25 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %30
26: ; preds = %19
%27 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %30
28: ; preds = %19
%29 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %30
30: ; preds = %28, %26, %24, %22
br label %33
31: ; preds = %15
%32 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
br label %33
33: ; preds = %31, %30
br label %34
34: ; preds = %38, %33
%35 = call signext i8 (...) @getchar()
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 10
br i1 %37, label %38, label %39
38: ; preds = %34
br label %34
39: ; preds = %34
%40 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
br label %6
41: ; preds = %6
ret i32 0
}

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