// File: /workspace/github_c_makefile_star2_O3/jsh58[P]Genrich/Genrich.c
// Function: findDupsPr
void findDupsPr(Read** readPr, int readIdxPr,
    int readLenPr, uint64_t* countPr, uint64_t* dupsPr,
    uint64_t* pairedPr, double* totalLen, float asDiff,
    bool atacOpt, int atacLen5, int atacLen3, bool atacAdj,
    File bed, bool bedOpt, bool gzOut, bool ctrl,
    int sample, HashAln*** table, uint32_t* tableMem,
    HashAln** tableSn, uint32_t hashSizeSn, 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) {

  // initialize hashtable
  uint32_t count = readIdxPr * MAX_SIZE + readLenPr;
  uint32_t hashSize = calcHashSize(count);
  if (hashSize > *tableMem) {
    *table = (HashAln**) memrealloc(*table,
      hashSize * sizeof(HashAln*));
    *tableMem = hashSize;
  } else
    hashSize = *tableMem;
  for (uint32_t i = 0; i < hashSize; i++)
    (*table)[i] = NULL;

  // get sort order of reads by qual score sum
  sortReads(readPr, count, order, qual, order0, order1,
    order2, qual0, qual1, qual2);

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

    // check hashtable for matches
    if (checkHashPr(r, *table, hashSize, dups,
        dupsVerb, gzOut))
      (*dupsPr)++;
    else {
      // add alignments to hashtable(s)
      addHashPr(r, *table, hashSize, dupsVerb,
        tableSn, hashSizeSn);
      // process alignments too
      *pairedPr += processPair(r->name, r->aln,
        r->alnLen, totalLen, r->score, asDiff,
        atacOpt, atacLen5, atacLen3, atacAdj,
        bed, bedOpt, gzOut, ctrl, sample, errCount,
        verbose);
    }

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

    (*countPr)++;
  }

  // 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 $0x58, %rsp
movss %xmm0, 0x14(%rsp)
movq %r9, 0x40(%rsp)
movq %r8, 0x50(%rsp)
movq %rcx, 0x48(%rsp)
movq %rdi, 0x18(%rsp)
movq 0xe8(%rsp), %rdi
imull $0xfff0, %esi, %r13d    # imm = 0xFFF0
addl %edx, %r13d
leal (,%r13,4), %ecx
movl $0x2, %ebp
cmpl $0x9, %ecx
jb 0xacf0
movl $0xaaaaaaab, %eax       # imm = 0xAAAAAAAB
imulq %rcx, %rax
shrq $0x21, %rax
movl $0x1, %ecx
addl %ebp, %ebp
cmpl $0x1d, %ecx
ja 0xacf0
incl %ecx
cmpl %eax, %ebp
jb 0xace3
movq 0x148(%rsp), %r14
movq 0x140(%rsp), %r15
movq 0x138(%rsp), %r11
movq 0x130(%rsp), %rcx
movq 0x128(%rsp), %r10
movq 0x120(%rsp), %r9
movq 0x118(%rsp), %r8
movq 0xe0(%rsp), %rbx
movl (%rdi), %r12d
cmpl %r12d, %ebp
jbe 0xad8a
movq (%rbx), %rdi
movl %ebp, %esi
shlq $0x3, %rsi
movq %r10, %r12
movq %r11, %r15
movq %r9, %r14
callq 0x3925
movq 0x118(%rsp), %r8
movq 0x130(%rsp), %rcx
movq %r14, %r9
movq %r15, %r11
movq 0x140(%rsp), %r15
movq 0x148(%rsp), %r14
movq %r12, %r10
movq %rax, (%rbx)
movq 0xe8(%rsp), %rax
movl %ebp, (%rax)
movl %ebp, %r12d
jmp 0xad93
testl %r12d, %r12d
je 0xafbd
movl %r12d, %eax
xorl %edi, %edi
movq 0xe0(%rsp), %rsi
movq (%rsi), %rdx
movq $0x0, (%rdx,%rdi,8)
incq %rdi
cmpq %rdi, %rax
jne 0xada0
movl $0x0, 0xc(%rsp)
movq 0x18(%rsp), %rdi
movl %r13d, %esi
movq 0x110(%rsp), %rdx
pushq %r14
pushq %r15
pushq %r11
pushq %r10
callq 0xa572
addq $0x20, %rsp
testl %r13d, %r13d
je 0xaf68
movl %r13d, %ebp
xorl %r14d, %r14d
movzbl 0x108(%rsp), %r13d
movzbl 0xc8(%rsp), %ebx
movzbl 0x158(%rsp), %eax
movq %rax, 0x38(%rsp)
movzbl 0xd0(%rsp), %eax
movq %rax, 0x30(%rsp)
movzbl 0xc0(%rsp), %eax
movq %rax, 0x28(%rsp)
movzbl 0xb0(%rsp), %eax
movq %rax, 0x20(%rsp)
movzbl 0x98(%rsp), %eax
movl %eax, 0x10(%rsp)
movq 0x110(%rsp), %rax
movl (%rax,%r14,4), %eax
movl %eax, %ecx
shrl $0x4, %ecx
imulq $0x10010011, %rcx, %rcx # imm = 0x10010011
shrq $0x28, %rcx
imull $0xfff0, %ecx, %edx     # imm = 0xFFF0
subl %edx, %eax
leaq (%rax,%rax,2), %r15
shlq $0x4, %r15
movq 0x18(%rsp), %rax
addq (%rax,%rcx,8), %r15
movq 0xe0(%rsp), %rax
movq (%rax), %rsi
movq %r15, %rdi
movl %r12d, %edx
movq 0x100(%rsp), %rcx
movl %r13d, %r8d
movl %ebx, %r9d
callq 0xab7f
movl $0x1, %ecx
movq 0x50(%rsp), %rdx
testb %al, %al
jne 0xaf40
movq 0xe0(%rsp), %rax
movq (%rax), %rsi
movq %r15, %rdi
movl %r12d, %edx
movl %r13d, %ecx
movq 0xf0(%rsp), %r8
movl 0xf8(%rsp), %r9d
callq 0xa9fb
movq (%r15), %rdi
movq 0x8(%r15), %rsi
movzbl 0x10(%r15), %edx
movss 0x28(%r15), %xmm0
subq $0x8, %rsp
movq 0x98(%rsp), %rcx
movss 0x1c(%rsp), %xmm1
movl 0x18(%rsp), %r8d
movl 0xa8(%rsp), %r9d
pushq 0x40(%rsp)
pushq 0x160(%rsp)
movl 0xf0(%rsp), %eax
pushq %rax
pushq 0x50(%rsp)
pushq %rbx
pushq 0x58(%rsp)
pushq 0xf0(%rsp)
pushq 0x60(%rsp)
movl 0xf0(%rsp), %eax
pushq %rax
callq 0x9c6a
addq $0x50, %rsp
movl %eax, %ecx
movq 0x40(%rsp), %rdx
addq %rcx, (%rdx)
movq (%r15), %rdi
callq 0x2040
movq 0x8(%r15), %rdi
callq 0x2040
movq 0x48(%rsp), %rax
incq (%rax)
incq %r14
cmpq %r14, %rbp
jne 0xae3c
cmpb $0x0, 0xc(%rsp)
movq 0xe0(%rsp), %r13
jne 0xafae
movl %r12d, %r14d
xorl %r15d, %r15d
movq (%r13), %rax
movq (%rax,%r15,8), %rbx
testq %rbx, %rbx
je 0xafa6
movq (%rbx), %rdi
callq 0x2040
movq 0x28(%rbx), %r12
movq %rbx, %rdi
callq 0x2040
movq %r12, %rbx
testq %r12, %r12
jne 0xaf8a
incq %r15
cmpq %r14, %r15
jne 0xaf7d
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r12d, %r12d
movb $0x1, %al
movl %eax, 0xc(%rsp)
jmp 0xadbb