#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 */
struct Animal {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ animalPrintGreeting(struct Animal *);
int /*<<< orphan*/ animalPrintMenu(struct Animal *);
struct Animal *createCat(char *);
struct Animal *createDog(char *);
int /*<<< orphan*/ free(struct Animal *);
void testAnimals(void) {
  struct Animal *p1 = createDog("Hamlet");
  struct Animal *p2 = createCat("Ofelija");
  struct Animal *p3 = createDog("Polonije");
  animalPrintGreeting(p1);
  animalPrintGreeting(p2);
  animalPrintGreeting(p3);
  animalPrintMenu(p1);
  animalPrintMenu(p2);
  animalPrintMenu(p3);
  free(p1);
  free(p2);
  free(p3);
}


x86 assembly (clang, -O0):
<testAnimals>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xea1(%rip),%rdi
call   1070 <createDog@plt>
mov    %rax,-0x8(%rbp)
lea    0xe98(%rip),%rdi
call   1050 <createCat@plt>
mov    %rax,-0x10(%rbp)
lea    0xe90(%rip),%rdi
call   1070 <createDog@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <animalPrintGreeting@plt>
mov    -0x10(%rbp),%rdi
call   1060 <animalPrintGreeting@plt>
mov    -0x18(%rbp),%rdi
call   1060 <animalPrintGreeting@plt>
mov    -0x8(%rbp),%rdi
call   1040 <animalPrintMenu@plt>
mov    -0x10(%rbp),%rdi
call   1040 <animalPrintMenu@plt>
mov    -0x18(%rbp),%rdi
call   1040 <animalPrintMenu@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testAnimals>:
push   %r15
push   %r14
push   %rbx
lea    0xea4(%rip),%rdi
call   1070 <createDog@plt>
mov    %rax,%r14
lea    0xe9c(%rip),%rdi
call   1050 <createCat@plt>
mov    %rax,%r15
lea    0xe95(%rip),%rdi
call   1070 <createDog@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1060 <animalPrintGreeting@plt>
mov    %r15,%rdi
call   1060 <animalPrintGreeting@plt>
mov    %rbx,%rdi
call   1060 <animalPrintGreeting@plt>
mov    %r14,%rdi
call   1040 <animalPrintMenu@plt>
mov    %r15,%rdi
call   1040 <animalPrintMenu@plt>
mov    %rbx,%rdi
call   1040 <animalPrintMenu@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
%struct.Animal = type { i32 }
@.str = [7 x i8] c"Hamlet\00"
@.str.1 = [8 x i8] c"Ofelija\00"
@.str.2 = [9 x i8] c"Polonije\00"
define void @testAnimals() {
%1 = alloca %struct.Animal*
%2 = alloca %struct.Animal*
%3 = alloca %struct.Animal*
%4 = call %struct.Animal* @createDog(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store %struct.Animal* %4, %struct.Animal** %1
%5 = call %struct.Animal* @createCat(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
store %struct.Animal* %5, %struct.Animal** %2
%6 = call %struct.Animal* @createDog(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
store %struct.Animal* %6, %struct.Animal** %3
%7 = load %struct.Animal*, %struct.Animal** %1
%8 = call i32 @animalPrintGreeting(%struct.Animal* %7)
%9 = load %struct.Animal*, %struct.Animal** %2
%10 = call i32 @animalPrintGreeting(%struct.Animal* %9)
%11 = load %struct.Animal*, %struct.Animal** %3
%12 = call i32 @animalPrintGreeting(%struct.Animal* %11)
%13 = load %struct.Animal*, %struct.Animal** %1
%14 = call i32 @animalPrintMenu(%struct.Animal* %13)
%15 = load %struct.Animal*, %struct.Animal** %2
%16 = call i32 @animalPrintMenu(%struct.Animal* %15)
%17 = load %struct.Animal*, %struct.Animal** %3
%18 = call i32 @animalPrintMenu(%struct.Animal* %17)
%19 = load %struct.Animal*, %struct.Animal** %1
%20 = call i32 @free(%struct.Animal* %19)
%21 = load %struct.Animal*, %struct.Animal** %2
%22 = call i32 @free(%struct.Animal* %21)
%23 = load %struct.Animal*, %struct.Animal** %3
%24 = call i32 @free(%struct.Animal* %23)
ret void
}

LLVM IR (-O2):
%struct.Animal = type { i32 }
@.str = [7 x i8] c"Hamlet\00"
@.str.1 = [8 x i8] c"Ofelija\00"
@.str.2 = [9 x i8] c"Polonije\00"
define void @testAnimals() {
%1 = tail call %struct.Animal* @createDog(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%2 = tail call %struct.Animal* @createCat(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call %struct.Animal* @createDog(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 @animalPrintGreeting(%struct.Animal* %1)
%5 = tail call i32 @animalPrintGreeting(%struct.Animal* %2)
%6 = tail call i32 @animalPrintGreeting(%struct.Animal* %3)
%7 = tail call i32 @animalPrintMenu(%struct.Animal* %1)
%8 = tail call i32 @animalPrintMenu(%struct.Animal* %2)
%9 = tail call i32 @animalPrintMenu(%struct.Animal* %3)
%10 = tail call i32 @free(%struct.Animal* %1)
%11 = tail call i32 @free(%struct.Animal* %2)
%12 = tail call i32 @free(%struct.Animal* %3)
ret void
}