// File: /workspace/github_c_makefile_star2_O0/yhg926[P]public_kssd/command_dist.c
// Function: dist_print_nobin
void dist_print_nobin (const char *distout_dir,unsigned int ref_num, unsigned int qry_num, unsigned int*ref_ctx_ct_list,
      unsigned int*qry_ctx_ct_list, int num_cof_batch, char (*refname)[PATHLEN], char (*qryfname)[PATHLEN],dist_opt_val_t *opt_val)
{
 if( opt_val->shared_kmerpath[0] != '\0') strcpy(full_distfcode, opt_val->shared_kmerpath );
  else sprintf(full_distfcode,"%s/sharedk_ct.dat",distout_dir);
  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_t * 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));
  close(fd);
 int p_fit_mem= opt_val->p;
 prt_line_t * prt_buf = malloc(ref_num * sizeof(prt_line_t));
 char distf[PATHLEN];
  sprintf(distf, "%s/distance.out", distout_dir);
 FILE *distfp = fopen(distf,"w") ;
  if( distfp == NULL ) err(errno,"dist_print_nobin():%s",distf);
 int num_mapping_distf = qry_num / num_cof_batch; int bnum_infile;
 print_ctrl_t outfield;
 outfield.metric = opt_val->metric ;
 outfield.pfield = opt_val->outfields;
 outfield.correction = opt_val->correction;
 outfield.dthreshold = opt_val->mut_dist_max;
 outfield.cmprsn_num = ref_num*qry_num;
#define MAX_CNAME_SIZE 30
 char header[2][3][MAX_CNAME_SIZE] = {
  {"Jaccard\tMashD","P-value(J)\tFDR(J)","Jaccard_CI\tMashD_CI" },
  {"ContainmentM\tAafD","P-value(C)\tFDR(C)","ContainmentM_CI\tAafD_CI" }
 };
 fprintf(distfp,"Qry\tRef\tShared_k|Ref_s|Qry_s");
 for( int i = 0 ; i<= (int)outfield.pfield ; i++)
  fprintf(distfp,"\t%s", header[outfield.metric][i]);
 fprintf(distfp,"\n");
#define NREF 1024
 int N_max = opt_val->num_neigb;
 if( (N_max > NREF) || (N_max > ref_num) ) { err(errno,"neighborN_max %d should smaller than NREF %d and ref_num %d",N_max,NREF,ref_num); } ;
 typedef struct { double metric; int rid; } Nref_stuct;
 Nref_stuct bestNref[NREF];
 for(int b=0;b<=num_mapping_distf;b++){
    if(b==num_mapping_distf){
      bnum_infile = qry_num % num_cof_batch ;
      if( bnum_infile == 0 ) continue;
    }else bnum_infile = num_cof_batch;
    size_t maplength = (size_t)bnum_infile * ref_num * sizeof(ctx_obj_ct_t);
  for(int qid = 0; qid < bnum_infile; qid++) {
   outfield.Y_size = qry_ctx_ct_list[b*num_cof_batch + qid];
   outfield.qname = qryfname[b*num_cof_batch + qid];
   outfield.qry_len = strlen(outfield.qname);
   llong offset = ((llong)b*num_cof_batch + qid)*ref_num;
   if( N_max ) {
    for (int i=0; i< N_max ;i++ ) bestNref[i] = (Nref_stuct){0, -1};
    for(int rid = 0; rid < ref_num; rid++) {
     unsigned int X_size = ref_ctx_ct_list[rid];
         unsigned int XnY_size = ctx_obj_ct[offset + rid];
         double metric = outfield.metric == Ctm ?
        (double) XnY_size / (X_size < outfield.Y_size ? X_size : outfield.Y_size) :
        (double) XnY_size / (X_size + outfield.Y_size - XnY_size) ;
     for(int i = N_max - 1 ; i>=0; i-- ){
      if(metric > bestNref[i].metric){
        bestNref[i+1] = bestNref[i];
        bestNref[i] = (Nref_stuct){ metric, rid };
      }
      else break;
     }
    }
#pragma omp parallel for num_threads(p_fit_mem) schedule(guided)
    for( int i = 0 ; i< N_max;i++ ){
     if (bestNref[i].rid != -1)
       output_ctrl( ref_ctx_ct_list[ bestNref[i].rid ], ctx_obj_ct[offset + bestNref[i].rid], &outfield, refname[bestNref[i].rid], &prt_buf[i]);
     else prt_buf[i].len = 0 ;
    }
    for( int i = 0 ; i< N_max;i++ )
          if(prt_buf[i].len >1) fwrite(prt_buf[i].line, prt_buf[i].len, 1, distfp);;
   }
   else {
#pragma omp parallel for num_threads(p_fit_mem) schedule(guided)
    for(int rid = 0; rid < ref_num; rid++)
     output_ctrl( ref_ctx_ct_list[ rid ], ctx_obj_ct[ offset + rid ], &outfield, refname[rid], &prt_buf[rid]);
    for(int rid = 0; rid < ref_num; rid++)
     if(prt_buf[rid].len >1) fwrite(prt_buf[rid].line, prt_buf[rid].len, 1, distfp);;
   }
  }
  munmap(ctx_obj_ct + (size_t)b*num_cof_batch*ref_num, maplength);
 }
 fclose(distfp);
  free(prt_buf);
 if(!opt_val->keep_shared_kmer) remove(full_distfcode);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4380, %rsp           # imm = 0x4380
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movq 0x20(%rbp), %rax
movsbl 0x54b(%rax), %eax
cmpl $0x0, %eax
je 0xcf76
movq 0x20(%rbp), %rsi
addq $0x54b, %rsi            # imm = 0x54B
leaq 0x57581(%rip), %rdi     # 0x644f0
callq 0x3070
jmp 0xcf8f
movq -0x8(%rbp), %rdx
leaq 0x5756f(%rip), %rdi     # 0x644f0
leaq 0x10027(%rip), %rsi     # 0x1cfaf
movb $0x0, %al
callq 0x3400
leaq 0x5755a(%rip), %rdi     # 0x644f0
xorl %esi, %esi
movb $0x0, %al
callq 0x3350
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
setl %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4360(%rbp)
callq 0x3050
movl (%rax), %edi
callq 0x3440
movl -0x4360(%rbp), %edi
movq %rax, %rcx
leaq 0xf1cf(%rip), %rsi      # 0x1c19f
leaq 0x57519(%rip), %rdx     # 0x644f0
movb $0x0, %al
callq 0xe860
movl -0x28(%rbp), %edi
leaq -0xb8(%rbp), %rsi
callq 0x3470
movq -0x88(%rbp), %rsi
movl -0x28(%rbp), %r8d
xorl %eax, %eax
movl %eax, %r9d
movl $0x1, %edx
movl $0x2, %ecx
movq %r9, %rdi
callq 0x3130
movq %rax, -0xc0(%rbp)
movq $-0x1, %rax
cmpq %rax, -0xc0(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x435c(%rbp)
callq 0x3050
movl (%rax), %edi
callq 0x3440
movl -0x435c(%rbp), %edi
movq %rax, %rcx
leaq 0xf164(%rip), %rsi      # 0x1c1b2
leaq 0x5749b(%rip), %rdx     # 0x644f0
movb $0x0, %al
callq 0xe860
movl -0x28(%rbp), %edi
callq 0x3200
movq 0x20(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0xc4(%rbp)
movl -0xc(%rbp), %eax
imulq $0x404, %rax, %rdi      # imm = 0x404
callq 0x3310
movq %rax, -0xd0(%rbp)
leaq -0x1d0(%rbp), %rdi
movq -0x8(%rbp), %rdx
leaq 0xfebd(%rip), %rsi      # 0x1cf56
movb $0x0, %al
callq 0x3400
leaq -0x1d0(%rbp), %rdi
leaq 0xf2f9(%rip), %rsi      # 0x1c3a7
callq 0x3370
movq %rax, -0x1d8(%rbp)
cmpq $0x0, -0x1d8(%rbp)
jne 0xd0e0
callq 0x3050
movl (%rax), %edi
leaq -0x1d0(%rbp), %rdx
leaq 0x101d2(%rip), %rsi     # 0x1d2ab
movb $0x0, %al
callq 0x3300
movl -0x10(%rbp), %eax
xorl %edx, %edx
divl -0x24(%rbp)
movl %eax, -0x1dc(%rbp)
movq 0x20(%rbp), %rax
movl 0x440(%rax), %eax
movl %eax, -0x218(%rbp)
movq 0x20(%rbp), %rax
movl 0x444(%rax), %eax
movl %eax, -0x214(%rbp)
movq 0x20(%rbp), %rax
movb 0x448(%rax), %al
andb $0x1, %al
movb %al, -0x210(%rbp)
movq 0x20(%rbp), %rax
movsd 0x438(%rax), %xmm0
movsd %xmm0, -0x208(%rbp)
movl -0xc(%rbp), %eax
imull -0x10(%rbp), %eax
movl %eax, %eax
movq %rax, -0x1f8(%rbp)
leaq -0x2d0(%rbp), %rdi
leaq 0xf5be(%rip), %rsi      # 0x1c710
movl $0xb4, %edx
callq 0x32c0
movq -0x1d8(%rbp), %rdi
leaq 0x101be(%rip), %rsi     # 0x1d328
movb $0x0, %al
callq 0x3290
movl $0x0, -0x2d4(%rbp)
movl -0x2d4(%rbp), %eax
cmpl -0x214(%rbp), %eax
jg 0xd1d1
movq -0x1d8(%rbp), %rdi
movl -0x218(%rbp), %eax
leaq -0x2d0(%rbp), %rdx
imulq $0x5a, %rax, %rax
addq %rax, %rdx
movslq -0x2d4(%rbp), %rax
imulq $0x1e, %rax, %rax
addq %rax, %rdx
leaq 0x1018c(%rip), %rsi     # 0x1d345
movb $0x0, %al
callq 0x3290
movl -0x2d4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2d4(%rbp)
jmp 0xd17b
movq -0x1d8(%rbp), %rdi
leaq 0x11dd0(%rip), %rsi     # 0x1efaf
movb $0x0, %al
callq 0x3290
movq 0x20(%rbp), %rax
movl 0x430(%rax), %eax
movl %eax, -0x2d8(%rbp)
cmpl $0x400, -0x2d8(%rbp)    # imm = 0x400
jg 0xd20d
movl -0x2d8(%rbp), %eax
cmpl -0xc(%rbp), %eax
jbe 0xd231
callq 0x3050
movl (%rax), %edi
movl -0x2d8(%rbp), %edx
movl -0xc(%rbp), %r8d
leaq 0x10124(%rip), %rsi     # 0x1d349
movl $0x400, %ecx            # imm = 0x400
movb $0x0, %al
callq 0x3300
movl $0x0, -0x42e4(%rbp)
movl -0x42e4(%rbp), %eax
cmpl -0x1dc(%rbp), %eax
jg 0xd8a2
movl -0x42e4(%rbp), %eax
cmpl -0x1dc(%rbp), %eax
jne 0xd279
movl -0x10(%rbp), %eax
xorl %edx, %edx
divl -0x24(%rbp)
movl %edx, -0x1e0(%rbp)
cmpl $0x0, -0x1e0(%rbp)
jne 0xd277
jmp 0xd88e
jmp 0xd282
movl -0x24(%rbp), %eax
movl %eax, -0x1e0(%rbp)
movslq -0x1e0(%rbp), %rax
movl -0xc(%rbp), %ecx
imulq %rcx, %rax
shlq $0x2, %rax
movq %rax, -0x42f0(%rbp)
movl $0x0, -0x42f4(%rbp)
movl -0x42f4(%rbp), %eax
cmpl -0x1e0(%rbp), %eax
jge 0xd85e
movq -0x20(%rbp), %rax
movl -0x42e4(%rbp), %ecx
imull -0x24(%rbp), %ecx
addl -0x42f4(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x200(%rbp)
movq 0x18(%rbp), %rax
movl -0x42e4(%rbp), %ecx
imull -0x24(%rbp), %ecx
addl -0x42f4(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x8, %rcx
addq %rcx, %rax
movq %rax, -0x1f0(%rbp)
movq -0x1f0(%rbp), %rdi
callq 0x3110
movl %eax, -0x1e8(%rbp)
movslq -0x42e4(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq %rcx, %rax
movslq -0x42f4(%rbp), %rcx
addq %rcx, %rax
movl -0xc(%rbp), %ecx
imulq %rcx, %rax
movq %rax, -0x4300(%rbp)
cmpl $0x0, -0x2d8(%rbp)
je 0xd731
movl $0x0, -0x4304(%rbp)
movl -0x4304(%rbp), %eax
cmpl -0x2d8(%rbp), %eax
jge 0xd3aa
movslq -0x4304(%rbp), %rcx
leaq -0x42e0(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movsd %xmm0, -0x4318(%rbp)
movl $0xffffffff, -0x4310(%rbp) # imm = 0xFFFFFFFF
movq -0x4318(%rbp), %rcx
movq %rcx, (%rax)
movq -0x4310(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl -0x4304(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4304(%rbp)
jmp 0xd34c
movl $0x0, -0x431c(%rbp)
movl -0x431c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jae 0xd593
movq -0x18(%rbp), %rax
movslq -0x431c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x4320(%rbp)
movq -0xc0(%rbp), %rax
movq -0x4300(%rbp), %rcx
movslq -0x431c(%rbp), %rdx
addq %rdx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x4324(%rbp)
cmpl $0x1, -0x218(%rbp)
jne 0xd45f
movl -0x4324(%rbp), %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x4368(%rbp)
movl -0x4320(%rbp), %eax
cmpl -0x200(%rbp), %eax
jae 0xd430
movl -0x4320(%rbp), %eax
movl %eax, -0x436c(%rbp)
jmp 0xd43c
movl -0x200(%rbp), %eax
movl %eax, -0x436c(%rbp)
movsd -0x4368(%rbp), %xmm0
movl -0x436c(%rbp), %eax
movl %eax, %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x4378(%rbp)
jmp 0xd48d
movl -0x4324(%rbp), %eax
movl %eax, %ecx
cvtsi2sd %rax, %xmm0
movl -0x4320(%rbp), %eax
movl -0x200(%rbp), %edx
addl %edx, %eax
subl %ecx, %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x4378(%rbp)
movsd -0x4378(%rbp), %xmm0
movsd %xmm0, -0x4330(%rbp)
movl -0x2d8(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x4334(%rbp)
cmpl $0x0, -0x4334(%rbp)
jl 0xd57d
movsd -0x4330(%rbp), %xmm0
movslq -0x4334(%rbp), %rcx
leaq -0x42e0(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
ucomisd (%rax), %xmm0
jbe 0xd565
movl -0x4334(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq -0x42e0(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movslq -0x4334(%rbp), %rdx
leaq -0x42e0(%rbp), %rcx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
movslq -0x4334(%rbp), %rcx
leaq -0x42e0(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movsd -0x4330(%rbp), %xmm0
movsd %xmm0, -0x4348(%rbp)
movl -0x431c(%rbp), %ecx
movl %ecx, -0x4340(%rbp)
movq -0x4348(%rbp), %rcx
movq %rcx, (%rax)
movq -0x4340(%rbp), %rcx
movq %rcx, 0x8(%rax)
jmp 0xd567
jmp 0xd57d
jmp 0xd569
movl -0x4334(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4334(%rbp)
jmp 0xd4ac
jmp 0xd57f
movl -0x431c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x431c(%rbp)
jmp 0xd3b4
movl $0x0, -0x434c(%rbp)
movl -0x434c(%rbp), %eax
cmpl -0x2d8(%rbp), %eax
jge 0xd699
movslq -0x434c(%rbp), %rcx
leaq -0x42e0(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
cmpl $-0x1, 0x8(%rax)
je 0xd665
movq -0x18(%rbp), %rax
movslq -0x434c(%rbp), %rdx
leaq -0x42e0(%rbp), %rcx
shlq $0x4, %rdx
addq %rdx, %rcx
movslq 0x8(%rcx), %rcx
movl (%rax,%rcx,4), %edi
movq -0xc0(%rbp), %rax
movq -0x4300(%rbp), %rcx
movslq -0x434c(%rbp), %rsi
leaq -0x42e0(%rbp), %rdx
shlq $0x4, %rsi
addq %rsi, %rdx
movslq 0x8(%rdx), %rdx
addq %rdx, %rcx
movl (%rax,%rcx,4), %esi
movq 0x10(%rbp), %rcx
movslq -0x434c(%rbp), %rdx
leaq -0x42e0(%rbp), %rax
shlq $0x4, %rdx
addq %rdx, %rax
movslq 0x8(%rax), %rax
shlq $0x8, %rax
addq %rax, %rcx
movq -0xd0(%rbp), %r8
movslq -0x434c(%rbp), %rax
imulq $0x404, %rax, %rax      # imm = 0x404
addq %rax, %r8
leaq -0x218(%rbp), %rdx
callq 0xf940
jmp 0xd683
movq -0xd0(%rbp), %rax
movslq -0x434c(%rbp), %rcx
imulq $0x404, %rcx, %rcx      # imm = 0x404
addq %rcx, %rax
movl $0x0, (%rax)
jmp 0xd685
movl -0x434c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x434c(%rbp)
jmp 0xd59d
movl $0x0, -0x4350(%rbp)
movl -0x4350(%rbp), %eax
cmpl -0x2d8(%rbp), %eax
jge 0xd72c
movq -0xd0(%rbp), %rax
movslq -0x4350(%rbp), %rcx
imulq $0x404, %rcx, %rcx      # imm = 0x404
addq %rcx, %rax
cmpl $0x1, (%rax)
jle 0xd716
movq -0xd0(%rbp), %rdi
movslq -0x4350(%rbp), %rax
imulq $0x404, %rax, %rax      # imm = 0x404
addq %rax, %rdi
addq $0x4, %rdi
movq -0xd0(%rbp), %rax
movslq -0x4350(%rbp), %rcx
imulq $0x404, %rcx, %rcx      # imm = 0x404
addq %rcx, %rax
movslq (%rax), %rsi
movq -0x1d8(%rbp), %rcx
movl $0x1, %edx
callq 0x3420
jmp 0xd718
movl -0x4350(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4350(%rbp)
jmp 0xd6a3
jmp 0xd848
movl $0x0, -0x4354(%rbp)
movl -0x4354(%rbp), %eax
cmpl -0xc(%rbp), %eax
jae 0xd7b6
movq -0x18(%rbp), %rax
movslq -0x4354(%rbp), %rcx
movl (%rax,%rcx,4), %edi
movq -0xc0(%rbp), %rax
movq -0x4300(%rbp), %rcx
movslq -0x4354(%rbp), %rdx
addq %rdx, %rcx
movl (%rax,%rcx,4), %esi
movq 0x10(%rbp), %rcx
movslq -0x4354(%rbp), %rax
shlq $0x8, %rax
addq %rax, %rcx
movq -0xd0(%rbp), %r8
movslq -0x4354(%rbp), %rax
imulq $0x404, %rax, %rax      # imm = 0x404
addq %rax, %r8
leaq -0x218(%rbp), %rdx
callq 0xf940
movl -0x4354(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4354(%rbp)
jmp 0xd73b
movl $0x0, -0x4358(%rbp)
movl -0x4358(%rbp), %eax
cmpl -0xc(%rbp), %eax
jae 0xd846
movq -0xd0(%rbp), %rax
movslq -0x4358(%rbp), %rcx
imulq $0x404, %rcx, %rcx      # imm = 0x404
addq %rcx, %rax
cmpl $0x1, (%rax)
jle 0xd830
movq -0xd0(%rbp), %rdi
movslq -0x4358(%rbp), %rax
imulq $0x404, %rax, %rax      # imm = 0x404
addq %rax, %rdi
addq $0x4, %rdi
movq -0xd0(%rbp), %rax
movslq -0x4358(%rbp), %rcx
imulq $0x404, %rcx, %rcx      # imm = 0x404
addq %rcx, %rax
movslq (%rax), %rsi
movq -0x1d8(%rbp), %rcx
movl $0x1, %edx
callq 0x3420
jmp 0xd832
movl -0x4358(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4358(%rbp)
jmp 0xd7c0
jmp 0xd848
jmp 0xd84a
movl -0x42f4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x42f4(%rbp)
jmp 0xd2a5
movq -0xc0(%rbp), %rdi
movslq -0x42e4(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq %rcx, %rax
movl -0xc(%rbp), %ecx
imulq %rcx, %rax
shlq $0x2, %rax
addq %rax, %rdi
movq -0x42f0(%rbp), %rsi
callq 0x3330
movl -0x42e4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x42e4(%rbp)
jmp 0xd23b
movq -0x1d8(%rbp), %rdi
callq 0x30e0
movq -0xd0(%rbp), %rdi
callq 0x3040
movq 0x20(%rbp), %rax
testb $0x1, 0x64b(%rax)
jne 0xd8d3
leaq 0x56c22(%rip), %rdi     # 0x644f0
callq 0x3060
addq $0x4380, %rsp           # imm = 0x4380
popq %rbp
retq
nopl (%rax)