// File: /workspace/github_c_makefile_star2_O1/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 %ecx, %r15d
movq %rdx, %r12
movl %esi, %ebx
movq %rdi, -0x80(%rbp)
movl %r8d, -0x2c(%rbp)
movl %r8d, %edx
movl %r9d, %ecx
xorl %r8d, %r8d
callq 0x4a76
testl %r15d, %r15d
jle 0x535c
movl -0x2c(%rbp), %eax
movslq %eax, %rcx
movq %rcx, -0x38(%rbp)
movl %eax, %eax
movl %r15d, %edx
xorl %esi, %esi
leaq 0xf(,%rax,4), %rcx
shlq $0x2, %rax
movq %rax, -0x48(%rbp)
andq $-0x10, %rcx
movq %rcx, -0x50(%rbp)
movzbl %r14b, %eax
movq %rax, -0x78(%rbp)
movzbl %bl, %eax
movl %eax, -0x40(%rbp)
movl %r14d, -0x3c(%rbp)
movq %r12, -0x60(%rbp)
movq %rdx, -0x58(%rbp)
movl -0x2c(%rbp), %r13d
imulq $0x68, %rsi, %rbx
cmpb $0x0, 0xc(%r12,%rbx)
jne 0x5350
addq %r12, %rbx
testb %r14b, %r14b
je 0x525f
cmpq $0x0, 0x60(%rbx)
je 0x5350
testb %r14b, %r14b
jne 0x5272
movq 0x48(%rbx), %rax
movq -0x38(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x5350
movq %rsi, -0x70(%rbp)
movq %rsp, -0x68(%rbp)
movq %rsp, %r14
subq -0x50(%rbp), %r14
movq %r14, %rsp
cmpl $0x0, -0x2c(%rbp)
jle 0x5298
movq %r14, %rdi
xorl %esi, %esi
movq -0x48(%rbp), %rdx
callq 0x2140
movq %r14, -0x88(%rbp)
movq 0x50(%rbx), %rax
movq -0x38(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x533c
xorl %r12d, %r12d
xorl %ecx, %ecx
xorl %r15d, %r15d
xorl %r14d, %r14d
subq $0x8, %rsp
movq -0x80(%rbp), %rdi
movl -0x40(%rbp), %esi
movq %rbx, %rdx
movl %r13d, %r8d
movl %r12d, %r9d
pushq $0x0
pushq -0x78(%rbp)
pushq -0x88(%rbp)
pushq %r15
pushq %r14
callq 0x5071
addq $0x30, %rsp
testl %r13d, %r13d
jne 0x531a
movq 0x28(%rbx), %rax
movq 0x38(%rbx), %rcx
movq (%rcx), %rcx
movl %r15d, %edx
movq (%rax), %rax
movl %r14d, %esi
movl (%rax,%rsi,4), %eax
cmpl %eax, (%rcx,%rdx,4)
jae 0x530e
incl %r15d
jmp 0x531a
sete %al
movzbl %al, %eax
addl %eax, %r15d
incl %r14d
movq 0x48(%rbx), %rax
movq 0x50(%rbx), %rdx
movq -0x38(%rbp), %rsi
movq (%rax,%rsi,8), %rax
movq (%rax), %rax
movl (%rax,%r12,4), %ecx
incq %r12
movl (%rdx,%rsi,4), %eax
cmpq %rax, %r12
jb 0x52bc
movq -0x68(%rbp), %rsp
movl -0x3c(%rbp), %r14d
movq -0x60(%rbp), %r12
movq -0x58(%rbp), %rdx
movq -0x70(%rbp), %rsi
incq %rsi
cmpq %rdx, %rsi
jne 0x5237
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq