// File: /workspace/github_c_makefile_star2_O1/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, 0xc(%rsp)
movq %r9, 0x38(%rsp)
movq %r8, 0x50(%rsp)
movq %rcx, 0x48(%rsp)
movq %rdi, 0x10(%rsp)
movq 0xe8(%rsp), %rbx
imull $0xfff0, %esi, %r13d    # imm = 0xFFF0
addl %edx, %r13d
leal (,%r13,4), %ecx
movl $0x2, %r14d
cmpl $0x9, %ecx
jb 0xab33
movl $0xaaaaaaab, %eax       # imm = 0xAAAAAAAB
imulq %rcx, %rax
shrq $0x21, %rax
movl $0x1, %ecx
addl %r14d, %r14d
cmpl $0x1d, %ecx
ja 0xab33
incl %ecx
cmpl %eax, %r14d
jb 0xab24
movq 0xe0(%rsp), %r15
movl (%rbx), %ebp
cmpl %ebp, %r14d
jbe 0xab5a
movq (%r15), %rdi
movl %r14d, %esi
shlq $0x3, %rsi
callq 0x3915
movq %rax, (%r15)
movl %r14d, (%rbx)
movl %r14d, %ebp
movq 0x148(%rsp), %rbx
movq 0x140(%rsp), %r11
movq 0x138(%rsp), %r10
movq 0x130(%rsp), %rcx
movq 0x128(%rsp), %rax
movq 0x120(%rsp), %r9
movq 0x118(%rsp), %r8
movl %ebp, %r12d
testl %ebp, %ebp
je 0xabae
xorl %edx, %edx
movq (%r15), %rsi
movq $0x0, (%rsi,%rdx,8)
incq %rdx
cmpq %rdx, %r12
jne 0xab9b
movq 0x10(%rsp), %rdi
movl %r13d, %esi
movq 0x110(%rsp), %rdx
pushq %rbx
pushq %r11
pushq %r10
pushq %rax
callq 0xa3f0
addq $0x20, %rsp
testl %r13d, %r13d
je 0xad5e
movl %r13d, %eax
movq %rax, 0x40(%rsp)
xorl %r14d, %r14d
movzbl 0x108(%rsp), %r13d
movzbl 0xc8(%rsp), %ebx
movzbl 0x158(%rsp), %eax
movq %rax, 0x30(%rsp)
movzbl 0xd0(%rsp), %eax
movq %rax, 0x28(%rsp)
movzbl 0xc0(%rsp), %eax
movq %rax, 0x20(%rsp)
movzbl 0xb0(%rsp), %eax
movq %rax, 0x18(%rsp)
movzbl 0x98(%rsp), %eax
movl %eax, 0x8(%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 0x10(%rsp), %rax
addq (%rax,%rcx,8), %r15
movq 0xe0(%rsp), %rax
movq (%rax), %rsi
movq %r15, %rdi
movl %ebp, %edx
movq 0x100(%rsp), %rcx
movl %r13d, %r8d
movl %ebx, %r9d
callq 0xa9bb
movl $0x1, %ecx
movq 0x50(%rsp), %rdx
testb %al, %al
jne 0xad34
movq 0xe0(%rsp), %rax
movq (%rax), %rsi
movq %r15, %rdi
movl %ebp, %edx
movl %r13d, %ecx
movq 0xf0(%rsp), %r8
movl 0xf8(%rsp), %r9d
callq 0xa871
movq (%r15), %rdi
movq 0x8(%r15), %rsi
movzbl 0x10(%r15), %edx
movss 0x28(%r15), %xmm0
subq $0x8, %rsp
movq 0x98(%rsp), %rcx
movss 0x14(%rsp), %xmm1
movl 0x10(%rsp), %r8d
movl 0xa8(%rsp), %r9d
pushq 0x38(%rsp)
pushq 0x160(%rsp)
movl 0xf0(%rsp), %eax
pushq %rax
pushq 0x48(%rsp)
pushq %rbx
pushq 0x50(%rsp)
pushq 0xf0(%rsp)
pushq 0x58(%rsp)
movl 0xf0(%rsp), %eax
pushq %rax
callq 0x9b16
addq $0x50, %rsp
movl %eax, %ecx
movq 0x38(%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, 0x40(%rsp)
jne 0xac32
testl %ebp, %ebp
movq 0xe0(%rsp), %r13
je 0xad9e
xorl %r14d, %r14d
movq (%r13), %rax
movq (%rax,%r14,8), %rbx
testq %rbx, %rbx
je 0xad96
movq (%rbx), %rdi
callq 0x2040
movq 0x28(%rbx), %r15
movq %rbx, %rdi
callq 0x2040
movq %r15, %rbx
testq %r15, %r15
jne 0xad7a
incq %r14
cmpq %r12, %r14
jne 0xad6d
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq