// File: /workspace/github_c_makefile_star2_O1/jsh58[P]Genrich/Genrich.c
// Function: processSingle
int processSingle(char* qname, Aln* aln, int alnLen,
    bool extendOpt, int extend, bool avgExtOpt,
    Aln*** unpair, int* unpairIdx, int* unpairLen,
    int* unpairMem, float score, float asDiff,
    bool first, 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 unpaired 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->first == first
        && 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)
    subsampleSingle(aln, alnLen, first, &count, &score);

  // find unpaired alns to save
  uint8_t saved = 0;
  for (int i = 0; i < alnLen; i++) {
    Aln* a = aln + i;
    if (! a->paired && a->first == first
        && a->score >= score && a->chrom->save
        && ! a->chrom->skip) {

      if (avgExtOpt)
        // for average-extension option, save alignment
        //   for later processing by processAvgExt()
        saveAvgExt(qname, a, count, unpair,
          unpairIdx, unpairLen, unpairMem);

      else
        // for other options, save interval
        saveUnpair(qname, a, count, extendOpt, extend,
          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));
  }

  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl %r9d, %ebp
movl %r8d, 0x24(%rsp)
movl %ecx, %r12d
movl %edx, %r13d
movq %rsi, %r15
movq %rdi, 0x10(%rsp)
movb 0x130(%rsp), %r14b
movaps %xmm0, %xmm2
subss %xmm1, %xmm2
movss 0x89bf(%rip), %xmm1     # 0x12178
cmpneqss %xmm0, %xmm1
andps %xmm1, %xmm2
andnps %xmm0, %xmm1
orps %xmm2, %xmm1
movss %xmm1, 0xc(%rsp)
movb $0x0, 0x7(%rsp)
xorl %eax, %eax
movl %edx, %ebx
testl %edx, %edx
jle 0x9826
leaq (,%rbx,8), %rcx
leaq (%rcx,%rcx,4), %rdx
xorl %esi, %esi
xorl %ecx, %ecx
cmpb $0x0, 0xd(%r15,%rsi)
jne 0x981b
cmpb %r14b, 0xf(%r15,%rsi)
jne 0x981b
movss 0x8(%r15,%rsi), %xmm0
ucomiss %xmm1, %xmm0
jb 0x981b
movq 0x20(%r15,%rsi), %rdi
cmpb $0x1, 0xd(%rdi)
jne 0x981b
movb 0xc(%rdi), %dil
xorb $0x1, %dil
addb %dil, %cl
addq $0x28, %rsi
cmpq %rsi, %rdx
jne 0x97ea
jmp 0x9828
xorl %ecx, %ecx
movb %cl, 0x7(%rsp)
testb %cl, %cl
je 0x99e4
cmpb $0xa, %cl
ja 0x9846
cmpb $0x9, %cl
je 0x9846
movzbl %cl, %eax
cmpl $0x7, %eax
jne 0x985f
movzbl %r14b, %edx
leaq 0x7(%rsp), %rcx
leaq 0xc(%rsp), %r8
movq %r15, %rdi
movl %r13d, %esi
callq 0x9698
testl %r13d, %r13d
jle 0x99d2
movl %ebp, 0x20(%rsp)
movss 0xc(%rsp), %xmm1
movb 0x7(%rsp), %r13b
decq %rbx
xorl %ebp, %ebp
movzbl %r13b, %eax
movl %eax, 0x8(%rsp)
movzbl 0x188(%rsp), %eax
movq %rax, 0x48(%rsp)
movzbl 0x170(%rsp), %eax
movq %rax, 0x40(%rsp)
movzbl %r12b, %eax
movl %eax, 0x18(%rsp)
movzbl 0x168(%rsp), %eax
movq %rax, 0x38(%rsp)
movzbl 0x160(%rsp), %eax
movq %rax, 0x30(%rsp)
movzbl 0x150(%rsp), %eax
movq %rax, 0x28(%rsp)
movzbl 0x138(%rsp), %r12d
movss %xmm1, 0x1c(%rsp)
cmpb $0x0, 0xd(%r15)
jne 0x9904
cmpb %r14b, 0xf(%r15)
jne 0x9904
movss 0x8(%r15), %xmm0
ucomiss %xmm1, %xmm0
jb 0x9904
movq 0x20(%r15), %rax
cmpb $0x1, 0xd(%rax)
jne 0x9904
cmpb $0x0, 0xc(%rax)
je 0x9922
xorl %eax, %eax
subq $0x1, %rbx
setb %cl
testb %al, %al
jne 0x99d4
addq $0x28, %r15
testb %cl, %cl
je 0x98dc
jmp 0x99d4
cmpb $0x0, 0x20(%rsp)
je 0x9963
subq $0x8, %rsp
movq 0x18(%rsp), %rdi
movq %r15, %rsi
movl 0x10(%rsp), %edx
movq 0x118(%rsp), %rcx
movq 0x120(%rsp), %r8
movq 0x128(%rsp), %r9
pushq 0x130(%rsp)
callq 0x8c64
addq $0x10, %rsp
jmp 0x99be
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movl 0x8(%rsp), %edx
movl 0x18(%rsp), %ecx
movl 0x24(%rsp), %r8d
movl %r12d, %r9d
pushq 0x48(%rsp)
pushq 0x188(%rsp)
movl 0x188(%rsp), %eax
pushq %rax
pushq 0x58(%rsp)
pushq 0x58(%rsp)
pushq 0x58(%rsp)
pushq 0x188(%rsp)
pushq 0x60(%rsp)
movl 0x188(%rsp), %eax
pushq %rax
movl 0x188(%rsp), %eax
pushq %rax
callq 0x8d4c
addq $0x50, %rsp
incb %bpl
cmpb %r13b, %bpl
sete %al
movss 0x1c(%rsp), %xmm1
jmp 0x9906
xorl %ebp, %ebp
movzbl 0x7(%rsp), %r8d
movl $0x1, %eax
cmpb %r8b, %bpl
jne 0x99f6
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movzbl %bpl, %edx
leaq 0xa0d9(%rip), %rsi      # 0x13ada
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movq 0x10(%rsp), %rcx
xorl %eax, %eax
callq 0x2290
movq %r14, %rdi
movl $0x21, %esi
callq 0x22f0
movl $0x1, %edi
callq 0x22a0