#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 */
double getAverage(int *, int);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ testArray();
int main(int argc, const char *argv[]) {
  testArray();
  double arr[] = {1, 2, 3, 4, 6};
  double res = getAverage((int *)arr, 5);
  printf("res-> %f", res);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <testArray@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
movsd  0xeab(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe96(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe81(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe6c(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe57(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
mov    $0x5,%esi
call   1030 <getAverage@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
xor    %eax,%eax
call   1050 <testArray@plt>
movaps 0xebe(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xec3(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x4018000000000000,%rax
mov    %rax,0x20(%rsp)
mov    %rsp,%rdi
mov    $0x5,%esi
call   1030 <getAverage@plt>
lea    0xeab(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"res-> %f\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [5 x double]
%7 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (...) @testArray()
%9 = bitcast [5 x double]* %6 to i8*
%10 = bitcast i8* %9 to [5 x double]*
%11 = getelementptr inbounds [5 x double], [5 x double]* %10, i32 0, i32 0
store double 1.000000e+00, double* %11
%12 = getelementptr inbounds [5 x double], [5 x double]* %10, i32 0, i32 1
store double 2.000000e+00, double* %12
%13 = getelementptr inbounds [5 x double], [5 x double]* %10, i32 0, i32 2
store double 3.000000e+00, double* %13
%14 = getelementptr inbounds [5 x double], [5 x double]* %10, i32 0, i32 3
store double 4.000000e+00, double* %14
%15 = getelementptr inbounds [5 x double], [5 x double]* %10, i32 0, i32 4
store double 6.000000e+00, double* %15
%16 = getelementptr inbounds [5 x double], [5 x double]* %6, i64 0, i64 0
%17 = bitcast double* %16 to i32*
%18 = call double @getAverage(i32* %17, i32 5)
store double %18, double* %7
%19 = load double, double* %7
%20 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), double %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"res-> %f\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [5 x double]
%4 = tail call i32 (...) @testArray()
%5 = bitcast [5 x double]* %3 to i8*
%6 = bitcast [5 x double]* %3 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 2.000000e+00>, <2 x double>* %6
%7 = getelementptr inbounds [5 x double], [5 x double]* %3, i64 0, i64 2
%8 = bitcast double* %7 to <2 x double>*
store <2 x double> <double 3.000000e+00, double 4.000000e+00>, <2 x double>* %8
%9 = getelementptr inbounds [5 x double], [5 x double]* %3, i64 0, i64 4
store double 6.000000e+00, double* %9
%10 = bitcast [5 x double]* %3 to i32*
%11 = call double @getAverage(i32* %10, i32 5)
%12 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), double %11)
ret i32 0
}