#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);
double pvalue(double, double, double);
double sd(double *, int, double);
int /*<<< orphan*/ t_assert_msg(struct test *, int, char *);
int /*<<< orphan*/ t_log(struct test *, char *, double);
int /*<<< orphan*/ t_set_msg(struct test *, char *);
void test_pvalue(struct test *t) {
  t_set_msg(t, "Testing the pvalue 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 test_mean = mean(test_list, 11);
  double test_sd = sd(test_list, 11, test_mean);
  double result = pvalue(test_mean, test_sd, 1.0);
  t_log(t, "pvalue: %lf", result);
  t_assert_msg(t, fabs(result - 0.023448) < 10e-4, "pvalue function incorrect");
}


x86 assembly (clang, -O0):
<test_pvalue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1060 <t_set_msg@plt>
lea    -0x60(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x58,%edx
call   1050 <memcpy@plt>
lea    -0x60(%rbp),%rdi
mov    $0xb,%esi
call   1080 <mean@plt>
movsd  %xmm0,-0x68(%rbp)
lea    -0x60(%rbp),%rdi
movsd  -0x68(%rbp),%xmm0
mov    $0xb,%esi
call   1030 <sd@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
movsd  0xe1f(%rip),%xmm2
call   10a0 <pvalue@plt>
movsd  %xmm0,-0x78(%rbp)
mov    -0x8(%rbp),%rdi
movsd  -0x78(%rbp),%xmm0
lea    0xe2c(%rip),%rsi
call   1090 <t_log@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x80(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  0xde3(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1040 <fabs@plt>
mov    -0x80(%rbp),%rdi
cvtsi2sd %eax,%xmm1
movsd  0xdc2(%rip),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xdf2(%rip),%rdx
call   1070 <t_assert_msg@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_pvalue>:
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %rdi,%rbx
lea    0xe8f(%rip),%rsi
call   1050 <t_set_msg@plt>
mov    0xf23(%rip),%rax
mov    %rax,0x60(%rsp)
movaps 0xf07(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xeeb(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xecf(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeb3(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe97(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0xb,%esi
call   1070 <mean@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
mov    $0xb,%esi
call   1030 <sd@plt>
movaps %xmm0,%xmm1
movsd  0xe02(%rip),%xmm2
movsd  0x8(%rsp),%xmm0
call   1090 <pvalue@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xe19(%rip),%rsi
mov    %rbx,%rdi
call   1080 <t_log@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xddc(%rip),%xmm0
call   1040 <fabs@plt>
xor    %esi,%esi
test   %eax,%eax
setle  %sil
lea    0xdfb(%rip),%rdx
mov    %rbx,%rdi
call   1060 <t_assert_msg@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.test = type { i32 }
@.str = [31 x i8] c"Testing the pvalue function...\00"
@__const.test_pvalue.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 = [12 x i8] c"pvalue: %lf\00"
@.str.2 = [26 x i8] c"pvalue function incorrect\00"
define void @test_pvalue(%struct.test* %0) {
%2 = alloca %struct.test*
%3 = alloca [11 x double]
%4 = alloca double
%5 = alloca double
%6 = alloca double
store %struct.test* %0, %struct.test** %2
%7 = load %struct.test*, %struct.test** %2
%8 = call i32 @t_set_msg(%struct.test* %7, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%9 = bitcast [11 x double]* %3 to i8*
%10 = getelementptr inbounds [11 x double], [11 x double]* %3, i64 0, i64 0
%11 = call double @mean(double* %10, i32 11)
store double %11, double* %4
%12 = getelementptr inbounds [11 x double], [11 x double]* %3, i64 0, i64 0
%13 = load double, double* %4
%14 = call double @sd(double* %12, i32 11, double %13)
store double %14, double* %5
%15 = load double, double* %4
%16 = load double, double* %5
%17 = call double @pvalue(double %15, double %16, double 1.000000e+00)
store double %17, double* %6
%18 = load %struct.test*, %struct.test** %2
%19 = load double, double* %6
%20 = call i32 @t_log(%struct.test* %18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %19)
%21 = load %struct.test*, %struct.test** %2
%22 = load double, double* %6
%23 = fsub double %22, 2.344800e-02
%24 = call i32 @fabs(double %23)
%25 = sitofp i32 %24 to double
%26 = fcmp olt double %25, 1.000000e-03
%27 = zext i1 %26 to i32
%28 = call i32 @t_assert_msg(%struct.test* %21, i32 %27, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.test = type { i32 }
@.str = [31 x i8] c"Testing the pvalue function...\00"
@__const.test_pvalue.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 = [12 x i8] c"pvalue: %lf\00"
@.str.2 = [26 x i8] c"pvalue function incorrect\00"
define void @test_pvalue(%struct.test* %0) {
%2 = alloca [11 x double]
%3 = tail call i32 @t_set_msg(%struct.test* %0, i8* getelementptr inbounds ([31 x i8], [31 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 = call double @sd(double* %5, i32 11, double %6)
%8 = call double @pvalue(double %6, double %7, double 1.000000e+00)
%9 = call i32 @t_log(%struct.test* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %8)
%10 = fadd double %8, -2.344800e-02
%11 = call i32 @fabs(double %10)
%12 = icmp slt i32 %11, 1
%13 = zext i1 %12 to i32
%14 = call i32 @t_assert_msg(%struct.test* %0, i32 %13, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
ret void
}