// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/distributions.c
// Function: kolmogorov_one_sample
double kolmogorov_one_sample(int n, double d) 
{ 
 int k, m, i, j, g;
 double h, s;
 matrix H, Q;
 s = d * d * n; 
 if (s > 7.24 || (s > 3.76 && n > 99)) 
   return 1 - 2 * exp(-(2.000071 + .331 / sqrt(n) + 1.409 / n) * s);
 k = (int)(n * d) + 1; 
 m = 2 * k - 1; 
 h = k - n * d; 
 H = matrix_alloc(m, m); 
 for (i = 0; i < m; i++) 
   for (j = 0; j < m; j++)
     if (i - j + 1 < 0) 
       H.values[i][j] = 0; 
     else 
       H.values[i][j] = 1; 
 for (i = 0; i < m; i++) 
  {
   H.values[i][0] -= pow(h, i + 1); 
   H.values[m - 1][i] -= pow(h, (m - i));
  } 
 H.values[m - 1][0] += (2 * h - 1 > 0 ? pow(2 * h - 1, m):0); 
 for (i = 0; i < m; i++) 
   for (j = 0; j < m; j++)
     if (i - j + 1 > 0) 
      for (g = 1; g <= i - j + 1; g++) 
        H.values[i][j] /= g; 
 Q = matrix_power(H, n); 
 s = Q.values[k - 1][k - 1]; 
 for (i = 1;i <= n; i++) 
   s = (s * i) / n; 
 matrix_free(H); 
 matrix_free(Q); 
 return s;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movapd %xmm0, %xmm2
mulsd %xmm0, %xmm2
cvtsi2sd %edi, %xmm1
mulsd %xmm1, %xmm2
ucomisd 0x7912e(%rip), %xmm2    # 0x97cf0
ja 0x1ebdb
cmpl $0x64, %edi
jl 0x1ec5c
ucomisd 0x79123(%rip), %xmm2    # 0x97cf8
jbe 0x1ec5c
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jb 0x1ebeb
sqrtsd %xmm1, %xmm0
jmp 0x1ec0a
movapd %xmm1, %xmm0
movapd %xmm1, 0x20(%rsp)
movsd %xmm2, (%rsp)
callq 0x4300
movsd (%rsp), %xmm2
movapd 0x20(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movapd 0x78e0a(%rip), %xmm0    # 0x97a20
divpd %xmm1, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd 0x790d6(%rip), %xmm1    # 0x97d00
addsd %xmm0, %xmm1
xorpd 0x7759a(%rip), %xmm1    # 0x961d0
mulsd %xmm1, %xmm2
movapd %xmm2, %xmm0
callq 0x4060
addsd %xmm0, %xmm0
movsd 0x768d1(%rip), %xmm1    # 0x95520
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
jmp 0x1ee84
movl %edi, 0x1c(%rsp)
movapd %xmm1, %xmm2
movsd %xmm0, 0x10(%rsp)
mulsd %xmm0, %xmm2
cvttsd2si %xmm2, %eax
leal 0x1(%rax), %ebp
leal 0x2(%rax,%rax), %r15d
movq %rax, 0x38(%rsp)
leal 0x1(%rax,%rax), %r12d
movapd 0x77544(%rip), %xmm0    # 0x961d0
movapd %xmm1, 0x20(%rsp)
xorpd %xmm1, %xmm0
movapd %xmm0, (%rsp)
movl %r12d, %edi
movl %r12d, %esi
callq 0x380d3
movq %rax, 0x40(%rsp)
movq %rdx, %r14
xorl %eax, %eax
testl %r12d, %r12d
movl $0x0, %r13d
cmovgl %r12d, %r13d
movsd 0x7685b(%rip), %xmm0    # 0x95520
cmpq %r13, %rax
je 0x1ecf8
movq (%r14,%rax,8), %rcx
movq %rax, %rdx
xorl %esi, %esi
cmpq %rsi, %r12
je 0x1ecf3
xorpd %xmm1, %xmm1
cmpq $-0x1, %rdx
jl 0x1ece6
movapd %xmm0, %xmm1
movsd %xmm1, (%rcx,%rsi,8)
incq %rsi
decq %rdx
jmp 0x1ecd3
incq %rax
jmp 0x1ecc5
cvtsi2sd %ebp, %xmm0
movapd (%rsp), %xmm1
mulsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, (%rsp)
movslq %r15d, %rax
movq %rax, 0x10(%rsp)
xorl %ebx, %ebx
movl %r12d, %ebp
cmpq %rbx, %r13
je 0x1ed72
leaq 0x1(%rbx), %r15
cvtsi2sd %r15d, %xmm1
movapd (%rsp), %xmm0
callq 0x42f0
movq (%r14,%rbx,8), %rax
movsd (%rax), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, (%rax)
cvtsi2sd %ebp, %xmm1
movapd (%rsp), %xmm0
callq 0x42f0
movq 0x10(%rsp), %rax
movq -0x10(%r14,%rax,8), %rax
movsd (%rax,%rbx,8), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rbx,8)
decl %ebp
movq %r15, %rbx
jmp 0x1ed1d
movapd (%rsp), %xmm1
addsd %xmm1, %xmm1
addsd 0x7702d(%rip), %xmm1    # 0x95db0
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jbe 0x1ed9b
movapd %xmm1, %xmm0
cvtsi2sd %r12d, %xmm1
callq 0x42f0
movq 0x10(%rsp), %rax
movq -0x10(%r14,%rax,8), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movl %r12d, %eax
pushq $0x1
popq %rcx
xorl %edx, %edx
movsd 0x76763(%rip), %xmm0    # 0x95520
movq 0x40(%rsp), %r15
cmpq %r13, %rdx
je 0x1ee13
xorl %esi, %esi
movl %ecx, %edi
testl %edi, %edi
movl $0x0, %r8d
cmovgl %edi, %r8d
cmpq %rax, %rsi
je 0x1ee0c
cmpq %rsi, %rdx
jae 0x1ede8
incq %rsi
decl %edi
jmp 0x1edcb
movapd %xmm0, %xmm1
subl $0x1, %r8d
jb 0x1ede1
movq (%r14,%rdx,8), %r9
movsd (%r9,%rsi,8), %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, (%r9,%rsi,8)
addsd %xmm0, %xmm1
jmp 0x1edec
incq %rdx
incl %ecx
jmp 0x1edc2
movq %r15, %rdi
movq %r14, %rsi
movl 0x1c(%rsp), %ebx
movl %ebx, %edx
callq 0x39d91
movq %rax, %r12
movq %rdx, %r13
movslq 0x38(%rsp), %rax
movq (%rdx,%rax,8), %rcx
movsd (%rcx,%rax,8), %xmm3
xorl %eax, %eax
testl %ebx, %ebx
cmovgl %ebx, %eax
movsd 0x766d9(%rip), %xmm0    # 0x95520
movapd %xmm0, %xmm1
movapd 0x20(%rsp), %xmm2
subl $0x1, %eax
jb 0x1ee64
mulsd %xmm1, %xmm3
divsd %xmm2, %xmm3
addsd %xmm0, %xmm1
jmp 0x1ee51
movq %r15, %rdi
movq %r14, %rsi
movsd %xmm3, (%rsp)
callq 0x3929f
movq %r12, %rdi
movq %r13, %rsi
callq 0x3929f
movsd (%rsp), %xmm0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop