// File: /workspace/github_c_makefile_star2_O1/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 $0xd8, %rsp
movl %r9d, %ebp
movl %r8d, %r13d
movq %rcx, %r14
movl %edx, %r12d
movq %rsi, %r15
movq %rdi, 0x20(%rsp)
movaps %xmm0, %xmm2
subss %xmm1, %xmm2
movss 0x862e(%rip), %xmm1     # 0x12178
cmpneqss %xmm0, %xmm1
andps %xmm1, %xmm2
andnps %xmm0, %xmm1
orps %xmm2, %xmm1
movss %xmm1, 0x10(%rsp)
movb $0x0, 0xf(%rsp)
xorl %eax, %eax
movl %edx, %ebx
testl %edx, %edx
jle 0x9bb8
leaq (,%rbx,8), %rcx
leaq (%rcx,%rcx,4), %rdx
xorl %esi, %esi
xorl %ecx, %ecx
cmpb $0x1, 0xd(%r15,%rsi)
jne 0x9bad
cmpb $0x1, 0xe(%r15,%rsi)
jne 0x9bad
movss 0x8(%r15,%rsi), %xmm0
ucomiss %xmm1, %xmm0
jb 0x9bad
movq 0x20(%r15,%rsi), %rdi
cmpb $0x1, 0xd(%rdi)
jne 0x9bad
movb 0xc(%rdi), %dil
xorb $0x1, %dil
addb %dil, %cl
addq $0x28, %rsi
cmpq %rsi, %rdx
jne 0x9b7b
jmp 0x9bba
xorl %ecx, %ecx
movb %cl, 0xf(%rsp)
testb %cl, %cl
je 0x9d52
cmpb $0xa, %cl
ja 0x9bd8
cmpb $0x9, %cl
je 0x9bd8
movzbl %cl, %eax
cmpl $0x7, %eax
jne 0x9bed
leaq 0xf(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movq %r15, %rdi
movl %r12d, %esi
callq 0x9a2c
testl %r12d, %r12d
jle 0x9d27
movl %ebp, 0x1c(%rsp)
movss 0x10(%rsp), %xmm1
movb 0xf(%rsp), %al
decq %rbx
xorl %ebp, %ebp
movzbl 0x150(%rsp), %ecx
movq %rcx, 0x48(%rsp)
movzbl 0x138(%rsp), %ecx
movq %rcx, 0x40(%rsp)
movzbl 0x130(%rsp), %ecx
movq %rcx, 0x38(%rsp)
movzbl 0x128(%rsp), %ecx
movq %rcx, 0x30(%rsp)
movzbl 0x118(%rsp), %ecx
movq %rcx, 0x28(%rsp)
movzbl %al, %r12d
movzbl %r13b, %eax
movl %eax, 0x14(%rsp)
xorl %r13d, %r13d
movss %xmm1, 0x18(%rsp)
cmpb $0x1, 0xd(%r15)
jne 0x9c88
cmpb $0x1, 0xe(%r15)
jne 0x9c88
movss 0x8(%r15), %xmm0
ucomiss %xmm1, %xmm0
jb 0x9c88
movq 0x20(%r15), %rax
cmpb $0x1, 0xd(%rax)
jne 0x9c88
cmpb $0x0, 0xc(%rax)
je 0x9c9f
xorl %eax, %eax
subq $0x1, %rbx
setb %cl
testb %al, %al
jne 0x9d04
addq $0x28, %r15
testb %cl, %cl
je 0x9c5f
jmp 0x9d04
movq 0x20(%rsp), %rdi
movq %r15, %rsi
movl %r12d, %edx
movl 0x14(%rsp), %ecx
movl 0x1c(%rsp), %r8d
movl 0x110(%rsp), %r9d
pushq 0x48(%rsp)
pushq 0x150(%rsp)
movl 0x150(%rsp), %eax
pushq %rax
pushq 0x58(%rsp)
pushq 0x58(%rsp)
pushq 0x58(%rsp)
pushq 0x150(%rsp)
pushq 0x60(%rsp)
callq 0x8fd9
movss 0x58(%rsp), %xmm1
addq $0x40, %rsp
movl %eax, %eax
addq %rax, %r13
incb %bpl
cmpb %r12b, %bpl
sete %al
jmp 0x9c8a
movq %r13, %xmm1
punpckldq 0x853f(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x8547(%rip), %xmm1     # 0x12260
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
jmp 0x9d2c
xorps %xmm0, %xmm0
xorl %ebp, %ebp
movzbl 0xf(%rsp), %r8d
cmpb %r8b, %bpl
jne 0x9d64
xorps %xmm1, %xmm1
cvtsi2sd %r8d, %xmm1
divsd %xmm1, %xmm0
addsd (%r14), %xmm0
movsd %xmm0, (%r14)
movl $0x1, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movzbl %bpl, %edx
leaq 0x9d6b(%rip), %rsi      # 0x13ada
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x2290
movq %r14, %rdi
movl $0x21, %esi
callq 0x22f0
movl $0x1, %edi
callq 0x22a0