#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*/ kstwo(float *, int, float *, int, float *, float *);
int /*<<< orphan*/ printf(char *, ...);
float sqrt(float);
float *vector(int, int);
int main(void) {
  long idum = (-1357);
  int i, j;
  float d, factr, prob, varnce, *data1, *data2;
  data1 = vector(1, 2000);
  data2 = vector(1, 1000);
  for (i = 1; i <= 2000; i++)
    data1[i] = gasdev(&idum);
  printf("%18s %15s %14s\n", "variance ratio", "k-s statistic", "probability");
  for (i = 1; i <= 11; i++) {
    varnce = 1.0 + (i - 1) * 0.1;
    factr = sqrt(varnce);
    for (j = 1; j <= 1000; j++)
      data2[j] = factr * gasdev(&idum);
    kstwo(data1, 2000, data2, 1000, &d, &prob);
    printf("%15.6f %15.6f %15.6f\n", varnce, d, prob);
  }
  free_vector(data2, 1, 1000);
  free_vector(data1, 1, 2000);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0xfffffffffffffab3,-0x10(%rbp)
ff
mov    $0x1,%edi
mov    $0x7d0,%esi
call   1050 <vector@plt>
mov    %rax,-0x30(%rbp)
mov    $0x1,%edi
mov    $0x3e8,%esi
call   1050 <vector@plt>
mov    %rax,-0x38(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x7d0,-0x14(%rbp)
jg     11d5 <main+0x75>
lea    -0x10(%rbp),%rdi
call   1080 <gasdev@plt>
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    11a4 <main+0x44>
lea    0xe34(%rip),%rdi
lea    0xe3d(%rip),%rsi
lea    0xe45(%rip),%rdx
lea    0xe4c(%rip),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
cmpl   $0xb,-0x14(%rbp)
jg     12e7 <main+0x187>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xde5(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xde1(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
call   1070 <sqrt@plt>
movss  %xmm0,-0x20(%rbp)
movl   $0x1,-0x18(%rbp)
cmpl   $0x3e8,-0x18(%rbp)
jg     1291 <main+0x131>
movss  -0x20(%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    -0x38(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    124a <main+0xea>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    $0x7d0,%esi
mov    $0x3e8,%ecx
lea    -0x1c(%rbp),%r8
lea    -0x24(%rbp),%r9
call   1060 <kstwo@plt>
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x24(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xd77(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ff <main+0x9f>
mov    -0x38(%rbp),%rdi
mov    $0x1,%esi
mov    $0x3e8,%edx
call   1040 <free_vector@plt>
mov    -0x30(%rbp),%rdi
mov    $0x1,%esi
mov    $0x7d0,%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   $0xfffffffffffffab3,0x10(%rsp)
ff ff
mov    $0x1,%edi
mov    $0x7d0,%esi
call   1050 <vector@plt>
mov    %rax,%r14
mov    $0x1,%edi
mov    $0x3e8,%esi
call   1050 <vector@plt>
mov    %rax,%rbx
mov    $0x1,%ebp
lea    0x10(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
call   1080 <gasdev@plt>
movss  %xmm0,(%r14,%rbp,4)
add    $0x1,%rbp
cmp    $0x7d1,%rbp
jne    11b0 <main+0x50>
lea    0xe42(%rip),%rdi
lea    0xe4b(%rip),%rsi
lea    0xe53(%rip),%rdx
lea    0xe5a(%rip),%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%r12d
lea    0x10(%rsp),%r15
lea    0xe4d(%rip),%rbp
lea    -0x1(%r12),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xdec(%rip),%xmm0
addsd  0xdec(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
ucomiss 0xde9(%rip),%xmm0
movss  %xmm0,(%rsp)
jb     1240 <main+0xe0>
xorps  %xmm1,%xmm1
sqrtss %xmm0,%xmm1
jmp    1248 <main+0xe8>
nopw   0x0(%rax,%rax,1)
call   1070 <sqrt@plt>
movaps %xmm0,%xmm1
mov    $0x1,%r13d
movss  %xmm1,0x4(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
call   1080 <gasdev@plt>
movss  0x4(%rsp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,(%rbx,%r13,4)
add    $0x1,%r13
cmp    $0x3e9,%r13
jne    1260 <main+0x100>
mov    %r14,%rdi
mov    $0x7d0,%esi
mov    %rbx,%rdx
mov    $0x3e8,%ecx
lea    0xc(%rsp),%r8
lea    0x8(%rsp),%r9
call   1060 <kstwo@plt>
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0xc(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  0x8(%rsp),%xmm2
cvtss2sd %xmm2,%xmm2
mov    %rbp,%rdi
mov    $0x3,%al
call   1030 <printf@plt>
add    $0x1,%r12d
cmp    $0xc,%r12d
jne    1200 <main+0xa0>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x3e8,%edx
call   1040 <free_vector@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x7d0,%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 = [16 x i8] c"%18s %15s %14s\0A\00"
@.str.1 = [15 x i8] c"variance ratio\00"
@.str.2 = [14 x i8] c"k-s statistic\00"
@.str.3 = [12 x i8] c"probability\00"
@.str.4 = [22 x i8] c"%15.6f %15.6f %15.6f\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 -1357, i64* %2
%11 = call float* @vector(i32 1, i32 2000)
store float* %11, float** %9
%12 = call float* @vector(i32 1, i32 1000)
store float* %12, float** %10
store i32 1, i32* %3
br label %13
13: ; preds = %22, %0
%14 = load i32, i32* %3
%15 = icmp sle i32 %14, 2000
br i1 %15, label %16, label %25
16: ; preds = %13
%17 = call float @gasdev(i64* %2)
%18 = load float*, float** %9
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds float, float* %18, i64 %20
store float %17, float* %21
br label %22
22: ; preds = %16
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %13
25: ; preds = %13
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %27
27: ; preds = %63, %25
%28 = load i32, i32* %3
%29 = icmp sle i32 %28, 11
br i1 %29, label %30, label %66
30: ; preds = %27
%31 = load i32, i32* %3
%32 = sub nsw i32 %31, 1
%33 = sitofp i32 %32 to double
%34 = call double @llvm.fmuladd.f64(double %33, double 1.000000e-01, double 1.000000e+00)
%35 = fptrunc double %34 to float
store float %35, float* %8
%36 = load float, float* %8
%37 = call float @sqrt(float %36)
store float %37, float* %6
store i32 1, i32* %4
br label %38
38: ; preds = %49, %30
%39 = load i32, i32* %4
%40 = icmp sle i32 %39, 1000
br i1 %40, label %41, label %52
41: ; preds = %38
%42 = load float, float* %6
%43 = call float @gasdev(i64* %2)
%44 = fmul float %42, %43
%45 = load float*, float** %10
%46 = load i32, i32* %4
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds float, float* %45, i64 %47
store float %44, float* %48
br label %49
49: ; preds = %41
%50 = load i32, i32* %4
%51 = add nsw i32 %50, 1
store i32 %51, i32* %4
br label %38
52: ; preds = %38
%53 = load float*, float** %9
%54 = load float*, float** %10
%55 = call i32 @kstwo(float* %53, i32 2000, float* %54, i32 1000, float* %5, float* %7)
%56 = load float, float* %8
%57 = fpext float %56 to double
%58 = load float, float* %5
%59 = fpext float %58 to double
%60 = load float, float* %7
%61 = fpext float %60 to double
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), double %57, double %59, double %61)
br label %63
63: ; preds = %52
%64 = load i32, i32* %3
%65 = add nsw i32 %64, 1
store i32 %65, i32* %3
br label %27
66: ; preds = %27
%67 = load float*, float** %10
%68 = call i32 @free_vector(float* %67, i32 1, i32 1000)
%69 = load float*, float** %9
%70 = call i32 @free_vector(float* %69, i32 1, i32 2000)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"%18s %15s %14s\0A\00"
@.str.1 = [15 x i8] c"variance ratio\00"
@.str.2 = [14 x i8] c"k-s statistic\00"
@.str.3 = [12 x i8] c"probability\00"
@.str.4 = [22 x i8] c"%15.6f %15.6f %15.6f\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca float
%3 = alloca float
%4 = bitcast i64* %1 to i8*
store i64 -1357, i64* %1
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call float* @vector(i32 1, i32 2000)
%8 = tail call float* @vector(i32 1, i32 1000)
br label %9
9: ; preds = %0, %9
%10 = phi i64 [ 1, %0 ], [ %13, %9 ]
%11 = call float @gasdev(i64* %1)
%12 = getelementptr inbounds float, float* %7, i64 %10
store float %11, float* %12
%13 = add nuw nsw i64 %10, 1
%14 = icmp eq i64 %13, 2001
br i1 %14, label %15, label %9
15: ; preds = %9
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %15, %31
%18 = phi i32 [ 1, %15 ], [ %39, %31 ]
%19 = add nsw i32 %18, -1
%20 = sitofp i32 %19 to double
%21 = call double @llvm.fmuladd.f64(double %20, double 1.000000e-01, double 1.000000e+00)
%22 = fptrunc double %21 to float
%23 = call float @sqrt(float %22)
br label %24
24: ; preds = %17, %24
%25 = phi i64 [ 1, %17 ], [ %29, %24 ]
%26 = call float @gasdev(i64* %1)
%27 = fmul float %23, %26
%28 = getelementptr inbounds float, float* %8, i64 %25
store float %27, float* %28
%29 = add nuw nsw i64 %25, 1
%30 = icmp eq i64 %29, 1001
br i1 %30, label %31, label %24
31: ; preds = %24
%32 = call i32 @kstwo(float* %7, i32 2000, float* %8, i32 1000, float* %2, float* %3)
%33 = fpext float %22 to double
%34 = load float, float* %2
%35 = fpext float %34 to double
%36 = load float, float* %3
%37 = fpext float %36 to double
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), double %33, double %35, double %37)
%39 = add nuw nsw i32 %18, 1
%40 = icmp eq i32 %39, 12
br i1 %40, label %41, label %17
41: ; preds = %31
%42 = call i32 @free_vector(float* %8, i32 1, i32 1000)
%43 = call i32 @free_vector(float* %7, i32 1, i32 2000)
ret i32 0
}