// File: /workspace/github_c_makefile_star2_O3/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 %ecx, %r15d
movq %rdx, %r14
movl %esi, %ebx
movq %rdi, -0x80(%rbp)
movl %r8d, -0x2c(%rbp)
movl %r8d, %edx
movl %r9d, -0x30(%rbp)
movl %r9d, %ecx
xorl %r8d, %r8d
callq 0x4a33
testl %r15d, %r15d
jle 0x530f
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 -0x30(%rbp), %eax
movq %rax, -0x78(%rbp)
movzbl %bl, %eax
movl %eax, -0x3c(%rbp)
movq %r14, -0x60(%rbp)
movq %rdx, -0x58(%rbp)
movl -0x2c(%rbp), %r13d
imulq $0x68, %rsi, %rbx
cmpb $0x0, 0xc(%r14,%rbx)
jne 0x5303
addq %r14, %rbx
cmpb $0x0, -0x30(%rbp)
je 0x5216
cmpq $0x0, 0x60(%rbx)
jne 0x5229
jmp 0x5303
movq 0x48(%rbx), %rax
movq -0x38(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x5303
movq %rsi, -0x70(%rbp)
movq %rsp, -0x68(%rbp)
movq %rsp, %r14
subq -0x50(%rbp), %r14
movq %r14, %rsp
cmpl $0x0, -0x2c(%rbp)
jle 0x524f
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 0x52f3
xorl %r12d, %r12d
xorl %ecx, %ecx
xorl %r15d, %r15d
xorl %r14d, %r14d
subq $0x8, %rsp
movq -0x80(%rbp), %rdi
movl -0x3c(%rbp), %esi
movq %rbx, %rdx
movl %r13d, %r8d
movl %r12d, %r9d
pushq $0x0
pushq -0x78(%rbp)
pushq -0x88(%rbp)
pushq %r15
pushq %r14
callq 0x502e
addq $0x30, %rsp
testl %r13d, %r13d
jne 0x52d1
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 0x52c5
incl %r15d
jmp 0x52d1
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 0x5273
movq -0x68(%rbp), %rsp
movq -0x60(%rbp), %r14
movq -0x58(%rbp), %rdx
movq -0x70(%rbp), %rsi
incq %rsi
cmpq %rdx, %rsi
jne 0x51f1
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq