#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*/ branching(char);
int /*<<< orphan*/ flush();
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ load(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ save(char *);
char tolower(int /*<<< orphan*/);
int main() {
  load("Dog_List.txt");
  char ch = 'i';
  printf("Assignment 5: Array of Structs and Enum Types\n\n");
  printf("Dog Adoption Center\n\n");
  do {
    printf("Please enter your selection:\n");
    printf("\ta: add a new dog to the list\n");
    printf("\ts: search for a dog on the list\n");
    printf("\td: display list of dogs\n");
    printf("\tq: quit and save your list\n");
    ch = tolower(getchar());
    flush();
    branching(ch);
  } while (ch != 'q');
  save("Dog_List.txt");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rdi
call   1090 <load@plt>
movb   $0x69,-0x5(%rbp)
lea    0xe77(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9b(%rip),%rdi
call   1040 <printf@plt>
lea    0xea5(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb7(%rip),%rdi
call   1040 <printf@plt>
lea    0xeca(%rip),%rdi
call   1040 <printf@plt>
lea    0xee0(%rip),%rdi
call   1040 <printf@plt>
lea    0xeee(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,%edi
call   1070 <tolower@plt>
mov    %al,-0x5(%rbp)
mov    $0x0,%al
call   1030 <flush@plt>
movsbl -0x5(%rbp),%edi
call   1080 <branching@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x71,%eax
jne    11a7 <main+0x37>
lea    0xde8(%rip),%rdi
call   1050 <save@plt>
xor    %eax,%eax
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    0xe7e(%rip),%rdi
call   1090 <load@plt>
lea    0xe7f(%rip),%rdi
call   1040 <puts@plt>
lea    0xea2(%rip),%rdi
call   1040 <puts@plt>
lea    0xeab(%rip),%r14
lea    0xec1(%rip),%r15
lea    0xed8(%rip),%r12
lea    0xef2(%rip),%r13
lea    0xf04(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%edi
call   1070 <tolower@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <flush@plt>
movsbl %bl,%ebx
mov    %ebx,%edi
call   1080 <branching@plt>
cmp    $0x71,%bl
jne    11d0 <main+0x60>
lea    0xddb(%rip),%rdi
call   1050 <save@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Dog_List.txt\00"
@.str.1 = [48 x i8] c"Assignment 5: Array of Structs and Enum Types\0A\0A\00"
@.str.2 = [22 x i8] c"Dog Adoption Center\0A\0A\00"
@.str.3 = [30 x i8] c"Please enter your selection:\0A\00"
@.str.4 = [31 x i8] c"\09a: add a new dog to the list\0A\00"
@.str.5 = [34 x i8] c"\09s: search for a dog on the list\0A\00"
@.str.6 = [26 x i8] c"\09d: display list of dogs\0A\00"
@.str.7 = [29 x i8] c"\09q: quit and save your list\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 @load(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i8 105, i8* %2
%4 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %6
6: ; preds = %17, %0
%7 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
%12 = call i32 (...) @getchar()
%13 = call signext i8 @tolower(i32 %12)
store i8 %13, i8* %2
%14 = call i32 (...) @flush()
%15 = load i8, i8* %2
%16 = call i32 @branching(i8 signext %15)
br label %17
17: ; preds = %6
%18 = load i8, i8* %2
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 113
br i1 %20, label %6, label %21
21: ; preds = %17
%22 = call i32 @save(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"Dog_List.txt\00"
@str = [47 x i8] c"Assignment 5: Array of Structs and Enum Types\0A\00"
@str.8 = [21 x i8] c"Dog Adoption Center\0A\00"
@str.9 = [29 x i8] c"Please enter your selection:\00"
@str.10 = [30 x i8] c"\09a: add a new dog to the list\00"
@str.11 = [33 x i8] c"\09s: search for a dog on the list\00"
@str.12 = [25 x i8] c"\09d: display list of dogs\00"
@str.13 = [28 x i8] c"\09q: quit and save your list\00"
define i32 @main() {
%1 = tail call i32 @load(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.8, i64 0, i64 0))
br label %4
4: ; preds = %4, %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.9, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.10, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.11, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.12, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.13, i64 0, i64 0))
%10 = tail call i32 (...) @getchar()
%11 = tail call signext i8 @tolower(i32 %10)
%12 = tail call i32 (...) @flush()
%13 = tail call i32 @branching(i8 signext %11)
%14 = icmp eq i8 %11, 113
br i1 %14, label %15, label %4
15: ; preds = %4
%16 = tail call i32 @save(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
ret i32 0
}