// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: processPair
int processPair(char* qname, Aln* aln, int alnLen,
    double* totalLen, float score, float asDiff,
    bool atacOpt, int atacLen5, int atacLen3, bool atacAdj,
    File bed, bool bedOpt, bool gzOut, bool ctrl,
    int sample, uint64_t* errCount, bool verbose) {

  // adjust AS tolerance for secondary alns
  if (score != NOSCORE)
    score -= asDiff;

  // determine number of valid paired alignments
  //   (within score threshold and not to skipped chrom)
  uint8_t count = 0;
  for (int i = 0; i < alnLen; i++) {
    Aln* a = aln + i;
    if (a->paired && a->full && a->score >= score
        && a->chrom->save && ! a->chrom->skip)
      count++;
  }
  if (! count)
    return 0;

  // adjust score so that num alns is OK (1/2/3/4/5/6/8/10)
  if (count > 10 || count == 7 || count == 9)
    subsamplePair(aln, alnLen, &count, &score);

  // find full fragments to save
  uint64_t fragLen = 0;     // local sum of fragment lengths
  uint8_t saved = 0;
  for (int i = 0; i < alnLen; i++) {
    Aln* a = aln + i;
    if (a->paired && a->full && a->score >= score
        && a->chrom->save && ! a->chrom->skip) {

      // save full fragment
      fragLen += saveFragment(qname, a, count,
        atacOpt, atacLen5, atacLen3, atacAdj, bed, bedOpt,
        gzOut, ctrl, sample, errCount, verbose);

      if (++saved == count)
        break;  // in case of AS ties
    }
  }

  // check for error saving alignments
  if (saved != count) {
    char msg[MAX_ALNS];
    sprintf(msg, "Saved %d alignments for read %s; should have been %d",
      saved, qname, count);
    exit(error(msg, ERRISSUE));
  }

  *totalLen += (double) fragLen / count;
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movl %r9d, 0x10(%rsp)
movl %r8d, 0x20(%rsp)
movq %rsi, %r15
movq %rdi, 0x18(%rsp)
movb 0x160(%rsp), %bl
movb 0x148(%rsp), %r12b
movb 0x140(%rsp), %r11b
movb 0x138(%rsp), %r8b
movb 0x128(%rsp), %r9b
movaps %xmm0, %xmm2
subss %xmm1, %xmm2
movss 0x79a0(%rip), %xmm1     # 0x1018c
cmpneqss %xmm0, %xmm1
andps %xmm1, %xmm2
andnps %xmm0, %xmm1
orps %xmm2, %xmm1
movss %xmm1, 0x14(%rsp)
xorl %eax, %eax
testl %edx, %edx
movl $0x0, %ebp
cmovgl %edx, %ebp
imulq $0x28, %rbp, %rdi
xorl %r14d, %r14d
cmpq %rax, %rdi
je 0x8850
cmpb $0x1, 0xd(%r15,%rax)
jne 0x884a
cmpb $0x1, 0xe(%r15,%rax)
jne 0x884a
movss 0x8(%r15,%rax), %xmm0
ucomiss %xmm1, %xmm0
jb 0x884a
movq 0x20(%r15,%rax), %rsi
cmpb $0x1, 0xd(%rsi)
jne 0x884a
movb 0xc(%rsi), %sil
xorb $0x1, %sil
addb %sil, %r14b
addq $0x28, %rax
jmp 0x8813
movb %r14b, 0x7(%rsp)
testb %r14b, %r14b
je 0x8a12
movq %rcx, 0x58(%rsp)
cmpb $0xa, %r14b
ja 0x8878
cmpb $0x9, %r14b
je 0x8878
movzbl %r14b, %eax
cmpl $0x7, %eax
jne 0x88c0
leaq 0x7(%rsp), %r13
leaq 0x14(%rsp), %r14
movq %r15, %rdi
movl %edx, %esi
movq %r13, %rdx
movq %r14, %rcx
movl %r8d, %r12d
callq 0x86b4
movb 0x140(%rsp), %r11b
movl %r12d, %r8d
movb 0x148(%rsp), %r12b
movb 0x160(%rsp), %bl
movss (%r14), %xmm1
movb (%r13), %r14b
movb 0x128(%rsp), %r9b
xorl %r10d, %r10d
movzbl %bl, %r13d
movzbl %r12b, %eax
movq %rax, 0x50(%rsp)
movzbl %r11b, %r11d
movzbl %r8b, %ebx
movzbl %r9b, %r12d
movzbl %r14b, %r9d
movzbl 0x20(%rsp), %ecx
xorl %edx, %edx
subq $0x1, %rbp
jb 0x89d1
cmpb $0x1, 0xd(%r15)
jne 0x89c8
cmpb $0x1, 0xe(%r15)
jne 0x89c8
movss 0x8(%r15), %xmm0
ucomiss %xmm1, %xmm0
jb 0x89c8
movq 0x20(%r15), %rax
cmpb $0x1, 0xd(%rax)
jne 0x89c8
cmpb $0x0, 0xc(%rax)
jne 0x89c8
movq 0x18(%rsp), %rdi
movq %r15, %rsi
movq %rdx, 0x40(%rsp)
movl %r9d, %edx
movq %r10, 0x48(%rsp)
movl %ecx, 0x8(%rsp)
movl 0x10(%rsp), %r8d
movl %r9d, 0xc(%rsp)
movl 0x120(%rsp), %r9d
pushq %r13
pushq 0x160(%rsp)
movl 0x160(%rsp), %eax
pushq %rax
pushq 0x68(%rsp)
pushq %r11
pushq %rbx
pushq 0x160(%rsp)
pushq %r12
movaps %xmm1, 0x60(%rsp)
movq %r12, 0x78(%rsp)
movq %rbx, %r12
movq %r11, %rbx
callq 0x7cab
movl 0x48(%rsp), %ecx
movq 0x80(%rsp), %rdx
movq 0x88(%rsp), %r10
movq %rbx, %r11
movq %r12, %rbx
movq 0x78(%rsp), %r12
movl 0x4c(%rsp), %r9d
movaps 0x60(%rsp), %xmm1
addq $0x40, %rsp
movl %eax, %eax
addq %rax, %r10
incb %dl
cmpb %r9b, %dl
je 0x89d6
addq $0x28, %r15
jmp 0x88e7
cmpb %r14b, %dl
jne 0x8a26
movq %r10, %xmm0
punpckldq 0x784d(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x7855(%rip), %xmm0     # 0x10240
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
cvtsi2sd %r9d, %xmm0
divsd %xmm0, %xmm1
movq 0x58(%rsp), %rax
addsd (%rax), %xmm1
movsd %xmm1, (%rax)
pushq $0x1
popq %rax
jmp 0x8a14
xorl %eax, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movzbl %dl, %edx
leaq 0x8ffa(%rip), %rsi      # 0x11a2a
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq 0x18(%rsp), %rcx
movl %r9d, %r8d
xorl %eax, %eax
callq 0x2290
pushq $0x21
popq %rsi
movq %rbx, %rdi
callq 0x2724
pushq $0x1
popq %rdi
callq 0x22a0