// File: /workspace/github_c_makefile_star2_O3/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 $0x48, %rsp
movss %xmm0, 0x24(%rsp)
movq %r9, 0x28(%rsp)
movq %r8, 0x40(%rsp)
movq %rcx, 0x38(%rsp)
movl %edx, %r14d
movq 0xf8(%rsp), %rdx
movq 0x118(%rsp), %rcx
movq 0x100(%rsp), %r8
movq 0x108(%rsp), %r9
imull $0xfff0, %esi, %r15d    # imm = 0xFFF0
leal (%r15,%r14), %esi
movq %rdi, 0x30(%rsp)
pushq 0x130(%rsp)
pushq 0x130(%rsp)
pushq 0x130(%rsp)
pushq 0x128(%rsp)
callq 0xa572
addq $0x20, %rsp
movl 0xe0(%rsp), %edx
addl %r14d, %r15d
je 0xbd5c
movl %r15d, %r12d
xorl %r13d, %r13d
movzbl 0xf0(%rsp), %ebp
movzbl 0xc0(%rsp), %r14d
movzbl 0x140(%rsp), %eax
movl %eax, 0x20(%rsp)
movzbl 0xc8(%rsp), %eax
movl %eax, 0x1c(%rsp)
movzbl 0xb8(%rsp), %eax
movl %eax, 0x18(%rsp)
movzbl 0xa8(%rsp), %eax
movl %eax, 0x14(%rsp)
movzbl 0x90(%rsp), %eax
movl %eax, 0x10(%rsp)
movzbl 0x80(%rsp), %eax
movl %eax, 0xc(%rsp)
movq 0xf8(%rsp), %rax
movl (%rax,%r13,4), %eax
movl %eax, %ecx
shrl $0x4, %ecx
imulq $0x10010011, %rcx, %rcx # imm = 0x10010011
shrq $0x28, %rcx
imull $0xfff0, %ecx, %esi     # imm = 0xFFF0
subl %esi, %eax
leaq (%rax,%rax,2), %r15
shlq $0x4, %r15
movq 0x30(%rsp), %rax
addq (%rax,%rcx,8), %r15
movq %r15, %rdi
movq 0xd8(%rsp), %rsi
movl %edx, %ebx
movq 0xe8(%rsp), %rcx
movl %ebp, %r8d
movl %r14d, %r9d
callq 0xb9eb
movl $0x1, %ecx
movq 0x40(%rsp), %rdx
testb %al, %al
jne 0xbd32
movq %r15, %rdi
movq 0xd8(%rsp), %rsi
movl %ebx, %edx
movl %ebp, %ecx
callq 0xb927
movq (%r15), %rdi
movq 0x8(%r15), %rsi
movzbl 0x10(%r15), %edx
movss 0x28(%r15), %xmm0
movzbl 0x24(%r15), %eax
subq $0x80, %rsp
movl 0xa0(%rsp), %ecx
movl %ecx, 0x78(%rsp)
movq 0x1b8(%rsp), %rcx
movq %rcx, 0x70(%rsp)
movl 0x150(%rsp), %ecx
movl %ecx, 0x68(%rsp)
movl 0x9c(%rsp), %ecx
movl %ecx, 0x60(%rsp)
movl %r14d, 0x58(%rsp)
movl 0x98(%rsp), %ecx
movl %ecx, 0x50(%rsp)
movq 0x130(%rsp), %rcx
movq %rcx, 0x48(%rsp)
movl 0x94(%rsp), %ecx
movl %ecx, 0x40(%rsp)
movl 0x120(%rsp), %ecx
movl %ecx, 0x38(%rsp)
movl 0x118(%rsp), %ecx
movl %ecx, 0x30(%rsp)
movl 0x90(%rsp), %ecx
movl %ecx, 0x28(%rsp)
movl %eax, 0x20(%rsp)
xorps %xmm1, %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm1, (%rsp)
movl 0x8c(%rsp), %ecx
movl 0x108(%rsp), %r8d
xorl %r9d, %r9d
movss 0xa4(%rsp), %xmm1
callq 0x98a6
addq $0x80, %rsp
movl %eax, %ecx
movq 0x28(%rsp), %rdx
addq %rcx, (%rdx)
movq (%r15), %rdi
callq 0x2040
movq 0x8(%r15), %rdi
callq 0x2040
movq 0x38(%rsp), %rax
incq (%rax)
incq %r13
cmpq %r13, %r12
movl %ebx, %edx
jne 0xbbe4
testl %edx, %edx
je 0xbd9b
movl %edx, %r15d
xorl %r12d, %r12d
movq 0xd8(%rsp), %rax
movq (%rax,%r12,8), %r14
testq %r14, %r14
je 0xbd93
movq (%r14), %rdi
callq 0x2040
movq 0x28(%r14), %r13
movq %r14, %rdi
callq 0x2040
movq %r13, %r14
testq %r13, %r13
jne 0xbd77
incq %r12
cmpq %r15, %r12
jne 0xbd66
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq