// File: /workspace/github_c_makefile_star2_O2/yhg926[P]public_kssd/command_dist.c
// Function: fname_dist_print
void fname_dist_print(int ref_bin_code, int qry_fcode, const char *distout_dir, unsigned int*ref_ctx_ct_list,
   unsigned int*qry_ctx_ct_list, char (*refname)[PATHLEN], char (*qryfname)[PATHLEN], FILE *dout_fp)
{
 sprintf(full_distfcode,"%s/%d.%d.dist",distout_dir,ref_bin_code,qry_fcode);
  ctx_obj_ct_t *ctx_obj_ct;
 int fd;
 struct stat s;
 fd = open (full_distfcode, O_RDONLY);
 check (fd < 0, "open %s failed: %s", full_distfcode, strerror (errno));
 fstat (fd, & s);
 ctx_obj_ct = mmap(0, s.st_size , PROT_READ, MAP_PRIVATE, fd, 0);
 check ( ctx_obj_ct == MAP_FAILED, "mmap %s failed: %s", full_distfcode, strerror (errno));
 double jac_ind,contain_ind,Dm,Da,P_K_in_X_XnY, P_K_in_Y_XnY,
 j_prim, c_prim,
 sd_j_prim, sd_c_prim,
 CI95_j_prim1, CI95_j_prim2, CI95_c_prim1, CI95_c_prim2,
 CI95_Dm_prim1,CI95_Dm_prim2,CI95_Da_prim1,CI95_Da_prim2;
 int Min_XY_size, X_size, Y_size, XnY_size, XuY_size, X_XnY_size, Y_XnY_size ;
 for(llong i = 0;i < s.st_size/sizeof(ctx_obj_ct_t); i++) {
  X_size = ref_ctx_ct_list[ref_bin_code*BIN_SZ + i];
  Y_size = qry_ctx_ct_list[qry_fcode];
  Min_XY_size = X_size < Y_size ? X_size : Y_size ;
  XnY_size = ctx_obj_ct[i];
  XuY_size = X_size + Y_size - XnY_size ;
  X_XnY_size = X_size - XnY_size;
  Y_XnY_size = Y_size- XnY_size;
  jac_ind = (double)XnY_size / XuY_size;
  contain_ind = (double)XnY_size / Min_XY_size ;
  Dm = jac_ind ==1? 0: -log(2*jac_ind/(1+jac_ind)) / kmerlen ;
  Da = contain_ind==1? 0: -log(contain_ind) / kmerlen ;
  P_K_in_X_XnY = 1 - pow( (1- 1/pow(alp_size,(kmerlen - dim_reduct_len) )), X_XnY_size );
  P_K_in_Y_XnY = 1 - pow( (1- 1/pow(alp_size,(kmerlen - dim_reduct_len) )), Y_XnY_size );
  double rs = P_K_in_X_XnY * P_K_in_Y_XnY * ( X_XnY_size + Y_XnY_size )
       /(P_K_in_X_XnY + P_K_in_Y_XnY - 2*P_K_in_X_XnY * P_K_in_Y_XnY);
  j_prim = ((double)XnY_size - rs) / XuY_size ;
  c_prim = ((double)XnY_size - rs) / Min_XY_size ;
  sd_j_prim = pow(j_prim*(1 - j_prim) / XuY_size, 0.5) ;
  sd_c_prim = pow(c_prim*(1 - c_prim) / Min_XY_size,0.5) ;
  CI95_j_prim1 = j_prim - 1.96*sd_j_prim;
  CI95_j_prim2 = j_prim + 1.96*sd_j_prim;
  CI95_c_prim1 = c_prim - 1.96*sd_c_prim;
  CI95_c_prim2 = c_prim + 1.96*sd_c_prim;
  CI95_Dm_prim1 = CI95_j_prim2 == 1? 0:-log(2*CI95_j_prim2/(1+CI95_j_prim2)) / kmerlen ;
  CI95_Dm_prim2 = CI95_j_prim1 == 1? 0:-log(2*CI95_j_prim1/(1+CI95_j_prim1)) / kmerlen ;
  CI95_Da_prim1 = CI95_c_prim2 == 1? 0:-log(CI95_c_prim2) / kmerlen ;
  CI95_Da_prim2 = CI95_c_prim1 == 1? 0:-log(CI95_c_prim1) / kmerlen ;
  double pv_j_prim = 0.5 * erfc( j_prim / sd_j_prim * pow(0.5,0.5) );
  double pv_c_prim = 0.5 * erfc( c_prim/sd_c_prim * pow(0.5,0.5) );
  double qv_j_prim = pv_j_prim * ref_seq_num*qry_seq_num ;
  double qv_c_prim = pv_c_prim * ref_seq_num*qry_seq_num ;
  fprintf(dout_fp,"%s\t%s\t%u-%u|%u|%u\t%lf\t%lf\t%lf\t%lf\t[%lf,%lf]\t[%lf,%lf]\t[%lf,%lf]\t[%lf,%lf]\t%E\t%E\t%E\t%E\n", qryfname[qry_fcode],refname[ref_bin_code*BIN_SZ + i],XnY_size,(unsigned int)rs,X_size,Y_size,jac_ind,Dm,
        contain_ind,Da,CI95_j_prim1,CI95_j_prim2,CI95_Dm_prim1,CI95_Dm_prim2,CI95_c_prim1,
    CI95_c_prim2,CI95_Da_prim1,CI95_Da_prim2,pv_j_prim,pv_c_prim,qv_j_prim,qv_c_prim);
 }
 close(fd);
  munmap(ctx_obj_ct, s.st_size);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %r9, 0x68(%rsp)
movq %r8, 0xd8(%rsp)
movq %rcx, 0x58(%rsp)
movl %esi, %r8d
movl %esi, 0x60(%rsp)
movl %edi, %r15d
movq 0x238(%rsp), %rax
movq %rax, 0xd0(%rsp)
leaq 0x544eb(%rip), %r13     # 0x5d500
leaq 0xbed9(%rip), %rsi      # 0x14ef5
xorl %ebx, %ebx
movq %r13, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x3430
movq %r13, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x3380
movl %eax, %r14d
movl %eax, %r12d
shrl $0x1f, %r12d
callq 0x3060
movq %rax, %rbp
movl (%rax), %edi
callq 0x3470
leaq 0xb158(%rip), %rsi      # 0x141af
movl %r12d, %edi
movq %r13, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xb564
leaq 0x168(%rsp), %r12
movl %r14d, %edi
movq %r12, %rsi
callq 0x34a0
movq 0x30(%r12), %r12
pushq $0x1
popq %rdx
pushq $0x2
popq %rcx
xorl %edi, %edi
movq %r12, %rsi
movl %r14d, 0x7c(%rsp)
movl %r14d, %r8d
xorl %r9d, %r9d
callq 0x3150
xorl %r13d, %r13d
movq %rax, 0x80(%rsp)
cmpq $-0x1, %rax
sete %r13b
movl (%rbp), %edi
callq 0x3470
leaq 0xb106(%rip), %rsi      # 0x141c2
movl %r13d, %edi
leaq 0x5443a(%rip), %rdx     # 0x5d500
movq %rax, %rcx
xorl %eax, %eax
callq 0xb564
movq %r12, 0xb0(%rsp)
shrq $0x2, %r12
movq %r12, 0xe0(%rsp)
shll $0x10, %r15d
movslq 0x60(%rsp), %rcx
movq %rcx, 0xc8(%rsp)
shlq $0x8, %rcx
addq 0x230(%rsp), %rcx
movq %rcx, 0xc0(%rsp)
movslq %r15d, %r15
movq 0x58(%rsp), %rax
leaq (%rax,%r15,4), %rax
movq %rax, 0xb8(%rsp)
shlq $0x8, %r15
addq 0x68(%rsp), %r15
movsd 0xb5ea(%rip), %xmm2     # 0x14718
cmpq %rbx, 0xe0(%rsp)
je 0x9701
movq %r15, 0xf8(%rsp)
movq 0xb8(%rsp), %rax
movl (%rax,%rbx,4), %r12d
movq 0xd8(%rsp), %rax
movq 0xc8(%rsp), %rcx
movl (%rax,%rcx,4), %r14d
cmpl %r14d, %r12d
movl %r14d, %r15d
cmovll %r12d, %r15d
movq 0x80(%rsp), %rax
movl (%rax,%rbx,4), %ebp
leal (%r14,%r12), %eax
cvtsi2sd %ebp, %xmm3
subl %ebp, %eax
cvtsi2sd %eax, %xmm0
movapd %xmm3, %xmm1
movsd %xmm0, 0x60(%rsp)
divsd %xmm0, %xmm1
xorpd %xmm0, %xmm0
movsd %xmm1, 0xa8(%rsp)
ucomisd %xmm2, %xmm1
movsd %xmm3, 0x68(%rsp)
jne 0x91b0
jnp 0x91f0
movsd 0xa8(%rsp), %xmm1
movapd %xmm1, %xmm0
addsd %xmm1, %xmm0
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x3230
movsd 0x68(%rsp), %xmm3
movsd 0xb53c(%rip), %xmm2     # 0x14718
xorpd 0xb56c(%rip), %xmm0     # 0x14750
cvtsi2sdl 0x5430c(%rip), %xmm1 # 0x5d4f8
divsd %xmm1, %xmm0
movapd %xmm0, 0x150(%rsp)
cvtsi2sd %r15d, %xmm1
movapd %xmm3, %xmm0
movsd %xmm1, 0x70(%rsp)
divsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
movsd %xmm0, 0xf0(%rsp)
jne 0x9232
jp 0x9232
xorpd %xmm0, %xmm0
movapd %xmm0, 0x100(%rsp)
movl 0x542c8(%rip), %eax     # 0x5d4f8
jmp 0x9256
callq 0x3230
xorpd 0xb511(%rip), %xmm0     # 0x14750
movl 0x542b3(%rip), %eax     # 0x5d4f8
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movapd %xmm0, 0x100(%rsp)
movl %r12d, %r13d
subl %ebp, %r13d
movl %r14d, %r15d
subl %ebp, %r15d
cvtsi2sdl 0x1258e(%rip), %xmm0 # 0x1b7f8
subl 0x5428c(%rip), %eax     # 0x5d4fc
cvtsi2sd %eax, %xmm1
callq 0x30f0
movsd 0xb497(%rip), %xmm2     # 0x14718
movapd %xmm2, %xmm1
divsd %xmm0, %xmm1
movapd %xmm2, %xmm0
subsd %xmm1, %xmm0
cvtsi2sd %r13d, %xmm1
callq 0x30f0
movsd 0xb475(%rip), %xmm1     # 0x14718
subsd %xmm0, %xmm1
movsd %xmm1, 0x58(%rsp)
cvtsi2sdl 0x12543(%rip), %xmm0 # 0x1b7f8
movl 0x5423d(%rip), %eax     # 0x5d4f8
subl 0x5423b(%rip), %eax     # 0x5d4fc
cvtsi2sd %eax, %xmm1
callq 0x30f0
movsd 0xb446(%rip), %xmm2     # 0x14718
movapd %xmm2, %xmm1
divsd %xmm0, %xmm1
movapd %xmm2, %xmm0
subsd %xmm1, %xmm0
cvtsi2sd %r15d, %xmm1
callq 0x30f0
movsd 0xb424(%rip), %xmm3     # 0x14718
movapd %xmm3, %xmm1
subsd %xmm0, %xmm1
movsd 0x58(%rsp), %xmm4
movapd %xmm4, %xmm0
addl %r13d, %r15d
cvtsi2sd %r15d, %xmm2
mulsd %xmm1, %xmm0
mulsd %xmm0, %xmm2
movapd %xmm4, %xmm0
addsd %xmm1, %xmm0
mulsd 0xb3fa(%rip), %xmm4     # 0x14720
mulsd %xmm1, %xmm4
addsd %xmm0, %xmm4
divsd %xmm4, %xmm2
movsd 0x68(%rsp), %xmm0
movsd %xmm2, 0xe8(%rsp)
subsd %xmm2, %xmm0
movapd %xmm0, %xmm2
movsd 0x60(%rsp), %xmm1
divsd %xmm1, %xmm2
movsd %xmm2, 0x58(%rsp)
divsd 0x70(%rsp), %xmm0
movsd %xmm0, 0x68(%rsp)
movapd %xmm3, %xmm0
subsd %xmm2, %xmm0
mulsd %xmm2, %xmm0
divsd %xmm1, %xmm0
movsd 0xb3ab(%rip), %xmm1     # 0x14728
callq 0x30f0
movsd %xmm0, 0x60(%rsp)
movsd 0xb388(%rip), %xmm0     # 0x14718
movsd 0x68(%rsp), %xmm1
subsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
divsd 0x70(%rsp), %xmm0
movsd 0xb37c(%rip), %xmm1     # 0x14728
callq 0x30f0
movsd 0x60(%rsp), %xmm4
movsd 0x58(%rsp), %xmm3
movsd 0xb353(%rip), %xmm2     # 0x14718
movapd %xmm0, %xmm5
movapd %xmm4, %xmm0
mulsd 0xb363(%rip), %xmm0     # 0x14738
addsd %xmm3, %xmm0
xorpd %xmm1, %xmm1
movapd %xmm1, 0x120(%rsp)
movsd %xmm0, 0xa0(%rsp)
ucomisd %xmm2, %xmm0
xorpd %xmm0, %xmm0
movsd %xmm5, 0x70(%rsp)
jne 0x9401
jnp 0x944d
movsd 0xa0(%rsp), %xmm1
movapd %xmm1, %xmm0
addsd %xmm1, %xmm0
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x3230
movsd 0x70(%rsp), %xmm5
movsd 0x60(%rsp), %xmm4
movsd 0x58(%rsp), %xmm3
movsd 0xb2df(%rip), %xmm2     # 0x14718
xorpd 0xb30f(%rip), %xmm0     # 0x14750
cvtsi2sdl 0x540af(%rip), %xmm1 # 0x5d4f8
divsd %xmm1, %xmm0
movapd %xmm0, 0x140(%rsp)
movapd %xmm4, %xmm0
mulsd 0xb2ce(%rip), %xmm0     # 0x14730
addsd %xmm3, %xmm0
movsd %xmm0, 0x98(%rsp)
ucomisd %xmm2, %xmm0
jne 0x9477
jnp 0x94cc
movsd 0x98(%rsp), %xmm1
movapd %xmm1, %xmm0
addsd %xmm1, %xmm0
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x3230
movsd 0x70(%rsp), %xmm5
movsd 0x60(%rsp), %xmm4
movsd 0x58(%rsp), %xmm3
movsd 0xb269(%rip), %xmm2     # 0x14718
xorpd 0xb299(%rip), %xmm0     # 0x14750
cvtsi2sdl 0x54039(%rip), %xmm1 # 0x5d4f8
divsd %xmm1, %xmm0
movapd %xmm0, 0x120(%rsp)
movapd %xmm5, %xmm0
mulsd 0xb260(%rip), %xmm0     # 0x14738
movsd 0x68(%rsp), %xmm1
addsd %xmm1, %xmm0
xorpd %xmm6, %xmm6
movapd %xmm6, 0x110(%rsp)
movsd %xmm0, 0x90(%rsp)
ucomisd %xmm2, %xmm0
xorpd %xmm0, %xmm0
jne 0x9504
jnp 0x9546
movsd 0x90(%rsp), %xmm0
callq 0x3230
movsd 0x70(%rsp), %xmm5
movsd 0x60(%rsp), %xmm4
movsd 0x58(%rsp), %xmm3
movsd 0x68(%rsp), %xmm1
movsd 0xb1e6(%rip), %xmm2     # 0x14718
xorpd 0xb216(%rip), %xmm0     # 0x14750
cvtsi2sdl 0x53fb6(%rip), %xmm6 # 0x5d4f8
divsd %xmm6, %xmm0
movapd %xmm0, 0x130(%rsp)
mulsd 0xb1d9(%rip), %xmm5     # 0x14730
addsd %xmm1, %xmm5
movsd %xmm5, 0x88(%rsp)
ucomisd %xmm2, %xmm5
movq 0xf8(%rsp), %r15
jne 0x9574
jnp 0x95ab
movsd 0x88(%rsp), %xmm0
callq 0x3230
movsd 0x60(%rsp), %xmm4
movsd 0x58(%rsp), %xmm3
xorpd 0xb1ba(%rip), %xmm0     # 0x14750
cvtsi2sdl 0x53f5a(%rip), %xmm1 # 0x5d4f8
divsd %xmm1, %xmm0
movapd %xmm0, 0x110(%rsp)
divsd %xmm4, %xmm3
movsd 0xb189(%rip), %xmm0     # 0x14740
mulsd %xmm0, %xmm3
movapd %xmm3, %xmm0
callq 0x3030
movapd %xmm0, %xmm1
movsd 0xb158(%rip), %xmm0     # 0x14728
mulsd %xmm0, %xmm1
movsd %xmm1, 0x58(%rsp)
movsd 0x68(%rsp), %xmm0
divsd 0x70(%rsp), %xmm0
mulsd 0xb152(%rip), %xmm0     # 0x14740
callq 0x3030
mulsd 0xb12d(%rip), %xmm0     # 0x14728
cvtsi2sdl 0x53eed(%rip), %xmm1 # 0x5d4f0
movsd 0x58(%rsp), %xmm4
movapd %xmm4, %xmm2
mulsd %xmm1, %xmm2
cvtsi2sdl 0x53edb(%rip), %xmm3 # 0x5d4f4
mulsd %xmm3, %xmm2
mulsd %xmm0, %xmm1
mulsd %xmm3, %xmm1
cvttsd2si 0xe8(%rsp), %r9
movsd %xmm1, 0x48(%rsp)
movsd %xmm2, 0x40(%rsp)
movsd %xmm0, 0x38(%rsp)
movsd %xmm4, 0x30(%rsp)
movaps 0x110(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movaps 0x130(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x88(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movl %r14d, 0x8(%rsp)
movl %r12d, (%rsp)
movq 0xd0(%rsp), %rdi
leaq 0xbbeb(%rip), %rsi      # 0x15284
movq 0xc0(%rsp), %rdx
movq %r15, %rcx
movl %ebp, %r8d
movsd 0xa8(%rsp), %xmm0
movaps 0x150(%rsp), %xmm1
movsd 0xf0(%rsp), %xmm2
movaps 0x100(%rsp), %xmm3
movsd 0x98(%rsp), %xmm4
movsd 0xa0(%rsp), %xmm5
movaps 0x140(%rsp), %xmm6
movaps 0x120(%rsp), %xmm7
movb $0x8, %al
callq 0x32c0
incq %rbx
addq $0x100, %r15            # imm = 0x100
jmp 0x9126
movl 0x7c(%rsp), %edi
callq 0x3220
movq 0x80(%rsp), %rdi
movq 0xb0(%rsp), %rsi
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3360