// File: /workspace/github_c_makefile_star2_O2/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 $0xe8, %rsp
movl %r9d, 0x20(%rsp)
movl %ecx, %r9d
movq %rsi, %r15
movq %rdi, 0x8(%rsp)
movb 0x198(%rsp), %dil
movb 0x180(%rsp), %r14b
movb 0x178(%rsp), %r11b
movb 0x170(%rsp), %r10b
movaps %xmm0, %xmm2
subss %xmm1, %xmm2
movss 0x7d53(%rip), %xmm1     # 0x1018c
cmpneqss %xmm0, %xmm1
andps %xmm1, %xmm2
andnps %xmm0, %xmm1
orps %xmm2, %xmm1
movss %xmm1, 0x24(%rsp)
xorl %eax, %eax
testl %edx, %edx
movl $0x0, %ebp
cmovgl %edx, %ebp
movb 0x140(%rsp), %r12b
imulq $0x28, %rbp, %rcx
xorl %ebx, %ebx
cmpq %rax, %rcx
je 0x84a3
cmpb $0x0, 0xd(%r15,%rax)
jne 0x849d
cmpb %r12b, 0xf(%r15,%rax)
jne 0x849d
movss 0x8(%r15,%rax), %xmm0
ucomiss %xmm1, %xmm0
jb 0x849d
movq 0x20(%r15,%rax), %rsi
cmpb $0x1, 0xd(%rsi)
jne 0x849d
movb 0xc(%rsi), %sil
xorb $0x1, %sil
addb %sil, %bl
addq $0x28, %rax
jmp 0x8467
movb %bl, 0x7(%rsp)
testb %bl, %bl
je 0x86a0
movl %r8d, 0x1c(%rsp)
cmpb $0xa, %bl
ja 0x84c6
cmpb $0x9, %bl
je 0x84c6
movzbl %bl, %eax
cmpl $0x7, %eax
jne 0x8513
movzbl %r12b, %eax
leaq 0x7(%rsp), %rbx
leaq 0x24(%rsp), %r14
movq %r15, %rdi
movl %edx, %esi
movl %eax, %edx
movq %rbx, %rcx
movq %r14, %r8
movl %r9d, %r13d
callq 0x8311
movb 0x178(%rsp), %r11b
movb 0x170(%rsp), %r10b
movb 0x198(%rsp), %dil
movl %r13d, %r9d
movss (%r14), %xmm1
movb 0x180(%rsp), %r14b
movb (%rbx), %bl
xorl %r13d, %r13d
movzbl %bl, %r8d
pushq $0x1
popq %rax
movzbl %dil, %ecx
movq %rcx, 0x48(%rsp)
movzbl %r14b, %ecx
movq %rcx, 0x40(%rsp)
movzbl %r11b, %ecx
movq %rcx, 0x38(%rsp)
movzbl %r10b, %ecx
movq %rcx, 0x30(%rsp)
movzbl 0x160(%rsp), %ecx
movq %rcx, 0x28(%rsp)
movzbl %r9b, %ecx
movl %ecx, 0x18(%rsp)
movzbl 0x148(%rsp), %ecx
movl %ecx, 0x14(%rsp)
subq $0x1, %rbp
jb 0x8669
cmpb $0x0, 0xd(%r15)
jne 0x8660
cmpb %r12b, 0xf(%r15)
jne 0x8660
movss 0x8(%r15), %xmm0
ucomiss %xmm1, %xmm0
jb 0x8660
movq 0x20(%r15), %rcx
cmpb $0x1, 0xd(%rcx)
jne 0x8660
cmpb $0x0, 0xc(%rcx)
jne 0x8660
movaps %xmm1, 0x50(%rsp)
cmpb $0x0, 0x20(%rsp)
je 0x85ee
subq $0x8, %rsp
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movl %r8d, %r14d
movl %r8d, %edx
movq 0x128(%rsp), %rcx
movq 0x130(%rsp), %r8
movq 0x138(%rsp), %r9
pushq 0x140(%rsp)
callq 0x7919
popq %rax
popq %rcx
jmp 0x864d
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movl %r8d, %r14d
movl %r8d, %edx
movl 0x18(%rsp), %ecx
movl 0x1c(%rsp), %r8d
movl 0x14(%rsp), %r9d
pushq 0x48(%rsp)
pushq 0x198(%rsp)
movl 0x198(%rsp), %eax
pushq %rax
pushq 0x58(%rsp)
pushq 0x58(%rsp)
pushq 0x58(%rsp)
pushq 0x198(%rsp)
pushq 0x60(%rsp)
movl 0x198(%rsp), %eax
pushq %rax
movl 0x198(%rsp), %eax
pushq %rax
callq 0x7a07
addq $0x50, %rsp
incb %r13b
cmpb %bl, %r13b
movaps 0x50(%rsp), %xmm1
movl %r14d, %r8d
pushq $0x1
popq %rax
je 0x86a2
addq $0x28, %r15
jmp 0x8562
cmpb %bl, %r13b
je 0x86a2
movzbl %r13b, %edx
leaq 0x93b1(%rip), %rsi      # 0x11a2a
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0x2290
pushq $0x21
popq %rsi
movq %r14, %rdi
callq 0x2724
pushq $0x1
popq %rdi
callq 0x22a0
xorl %eax, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq