#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*/ addBook(char *, int, char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ show();
int /*<<< orphan*/ sortInventory();
int main(void) {
  addBook("Algorithms in C", 1998, "Matthews", 3);
  addBook("C", 1978, "Smith", 2);
  addBook("C", 1988, "Jacob", 4);
  addBook("Algorithms", 1990, "Cohen", 1);
  addBook("Art of Computer Programming", 1978, "Burger", 2);
  addBook("Fortran", 1965, "Moran", 3);
  addBook("The Practice of Programming", 1999, "Andrews", 4);
  printf("Inventory\n ");
  show();
  sortInventory();
  printf("\nInventory in sorted order: \n");
  show();
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x7ce,%esi
lea    0xeae(%rip),%rdx
mov    $0x3,%ecx
call   1040 <addBook@plt>
lea    0xe9b(%rip),%rdi
mov    $0x7ba,%esi
lea    0xe9a(%rip),%rdx
mov    $0x2,%ecx
call   1040 <addBook@plt>
lea    0xe7e(%rip),%rdi
mov    $0x7c4,%esi
lea    0xe83(%rip),%rdx
mov    $0x4,%ecx
call   1040 <addBook@plt>
lea    0xe78(%rip),%rdi
mov    $0x7c6,%esi
lea    0xe77(%rip),%rdx
mov    $0x1,%ecx
call   1040 <addBook@plt>
lea    0xe6c(%rip),%rdi
mov    $0x7ba,%esi
lea    0xe7c(%rip),%rdx
mov    $0x2,%ecx
call   1040 <addBook@plt>
lea    0xe72(%rip),%rdi
mov    $0x7ad,%esi
lea    0xe6e(%rip),%rdx
mov    $0x3,%ecx
call   1040 <addBook@plt>
lea    0xe63(%rip),%rdi
mov    $0x7cf,%esi
lea    0xe73(%rip),%rdx
mov    $0x4,%ecx
call   1040 <addBook@plt>
lea    0xe6a(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <show@plt>
mov    $0x0,%al
call   1030 <sortInventory@plt>
lea    0xe5c(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <show@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xea8(%rip),%rdi
lea    0xeb1(%rip),%rdx
mov    $0x7ce,%esi
mov    $0x3,%ecx
call   1050 <addBook@plt>
lea    0xe99(%rip),%rbx
lea    0xe9d(%rip),%rdx
mov    %rbx,%rdi
mov    $0x7ba,%esi
mov    $0x2,%ecx
call   1050 <addBook@plt>
lea    0xe8a(%rip),%rdx
mov    %rbx,%rdi
mov    $0x7c4,%esi
mov    $0x4,%ecx
call   1050 <addBook@plt>
lea    0xe77(%rip),%rdi
lea    0xe7b(%rip),%rdx
mov    $0x7c6,%esi
mov    $0x1,%ecx
call   1050 <addBook@plt>
lea    0xe6b(%rip),%rdi
lea    0xe80(%rip),%rdx
mov    $0x7ba,%esi
mov    $0x2,%ecx
call   1050 <addBook@plt>
lea    0xe71(%rip),%rdi
lea    0xe72(%rip),%rdx
mov    $0x7ad,%esi
mov    $0x3,%ecx
call   1050 <addBook@plt>
lea    0xe62(%rip),%rdi
lea    0xe77(%rip),%rdx
mov    $0x7cf,%esi
mov    $0x4,%ecx
call   1050 <addBook@plt>
lea    0xe69(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <show@plt>
xor    %eax,%eax
call   1030 <sortInventory@plt>
lea    0xe5b(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1070 <show@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Algorithms in C\00"
@.str.1 = [9 x i8] c"Matthews\00"
@.str.2 = [2 x i8] c"C\00"
@.str.3 = [6 x i8] c"Smith\00"
@.str.4 = [6 x i8] c"Jacob\00"
@.str.5 = [11 x i8] c"Algorithms\00"
@.str.6 = [6 x i8] c"Cohen\00"
@.str.7 = [28 x i8] c"Art of Computer Programming\00"
@.str.8 = [7 x i8] c"Burger\00"
@.str.9 = [8 x i8] c"Fortran\00"
@.str.10 = [6 x i8] c"Moran\00"
@.str.11 = [28 x i8] c"The Practice of Programming\00"
@.str.12 = [8 x i8] c"Andrews\00"
@.str.13 = [12 x i8] c"Inventory\0A \00"
@.str.14 = [30 x i8] c"\0AInventory in sorted order: \0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @addBook(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 1998, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 3)
%3 = call i32 @addBook(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1978, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 2)
%4 = call i32 @addBook(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1988, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 4)
%5 = call i32 @addBook(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 1990, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 1)
%6 = call i32 @addBook(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 1978, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 2)
%7 = call i32 @addBook(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i32 1965, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i32 3)
%8 = call i32 @addBook(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0), i32 1999, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), i32 4)
%9 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
%10 = call i32 (...) @show()
%11 = call i32 (...) @sortInventory()
%12 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.14, i64 0, i64 0))
%13 = call i32 (...) @show()
ret i32 1
}

LLVM IR (-O2):
@.str = [16 x i8] c"Algorithms in C\00"
@.str.1 = [9 x i8] c"Matthews\00"
@.str.2 = [2 x i8] c"C\00"
@.str.3 = [6 x i8] c"Smith\00"
@.str.4 = [6 x i8] c"Jacob\00"
@.str.5 = [11 x i8] c"Algorithms\00"
@.str.6 = [6 x i8] c"Cohen\00"
@.str.7 = [28 x i8] c"Art of Computer Programming\00"
@.str.8 = [7 x i8] c"Burger\00"
@.str.9 = [8 x i8] c"Fortran\00"
@.str.10 = [6 x i8] c"Moran\00"
@.str.11 = [28 x i8] c"The Practice of Programming\00"
@.str.12 = [8 x i8] c"Andrews\00"
@.str.13 = [12 x i8] c"Inventory\0A \00"
@str = [29 x i8] c"\0AInventory in sorted order: \00"
define i32 @main() {
%1 = tail call i32 @addBook(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 1998, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 3)
%2 = tail call i32 @addBook(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1978, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 2)
%3 = tail call i32 @addBook(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1988, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 4)
%4 = tail call i32 @addBook(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 1990, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 1)
%5 = tail call i32 @addBook(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 1978, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 2)
%6 = tail call i32 @addBook(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i32 1965, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i32 3)
%7 = tail call i32 @addBook(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0), i32 1999, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), i32 4)
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
%9 = tail call i32 (...) @show()
%10 = tail call i32 (...) @sortInventory()
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 (...) @show()
ret i32 1
}