// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: parseAlign
bool parseAlign(Aln** aln, int* alnLen, uint16_t flag,
    Chrom* chrom, uint32_t pos, int length, uint32_t pnext,
    uint64_t* paired, uint64_t* single, uint64_t* secPair,
    uint64_t* secSingle, uint64_t* skipped, bool singleOpt,
    float score, bool dupsOpt, char* qual, int qualLen,
    int offset, uint16_t* qualR1, uint16_t* qualR2) {

  // check for linear template or missing index
  if (flag & 0x1) {
    if ((flag & 0xC0) == 0xC0)
      exit(error("", ERRLINEAR));
    if (!(flag & 0xC0))
      exit(error("", ERRINDEX));
  }

  // save sum of quality scores (only if removing dups)
  if (dupsOpt) {
    if (flag & 0x40) {
      if (! *qualR1 && strcmp(qual, "*"))
        *qualR1 = sumQual(qual, qualLen, offset);
    } else {
      if (! *qualR2 && strcmp(qual, "*"))
        *qualR2 = sumQual(qual, qualLen, offset);
    }
  }

  // paired alignment: save alignment information
  if ((flag & 0x3) == 0x3) {

    // update counts
    if (chrom->skip || ! chrom->save)
      (*skipped)++;
    else {
      (*paired)++;
      if (flag & 0x100)
        (*secPair)++;
    }

    // search for matching paired alignment (already analyzed)
    for (int i = 0; i < *alnLen; i++) {
      Aln* a = *aln + i;
      if ( a->paired && ! a->full && a->chrom == chrom
          && (flag & 0x40 ? (! a->first && a->pos[0] == pos)
            : (a->first && a->pos[1] == pos) )
          && (flag & 0x100 ? ! a->primary : a->primary) ) {
        // complete paired alignment
        updatePairedAln(a, flag, pos, length, score);
        return true;
      }
    }

    // not found: start new paired alignment
    return savePairedAln(aln, alnLen, flag, chrom,
      pos, length, pnext, score);
  }

  // unpaired alignment
  if (chrom->skip || ! chrom->save)
    (*skipped)++;
  else {
    (*single)++;
    if (flag & 0x100)
      (*secSingle)++;
  }

  // save alignment info
  if (singleOpt)
    return saveSingleAln(aln, alnLen, flag, chrom,
      pos, length, score);

  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r9d, 0x10(%rsp)
movq %rcx, %r14
movl %edx, %r15d
movq %rsi, %r11
movq %rdi, %r13
movq 0xe0(%rsp), %rax
movq 0xd8(%rsp), %rbp
movl 0xd0(%rsp), %edx
movl 0xc8(%rsp), %esi
movq 0xc0(%rsp), %rdi
movb 0xb8(%rsp), %cl
movb 0xb0(%rsp), %r12b
movq 0xa8(%rsp), %rbx
movq 0xa0(%rsp), %r9
movq %r9, 0x40(%rsp)
movq 0x98(%rsp), %r9
movq %r9, 0x28(%rsp)
movq 0x90(%rsp), %r9
movq %r9, 0x38(%rsp)
movq 0x88(%rsp), %r9
movq %r9, 0x30(%rsp)
movl 0x80(%rsp), %r9d
testb $0x1, %r15b
je 0xaf75
testb $-0x40, %r15b
je 0xb10d
movl %r15d, %r10d
andl $0xc0, %r10d
cmpl $0xc0, %r10d
je 0xb118
testb %cl, %cl
je 0xafdf
testb $0x40, %r15b
jne 0xaf95
cmpw $0x0, (%rax)
jne 0xafdf
cmpb $0x2a, (%rdi)
jne 0xafa9
cmpb $0x0, 0x1(%rdi)
movq %rax, %rbp
jne 0xafac
jmp 0xafdf
cmpw $0x0, (%rbp)
jne 0xafdf
cmpb $0x2a, (%rdi)
jne 0xafac
cmpb $0x0, 0x1(%rdi)
jne 0xafac
jmp 0xafdf
movq %rax, %rbp
movss %xmm0, 0x1c(%rsp)
movl %r9d, 0x14(%rsp)
movl %r8d, 0x18(%rsp)
movq %r11, 0x20(%rsp)
callq 0xae8e
movq 0x20(%rsp), %r11
movl 0x18(%rsp), %r8d
movl 0x14(%rsp), %r9d
movss 0x1c(%rsp), %xmm0
movw %ax, (%rbp)
movl %r15d, %ecx
notl %ecx
movb 0xc(%r14), %al
testb $0x3, %cl
jne 0xb015
testb %al, %al
jne 0xb065
cmpb $0x0, 0xd(%r14)
je 0xb065
movq 0x30(%rsp), %rax
incq (%rax)
movb $0x1, %al
btl $0x8, %r15d
jae 0xb070
movq 0x28(%rsp), %rax
incq (%rax)
xorl %eax, %eax
jmp 0xb070
testb %al, %al
jne 0xb034
cmpb $0x1, 0xd(%r14)
jne 0xb034
movq 0x38(%rsp), %rax
incq (%rax)
btl $0x8, %r15d
movq 0x40(%rsp), %rbx
jae 0xb037
incq (%rbx)
testb %r12b, %r12b
je 0xb0df
movzwl %r15w, %edx
movq %r13, %rdi
movq %r11, %rsi
movq %r14, %rcx
movl 0x10(%rsp), %r9d
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xae32
incq (%rbx)
btl $0x8, %r15d
setae %al
movl (%r11), %edx
xorl %ecx, %ecx
testl %edx, %edx
cmovlel %ecx, %edx
imulq $0x28, %rdx, %rdx
cmpq %rcx, %rdx
je 0xb0e3
movq (%r13), %rdi
cmpb $0x1, 0xd(%rdi,%rcx)
jne 0xb09c
cmpb $0x0, 0xe(%rdi,%rcx)
jne 0xb09c
cmpq %r14, 0x20(%rdi,%rcx)
je 0xb0a2
addq $0x28, %rcx
jmp 0xb07e
movb 0xf(%rdi,%rcx), %sil
testb $0x40, %r15b
jne 0xb0bb
testb %sil, %sil
je 0xb09c
cmpl %r8d, 0x4(%rdi,%rcx)
jne 0xb09c
jmp 0xb0c6
testb %sil, %sil
jne 0xb09c
cmpl %r8d, (%rdi,%rcx)
jne 0xb09c
cmpb 0xc(%rdi,%rcx), %al
jne 0xb09c
addq %rcx, %rdi
movzwl %r15w, %esi
movl %r8d, %edx
movl 0x10(%rsp), %ecx
callq 0xad7a
movb $0x1, %al
jmp 0xb0fe
movl %r9d, (%rsp)
movzwl %r15w, %edx
movq %r13, %rdi
movq %r11, %rsi
movq %r14, %rcx
movl 0x10(%rsp), %r9d
callq 0xadc0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x69fb(%rip), %rdi      # 0x11b0f
pushq $0x1e
jmp 0xb121
leaq 0x69f0(%rip), %rdi      # 0x11b0f
pushq $0x1d
popq %rsi
callq 0x2724
pushq $0x1
popq %rdi
callq 0x22a0