#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 */
int /*<<< orphan*/ free_vector(float *, int, int);
float gasdev(long *);
int /*<<< orphan*/ printf(char *, ...);
float sqrt(double);
int /*<<< orphan*/ tutest(float *, int, float *, int, float *, float *);
float *vector(int, int);
int main(void) {
  long idum = (-51773);
  int i, j;
  float fctr1, fctr2, prob, t, *data1, *data2;
  data1 = vector(1, 5000);
  data2 = vector(1, 1000);
  fctr1 = sqrt(1.0);
  for (i = 1; i <= 5000; i++)
    data1[i] = fctr1 * gasdev(&idum);
  fctr2 = sqrt(4.0);
  for (i = 1; i <= 1000; i++)
    data2[i] = 10 / 2.0 * 0.02 + fctr2 * gasdev(&idum);
  printf("\nDistribution #1 : variance = %6.2f\n", 1.0);
  printf("Distribution #2 : variance = %6.2f\n\n", 4.0);
  printf("%7s %8s %16s\n", "shift", "t", "probability");
  for (i = 1; i <= 10 + 1; i++) {
    tutest(data1, 5000, data2, 1000, &t, &prob);
    printf("%6.2f %10.2f %11.2f\n", (i - 1) * 0.02, t, prob);
    for (j = 1; j <= 5000; j++)
      data1[j] += 0.02;
  }
  free_vector(data2, 1, 1000);
  free_vector(data1, 1, 5000);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0xffffffffffff35c3,-0x10(%rbp)
ff
mov    $0x1,%edi
mov    $0x1388,%esi
call   1060 <vector@plt>
mov    %rax,-0x30(%rbp)
mov    $0x1,%edi
mov    $0x3e8,%esi
call   1060 <vector@plt>
mov    %rax,-0x38(%rbp)
movsd  0xe5b(%rip),%xmm0
call   1070 <sqrt@plt>
movss  %xmm0,-0x1c(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x1388,-0x14(%rbp)
jg     11fd <main+0x9d>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
lea    -0x10(%rbp),%rdi
call   1080 <gasdev@plt>
movaps %xmm0,%xmm1
movss  -0x3c(%rbp),%xmm0
mulss  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movslq -0x14(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b6 <main+0x56>
movsd  0xe03(%rip),%xmm0
call   1070 <sqrt@plt>
movss  %xmm0,-0x20(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x3e8,-0x14(%rbp)
jg     1271 <main+0x111>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x40(%rbp)
lea    -0x10(%rbp),%rdi
call   1080 <gasdev@plt>
movaps %xmm0,%xmm1
movss  -0x40(%rbp),%xmm0
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdca(%rip),%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x38(%rbp),%rax
movslq -0x14(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1216 <main+0xb6>
lea    0xda8(%rip),%rdi
movsd  0xd80(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xdb7(%rip),%rdi
movsd  0xd72(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xdc6(%rip),%rdi
lea    0xdcd(%rip),%rsi
lea    0xdca(%rip),%rdx
lea    0xdc5(%rip),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
cmpl   $0xb,-0x14(%rbp)
jg     1381 <main+0x221>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    $0x1388,%esi
mov    $0x3e8,%ecx
lea    -0x28(%rbp),%r8
lea    -0x24(%rbp),%r9
call   1050 <tutest@plt>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xd0e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movss  -0x28(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x24(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xd6b(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movl   $0x1,-0x18(%rbp)
cmpl   $0x1388,-0x18(%rbp)
jg     136e <main+0x20e>
mov    -0x30(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xcbd(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    132d <main+0x1cd>
jmp    1373 <main+0x213>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12c7 <main+0x167>
mov    -0x38(%rbp),%rdi
mov    $0x1,%esi
mov    $0x3e8,%edx
call   1040 <free_vector@plt>
mov    -0x30(%rbp),%rdi
mov    $0x1,%esi
mov    $0x1388,%edx
call   1040 <free_vector@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0xffffffffffff35c3,0x10(%rsp)
ff ff
mov    $0x1,%edi
mov    $0x1388,%esi
call   1060 <vector@plt>
mov    %rax,%rbx
mov    $0x1,%edi
mov    $0x3e8,%esi
call   1060 <vector@plt>
mov    %rax,%r14
movsd  0xe5d(%rip),%xmm0
call   1070 <sqrt@plt>
movss  %xmm0,0x4(%rsp)
mov    $0x1,%ebp
lea    0x10(%rsp),%r15
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1080 <gasdev@plt>
mulss  0x4(%rsp),%xmm0
movss  %xmm0,(%rbx,%rbp,4)
add    $0x1,%rbp
cmp    $0x1389,%rbp
jne    11c0 <main+0x60>
movsd  0xe20(%rip),%xmm0
call   1070 <sqrt@plt>
movss  %xmm0,0x4(%rsp)
mov    $0x1,%ebp
lea    0x10(%rsp),%r15
nopl   (%rax)
mov    %r15,%rdi
call   1080 <gasdev@plt>
mulss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0xdf6(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14,%rbp,4)
add    $0x1,%rbp
cmp    $0x3e9,%rbp
jne    1200 <main+0xa0>
lea    0xdf8(%rip),%rdi
movsd  0xdc0(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe07(%rip),%rdi
movsd  0xdb2(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe16(%rip),%rdi
lea    0xe1d(%rip),%rsi
lea    0xe1a(%rip),%rdx
lea    0xe15(%rip),%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
lea    0x8(%rsp),%r15
lea    0xc(%rsp),%r12
lea    0xe04(%rip),%r13
jmp    12ac <main+0x14c>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0xc,%ebp
je     13b3 <main+0x253>
mov    %rbx,%rdi
mov    $0x1388,%esi
mov    %r14,%rdx
mov    $0x3e8,%ecx
mov    %r15,%r8
mov    %r12,%r9
call   1050 <tutest@plt>
lea    -0x1(%rbp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xd3f(%rip),%xmm0
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  0xc(%rsp),%xmm2
cvtss2sd %xmm2,%xmm2
mov    %r13,%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movapd 0xd21(%rip),%xmm4
mov    $0xd,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cvtps2pd -0x28(%rbx,%rax,4),%xmm0
cvtps2pd -0x30(%rbx,%rax,4),%xmm1
cvtps2pd -0x18(%rbx,%rax,4),%xmm2
cvtps2pd -0x20(%rbx,%rax,4),%xmm3
addpd  %xmm4,%xmm1
addpd  %xmm4,%xmm0
addpd  %xmm4,%xmm3
cvtpd2ps %xmm0,%xmm0
addpd  %xmm4,%xmm2
cvtpd2ps %xmm1,%xmm1
unpcklpd %xmm0,%xmm1
cvtpd2ps %xmm2,%xmm0
cvtpd2ps %xmm3,%xmm2
unpcklpd %xmm0,%xmm2
movupd %xmm1,-0x30(%rbx,%rax,4)
movupd %xmm2,-0x20(%rbx,%rax,4)
cmp    $0x138d,%rax
je     12a0 <main+0x140>
cvtps2pd -0x8(%rbx,%rax,4),%xmm0
cvtps2pd -0x10(%rbx,%rax,4),%xmm1
cvtps2pd 0x8(%rbx,%rax,4),%xmm2
cvtps2pd (%rbx,%rax,4),%xmm3
addpd  %xmm4,%xmm1
addpd  %xmm4,%xmm0
addpd  %xmm4,%xmm3
cvtpd2ps %xmm0,%xmm0
addpd  %xmm4,%xmm2
cvtpd2ps %xmm1,%xmm1
unpcklpd %xmm0,%xmm1
cvtpd2ps %xmm2,%xmm0
cvtpd2ps %xmm3,%xmm2
unpcklpd %xmm0,%xmm2
movupd %xmm1,-0x10(%rbx,%rax,4)
movupd %xmm2,(%rbx,%rax,4)
add    $0x10,%rax
jmp    1310 <main+0x1b0>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x3e8,%edx
call   1040 <free_vector@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1388,%edx
call   1040 <free_vector@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"\0ADistribution : variance = %6.2f\0A\00"
@.str.1 = [37 x i8] c"Distribution : variance = %6.2f\0A\0A\00"
@.str.2 = [14 x i8] c"%7s %8s %16s\0A\00"
@.str.3 = [6 x i8] c"shift\00"
@.str.4 = [2 x i8] c"t\00"
@.str.5 = [12 x i8] c"probability\00"
@.str.6 = [21 x i8] c"%6.2f %10.2f %11.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float*
%10 = alloca float*
store i32 0, i32* %1
store i64 -51773, i64* %2
%11 = call float* @vector(i32 1, i32 5000)
store float* %11, float** %9
%12 = call float* @vector(i32 1, i32 1000)
store float* %12, float** %10
%13 = call float @sqrt(double 1.000000e+00)
store float %13, float* %5
store i32 1, i32* %3
br label %14
14: ; preds = %25, %0
%15 = load i32, i32* %3
%16 = icmp sle i32 %15, 5000
br i1 %16, label %17, label %28
17: ; preds = %14
%18 = load float, float* %5
%19 = call float @gasdev(i64* %2)
%20 = fmul float %18, %19
%21 = load float*, float** %9
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds float, float* %21, i64 %23
store float %20, float* %24
br label %25
25: ; preds = %17
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %14
28: ; preds = %14
%29 = call float @sqrt(double 4.000000e+00)
store float %29, float* %6
store i32 1, i32* %3
br label %30
30: ; preds = %44, %28
%31 = load i32, i32* %3
%32 = icmp sle i32 %31, 1000
br i1 %32, label %33, label %47
33: ; preds = %30
%34 = load float, float* %6
%35 = call float @gasdev(i64* %2)
%36 = fmul float %34, %35
%37 = fpext float %36 to double
%38 = fadd double 1.000000e-01, %37
%39 = fptrunc double %38 to float
%40 = load float*, float** %10
%41 = load i32, i32* %3
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds float, float* %40, i64 %42
store float %39, float* %43
br label %44
44: ; preds = %33
%45 = load i32, i32* %3
%46 = add nsw i32 %45, 1
store i32 %46, i32* %3
br label %30
47: ; preds = %30
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), double 1.000000e+00)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double 4.000000e+00)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %51
51: ; preds = %83, %47
%52 = load i32, i32* %3
%53 = icmp sle i32 %52, 11
br i1 %53, label %54, label %86
54: ; preds = %51
%55 = load float*, float** %9
%56 = load float*, float** %10
%57 = call i32 @tutest(float* %55, i32 5000, float* %56, i32 1000, float* %8, float* %7)
%58 = load i32, i32* %3
%59 = sub nsw i32 %58, 1
%60 = sitofp i32 %59 to double
%61 = fmul double %60, 2.000000e-02
%62 = load float, float* %8
%63 = fpext float %62 to double
%64 = load float, float* %7
%65 = fpext float %64 to double
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), double %61, double %63, double %65)
store i32 1, i32* %4
br label %67
67: ; preds = %79, %54
%68 = load i32, i32* %4
%69 = icmp sle i32 %68, 5000
br i1 %69, label %70, label %82
70: ; preds = %67
%71 = load float*, float** %9
%72 = load i32, i32* %4
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds float, float* %71, i64 %73
%75 = load float, float* %74
%76 = fpext float %75 to double
%77 = fadd double %76, 2.000000e-02
%78 = fptrunc double %77 to float
store float %78, float* %74
br label %79
79: ; preds = %70
%80 = load i32, i32* %4
%81 = add nsw i32 %80, 1
store i32 %81, i32* %4
br label %67
82: ; preds = %67
br label %83
83: ; preds = %82
%84 = load i32, i32* %3
%85 = add nsw i32 %84, 1
store i32 %85, i32* %3
br label %51
86: ; preds = %51
%87 = load float*, float** %10
%88 = call i32 @free_vector(float* %87, i32 1, i32 1000)
%89 = load float*, float** %9
%90 = call i32 @free_vector(float* %89, i32 1, i32 5000)
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"\0ADistribution : variance = %6.2f\0A\00"
@.str.1 = [37 x i8] c"Distribution : variance = %6.2f\0A\0A\00"
@.str.2 = [14 x i8] c"%7s %8s %16s\0A\00"
@.str.3 = [6 x i8] c"shift\00"
@.str.4 = [2 x i8] c"t\00"
@.str.5 = [12 x i8] c"probability\00"
@.str.6 = [21 x i8] c"%6.2f %10.2f %11.2f\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca float
%3 = alloca float
%4 = bitcast i64* %1 to i8*
store i64 -51773, i64* %1
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call float* @vector(i32 1, i32 5000)
%8 = tail call float* @vector(i32 1, i32 1000)
%9 = tail call float @sqrt(double 1.000000e+00)
br label %10
10: ; preds = %0, %10
%11 = phi i64 [ 1, %0 ], [ %15, %10 ]
%12 = call float @gasdev(i64* %1)
%13 = fmul float %9, %12
%14 = getelementptr inbounds float, float* %7, i64 %11
store float %13, float* %14
%15 = add nuw nsw i64 %11, 1
%16 = icmp eq i64 %15, 5001
br i1 %16, label %17, label %10
17: ; preds = %10
%18 = call float @sqrt(double 4.000000e+00)
br label %19
19: ; preds = %17, %19
%20 = phi i64 [ 1, %17 ], [ %27, %19 ]
%21 = call float @gasdev(i64* %1)
%22 = fmul float %18, %21
%23 = fpext float %22 to double
%24 = fadd double %23, 1.000000e-01
%25 = fptrunc double %24 to float
%26 = getelementptr inbounds float, float* %8, i64 %20
store float %25, float* %26
%27 = add nuw nsw i64 %20, 1
%28 = icmp eq i64 %27, 1001
br i1 %28, label %29, label %19
29: ; preds = %19
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), double 1.000000e+00)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double 4.000000e+00)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %33
33: ; preds = %29, %79
%34 = phi i32 [ 1, %29 ], [ %80, %79 ]
%35 = call i32 @tutest(float* %7, i32 5000, float* %8, i32 1000, float* %3, float* %2)
%36 = add nsw i32 %34, -1
%37 = sitofp i32 %36 to double
%38 = fmul double %37, 2.000000e-02
%39 = load float, float* %3
%40 = fpext float %39 to double
%41 = load float, float* %2
%42 = fpext float %41 to double
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), double %38, double %40, double %42)
br label %44
44: ; preds = %62, %33
%45 = phi i64 [ 0, %33 ], [ %78, %62 ]
%46 = or i64 %45, 1
%47 = getelementptr inbounds float, float* %7, i64 %46
%48 = bitcast float* %47 to <4 x float>*
%49 = load <4 x float>, <4 x float>* %48
%50 = getelementptr inbounds float, float* %47, i64 4
%51 = bitcast float* %50 to <4 x float>*
%52 = load <4 x float>, <4 x float>* %51
%53 = fpext <4 x float> %49 to <4 x double>
%54 = fpext <4 x float> %52 to <4 x double>
%55 = fadd <4 x double> %53, <double 2.000000e-02, double 2.000000e-02, double 2.000000e-02, double 2.000000e-02>
%56 = fadd <4 x double> %54, <double 2.000000e-02, double 2.000000e-02, double 2.000000e-02, double 2.000000e-02>
%57 = fptrunc <4 x double> %55 to <4 x float>
%58 = fptrunc <4 x double> %56 to <4 x float>
%59 = bitcast float* %47 to <4 x float>*
store <4 x float> %57, <4 x float>* %59
%60 = bitcast float* %50 to <4 x float>*
store <4 x float> %58, <4 x float>* %60
%61 = icmp eq i64 %45, 4992
br i1 %61, label %79, label %62
62: ; preds = %44
%63 = or i64 %45, 9
%64 = getelementptr inbounds float, float* %7, i64 %63
%65 = bitcast float* %64 to <4 x float>*
%66 = load <4 x float>, <4 x float>* %65
%67 = getelementptr inbounds float, float* %64, i64 4
%68 = bitcast float* %67 to <4 x float>*
%69 = load <4 x float>, <4 x float>* %68
%70 = fpext <4 x float> %66 to <4 x double>
%71 = fpext <4 x float> %69 to <4 x double>
%72 = fadd <4 x double> %70, <double 2.000000e-02, double 2.000000e-02, double 2.000000e-02, double 2.000000e-02>
%73 = fadd <4 x double> %71, <double 2.000000e-02, double 2.000000e-02, double 2.000000e-02, double 2.000000e-02>
%74 = fptrunc <4 x double> %72 to <4 x float>
%75 = fptrunc <4 x double> %73 to <4 x float>
%76 = bitcast float* %64 to <4 x float>*
store <4 x float> %74, <4 x float>* %76
%77 = bitcast float* %67 to <4 x float>*
store <4 x float> %75, <4 x float>* %77
%78 = add nuw nsw i64 %45, 16
br label %44
79: ; preds = %44
%80 = add nuw nsw i32 %34, 1
%81 = icmp eq i32 %80, 12
br i1 %81, label %82, label %33
82: ; preds = %79
%83 = call i32 @free_vector(float* %8, i32 1, i32 1000)
%84 = call i32 @free_vector(float* %7, i32 1, i32 5000)
ret i32 0
}