// File: /workspace/github_c_makefile_star2_O0/jsh58[P]Genrich/Genrich.c
// Function: processAvgExt
void processAvgExt(Aln** unpair, int unpairIdx,
    int unpairLen, double totalLen, uint64_t pairedPr,
    File bed, bool bedOpt, bool gzOut, bool ctrl,
    int sample, uint64_t* errCount, bool verbose) {

  // determine average fragment length
  int avgLen = calcAvgLen(totalLen, pairedPr, verbose);

  // process each alignment
  for (int i = 0; i <= unpairIdx; i++) {

    int end = (i == unpairIdx ? unpairLen : MAX_SIZE);
    for (int j = 0; j < end; j++) {

      Aln* a = unpair[i] + j;
      if (! avgLen)
        saveInterval(a->chrom, a->pos[0], a->pos[1], a->name,
          a->count, bed, bedOpt, gzOut, ctrl, sample,
          errCount, verbose);
      else if (a->strand)
        saveInterval(a->chrom, a->pos[0], a->pos[0] + avgLen,
          a->name, a->count, bed, bedOpt, gzOut, ctrl,
          sample, errCount, verbose);
      else
        saveInterval(a->chrom, (signed) (a->pos[1] - avgLen),
          a->pos[1], a->name, a->count, bed, bedOpt, gzOut,
          ctrl, sample, errCount, verbose);

      // free memory
      free(a->name);
    }

  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x90, %rsp
movl %r9d, %eax
movq %r8, %r11
movq %rcx, 0x40(%rsp)
movl %edx, %r8d
movl %esi, %r9d
movq %rdi, %r10
movq 0x40(%rsp), %rdi
movb %al, %sil
movb 0xd0(%rsp), %al
movq 0xc8(%rsp), %rcx
movl 0xc0(%rsp), %ecx
movb 0xb8(%rsp), %cl
movb 0xb0(%rsp), %dl
movq %r11, 0x88(%rsp)
movq %r10, 0x80(%rsp)
movl %r9d, 0x7c(%rsp)
movl %r8d, 0x78(%rsp)
movsd %xmm0, 0x70(%rsp)
movq %rdi, 0x68(%rsp)
andb $0x1, %sil
movb %sil, 0x67(%rsp)
andb $0x1, %dl
movb %dl, 0x66(%rsp)
andb $0x1, %cl
movb %cl, 0x65(%rsp)
andb $0x1, %al
movb %al, 0x64(%rsp)
movsd 0x70(%rsp), %xmm0
movq 0x68(%rsp), %rdi
movb 0x64(%rsp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0xbc10
movl %eax, 0x60(%rsp)
movl $0x0, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
cmpl 0x7c(%rsp), %eax
jg 0xc002
movl 0x5c(%rsp), %eax
cmpl 0x7c(%rsp), %eax
jne 0xbd94
movl 0x78(%rsp), %eax
movl %eax, 0x3c(%rsp)
jmp 0xbd9f
movl $0xfff0, %eax           # imm = 0xFFF0
movl %eax, 0x3c(%rsp)
jmp 0xbd9f
movl 0x3c(%rsp), %eax
movl %eax, 0x58(%rsp)
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
cmpl 0x58(%rsp), %eax
jge 0xbff0
movq 0x80(%rsp), %rax
movslq 0x5c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x54(%rsp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x48(%rsp)
cmpl $0x0, 0x60(%rsp)
jne 0xbe85
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x48(%rsp), %rax
movl (%rax), %eax
movl %eax, %esi
movq 0x48(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, %edx
movq 0x48(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x48(%rsp), %rax
movb 0x11(%rax), %r8b
movb 0x67(%rsp), %r14b
movb 0x66(%rsp), %bpl
movb 0x65(%rsp), %bl
movl 0xc0(%rsp), %r11d
movq 0xc8(%rsp), %r10
movb 0x64(%rsp), %al
movq 0x88(%rsp), %r9
andb $0x1, %r14b
andb $0x1, %bpl
andb $0x1, %bl
andb $0x1, %al
movzbl %r8b, %r8d
movzbl %r14b, %r14d
movl %r14d, (%rsp)
movzbl %bpl, %ebp
movl %ebp, 0x8(%rsp)
movzbl %bl, %ebx
movl %ebx, 0x10(%rsp)
movl %r11d, 0x18(%rsp)
movq %r10, 0x20(%rsp)
movzbl %al, %eax
movl %eax, 0x28(%rsp)
callq 0xb690
jmp 0xbfd2
movq 0x48(%rsp), %rax
testb $0x1, 0x10(%rax)
je 0xbf34
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x48(%rsp), %rax
movl (%rax), %eax
movl %eax, %esi
movq 0x48(%rsp), %rax
movl (%rax), %eax
addl 0x60(%rsp), %eax
movl %eax, %eax
movl %eax, %edx
movq 0x48(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x48(%rsp), %rax
movb 0x11(%rax), %r8b
movb 0x67(%rsp), %r14b
movb 0x66(%rsp), %bpl
movb 0x65(%rsp), %bl
movl 0xc0(%rsp), %r11d
movq 0xc8(%rsp), %r10
movb 0x64(%rsp), %al
movq 0x88(%rsp), %r9
andb $0x1, %r14b
andb $0x1, %bpl
andb $0x1, %bl
andb $0x1, %al
movzbl %r8b, %r8d
movzbl %r14b, %r14d
movl %r14d, (%rsp)
movzbl %bpl, %ebp
movl %ebp, 0x8(%rsp)
movzbl %bl, %ebx
movl %ebx, 0x10(%rsp)
movl %r11d, 0x18(%rsp)
movq %r10, 0x20(%rsp)
movzbl %al, %eax
movl %eax, 0x28(%rsp)
callq 0xb690
jmp 0xbfd0
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x48(%rsp), %rax
movl 0x4(%rax), %eax
subl 0x60(%rsp), %eax
movslq %eax, %rsi
movq 0x48(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, %edx
movq 0x48(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x48(%rsp), %rax
movb 0x11(%rax), %r8b
movb 0x67(%rsp), %r14b
movb 0x66(%rsp), %bpl
movb 0x65(%rsp), %bl
movl 0xc0(%rsp), %r11d
movq 0xc8(%rsp), %r10
movb 0x64(%rsp), %al
movq 0x88(%rsp), %r9
andb $0x1, %r14b
andb $0x1, %bpl
andb $0x1, %bl
andb $0x1, %al
movzbl %r8b, %r8d
movzbl %r14b, %r14d
movl %r14d, (%rsp)
movzbl %bpl, %ebp
movl %ebp, 0x8(%rsp)
movzbl %bl, %ebx
movl %ebx, 0x10(%rsp)
movl %r11d, 0x18(%rsp)
movq %r10, 0x20(%rsp)
movzbl %al, %eax
movl %eax, 0x28(%rsp)
callq 0xb690
jmp 0xbfd2
movq 0x48(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x2040
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0xbdaf
jmp 0xbff2
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0xbd72
addq $0x90, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop