// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: findDupsSn
void findDupsSn(Read** readSn, int readIdxSn,
    int readLenSn, uint64_t* countSn, uint64_t* dupsSn,
    uint64_t* singlePr, bool extendOpt, int extend,
    float asDiff, bool atacOpt, int atacLen5, int atacLen3,
    bool atacAdj, File bed, bool bedOpt, bool gzOut,
    bool ctrl, int sample, HashAln** table,
    uint32_t hashSize, File dups, bool dupsVerb,
    uint32_t* order, uint32_t* order0, uint32_t* order1,
    uint32_t* order2, uint16_t* qual, uint16_t* qual0,
    uint16_t* qual1, uint16_t* qual2, uint64_t* errCount,
    bool verbose) {

  // sort reads by qual score sum
  uint32_t count = readIdxSn * MAX_SIZE + readLenSn;
  sortReads(readSn, count, order, qual, order0, order1,
    order2, qual0, qual1, qual2);

  // loop through singleton reads
  for (uint32_t i = 0; i < count; i++) {
    Read* r = readSn[order[i] / MAX_SIZE]
      + order[i] % MAX_SIZE;

    // check hashtable for matches
    if (checkHashSn(r, table, hashSize, dups,
        dupsVerb, gzOut))
      (*dupsSn)++;
    else {
      // add alignments to hashtable
      addHashSn(r, table, hashSize, dupsVerb);
      // process alignments too
      *singlePr += processSingle(r->name, r->aln,
        r->alnLen, extendOpt, extend, false,
        NULL, NULL, NULL, NULL,
        r->score, asDiff, r->first,
        atacOpt, atacLen5, atacLen3, atacAdj,
        bed, bedOpt, gzOut, ctrl, sample, errCount,
        verbose);
    }

    // free Read
    free(r->name);
    free(r->aln);

    (*countSn)++;
  }

  // free nodes of hashtable
  for (uint32_t i = 0; i < hashSize; i++) {
    HashAln* tmp;
    HashAln* h = table[i];
    while (h != NULL) {
      free(h->name);
      tmp = h->next;
      free(h);
      h = tmp;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movss %xmm0, 0x1c(%rsp)
movq %r9, 0x20(%rsp)
movq %r8, 0x30(%rsp)
movq %rcx, 0x28(%rsp)
movq 0xe8(%rsp), %rax
movb 0xe0(%rsp), %r14b
movb 0xb0(%rsp), %r15b
imull $0xfff0, %esi, %ebp     # imm = 0xFFF0
addl %edx, %ebp
movb 0x80(%rsp), %r12b
movq 0x108(%rsp), %rcx
movq 0xf0(%rsp), %r8
movq 0xf8(%rsp), %r9
movq %rdi, %rbx
movl %ebp, %esi
movq %rax, %rdx
pushq 0x120(%rsp)
pushq 0x120(%rsp)
pushq 0x120(%rsp)
pushq 0x118(%rsp)
callq 0x9044
addq $0x20, %rsp
xorl %r13d, %r13d
movzbl %r14b, %r14d
movzbl %r15b, %r15d
movzbl 0x130(%rsp), %eax
movl %eax, 0x18(%rsp)
movzbl 0xb8(%rsp), %eax
movl %eax, 0x14(%rsp)
movzbl 0xa8(%rsp), %eax
movl %eax, 0x10(%rsp)
movzbl 0x98(%rsp), %eax
movl %eax, 0xc(%rsp)
movzbl %r12b, %eax
movl %eax, 0x8(%rsp)
movzbl 0x70(%rsp), %eax
movl %eax, 0x4(%rsp)
cmpq %r13, %rbp
je 0xa6b8
movq 0xe8(%rsp), %rax
movl (%rax,%r13,4), %eax
xorl %edx, %edx
movl $0xfff0, %ecx           # imm = 0xFFF0
divl %ecx
imulq $0x30, %rdx, %r12
addq (%rbx,%rax,8), %r12
movq %r12, %rdi
movq 0xc8(%rsp), %rsi
movl 0xd0(%rsp), %edx
movq 0xd8(%rsp), %rcx
movl %r14d, %r8d
movl %r15d, %r9d
callq 0xa342
movq 0x30(%rsp), %rdx
pushq $0x1
popq %rcx
testb %al, %al
jne 0xa692
movq %r12, %rdi
movq 0xc8(%rsp), %rsi
movl 0xd0(%rsp), %edx
movl %r14d, %ecx
callq 0xa289
movq (%r12), %rdi
movq 0x8(%r12), %rsi
movzbl 0x10(%r12), %edx
movss 0x28(%r12), %xmm0
movzbl 0x24(%r12), %eax
subq $0x80, %rsp
movl 0x98(%rsp), %ecx
movl %ecx, 0x78(%rsp)
movq 0x1a8(%rsp), %rcx
movq %rcx, 0x70(%rsp)
movl 0x140(%rsp), %ecx
movl %ecx, 0x68(%rsp)
movl 0x94(%rsp), %ecx
movl %ecx, 0x60(%rsp)
movl %r15d, 0x58(%rsp)
movl 0x90(%rsp), %ecx
movl %ecx, 0x50(%rsp)
movq 0x120(%rsp), %rcx
movq %rcx, 0x48(%rsp)
movl 0x8c(%rsp), %ecx
movl %ecx, 0x40(%rsp)
movl 0x110(%rsp), %ecx
movl %ecx, 0x38(%rsp)
movl 0x108(%rsp), %ecx
movl %ecx, 0x30(%rsp)
movl 0x88(%rsp), %ecx
movl %ecx, 0x28(%rsp)
movl %eax, 0x20(%rsp)
xorps %xmm1, %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm1, (%rsp)
movl 0x84(%rsp), %ecx
movl 0xf8(%rsp), %r8d
xorl %r9d, %r9d
movss 0x9c(%rsp), %xmm1
callq 0x83e9
addq $0x80, %rsp
movl %eax, %ecx
movq 0x20(%rsp), %rdx
addq %rcx, (%rdx)
movq (%r12), %rdi
callq 0x2040
movq 0x8(%r12), %rdi
callq 0x2040
movq 0x28(%rsp), %rax
incq (%rax)
incq %r13
jmp 0xa545
movl 0xd0(%rsp), %r15d
xorl %r12d, %r12d
cmpq %r15, %r12
je 0xa6f7
movq 0xc8(%rsp), %rax
movq (%rax,%r12,8), %r14
testq %r14, %r14
je 0xa6f2
movq (%r14), %rdi
callq 0x2040
movq 0x28(%r14), %r13
movq %r14, %rdi
callq 0x2040
movq %r13, %r14
jmp 0xa6d4
incq %r12
jmp 0xa6c3
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq