// File: /workspace/github_c_makefile_star2_O0/jsh58[P]Genrich/Genrich.c
// Function: computeQval
void computeQval(Chrom* chrom, int chromLen,
    uint64_t genomeLen, bool genomeOpt, int n,
    bool verbose) {

  // create "pileup" arrays for q-values
  for (int i = 0; i < chromLen; i++) {
    Chrom* chr = chrom + i;
    if (chr->skip || chr->pval[n] == NULL)
      continue;
    uint32_t num = chr->pvalLen[n]; // use last p-value array length
    chr->qval = (Pileup*) memalloc(sizeof(Pileup));
    chr->qval->end = (uint32_t*) memalloc(num * sizeof(uint32_t));
    chr->qval->cov = (float*) memalloc(num * sizeof(float));
  }

  // save all p-values (genome-wide) to hashtable
  int64_t pLen = 0;
  Hash** table = hashPval(chrom, chromLen, n, &pLen);

  // collect p-values from hashtable
  uint64_t* pEnd = memalloc(pLen * sizeof(uint64_t));
  uint64_t checkLen = 0;  // should match genomeLen
  float* pVal = collectPval(table, &pEnd, pLen, &checkLen);

  // check that collected p-value lengths match genomeLen
  if (genomeOpt && checkLen != genomeLen) {
    char msg[MAX_ALNS];
    sprintf(msg, "Genome length (%ld) does not match p-value length (%ld)",
      genomeLen, checkLen);
    exit(error(msg, ERRISSUE));
  }

  // convert p-values to q-values
  saveQval(chrom, chromLen, n, genomeLen, pVal, pEnd,
    pLen, verbose);

  // free memory
  free(pEnd);
  free(pVal);
  for (int i = 0; i < HASH_SIZE; i++) {
    Hash* tmp;
    Hash* h = table[i];
    while (h != NULL) {
      tmp = h->next;
      free(h);
      h = tmp;
    }
  }
  free(table);
}

// Assembly:
subq $0x118, %rsp            # imm = 0x118
movb %r9b, %al
movq %rdi, 0x110(%rsp)
movl %esi, 0x10c(%rsp)
movq %rdx, 0x100(%rsp)
andb $0x1, %cl
movb %cl, 0xff(%rsp)
movl %r8d, 0xf8(%rsp)
andb $0x1, %al
movb %al, 0xf7(%rsp)
movl $0x0, 0xf0(%rsp)
movl 0xf0(%rsp), %eax
cmpl 0x10c(%rsp), %eax
jge 0x38be
movq 0x110(%rsp), %rax
movslq 0xf0(%rsp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0xe8(%rsp)
movq 0xe8(%rsp), %rax
testb $0x1, 0xc(%rax)
jne 0x3823
movq 0xe8(%rsp), %rax
movq 0x48(%rax), %rax
movslq 0xf8(%rsp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x3828
jmp 0x38a8
movq 0xe8(%rsp), %rax
movq 0x50(%rax), %rax
movslq 0xf8(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0xe4(%rsp)
movl $0x10, %edi
callq 0x2890
movq %rax, %rcx
movq 0xe8(%rsp), %rax
movq %rcx, 0x60(%rax)
movl 0xe4(%rsp), %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x2890
movq %rax, %rcx
movq 0xe8(%rsp), %rax
movq 0x60(%rax), %rax
movq %rcx, (%rax)
movl 0xe4(%rsp), %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x2890
movq %rax, %rcx
movq 0xe8(%rsp), %rax
movq 0x60(%rax), %rax
movq %rcx, 0x8(%rax)
movl 0xf0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf0(%rsp)
jmp 0x37c7
movq $0x0, 0xd8(%rsp)
movq 0x110(%rsp), %rdi
movl 0x10c(%rsp), %esi
movl 0xf8(%rsp), %edx
leaq 0xd8(%rsp), %rcx
callq 0x34e0
movq %rax, 0xd0(%rsp)
movq 0xd8(%rsp), %rdi
shlq $0x3, %rdi
callq 0x2890
movq %rax, 0xc8(%rsp)
movq $0x0, 0xc0(%rsp)
movq 0xd0(%rsp), %rdi
movq 0xd8(%rsp), %rdx
leaq 0xc8(%rsp), %rsi
leaq 0xc0(%rsp), %rcx
callq 0x3670
movq %rax, 0xb8(%rsp)
testb $0x1, 0xff(%rsp)
je 0x399c
movq 0xc0(%rsp), %rax
cmpq 0x100(%rsp), %rax
je 0x399c
leaq 0x30(%rsp), %rdi
movq 0x100(%rsp), %rdx
movq 0xc0(%rsp), %rcx
leaq 0x1bc0f(%rip), %rsi     # 0x1f58e
movb $0x0, %al
callq 0x22a0
leaq 0x30(%rsp), %rdi
movl $0x21, %esi
callq 0x2840
movl %eax, %edi
callq 0x22b0
movq 0x110(%rsp), %rdi
movl 0x10c(%rsp), %esi
movl 0xf8(%rsp), %edx
movq 0x100(%rsp), %rcx
movq 0xb8(%rsp), %r8
movq 0xc8(%rsp), %r9
movq 0xd8(%rsp), %r10
movb 0xf7(%rsp), %al
andb $0x1, %al
movq %r10, (%rsp)
movzbl %al, %eax
movl %eax, 0x8(%rsp)
callq 0x2dc0
movq 0xc8(%rsp), %rdi
callq 0x2040
movq 0xb8(%rsp), %rdi
callq 0x2040
movl $0x0, 0x2c(%rsp)
cmpl $0x13fed1, 0x2c(%rsp)   # imm = 0x13FED1
jge 0x3a68
movq 0xd0(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
je 0x3a59
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x18(%rsp), %rdi
callq 0x2040
movq 0x20(%rsp), %rax
movq %rax, 0x18(%rsp)
jmp 0x3a2d
jmp 0x3a5b
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x3a0d
movq 0xd0(%rsp), %rdi
callq 0x2040
addq $0x118, %rsp            # imm = 0x118
retq
nopl (%rax)