// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/distributions.c
// Function: studentized_range
double studentized_range(double q, double v, double r)
{
 double pj,ehj,hj,x,pz,w0,pk,gk,pk1,pk2,gstep,gmid,c,v2,h,r1,g,vw[30],qw[30],pcutj=0.00003,pcutk=0.0001,step=0.45,vmax=12000.0,fifth=0.2,cv1=0.193064705,cv2=0.293525326,cvmax=0.39894228,cv[4]={0.318309886,-0.00268132716,-0.00347222222,0.0833333333},result;
 int j,k,jmin=3,jmax=15,kmin=7,kmax=15,jump,jj,op,op2;
 result=0;
 if (q<=0)
   return result;
 g=step*pow(r,-fifth);
 gmid=0.5*log(r);
 r1=r-1;
 c=log(r*g*cvmax);
 if (c<vmax)
  {
   h=step*pow(v,-0.5);
   v2=v*0.5;
   if (v==1)
     c=cv1;
   else
     if (v==2)
       c=cv2;
     else
       c=sqrt(v2)*cv[0]/(1+((cv[1]/v2+cv[2])/v2+cv[3])/v2);
   c=log(c*g*r*h);
  }
 gstep=g;
 qw[0]=-1;
 qw[jmax]=-1;
 pk1=1;
 pk2=1;
 for (k=1;k<=kmax;k++)
  {
   gstep=gstep-g;
   op2=0;
   while ((gstep>0)||(op2==0))
    {
     gstep=-gstep;
     gk=gmid+gstep;
     pk=0;
     if ((pk2>pcutk)||(k<=kmin))
      {
       w0=c-0.5*gk*gk;
       pz=normal(gk,1);
       x=normal(gk-q,1)-pz;
       if (x>0)
         pk=exp(w0+r1*log(x));
       if (v<=vmax)
        {
         jump=-jmax;
         op=0;
         while ((h<0)||(op==0))
          {
           jump=jump+jmax;
           for (j=1;j<=jmax;j++)
            {
             jj=j+jump;
             if (qw[jj-1]<=0)
              {
               hj=h*j;
               if (j<jmax)
                 qw[jj]=-1;
               ehj=exp(hj);
               qw[jj-1]=q*ehj;
               vw[jj-1]=v*(hj+0.5-0.5*ehj*ehj);
              }
             pj=0;
             x=normal(gk-qw[jj-1],1)-pz;
             if (x>0)
               pj=exp(w0+vw[jj-1]+r1*log(x));
             pk=pk+pj;
             if (pj<=pcutj)
               if ((jj>jmin)||(k>kmin))
                 break;
            }
           h=-h;
           op++;
          }
        }
      }
     result=result+pk;
     if ((k>kmin)&&(pk<=pcutk)&&(pk1<=pcutk))
       return result;
     pk2=pk1;
     pk1=pk;
     op2++;
    }
  }
 return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movsd %xmm2, 0x8(%rsp)
movsd %xmm1, 0x20(%rsp)
xorpd %xmm2, %xmm2
movsd %xmm0, 0x80(%rsp)
xorpd %xmm1, %xmm1
movsd %xmm1, 0x18(%rsp)
ucomisd %xmm0, %xmm2
jae 0x1e600
movsd 0x79b15(%rip), %xmm1    # 0x97c20
movsd 0x8(%rsp), %xmm0
callq 0x42f0
mulsd 0x79b0a(%rip), %xmm0    # 0x97c28
movsd %xmm0, 0x10(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x4160
movsd %xmm0, 0x30(%rsp)
movsd 0x10(%rsp), %xmm0
mulsd 0x8(%rsp), %xmm0
mulsd 0x79ae7(%rip), %xmm0    # 0x97c30
callq 0x4160
movsd 0x79ae2(%rip), %xmm1    # 0x97c38
movsd %xmm0, 0x78(%rsp)
ucomisd %xmm0, %xmm1
jbe 0x1e1ae
movsd 0x77c6e(%rip), %xmm1    # 0x95dd8
movsd 0x20(%rsp), %xmm0
callq 0x42f0
movsd 0x20(%rsp), %xmm3
mulsd 0x79aa5(%rip), %xmm0    # 0x97c28
movapd %xmm0, 0x60(%rsp)
ucomisd 0x7738f(%rip), %xmm3    # 0x95520
jne 0x1e1bf
jp 0x1e1bf
movsd 0x79aa3(%rip), %xmm0    # 0x97c40
movsd 0x8(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
jmp 0x1e256
movsd 0x8(%rsp), %xmm2
movsd 0x10(%rsp), %xmm4
jmp 0x1e27b
ucomisd 0x77e81(%rip), %xmm3    # 0x96048
movsd 0x8(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
jne 0x1e1e1
jp 0x1e1e1
movsd 0x79a69(%rip), %xmm0    # 0x97c48
jmp 0x1e256
movsd 0x77b37(%rip), %xmm4    # 0x95d20
mulsd %xmm3, %xmm4
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm4
jb 0x1e1fd
sqrtsd %xmm4, %xmm0
jmp 0x1e218
movapd %xmm4, %xmm0
movsd %xmm4, 0x28(%rsp)
callq 0x4300
movsd 0x28(%rsp), %xmm4
movsd 0x10(%rsp), %xmm2
mulsd 0x79a30(%rip), %xmm0    # 0x97c50
movsd 0x79a30(%rip), %xmm1    # 0x97c58
divsd %xmm4, %xmm1
addsd 0x79a2c(%rip), %xmm1    # 0x97c60
divsd %xmm4, %xmm1
addsd 0x79a28(%rip), %xmm1    # 0x97c68
divsd %xmm4, %xmm1
addsd 0x772d4(%rip), %xmm1    # 0x95520
divsd %xmm1, %xmm0
movsd 0x8(%rsp), %xmm1
mulsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
mulsd 0x60(%rsp), %xmm0
callq 0x4160
movsd 0x10(%rsp), %xmm4
movsd 0x8(%rsp), %xmm2
movsd %xmm0, 0x78(%rsp)
movsd 0x30(%rsp), %xmm0
mulsd 0x77a97(%rip), %xmm0    # 0x95d20
movsd %xmm0, 0x30(%rsp)
addsd 0x77b19(%rip), %xmm2    # 0x95db0
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
leaq 0xa0(%rsp), %rcx
movq %rax, (%rcx)
movq %rax, 0x78(%rcx)
pushq $0x1
popq %rbx
xorpd %xmm3, %xmm3
movsd 0x77261(%rip), %xmm0    # 0x95520
movapd %xmm4, 0x50(%rsp)
xorpd %xmm1, %xmm1
movsd %xmm1, 0x18(%rsp)
movl %ebx, %ebp
movapd %xmm0, %xmm5
movapd %xmm2, %xmm1
movapd %xmm4, %xmm2
movsd %xmm1, 0x8(%rsp)
cmpl $0x10, %ebp
je 0x1e600
movapd 0x50(%rsp), %xmm1
subsd %xmm2, %xmm1
movapd %xmm1, 0x50(%rsp)
xorl %r14d, %r14d
movapd %xmm5, %xmm4
movapd 0x50(%rsp), %xmm1
ucomisd %xmm3, %xmm1
seta %al
testl %r14d, %r14d
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x1e5f5
cmpl $0x8, %ebp
jb 0x1e338
xorpd %xmm5, %xmm5
ucomisd 0x79576(%rip), %xmm0    # 0x978a8
jbe 0x1e596
movsd %xmm4, 0x40(%rsp)
movsd 0x30(%rsp), %xmm0
subsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x98(%rsp)
movapd %xmm0, %xmm1
mulsd 0x77a79(%rip), %xmm1    # 0x95dd8
mulsd %xmm0, %xmm1
addsd 0x78(%rsp), %xmm1
movsd %xmm1, 0x88(%rsp)
movl %ebx, %edi
callq 0x1df1d
movsd %xmm0, 0x90(%rsp)
movsd 0x98(%rsp), %xmm0
subsd 0x80(%rsp), %xmm0
movl %ebx, %edi
callq 0x1df1d
subsd 0x90(%rsp), %xmm0
xorpd %xmm5, %xmm5
ucomisd %xmm5, %xmm0
jbe 0x1e3cb
callq 0x4160
mulsd 0x8(%rsp), %xmm0
addsd 0x88(%rsp), %xmm0
callq 0x4060
movapd %xmm0, %xmm5
movsd 0x79865(%rip), %xmm0    # 0x97c38
ucomisd 0x20(%rsp), %xmm0
movsd 0x10(%rsp), %xmm2
xorpd %xmm3, %xmm3
movsd 0x40(%rsp), %xmm4
jb 0x1e596
movl %r14d, 0x48(%rsp)
xorl %edx, %edx
pushq $0x1
popq %r15
leaq 0x190(%rsp), %r12
leaq 0xa0(%rsp), %r14
movapd 0x60(%rsp), %xmm0
movapd %xmm0, 0x60(%rsp)
ucomisd %xmm0, %xmm3
seta %al
testl %edx, %edx
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x1e591
movl %edx, 0x4c(%rsp)
xorl %r13d, %r13d
cmpq $0xf, %r13
je 0x1e56c
movsd %xmm5, 0x28(%rsp)
movsd (%r14,%r13,8), %xmm1
ucomisd %xmm1, %xmm3
jb 0x1e4c3
cmpq $0xe, %r13
movapd 0x60(%rsp), %xmm1
je 0x1e46b
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
movq %rax, 0x8(%r14,%r13,8)
leal 0x1(%r13), %eax
cvtsi2sd %eax, %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
callq 0x4060
movapd %xmm0, %xmm2
mulsd 0x7794a(%rip), %xmm2    # 0x95dd8
mulsd %xmm0, %xmm2
movapd %xmm0, %xmm1
mulsd 0x80(%rsp), %xmm1
movsd %xmm1, (%r14,%r13,8)
movsd 0x38(%rsp), %xmm0
addsd 0x7786d(%rip), %xmm0    # 0x95d20
addsd %xmm0, %xmm2
mulsd 0x20(%rsp), %xmm2
movsd %xmm2, (%r12,%r13,8)
movsd 0x98(%rsp), %xmm0
subsd %xmm1, %xmm0
movl %ebx, %edi
callq 0x1df1d
subsd 0x90(%rsp), %xmm0
xorpd %xmm3, %xmm3
ucomisd %xmm3, %xmm0
jbe 0x1e53f
movsd (%r12,%r13,8), %xmm1
addsd 0x88(%rsp), %xmm1
movsd %xmm1, 0x38(%rsp)
callq 0x4160
mulsd 0x8(%rsp), %xmm0
addsd 0x38(%rsp), %xmm0
callq 0x4060
xorpd %xmm3, %xmm3
movsd 0x28(%rsp), %xmm5
addsd %xmm0, %xmm5
movsd 0x79745(%rip), %xmm1    # 0x97c70
ucomisd %xmm0, %xmm1
movsd 0x10(%rsp), %xmm2
movsd 0x40(%rsp), %xmm4
jae 0x1e555
jmp 0x1e564
movsd 0x28(%rsp), %xmm5
addsd %xmm3, %xmm5
movsd 0x10(%rsp), %xmm2
movsd 0x40(%rsp), %xmm4
cmpl $0x7, %ebp
ja 0x1e56c
leaq (%r15,%r13), %rax
cmpq $0x3, %rax
jg 0x1e56c
incq %r13
jmp 0x1e434
movapd 0x60(%rsp), %xmm0
xorpd 0x77c56(%rip), %xmm0    # 0x961d0
movl 0x4c(%rsp), %edx
incl %edx
addq $0x78, %r14
addq $0x78, %r12
addq $0xf, %r15
jmp 0x1e410
movl 0x48(%rsp), %r14d
movaps 0x50(%rsp), %xmm0
xorps 0x77c2e(%rip), %xmm0    # 0x961d0
movaps %xmm0, 0x50(%rsp)
incl %r14d
movsd 0x18(%rsp), %xmm0
addsd %xmm5, %xmm0
movsd %xmm0, 0x18(%rsp)
movapd %xmm4, %xmm0
cmpl $0x8, %ebp
jb 0x1e2ff
movsd 0x792d9(%rip), %xmm0    # 0x978a8
ucomisd %xmm5, %xmm0
movapd %xmm4, %xmm0
jb 0x1e2ff
movsd 0x792c3(%rip), %xmm0    # 0x978a8
ucomisd %xmm4, %xmm0
movapd %xmm4, %xmm0
jb 0x1e2ff
jmp 0x1e600
incl %ebp
movapd %xmm4, %xmm5
jmp 0x1e2e3
movsd 0x18(%rsp), %xmm0
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq