#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 dinstance_normal(double *, int, int, double *, double *);
int /*<<< orphan*/ printTable();
int /*<<< orphan*/ printf(char *, ...);
double sqrt(int);
void stephens(double x[], int n) {
  double D, dinstance;
  double mu, sigma;
  double sqN;
  D = dinstance_normal(x, n, true, &mu, &sigma);
  sqN = sqrt(n) - .01 + .85 / sqrt(n);
  dinstance = D * sqN;
  printf("\n");
  printTable();
  printf("n         = %d\n", n);
  printf("mu        = %f\n", mu);
  printf("sigma     = %f\n", sigma);
  printf("D         = %f\n", D);
  printf("sqrt(N)   = %f\n", sqN);
  printf("D*sqrt(N) = %f\n", dinstance);
  printf("\n");
}


x86 assembly (clang, -O0):
<stephens>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0x1,%edx
lea    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   1040 <dinstance_normal@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1060 <sqrt@plt>
movsd  0xe8b(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0xc(%rbp),%edi
call   1060 <sqrt@plt>
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
movsd  0xe62(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <printTable@plt>
mov    -0xc(%rbp),%esi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
lea    0xe34(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
lea    0xe31(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
lea    0xe2e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x38(%rbp),%xmm0
lea    0xe2b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xe28(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stephens>:
push   %rbx
sub    $0x30,%rsp
mov    %esi,%ebx
lea    0x28(%rsp),%rcx
lea    0x20(%rsp),%r8
mov    $0x1,%edx
call   1050 <dinstance_normal@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebx,%edi
call   1070 <sqrt@plt>
addsd  0xe80(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1070 <sqrt@plt>
movsd  0xe73(%rip),%xmm1
divsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1060 <printTable@plt>
lea    0xe43(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movsd  0x28(%rsp),%xmm0
lea    0xe3d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x20(%rsp),%xmm0
lea    0xe39(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe3b(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe37(%rip),%rdi
movsd  0x18(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe33(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [16 x i8] c"n = %d\0A\00"
@.str.2 = [16 x i8] c"mu = %f\0A\00"
@.str.3 = [16 x i8] c"sigma = %f\0A\00"
@.str.4 = [16 x i8] c"D = %f\0A\00"
@.str.5 = [16 x i8] c"sqrt(N) = %f\0A\00"
@.str.6 = [16 x i8] c"D*sqrt(N) = %f\0A\00"
define void @stephens(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double* %0, double** %3
store i32 %1, i32* %4
%10 = load double*, double** %3
%11 = load i32, i32* %4
%12 = call double @dinstance_normal(double* %10, i32 %11, i32 1, double* %7, double* %8)
store double %12, double* %5
%13 = load i32, i32* %4
%14 = call double @sqrt(i32 %13)
%15 = fsub double %14, 1.000000e-02
%16 = load i32, i32* %4
%17 = call double @sqrt(i32 %16)
%18 = fdiv double 8.500000e-01, %17
%19 = fadd double %15, %18
store double %19, double* %9
%20 = load double, double* %5
%21 = load double, double* %9
%22 = fmul double %20, %21
store double %22, double* %6
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%24 = call i32 (...) @printTable()
%25 = load i32, i32* %4
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = load double, double* %7
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %27)
%29 = load double, double* %8
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), double %29)
%31 = load double, double* %5
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), double %31)
%33 = load double, double* %9
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), double %33)
%35 = load double, double* %6
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), double %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [16 x i8] c"n = %d\0A\00"
@.str.2 = [16 x i8] c"mu = %f\0A\00"
@.str.3 = [16 x i8] c"sigma = %f\0A\00"
@.str.4 = [16 x i8] c"D = %f\0A\00"
@.str.5 = [16 x i8] c"sqrt(N) = %f\0A\00"
@.str.6 = [16 x i8] c"D*sqrt(N) = %f\0A\00"
define void @stephens(double* %0, i32 %1) {
%3 = alloca double
%4 = alloca double
%5 = bitcast double* %3 to i8*
%6 = bitcast double* %4 to i8*
%7 = call double @dinstance_normal(double* %0, i32 %1, i32 1, double* %3, double* %4)
%8 = call double @sqrt(i32 %1)
%9 = fadd double %8, -1.000000e-02
%10 = call double @sqrt(i32 %1)
%11 = fdiv double 8.500000e-01, %10
%12 = fadd double %9, %11
%13 = fmul double %7, %12
%14 = call i32 @putchar(i32 10)
%15 = call i32 (...) @printTable()
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%17 = load double, double* %3
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %17)
%19 = load double, double* %4
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), double %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), double %7)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), double %12)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), double %13)
%24 = call i32 @putchar(i32 10)
ret void
}