// File: /workspace/github_c_makefile_star2_O0/jsh58[P]Genrich/Genrich.c
// Function: logIntervals
void logIntervals(File log, bool gzOut, Chrom* chrom,
    int chromLen, int n, bool qvalOpt) {
  // print header
  printLogHeader(log, gzOut, n, qvalOpt, false);

  // loop through chroms
  for (int i = 0; i < chromLen; i++) {
    Chrom* chr = chrom + i;
    if (chr->skip || (qvalOpt && chr->qval == NULL)
        || (! qvalOpt && chr->pval[n] == NULL) )
      continue;

    // create indexes into arrays (expt/ctrl pileup [if n == 0]
    //   and p-value arrays [if n > 0])
    uint32_t j = 0, k = 0;  // indexes into chr->expt, chr->ctrl
    uint32_t idx[n];        // indexes into each pval array
    for (int r = 0; r < n; r++)
      idx[r] = 0;

    // loop through intervals (defined by chr->pval[n])
    uint32_t start = 0;    // start of interval
    for (uint32_t m = 0; m < chr->pvalLen[n]; m++) {

      // print stats for interval
      printLog(log, gzOut, chr, start, n, m, j, k,
        idx, qvalOpt, false);

      // update chr->expt and chr->ctrl indexes
      if (! n) {
        if (chr->ctrl->end[k] < chr->expt->end[j])
          k++;
        else {
          if (chr->ctrl->end[k] == chr->expt->end[j])
            k++;
          j++;
        }
      }

      start = chr->pval[n]->end[m];
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x60, %rsp
movb %r9b, %al
movq %rdi, -0x18(%rbp)
andb $0x1, %sil
movb %sil, -0x19(%rbp)
movq %rdx, -0x28(%rbp)
movl %ecx, -0x2c(%rbp)
movl %r8d, -0x30(%rbp)
andb $0x1, %al
movb %al, -0x31(%rbp)
movb -0x19(%rbp), %cl
movl -0x30(%rbp), %edx
movb -0x31(%rbp), %al
movq -0x18(%rbp), %rdi
xorl %r8d, %r8d
andb $0x1, %cl
andb $0x1, %al
movzbl %cl, %esi
movzbl %al, %ecx
callq 0x4a30
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x5994
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
testb $0x1, 0xc(%rax)
jne 0x5804
testb $0x1, -0x31(%rbp)
je 0x57eb
movq -0x40(%rbp), %rax
cmpq $0x0, 0x60(%rax)
je 0x5804
testb $0x1, -0x31(%rbp)
jne 0x5809
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x30(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x5809
jmp 0x5986
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl -0x30(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x50(%rbp)
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x70(%rbp)
movq %rcx, %rsp
movq %rax, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x5867
movq -0x70(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x5845
movl $0x0, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
movq -0x40(%rbp), %rcx
movq 0x50(%rcx), %rcx
movslq -0x30(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jae 0x597f
movq -0x70(%rbp), %r10
movb -0x19(%rbp), %sil
movq -0x40(%rbp), %rdx
movl -0x60(%rbp), %ecx
movl -0x30(%rbp), %r8d
movl -0x64(%rbp), %r9d
movl -0x44(%rbp), %ebx
movl -0x48(%rbp), %r11d
movb -0x31(%rbp), %al
movq -0x18(%rbp), %rdi
xorl %r14d, %r14d
andb $0x1, %sil
andb $0x1, %al
subq $0x30, %rsp
movzbl %sil, %esi
movl %ebx, (%rsp)
movl %r11d, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movzbl %al, %eax
movl %eax, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
callq 0x5300
addq $0x30, %rsp
cmpl $0x0, -0x30(%rbp)
jne 0x5955
movq -0x40(%rbp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
movl -0x48(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movq -0x40(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq (%rcx), %rcx
movl -0x44(%rbp), %edx
cmpl (%rcx,%rdx,4), %eax
jae 0x591d
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x5953
movq -0x40(%rbp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
movl -0x48(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movq -0x40(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq (%rcx), %rcx
movl -0x44(%rbp), %edx
cmpl (%rcx,%rdx,4), %eax
jne 0x594a
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x5955
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movl -0x64(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x60(%rbp)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x5875
movq -0x50(%rbp), %rax
movq %rax, %rsp
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x57b1
leaq -0x10(%rbp), %rsp
popq %rbx
popq %r14
popq %rbp
retq
nopl (%rax)