#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 test {
  int dummy;
};

/* Variables and functions */
int fabs(double);
double mean(double *, int);
int /*<<< orphan*/ t_assert_msg(struct test *, int, char *);
int /*<<< orphan*/ t_set_msg(struct test *, char *);
void test_mean(struct test *t) {
  t_set_msg(t, "Testing the mean function...");
  double test_list[] = {3.0, 5.0, 3.0, 6.0, 3.0, 2.0, 4.0, 6.0, 7.0, 4.0, 3.0};
  double result = mean(test_list, 11);
  t_assert_msg(t, fabs(result - 4.181818) < 10e-4, "mean function incorrect");
}


x86 assembly (clang, -O0):
<test_mean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1050 <t_set_msg@plt>
lea    -0x60(%rbp),%rdi
lea    0xed9(%rip),%rsi
mov    $0x58,%edx
call   1040 <memcpy@plt>
lea    -0x60(%rbp),%rdi
mov    $0xb,%esi
call   1070 <mean@plt>
movsd  %xmm0,-0x68(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x70(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  0xe5f(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <fabs@plt>
mov    -0x70(%rbp),%rdi
cvtsi2sd %eax,%xmm1
movsd  0xe3e(%rip),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe58(%rip),%rdx
call   1060 <t_assert_msg@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_mean>:
push   %rbx
sub    $0x60,%rsp
mov    %rdi,%rbx
lea    0xeb9(%rip),%rsi
call   1040 <t_set_msg@plt>
mov    0xf35(%rip),%rax
mov    %rax,0x50(%rsp)
movaps 0xf19(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xefd(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xee1(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xec5(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movapd 0xea8(%rip),%xmm0
movapd %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0xb,%esi
call   1060 <mean@plt>
addsd  0xe4e(%rip),%xmm0
call   1030 <fabs@plt>
xor    %esi,%esi
test   %eax,%eax
setle  %sil
lea    0xe5f(%rip),%rdx
mov    %rbx,%rdi
call   1050 <t_assert_msg@plt>
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.test = type { i32 }
@.str = [29 x i8] c"Testing the mean function...\00"
@__const.test_mean.test_list = [11 x double] [double 3.000000e+00, double 5.000000e+00, double 3.000000e+00, double 6.000000e+00, double 3.000000e+00, double 2.000000e+00, double 4.000000e+00, double 6.000000e+00, double 7.000000e+00, double 4.000000e+00, double 3.000000e+00]
@.str.1 = [24 x i8] c"mean function incorrect\00"
define void @test_mean(%struct.test* %0) {
%2 = alloca %struct.test*
%3 = alloca [11 x double]
%4 = alloca double
store %struct.test* %0, %struct.test** %2
%5 = load %struct.test*, %struct.test** %2
%6 = call i32 @t_set_msg(%struct.test* %5, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%7 = bitcast [11 x double]* %3 to i8*
%8 = getelementptr inbounds [11 x double], [11 x double]* %3, i64 0, i64 0
%9 = call double @mean(double* %8, i32 11)
store double %9, double* %4
%10 = load %struct.test*, %struct.test** %2
%11 = load double, double* %4
%12 = fsub double %11, 0x4010BA2E7F6F4BE8
%13 = call i32 @fabs(double %12)
%14 = sitofp i32 %13 to double
%15 = fcmp olt double %14, 1.000000e-03
%16 = zext i1 %15 to i32
%17 = call i32 @t_assert_msg(%struct.test* %10, i32 %16, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.test = type { i32 }
@.str = [29 x i8] c"Testing the mean function...\00"
@__const.test_mean.test_list = [11 x double] [double 3.000000e+00, double 5.000000e+00, double 3.000000e+00, double 6.000000e+00, double 3.000000e+00, double 2.000000e+00, double 4.000000e+00, double 6.000000e+00, double 7.000000e+00, double 4.000000e+00, double 3.000000e+00]
@.str.1 = [24 x i8] c"mean function incorrect\00"
define void @test_mean(%struct.test* %0) {
%2 = alloca [11 x double]
%3 = tail call i32 @t_set_msg(%struct.test* %0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%4 = bitcast [11 x double]* %2 to i8*
%5 = getelementptr inbounds [11 x double], [11 x double]* %2, i64 0, i64 0
%6 = call double @mean(double* %5, i32 11)
%7 = fadd double %6, 0xC010BA2E7F6F4BE8
%8 = call i32 @fabs(double %7)
%9 = icmp slt i32 %8, 1
%10 = zext i1 %9 to i32
%11 = call i32 @t_assert_msg(%struct.test* %0, i32 %10, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
ret void
}