// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: processAlns
void processAlns(char* qname, Aln* aln, int alnLen,
    double* totalLen, uint64_t* pairedPr,
    uint64_t* singlePr, uint64_t* orphan, bool singleOpt,
    bool extendOpt, int extend, bool avgExtOpt,
    Aln*** unpair, int* unpairIdx, int* unpairLen,
    int* unpairMem, float asDiff, bool atacOpt,
    int atacLen5, int atacLen3, bool atacAdj, File bed,
    bool bedOpt, bool gzOut, bool ctrl, int sample,
    bool dupsOpt, Read*** readPr, int* readIdxPr,
    int* readLenPr, int* readMemPr, Read*** readDc,
    int* readIdxDc, int* readLenDc, int* readMemDc,
    Read*** readSn, int* readIdxSn, int* readLenSn,
    int* readMemSn, uint16_t qualR1, uint16_t qualR2,
    uint64_t* errCount, bool verbose) {

  // determine if paired alns are valid, and best score
  float scorePr = NOSCORE, scoreR1 = NOSCORE,
    scoreR2 = NOSCORE;
  bool pair = false, singleR1 = false, singleR2 = false;
  for (int i = 0; i < alnLen; i++) {
    Aln* a = aln + i;
    if (a->paired) {
      if (a->full) {
        // valid paired aln
        if (! pair || scorePr < a->score)
          scorePr = a->score; // best score so far
        pair = true;
      } else
        (*orphan)++;  // incomplete paired alignment
    } else if (singleOpt && ! pair) {
      // update best scores of unpaired alns
      if (a->first && scoreR1 <= a->score) {
        scoreR1 = a->score;
        singleR1 = true;
      } else if (! a->first && scoreR2 <= a->score) {
        scoreR2 = a->score;
        singleR2 = true;
      }
    }
  }

  if (dupsOpt)
    // save alignments for later evaluation of duplicates
    saveAlns(qname, aln, alnLen, pair, singleOpt, singleR1,
      singleR2, scorePr, scoreR1, scoreR2, asDiff,
      readPr, readIdxPr, readLenPr, readMemPr,
      readDc, readIdxDc, readLenDc, readMemDc,
      readSn, readIdxSn, readLenSn, readMemSn,
      qualR1, qualR2);

  else {
    // process alns directly
    if (pair)
      // process paired alignments
      *pairedPr += processPair(qname, aln, alnLen,
        totalLen, scorePr, asDiff, atacOpt, atacLen5,
        atacLen3, atacAdj, bed, bedOpt, gzOut, ctrl,
        sample, errCount, verbose);
    else if (singleOpt) {
      // process unpaired alignments (separately for R1, R2)
      if (singleR1)
        *singlePr += processSingle(qname, aln, alnLen,
          extendOpt, extend, avgExtOpt,
          unpair, unpairIdx, unpairLen, unpairMem,
          scoreR1, asDiff, true,
          atacOpt, atacLen5, atacLen3, atacAdj,
          bed, bedOpt, gzOut, ctrl, sample, errCount,
          verbose);
      if (singleR2)
        *singlePr += processSingle(qname, aln, alnLen,
          extendOpt, extend, avgExtOpt,
          unpair, unpairIdx, unpairLen, unpairMem,
          scoreR2, asDiff, false,
          atacOpt, atacLen5, atacLen3, atacAdj,
          bed, bedOpt, gzOut, ctrl, sample, errCount,
          verbose);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movaps %xmm0, %xmm3
movq %r9, 0x28(%rsp)
movq %r8, %r13
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
movb 0x100(%rsp), %dil
movb 0x78(%rsp), %r8b
xorl %r9d, %r9d
testl %edx, %edx
movl $0x0, %eax
cmovgl %edx, %eax
imulq $0x28, %rax, %rsi
movss 0x76eb(%rip), %xmm1     # 0x1018c
movaps %xmm1, %xmm2
movaps %xmm1, %xmm0
movzwl 0x168(%rsp), %edx
movq 0x70(%rsp), %rax
xorl %r10d, %r10d
xorl %r11d, %r11d
xorl %r12d, %r12d
cmpq %r9, %rsi
je 0x8b34
cmpb $0x1, 0xd(%r14,%r9)
jne 0x8ae8
cmpb $0x1, 0xe(%r14,%r9)
jne 0x8b12
movss 0x8(%r14,%r9), %xmm4
movb $0x1, %bl
testb $0x1, %r10b
je 0x8b1b
ucomiss %xmm0, %xmm4
jbe 0x8b18
jmp 0x8b1b
testb %r8b, %r8b
je 0x8b15
testb $0x1, %r10b
jne 0x8b15
movss 0x8(%r14,%r9), %xmm4
cmpb $0x1, 0xf(%r14,%r9)
jne 0x8b27
ucomiss %xmm1, %xmm4
jb 0x8b15
movaps %xmm4, %xmm1
movl %r10d, %ebx
movb $0x1, %r11b
jmp 0x8b18
incq (%rax)
movl %r10d, %ebx
movaps %xmm0, %xmm4
addq $0x28, %r9
movl %ebx, %r10d
movaps %xmm4, %xmm0
jmp 0x8abd
ucomiss %xmm2, %xmm4
jb 0x8b15
movb $0x1, %r12b
movaps %xmm4, %xmm2
jmp 0x8b15
testb %dil, %dil
je 0x8bd8
subq $0x8, %rsp
movzwl 0x178(%rsp), %ebx
movzwl %dx, %r13d
movzbl %r12b, %eax
andl $0x1, %eax
movzbl %r8b, %r8d
movzbl %r10b, %ecx
andl $0x1, %ecx
movzbl %r11b, %r9d
andl $0x1, %r9d
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %edx
pushq %rbx
pushq %r13
pushq 0x178(%rsp)
pushq 0x178(%rsp)
pushq 0x178(%rsp)
pushq 0x178(%rsp)
pushq 0x178(%rsp)
pushq 0x178(%rsp)
pushq 0x178(%rsp)
pushq 0x178(%rsp)
pushq 0x178(%rsp)
pushq 0x178(%rsp)
pushq 0x178(%rsp)
pushq 0x178(%rsp)
pushq %rax
callq 0x8175
addq $0xb8, %rsp
jmp 0x8e37
testb $0x1, %r10b
je 0x8c67
subq $0x8, %rsp
movzbl 0x188(%rsp), %eax
movzbl 0xf8(%rsp), %r10d
movzbl 0xf0(%rsp), %r11d
movzbl 0xe8(%rsp), %ebx
movzbl 0xd8(%rsp), %r12d
movzbl 0xc0(%rsp), %r8d
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %edx
movaps %xmm3, %xmm1
movl 0xc8(%rsp), %r9d
pushq %rax
pushq 0x188(%rsp)
movl 0x110(%rsp), %eax
pushq %rax
pushq %r10
pushq %r11
pushq %rbx
pushq 0x110(%rsp)
pushq %r12
movl 0x110(%rsp), %eax
pushq %rax
callq 0x8793
addq $0x50, %rsp
movl %eax, %eax
addq %rax, (%r13)
jmp 0x8e33
testb %r8b, %r8b
je 0x8e33
movzbl 0x180(%rsp), %eax
movq %rax, 0x10(%rsp)
movzbl 0xf0(%rsp), %eax
movq %rax, 0x18(%rsp)
movzbl 0xe8(%rsp), %eax
movq %rax, 0x20(%rsp)
movzbl 0xe0(%rsp), %r13d
movzbl 0xd0(%rsp), %ebx
movzbl 0xb8(%rsp), %r10d
movzbl 0x80(%rsp), %ecx
movzbl 0x90(%rsp), %r9d
testb $0x1, %r11b
je 0x8da8
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %edx
movl %ecx, (%rsp)
movl (%rsp), %ecx
movl 0x88(%rsp), %r8d
movl %r9d, 0x4(%rsp)
movl 0x4(%rsp), %r9d
movaps %xmm1, %xmm0
movaps %xmm3, %xmm1
pushq 0x10(%rsp)
pushq 0x180(%rsp)
movl 0x108(%rsp), %eax
pushq %rax
pushq 0x30(%rsp)
pushq 0x40(%rsp)
pushq %r13
pushq 0x108(%rsp)
pushq %rbx
movl 0x108(%rsp), %eax
pushq %rax
movl 0x108(%rsp), %eax
pushq %rax
pushq %r10
pushq $0x1
pushq 0x110(%rsp)
pushq 0x110(%rsp)
pushq 0x110(%rsp)
pushq 0x110(%rsp)
movss %xmm3, 0x8c(%rsp)
movss %xmm2, 0x88(%rsp)
movq %r13, 0xb0(%rsp)
movq %rbx, %r13
movq %r10, %rbx
callq 0x83e9
movl 0x84(%rsp), %r9d
movq %rbx, %r10
movq %r13, %rbx
movq 0xb0(%rsp), %r13
movss 0x88(%rsp), %xmm2
movss 0x8c(%rsp), %xmm3
addq $0x80, %rsp
movl %eax, %eax
movq 0x28(%rsp), %rcx
addq %rax, (%rcx)
movl (%rsp), %ecx
testb $0x1, %r12b
je 0x8e33
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %edx
movl 0x88(%rsp), %r8d
movaps %xmm2, %xmm0
movaps %xmm3, %xmm1
pushq 0x10(%rsp)
pushq 0x180(%rsp)
movl 0x108(%rsp), %eax
pushq %rax
pushq 0x30(%rsp)
pushq 0x40(%rsp)
pushq %r13
pushq 0x108(%rsp)
pushq %rbx
movl 0x108(%rsp), %eax
pushq %rax
movl 0x108(%rsp), %eax
pushq %rax
pushq %r10
pushq $0x0
pushq 0x110(%rsp)
pushq 0x110(%rsp)
pushq 0x110(%rsp)
pushq 0x110(%rsp)
callq 0x83e9
addq $0x80, %rsp
movl %eax, %eax
movq 0x28(%rsp), %rcx
addq %rax, (%rcx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq