// File: /workspace/github_c_makefile_star2_O1/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 $0x278, %rsp            # imm = 0x278
movsd %xmm1, 0x10(%rsp)
xorpd %xmm3, %xmm3
movsd %xmm0, 0x48(%rsp)
ucomisd %xmm0, %xmm3
jae 0x204f5
movsd 0x84b3e(%rip), %xmm1    # 0xa4be8
movapd %xmm2, %xmm0
movsd %xmm2, (%rsp)
callq 0x42f0
mulsd 0x84b30(%rip), %xmm0    # 0xa4bf0
movsd %xmm0, 0x8(%rsp)
movsd (%rsp), %xmm0
callq 0x4160
movsd %xmm0, 0x30(%rsp)
movsd 0x8(%rsp), %xmm0
mulsd (%rsp), %xmm0
mulsd 0x84b0f(%rip), %xmm0    # 0xa4bf8
callq 0x4160
movsd 0x84b0a(%rip), %xmm1    # 0xa4c00
movsd %xmm0, 0x40(%rsp)
ucomisd %xmm0, %xmm1
jbe 0x2014b
movsd 0x82cc6(%rip), %xmm1    # 0xa2dd0
movsd 0x10(%rsp), %xmm0
callq 0x42f0
movsd 0x10(%rsp), %xmm1
movapd %xmm0, %xmm3
mulsd 0x84ac9(%rip), %xmm3    # 0xa4bf0
ucomisd 0x823f1(%rip), %xmm1    # 0xa2520
movapd %xmm3, 0x20(%rsp)
jne 0x2015c
jp 0x2015c
movsd 0x84ac7(%rip), %xmm0    # 0xa4c08
movsd (%rsp), %xmm2
jmp 0x201ee
movsd (%rsp), %xmm8
movsd 0x8(%rsp), %xmm1
jmp 0x20219
ucomisd 0x82edc(%rip), %xmm1    # 0xa3040
movsd (%rsp), %xmm2
jne 0x20177
jp 0x20177
movsd 0x84a9b(%rip), %xmm0    # 0xa4c10
jmp 0x201ee
movsd 0x82b99(%rip), %xmm4    # 0xa2d18
mulsd %xmm1, %xmm4
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm4
jb 0x20196
xorps %xmm0, %xmm0
sqrtsd %xmm4, %xmm0
jmp 0x201b6
movapd %xmm4, %xmm0
movsd %xmm4, 0x18(%rsp)
callq 0x4300
movsd 0x18(%rsp), %xmm4
movapd 0x20(%rsp), %xmm3
movsd (%rsp), %xmm2
mulsd 0x84a5a(%rip), %xmm0    # 0xa4c18
movsd 0x84a5a(%rip), %xmm1    # 0xa4c20
divsd %xmm4, %xmm1
addsd 0x84a56(%rip), %xmm1    # 0xa4c28
divsd %xmm4, %xmm1
addsd 0x84a52(%rip), %xmm1    # 0xa4c30
divsd %xmm4, %xmm1
addsd 0x82336(%rip), %xmm1    # 0xa2520
divsd %xmm1, %xmm0
mulsd 0x8(%rsp), %xmm0
mulsd %xmm2, %xmm0
mulsd %xmm3, %xmm0
callq 0x4160
movsd (%rsp), %xmm8
movsd 0x8(%rsp), %xmm1
movapd 0x20(%rsp), %xmm6
movsd %xmm0, 0x40(%rsp)
movsd 0x30(%rsp), %xmm0
mulsd 0x82af1(%rip), %xmm0    # 0xa2d18
movsd %xmm0, 0x30(%rsp)
addsd 0x82b72(%rip), %xmm8    # 0xa2da8
movabsq $-0x4010000000000000, %rbx # imm = 0xBFF0000000000000
leaq 0x90(%rsp), %rax
movq %rbx, (%rax)
movq %rbx, 0x78(%rax)
movl $0x1, %ebp
movsd 0x822c4(%rip), %xmm7    # 0xa2520
movsd 0x84684(%rip), %xmm2    # 0xa48e8
xorpd %xmm3, %xmm3
movapd %xmm7, %xmm5
movapd %xmm1, %xmm4
movsd %xmm8, (%rsp)
subsd %xmm1, %xmm4
movsd %xmm3, 0x78(%rsp)
movsd %xmm7, 0x70(%rsp)
cmpl $0x8, %ebp
movapd %xmm4, 0x80(%rsp)
jb 0x202a2
xorpd %xmm7, %xmm7
ucomisd %xmm2, %xmm5
jbe 0x2049c
movapd %xmm6, 0x20(%rsp)
movsd 0x30(%rsp), %xmm0
subsd %xmm4, %xmm0
movsd %xmm0, 0x18(%rsp)
movapd %xmm0, %xmm1
mulsd 0x82b0c(%rip), %xmm1    # 0xa2dd0
mulsd %xmm0, %xmm1
addsd 0x40(%rsp), %xmm1
movsd %xmm1, 0x50(%rsp)
movl $0x1, %edi
callq 0x1fecd
movsd %xmm0, 0x58(%rsp)
movsd 0x18(%rsp), %xmm0
subsd 0x48(%rsp), %xmm0
movl $0x1, %edi
callq 0x1fecd
subsd 0x58(%rsp), %xmm0
xorpd %xmm7, %xmm7
ucomisd %xmm7, %xmm0
jbe 0x20323
callq 0x4160
mulsd (%rsp), %xmm0
addsd 0x50(%rsp), %xmm0
callq 0x4060
movapd %xmm0, %xmm7
movsd 0x848d5(%rip), %xmm0    # 0xa4c00
ucomisd 0x10(%rsp), %xmm0
jae 0x2033e
movapd 0x20(%rsp), %xmm6
jmp 0x2049c
leaq 0x180(%rsp), %r12
leaq 0x90(%rsp), %r13
xorl %r15d, %r15d
movapd 0x20(%rsp), %xmm0
movapd %xmm0, 0x60(%rsp)
movl $0x1, %r14d
movsd %xmm7, 0x20(%rsp)
xorpd %xmm0, %xmm0
ucomisd -0x8(%r13,%r14,8), %xmm0
jb 0x203d6
cmpq $0xf, %r14
je 0x20381
movq %rbx, (%r13,%r14,8)
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
mulsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
callq 0x4060
movapd %xmm0, %xmm1
mulsd 0x82a2a(%rip), %xmm1    # 0xa2dd0
mulsd %xmm0, %xmm1
mulsd 0x48(%rsp), %xmm0
movsd %xmm0, -0x8(%r13,%r14,8)
movsd 0x38(%rsp), %xmm0
addsd 0x82953(%rip), %xmm0    # 0xa2d18
addsd %xmm0, %xmm1
mulsd 0x10(%rsp), %xmm1
movsd %xmm1, -0x8(%r12,%r14,8)
movsd 0x18(%rsp), %xmm0
subsd -0x8(%r13,%r14,8), %xmm0
movl $0x1, %edi
callq 0x1fecd
movapd %xmm0, %xmm1
subsd 0x58(%rsp), %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jbe 0x2042d
movsd -0x8(%r12,%r14,8), %xmm0
addsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
movapd %xmm1, %xmm0
callq 0x4160
mulsd (%rsp), %xmm0
addsd 0x38(%rsp), %xmm0
callq 0x4060
leaq (%r15,%r14), %rax
cmpl $0x8, %ebp
setae %cl
movsd 0x20(%rsp), %xmm7
addsd %xmm0, %xmm7
movsd 0x847ef(%rip), %xmm1    # 0xa4c38
ucomisd %xmm0, %xmm1
setae %dl
cmpq $0x4, %rax
setae %al
orb %cl, %al
testb %al, %dl
jne 0x2046e
leaq 0x1(%r14), %rax
cmpq $0xf, %r14
movq %rax, %r14
jb 0x20363
movapd 0x60(%rsp), %xmm0
movapd %xmm0, %xmm6
xorpd 0x82d50(%rip), %xmm6    # 0xa31d0
addq $0xf, %r15
addq $0x78, %r13
addq $0x78, %r12
ucomisd %xmm6, %xmm0
movapd %xmm6, 0x60(%rsp)
ja 0x2035d
movsd 0x78(%rsp), %xmm3
addsd %xmm7, %xmm3
cmpl $0x8, %ebp
movsd 0x84437(%rip), %xmm2    # 0xa48e8
movsd 0x70(%rsp), %xmm5
jb 0x204c5
ucomisd %xmm7, %xmm2
jb 0x204c5
ucomisd %xmm5, %xmm2
jae 0x204f5
xorpd %xmm0, %xmm0
movapd 0x80(%rsp), %xmm4
ucomisd %xmm4, %xmm0
xorpd 0x82cf2(%rip), %xmm4    # 0xa31d0
ja 0x2027a
incl %ebp
cmpl $0x10, %ebp
movsd 0x8(%rsp), %xmm1
jne 0x20276
movapd %xmm3, %xmm0
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq