// File: /workspace/github_c_makefile_star2_O0/jsh58[P]Genrich/Genrich.c
// Function: savePval
void savePval(Chrom* chrom, int chromLen, int n,
    File pile, bool pileOpt, char* exptName,
    char* ctrlName, bool gzOut) {

  // print log header
  if (pileOpt)
    printPileHeader(pile, exptName, ctrlName, gzOut);

  // create pileups for each chrom
  for (int i = 0; i < chromLen; i++) {
    Chrom* chr = chrom + i;
    if (chr->skip)
      continue;

    // fill in missing pval arrays from previous samples
    if (chr->sample < n) {
      chr->pval = (Pileup**) memrealloc(chr->pval,
        n * sizeof(Pileup*));
      for (int j = n - 1; j >= chr->sample; j--)
        chr->pval[j] = NULL;
      chr->sample = n;
    }

    // p-values not to be saved: append a NULL
    if (! chr->save) {
      chr->pval = (Pileup**) memrealloc(chr->pval,
        (n + 1) * sizeof(Pileup*));
      chr->pval[n] = NULL;
      chr->sample++;
      continue;
    }

    // create 'pileup' arrays for p-values
    uint32_t num = countIntervals(chr);
    chr->pval = (Pileup**) memrealloc(chr->pval,
      (n + 1) * sizeof(Pileup*));
    chr->pval[n] = (Pileup*) memalloc(sizeof(Pileup));
    chr->pval[n]->end = (uint32_t*) memalloc(num * sizeof(uint32_t));
    chr->pval[n]->cov = (float*) memalloc(num * sizeof(float));
    chr->pvalLen = (uint32_t*) memrealloc(chr->pvalLen,
      (n + 1) * sizeof(uint32_t));
    chr->pvalLen[n] = num;
    chr->sample++;

    // save p-values to arrays
    Pileup* p = chr->pval[n];
    uint32_t start = 0;    // start of interval
    uint32_t j = 0, k = 0;
    for (uint32_t m = 0; m < num; m++) {
      if (chr->ctrl->end[k] < chr->expt->end[j]) {
        p->end[m] = chr->ctrl->end[k];
        p->cov[m] = calcPval(chr->expt->cov[j],
          chr->ctrl->cov[k]);
        if (pileOpt)
          printPile(pile, chr->name, start, p->end[m],
            chr->expt->cov[j], chr->ctrl->cov[k],
            p->cov[m], gzOut);
        k++;
      } else {
        p->end[m] = chr->expt->end[j];
        p->cov[m] = calcPval(chr->expt->cov[j],
          chr->ctrl->cov[k]);
        if (pileOpt)
          printPile(pile, chr->name, start, p->end[m],
            chr->expt->cov[j], chr->ctrl->cov[k],
            p->cov[m], gzOut);
        if (chr->ctrl->end[k] == chr->expt->end[j])
          k++;
        j++;
      }
      start = p->end[m];
    }

  }
}

// Assembly:
subq $0x58, %rsp
movl %r8d, %eax
movq %rcx, %r8
movb %al, %cl
movb 0x68(%rsp), %al
movq 0x60(%rsp), %r10
movq %r8, 0x50(%rsp)
movq %rdi, 0x48(%rsp)
movl %esi, 0x44(%rsp)
movl %edx, 0x40(%rsp)
andb $0x1, %cl
movb %cl, 0x3f(%rsp)
movq %r9, 0x30(%rsp)
andb $0x1, %al
movb %al, 0x2f(%rsp)
testb $0x1, 0x3f(%rsp)
je 0x8c1d
movq 0x30(%rsp), %rsi
movq 0x60(%rsp), %rdx
movb 0x2f(%rsp), %al
movq 0x50(%rsp), %rdi
andb $0x1, %al
movzbl %al, %ecx
callq 0x8930
movl $0x0, 0x28(%rsp)
movl 0x28(%rsp), %eax
cmpl 0x44(%rsp), %eax
jge 0x90bc
movq 0x48(%rsp), %rax
movslq 0x28(%rsp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
testb $0x1, 0xc(%rax)
je 0x8c59
jmp 0x90ac
movq 0x20(%rsp), %rax
movzbl 0x58(%rax), %eax
cmpl 0x40(%rsp), %eax
jge 0x8cd8
movq 0x20(%rsp), %rax
movq 0x48(%rax), %rdi
movslq 0x40(%rsp), %rsi
shlq $0x3, %rsi
callq 0x28e0
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x48(%rax)
movl 0x40(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
movq 0x20(%rsp), %rcx
movzbl 0x58(%rcx), %ecx
cmpl %ecx, %eax
jl 0x8cca
movq 0x20(%rsp), %rax
movq 0x48(%rax), %rax
movslq 0x1c(%rsp), %rcx
movq $0x0, (%rax,%rcx,8)
movl 0x1c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x8c96
movl 0x40(%rsp), %eax
movb %al, %cl
movq 0x20(%rsp), %rax
movb %cl, 0x58(%rax)
movq 0x20(%rsp), %rax
testb $0x1, 0xd(%rax)
jne 0x8d34
movq 0x20(%rsp), %rax
movq 0x48(%rax), %rdi
movl 0x40(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
shlq $0x3, %rsi
callq 0x28e0
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x48(%rax)
movq 0x20(%rsp), %rax
movq 0x48(%rax), %rax
movslq 0x40(%rsp), %rcx
movq $0x0, (%rax,%rcx,8)
movq 0x20(%rsp), %rax
movb 0x58(%rax), %cl
addb $0x1, %cl
movb %cl, 0x58(%rax)
jmp 0x90ac
movq 0x20(%rsp), %rdi
callq 0x8840
movl %eax, 0x18(%rsp)
movq 0x20(%rsp), %rax
movq 0x48(%rax), %rdi
movl 0x40(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
shlq $0x3, %rsi
callq 0x28e0
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x48(%rax)
movl $0x10, %edi
callq 0x2890
movq %rax, %rdx
movq 0x20(%rsp), %rax
movq 0x48(%rax), %rax
movslq 0x40(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movl 0x18(%rsp), %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x2890
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq 0x48(%rax), %rax
movslq 0x40(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, (%rax)
movl 0x18(%rsp), %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x2890
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq 0x48(%rax), %rax
movslq 0x40(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x8(%rax)
movq 0x20(%rsp), %rax
movq 0x50(%rax), %rdi
movl 0x40(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
shlq $0x2, %rsi
callq 0x28e0
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x50(%rax)
movl 0x18(%rsp), %edx
movq 0x20(%rsp), %rax
movq 0x50(%rax), %rax
movslq 0x40(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movq 0x20(%rsp), %rax
movb 0x58(%rax), %cl
addb $0x1, %cl
movb %cl, 0x58(%rax)
movq 0x20(%rsp), %rax
movq 0x48(%rax), %rax
movslq 0x40(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0x4(%rsp)
movl $0x0, (%rsp)
movl (%rsp), %eax
cmpl 0x18(%rsp), %eax
jae 0x90aa
movq 0x20(%rsp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
movl 0x4(%rsp), %ecx
movl (%rax,%rcx,4), %eax
movq 0x20(%rsp), %rcx
movq 0x28(%rcx), %rcx
movq (%rcx), %rcx
movl 0x8(%rsp), %edx
cmpl (%rcx,%rdx,4), %eax
jae 0x8f77
movq 0x20(%rsp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
movl 0x4(%rsp), %ecx
movl (%rax,%rcx,4), %edx
movq 0x10(%rsp), %rax
movq (%rax), %rax
movl (%rsp), %ecx
movl %edx, (%rax,%rcx,4)
movq 0x20(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
movl 0x8(%rsp), %ecx
movss (%rax,%rcx,4), %xmm0
movq 0x20(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rax
movl 0x4(%rsp), %ecx
movss (%rax,%rcx,4), %xmm1
callq 0x8650
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movl (%rsp), %ecx
movss %xmm0, (%rax,%rcx,4)
testb $0x1, 0x3f(%rsp)
je 0x8f67
movq 0x20(%rsp), %rax
movq (%rax), %rsi
movl 0xc(%rsp), %edx
movq 0x10(%rsp), %rax
movq (%rax), %rax
movl (%rsp), %ecx
movl (%rax,%rcx,4), %ecx
movq 0x20(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
movl 0x8(%rsp), %edi
movss (%rax,%rdi,4), %xmm0
movq 0x20(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rax
movl 0x4(%rsp), %edi
movss (%rax,%rdi,4), %xmm1
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movl (%rsp), %edi
movss (%rax,%rdi,4), %xmm2
movb 0x2f(%rsp), %al
movq 0x50(%rsp), %rdi
andb $0x1, %al
movzbl %al, %r8d
callq 0x8a60
movl 0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
jmp 0x908a
movq 0x20(%rsp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movl 0x8(%rsp), %ecx
movl (%rax,%rcx,4), %edx
movq 0x10(%rsp), %rax
movq (%rax), %rax
movl (%rsp), %ecx
movl %edx, (%rax,%rcx,4)
movq 0x20(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
movl 0x8(%rsp), %ecx
movss (%rax,%rcx,4), %xmm0
movq 0x20(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rax
movl 0x4(%rsp), %ecx
movss (%rax,%rcx,4), %xmm1
callq 0x8650
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movl (%rsp), %ecx
movss %xmm0, (%rax,%rcx,4)
testb $0x1, 0x3f(%rsp)
je 0x904c
movq 0x20(%rsp), %rax
movq (%rax), %rsi
movl 0xc(%rsp), %edx
movq 0x10(%rsp), %rax
movq (%rax), %rax
movl (%rsp), %ecx
movl (%rax,%rcx,4), %ecx
movq 0x20(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
movl 0x8(%rsp), %edi
movss (%rax,%rdi,4), %xmm0
movq 0x20(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rax
movl 0x4(%rsp), %edi
movss (%rax,%rdi,4), %xmm1
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movl (%rsp), %edi
movss (%rax,%rdi,4), %xmm2
movb 0x2f(%rsp), %al
movq 0x50(%rsp), %rdi
andb $0x1, %al
movzbl %al, %r8d
callq 0x8a60
movq 0x20(%rsp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
movl 0x4(%rsp), %ecx
movl (%rax,%rcx,4), %eax
movq 0x20(%rsp), %rcx
movq 0x28(%rcx), %rcx
movq (%rcx), %rcx
movl 0x8(%rsp), %edx
cmpl (%rcx,%rdx,4), %eax
jne 0x907f
movl 0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %rax
movl (%rsp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, 0xc(%rsp)
movl (%rsp), %eax
addl $0x1, %eax
movl %eax, (%rsp)
jmp 0x8e59
jmp 0x90ac
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x8c25
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)