// File: /workspace/github_c_makefile_star2_O2/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, 0x48(%rsp)
movq %rcx, 0x40(%rsp)
movq %rdi, 0x10(%rsp)
movq 0xe8(%rsp), %r14
movq 0xe0(%rsp), %r15
imull $0xfff0, %esi, %ebx     # imm = 0xFFF0
addl %edx, %ebx
movl %ebx, %edi
callq 0x90db
movl (%r14), %r13d
cmpl %r13d, %eax
jbe 0x979e
movl %eax, %ebp
movq (%r15), %rdi
movl %eax, %r13d
leaq (,%r13,8), %rsi
callq 0x2776
movq %r15, %r12
movq %rax, (%r15)
movl %ebp, (%r14)
movl %ebp, %eax
movq %rax, (%rsp)
jmp 0x97a5
movq %r15, %r12
movq %r13, (%rsp)
movq 0x148(%rsp), %r15
movq 0x140(%rsp), %r11
movq 0x138(%rsp), %r10
movq 0x130(%rsp), %rcx
movq 0x128(%rsp), %rax
movq 0x120(%rsp), %r9
movq 0x118(%rsp), %r8
movb 0xc8(%rsp), %bpl
movb 0x98(%rsp), %r14b
xorl %edx, %edx
cmpq %rdx, %r13
je 0x9802
movq (%r12), %rsi
andq $0x0, (%rsi,%rdx,8)
incq %rdx
jmp 0x97ef
movq 0x10(%rsp), %rdi
movl %ebx, %esi
movq 0x110(%rsp), %rdx
pushq %r15
pushq %r11
pushq %r10
pushq %rax
callq 0x9044
addq $0x20, %rsp
movl %ebx, %eax
movq %rax, 0x50(%rsp)
xorl %r15d, %r15d
movzbl 0x108(%rsp), %ebx
movzbl %bpl, %ebp
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 %r14b, %eax
movl %eax, 0x8(%rsp)
cmpq %r15, 0x50(%rsp)
je 0x9984
movq 0x110(%rsp), %rax
movl (%rax,%r15,4), %eax
xorl %edx, %edx
movl $0xfff0, %ecx           # imm = 0xFFF0
divl %ecx
imulq $0x30, %rdx, %r14
movq 0x10(%rsp), %rcx
addq (%rcx,%rax,8), %r14
movq (%r12), %rsi
movq %r14, %rdi
movq (%rsp), %rdx
movq 0x100(%rsp), %rcx
movl %ebx, %r8d
movl %ebp, %r9d
callq 0x9616
movq 0x48(%rsp), %rdx
pushq $0x1
popq %rcx
testb %al, %al
jne 0x9960
movq (%r12), %rsi
movq %r14, %rdi
movq (%rsp), %rdx
movl %ebx, %ecx
movq 0xf0(%rsp), %r8
movl 0xf8(%rsp), %r9d
callq 0x94da
movq (%r14), %rdi
movq 0x8(%r14), %rsi
movzbl 0x10(%r14), %edx
movss 0x28(%r14), %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 %rbp
pushq 0x50(%rsp)
pushq 0xf0(%rsp)
pushq 0x58(%rsp)
movl 0xf0(%rsp), %eax
pushq %rax
callq 0x8793
addq $0x50, %rsp
movl %eax, %ecx
movq 0x38(%rsp), %rdx
addq %rcx, (%rdx)
movq (%r14), %rdi
callq 0x2040
movq 0x8(%r14), %rdi
callq 0x2040
movq 0x40(%rsp), %rax
incq (%rax)
incq %r15
jmp 0x9873
xorl %r14d, %r14d
cmpq %r13, %r14
je 0x99b7
movq (%r12), %rax
movq (%rax,%r14,8), %rbx
testq %rbx, %rbx
je 0x99b2
movq (%rbx), %rdi
callq 0x2040
movq 0x28(%rbx), %r15
movq %rbx, %rdi
callq 0x2040
movq %r15, %rbx
jmp 0x9994
incq %r14
jmp 0x9987
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq