#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 */
float averageFloats(float *, int);
int /*<<< orphan*/ free(float *);
float *malloc(int);
int /*<<< orphan*/ printf(char *, float);
int main(int argc, const char *argv[]) {
  float *gradeBook = malloc(3 * sizeof(float));
  gradeBook[0] = 60.2;
  gradeBook[1] = 94.5;
  gradeBook[2] = 81.1;
  float average = averageFloats(gradeBook, 3);
  free(gradeBook);
  gradeBook = NULL;
  printf("Average = %.2f\n", average);
  float gradeBookLiteral[] = {60.2, 94.5, 81.1};
  average = averageFloats(gradeBookLiteral, 3);
  printf("Average = %.2f\n", average);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xc,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movss  0xe98(%rip),%xmm0
movss  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movss  0xe84(%rip),%xmm0
movss  %xmm0,0x4(%rax)
mov    -0x18(%rbp),%rax
movss  0xe6f(%rip),%xmm0
movss  %xmm0,0x8(%rax)
mov    -0x18(%rbp),%rdi
mov    $0x3,%esi
call   1040 <averageFloats@plt>
movss  %xmm0,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x18(%rbp)
movss  -0x1c(%rbp),%xmm0
lea    0xe46(%rip),%rdi
call   1050 <printf@plt>
mov    0xe4a(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe48(%rip),%eax
mov    %eax,-0x20(%rbp)
lea    -0x28(%rbp),%rdi
mov    $0x3,%esi
call   1040 <averageFloats@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
lea    0xe0e(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    $0xc,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
movabs $0x42bd00004270cccd,%rax
mov    %rax,(%rbx)
movl   $0x42a23333,0x8(%rbx)
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <averageFloats@plt>
movss  %xmm0,0xc(%rsp)
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xe78(%rip),%rbx
mov    %rbx,%rdi
movss  0xc(%rsp),%xmm0
call   1050 <printf@plt>
mov    0xe7c(%rip),%eax
mov    %eax,0x18(%rsp)
mov    0xe69(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x3,%esi
call   1040 <averageFloats@plt>
mov    %rbx,%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Average = %.2f\0A\00"
@__const.main.gradeBookLiteral = [3 x float] [float 0x404E1999A0000000, float 9.450000e+01, float 0x4054466660000000]
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float*
%7 = alloca float
%8 = alloca [3 x float]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call float* @malloc(i32 12)
store float* %9, float** %6
%10 = load float*, float** %6
%11 = getelementptr inbounds float, float* %10, i64 0
store float 0x404E1999A0000000, float* %11
%12 = load float*, float** %6
%13 = getelementptr inbounds float, float* %12, i64 1
store float 9.450000e+01, float* %13
%14 = load float*, float** %6
%15 = getelementptr inbounds float, float* %14, i64 2
store float 0x4054466660000000, float* %15
%16 = load float*, float** %6
%17 = call float @averageFloats(float* %16, i32 3)
store float %17, float* %7
%18 = load float*, float** %6
%19 = call i32 @free(float* %18)
store float* null, float** %6
%20 = load float, float* %7
%21 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), float %20)
%22 = bitcast [3 x float]* %8 to i8*
%23 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 0
%24 = call float @averageFloats(float* %23, i32 3)
store float %24, float* %7
%25 = load float, float* %7
%26 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), float %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"Average = %.2f\0A\00"
@__const.main.gradeBookLiteral = [3 x float] [float 0x404E1999A0000000, float 9.450000e+01, float 0x4054466660000000]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3 x float]
%4 = tail call float* @malloc(i32 12)
store float 0x404E1999A0000000, float* %4
%5 = getelementptr inbounds float, float* %4, i64 1
store float 9.450000e+01, float* %5
%6 = getelementptr inbounds float, float* %4, i64 2
store float 0x4054466660000000, float* %6
%7 = tail call float @averageFloats(float* %4, i32 3)
%8 = tail call i32 @free(float* %4)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), float %7)
%10 = bitcast [3 x float]* %3 to i8*
%11 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 0
%12 = call float @averageFloats(float* %11, i32 3)
%13 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), float %12)
ret i32 0
}