// File: /workspace/github_c_makefile_star2_O1/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 $0x68, %rsp
movq %rcx, %r14
movl %edx, %r13d
movq %rsi, %r10
movq %rdi, %r11
movq 0x100(%rsp), %rbp
movq 0xf8(%rsp), %r12
movl 0xf0(%rsp), %r15d
movl 0xe8(%rsp), %eax
movl %eax, 0x3c(%rsp)
movq 0xe0(%rsp), %rbx
movb 0xd8(%rsp), %al
movb 0xd0(%rsp), %sil
movq 0xc8(%rsp), %rdx
movq 0xc0(%rsp), %rcx
movq %rcx, 0x60(%rsp)
movq 0xb8(%rsp), %rcx
movq %rcx, 0x58(%rsp)
movq 0xb0(%rsp), %rcx
movq %rcx, 0x50(%rsp)
movq 0xa8(%rsp), %rcx
movq %rcx, 0x48(%rsp)
movl 0xa0(%rsp), %edi
testb $0x1, %r13b
je 0xc452
testb $-0x40, %r13b
je 0xc715
movl %r13d, %ecx
andl $0xc0, %ecx
cmpl $0xc0, %ecx
je 0xc71a
testb %al, %al
je 0xc5af
testb $0x40, %r13b
jne 0xc501
cmpw $0x0, (%rbp)
jne 0xc5af
movb %sil, 0x17(%rsp)
leaq 0x703c(%rip), %rsi      # 0x134b7
movl %edi, 0x20(%rsp)
movq %rbx, %rdi
movss %xmm0, 0x18(%rsp)
movl %r9d, 0x1c(%rsp)
movl %r8d, 0x24(%rsp)
movq %r10, 0x28(%rsp)
movq %r11, 0x40(%rsp)
movq %rdx, 0x30(%rsp)
callq 0x21b0
movb 0x17(%rsp), %sil
movq 0x30(%rsp), %rdx
movl 0x20(%rsp), %edi
movq 0x40(%rsp), %r11
movq 0x28(%rsp), %r10
movl 0x24(%rsp), %r8d
movl 0x1c(%rsp), %r9d
movss 0x18(%rsp), %xmm0
testl %eax, %eax
je 0xc5af
movl 0x3c(%rsp), %eax
testl %eax, %eax
jle 0xc597
movl %eax, %ecx
xorl %edx, %edx
xorl %eax, %eax
movsbl (%rbx,%rdx), %esi
subl %r15d, %eax
addl %esi, %eax
incq %rdx
cmpq %rdx, %rcx
jne 0xc4e8
movq %rbp, %r12
jmp 0xc58b
cmpw $0x0, (%r12)
jne 0xc5af
movb %sil, 0x17(%rsp)
leaq 0x6f9e(%rip), %rsi      # 0x134b7
movl %edi, 0x20(%rsp)
movq %rbx, %rdi
movss %xmm0, 0x18(%rsp)
movl %r9d, %ebp
movl %r8d, 0x24(%rsp)
movq %r10, 0x28(%rsp)
movq %r11, 0x40(%rsp)
movq %rdx, 0x30(%rsp)
callq 0x21b0
movb 0x17(%rsp), %sil
movq 0x30(%rsp), %rdx
movl 0x20(%rsp), %edi
movq 0x40(%rsp), %r11
movq 0x28(%rsp), %r10
movl 0x24(%rsp), %r8d
movl %ebp, %r9d
movss 0x18(%rsp), %xmm0
testl %eax, %eax
je 0xc5af
movl 0x3c(%rsp), %eax
testl %eax, %eax
jle 0xc59e
movl %eax, %ecx
xorl %edx, %edx
xorl %eax, %eax
movsbl (%rbx,%rdx), %esi
subl %r15d, %eax
addl %esi, %eax
incq %rdx
cmpq %rdx, %rcx
jne 0xc57a
movq 0x30(%rsp), %rdx
movb 0x17(%rsp), %sil
jmp 0xc5a0
xorl %eax, %eax
movq %rbp, %r12
jmp 0xc5a0
xorl %eax, %eax
movl $0xffff, %ecx           # imm = 0xFFFF
cmpl %ecx, %eax
cmovll %eax, %ecx
movw %cx, (%r12)
movl %r13d, %ecx
notl %ecx
movb 0xc(%r14), %al
testb $0x3, %cl
jne 0xc6bd
movl %edi, %ebp
testb %al, %al
jne 0xc5e2
cmpb $0x1, 0xd(%r14)
jne 0xc5e2
movq 0x48(%rsp), %rax
incq (%rax)
btl $0x8, %r13d
movq 0x58(%rsp), %rdx
jae 0xc5e5
incq (%rdx)
movslq (%r10), %rax
testq %rax, %rax
setg %bl
jle 0xc6a6
movq (%r11), %rdi
movq %rax, %rcx
negq %rcx
movl $0x1, %edx
cmpb $0x1, 0xd(%rdi)
jne 0xc614
cmpb $0x0, 0xe(%rdi)
jne 0xc614
cmpq %r14, 0x20(%rdi)
je 0xc630
cmpq %rax, %rdx
setb %bl
addq $0x28, %rdi
leaq (%rcx,%rdx), %rsi
incq %rsi
incq %rdx
cmpq $0x1, %rsi
jne 0xc602
jmp 0xc6a6
movb 0xf(%rdi), %sil
testb $0x40, %r13b
jne 0xc647
testb %sil, %sil
je 0xc614
cmpl %r8d, 0x4(%rdi)
jne 0xc614
jmp 0xc651
testb %sil, %sil
jne 0xc614
cmpl %r8d, (%rdi)
jne 0xc614
btl $0x8, %r13d
setae %sil
xorb 0xc(%rdi), %sil
jne 0xc614
movzwl %r13w, %esi
movl %r8d, %edx
movl %r9d, %ecx
movss %xmm0, 0x18(%rsp)
movss 0x18(%rsp), %xmm0
movl %r9d, 0x1c(%rsp)
movl %r8d, %r15d
movq %r10, 0x28(%rsp)
movq %r11, %r12
callq 0xc258
movq %r12, %r11
movq 0x28(%rsp), %r10
movl %r15d, %r8d
movl 0x1c(%rsp), %r9d
movss 0x18(%rsp), %xmm0
testb $0x1, %bl
jne 0xc704
movl %ebp, (%rsp)
movzwl %r13w, %edx
movq %r11, %rdi
movq %r10, %rsi
movq %r14, %rcx
callq 0xc29e
jmp 0xc706
testb %al, %al
jne 0xc6dc
cmpb $0x1, 0xd(%r14)
jne 0xc6dc
movq 0x50(%rsp), %rax
incq (%rax)
btl $0x8, %r13d
movq 0x60(%rsp), %rdx
jae 0xc6df
incq (%rdx)
testb %sil, %sil
je 0xc704
movzwl %r13w, %edx
movq %r11, %rdi
movq %r10, %rsi
movq %r14, %rcx
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc30f
movb $0x1, %al
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2f4f
callq 0x2f67