// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %r9d, %r14d
movl %r8d, %r15d
movl %ecx, %r12d
movq %rdx, %r13
movl %esi, %ebx
movq %rdi, -0x80(%rbp)
movl %r8d, %edx
movl %r9d, %ecx
xorl %r8d, %r8d
callq 0x381d
xorl %ecx, %ecx
movslq %r15d, %rsi
testl %esi, %esi
movl $0x0, %eax
movl %r15d, -0x44(%rbp)
cmovgl %r15d, %eax
movq %rax, -0x88(%rbp)
movl %esi, %eax
testl %r12d, %r12d
cmovlel %ecx, %r12d
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
movq %rax, -0x50(%rbp)
movl %r14d, -0x3c(%rbp)
movzbl %r14b, %eax
movq %rax, -0x78(%rbp)
movzbl %bl, %eax
movl %eax, -0x40(%rbp)
movq %r12, -0x60(%rbp)
movq %r13, -0x58(%rbp)
movq %rsi, -0x30(%rbp)
movl -0x44(%rbp), %ebx
cmpq %r12, %rcx
je 0x40ea
imulq $0x68, %rcx, %rdx
cmpb $0x0, 0xc(%r13,%rdx)
jne 0x40e2
addq %r13, %rdx
cmpb $0x0, -0x3c(%rbp)
je 0x3fec
cmpq $0x0, 0x60(%rdx)
jne 0x3ffb
jmp 0x40e2
movq 0x48(%rdx), %rax
cmpq $0x0, (%rax,%rsi,8)
je 0x40e2
movq %rsp, -0x68(%rbp)
movq %rsp, %r10
subq -0x50(%rbp), %r10
movq %r10, %rsp
xorl %eax, %eax
cmpq %rax, -0x88(%rbp)
je 0x401e
andl $0x0, (%r10,%rax,4)
incq %rax
jmp 0x400b
movq %rcx, -0x70(%rbp)
xorl %r12d, %r12d
xorl %r11d, %r11d
xorl %r15d, %r15d
xorl %ecx, %ecx
movq %r10, -0x38(%rbp)
movq 0x50(%rdx), %rax
movl (%rax,%rsi,4), %eax
cmpq %rax, %r12
jae 0x40d2
subq $0x8, %rsp
movq -0x80(%rbp), %rdi
movl -0x40(%rbp), %esi
movq %rdx, %r13
movl %ebx, %r8d
movl %r12d, %r9d
pushq $0x0
pushq -0x78(%rbp)
pushq %r10
pushq %r15
pushq %r11
movq %r11, %r14
callq 0x3df3
addq $0x30, %rsp
testl %ebx, %ebx
je 0x4080
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %r10
movq %r14, %r11
movq %r13, %rdx
jmp 0x40bb
movq 0x28(%r13), %rax
movq 0x38(%r13), %rcx
movq (%rcx), %rcx
movl %r15d, %edx
movq (%rax), %rax
movl %r14d, %esi
movl (%rax,%rsi,4), %eax
cmpl %eax, (%rcx,%rdx,4)
movq %r14, %r11
movq %r13, %rdx
jae 0x40a7
incl %r15d
jmp 0x40b3
sete %al
movzbl %al, %eax
addl %eax, %r15d
incl %r11d
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %r10
movq 0x48(%rdx), %rax
movq (%rax,%rsi,8), %rax
movq (%rax), %rax
movl (%rax,%r12,4), %ecx
incq %r12
jmp 0x4031
movq -0x68(%rbp), %rsp
movq -0x60(%rbp), %r12
movq -0x58(%rbp), %r13
movq -0x70(%rbp), %rcx
incq %rcx
jmp 0x3fbe
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq