// File: /workspace/github_c_makefile_star2_O1/jsh58[P]Genrich/Genrich.c
// Function: findDups
void findDups(Read** readPr, int readIdxPr, int readLenPr,
    Read** readDc, int readIdxDc, int readLenDc,
    Read** readSn, int readIdxSn, int readLenSn,
    HashAln*** table, uint32_t* tableMem,
    HashAln*** tableSn, uint32_t* tableSnMem,
    uint32_t** order, uint32_t** order0, uint32_t** order1,
    uint32_t** order2, uint16_t** qual, uint16_t** qual0,
    uint16_t** qual1, uint16_t** qual2, uint32_t* arrMem,
    uint64_t* countPr, uint64_t* dupsPr, uint64_t* countDc,
    uint64_t* dupsDc, uint64_t* countSn, uint64_t* dupsSn,
    bool singleOpt, uint64_t* pairedPr, uint64_t* singlePr,
    double* totalLen, bool extendOpt, int extend,
    bool avgExtOpt, float asDiff, bool atacOpt,
    int atacLen5, int atacLen3, bool atacAdj, File bed,
    bool bedOpt, bool gzOut, File dups, bool dupsVerb,
    bool ctrl, int sample, uint64_t* errCount, bool verbose) {

  // initialize hash table for singletons
  uint32_t hashSizeSn = 0;
  if (singleOpt && (readIdxSn || readLenSn)) {
    // calculate hashtable size
    uint32_t sum = MIN(UINT32_MAX,
      2 * (readIdxPr * MAX_SIZE + readLenPr)
      + 2 * (readIdxDc * MAX_SIZE + readLenDc)
      + readIdxSn * MAX_SIZE + readLenSn);
    hashSizeSn = calcHashSize(sum);

    // create/expand hashtable
    if (hashSizeSn > *tableSnMem) {
      *tableSn = (HashAln**) memrealloc(*tableSn,
        hashSizeSn * sizeof(HashAln*));
      *tableSnMem = hashSizeSn;
    } else
      hashSizeSn = *tableSnMem;
    for (uint32_t i = 0; i < hashSizeSn; i++)
      (*tableSn)[i] = NULL;
  }

  // initialize arrays for efficient sorting
  uint32_t count = MIN(UINT32_MAX,
    MAX(readIdxPr * MAX_SIZE + readLenPr,
    MAX(readIdxDc * MAX_SIZE + readLenDc,
    readIdxSn * MAX_SIZE + readLenSn)));
  if (count > *arrMem) {
    *order = (uint32_t*) memrealloc(*order, count * sizeof(uint32_t));
    *order0 = (uint32_t*) memrealloc(*order0, count * sizeof(uint32_t));
    *order1 = (uint32_t*) memrealloc(*order1, count * sizeof(uint32_t));
    *order2 = (uint32_t*) memrealloc(*order2, count * sizeof(uint32_t));
    *qual = (uint16_t*) memrealloc(*qual, count * sizeof(uint16_t));
    *qual0 = (uint16_t*) memrealloc(*qual0, count * sizeof(uint16_t));
    *qual1 = (uint16_t*) memrealloc(*qual1, count * sizeof(uint16_t));
    *qual2 = (uint16_t*) memrealloc(*qual2, count * sizeof(uint16_t));
    *arrMem = count;
  }

  // evaluate and process paired alignments
  if (readIdxPr || readLenPr)
    findDupsPr(readPr, readIdxPr, readLenPr, countPr,
      dupsPr, pairedPr, totalLen, asDiff, atacOpt,
      atacLen5, atacLen3, atacAdj, bed, bedOpt, gzOut,
      ctrl, sample, table, tableMem, *tableSn, hashSizeSn,
      dups, dupsVerb, *order, *order0, *order1, *order2,
      *qual, *qual0, *qual1, *qual2, errCount, verbose);

  if (singleOpt) {
    // with avgExtOpt, calculate average fragment length
    //   and save it as 'extend' with extendOpt=true
    if (avgExtOpt) {
      extend = calcAvgLen(*totalLen, *pairedPr, verbose);
      if (extend)
        extendOpt = true;
    }

    // evaluate and process discordant alignments
    if (readIdxDc || readLenDc)
      findDupsDc(readDc, readIdxDc, readLenDc, countDc,
        dupsDc, singlePr, extendOpt, extend, asDiff,
        atacOpt, atacLen5, atacLen3, atacAdj, bed, bedOpt,
        gzOut, ctrl, sample, table, tableMem, *tableSn,
        hashSizeSn, dups, dupsVerb, *order, *order0,
        *order1, *order2, *qual, *qual0, *qual1, *qual2,
        errCount, verbose);

    // evaluate and process singleton alignments
    if (readIdxSn || readLenSn)
      findDupsSn(readSn, readIdxSn, readLenSn, countSn,
        dupsSn, singlePr, extendOpt, extend, asDiff,
        atacOpt, atacLen5, atacLen3, atacAdj, bed, bedOpt,
        gzOut, ctrl, sample, *tableSn, hashSizeSn, dups,
        dupsVerb, *order, *order0, *order1, *order2, *qual,
        *qual0, *qual1, *qual2, errCount, verbose);
  }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movss %xmm0, 0x14(%rsp)
movq %rcx, 0x40(%rsp)
movl %esi, %r11d
movq %rdi, 0x20(%rsp)
movb 0x130(%rsp), %r12b
movl %r12d, %eax
xorb $0x1, %al
movq 0xf8(%rsp), %rbx
movq 0xa8(%rsp), %r14
movl 0x90(%rsp), %esi
movl 0x88(%rsp), %r15d
movl %esi, %ecx
orl %r15d, %ecx
movl %ecx, 0x28(%rsp)
sete %cl
xorl %edi, %edi
orb %al, %cl
movq %r9, 0x8(%rsp)
movq %r8, (%rsp)
jne 0xbc70
movq 0xb0(%rsp), %rdi
leal (%r8,%r11), %eax
imull $0xfff0, %eax, %eax     # imm = 0xFFF0
addl %r9d, %eax
addl %edx, %eax
imull $0xfff0, %r15d, %ecx    # imm = 0xFFF0
leal (%rcx,%rax,2), %ecx
addl %esi, %ecx
shll $0x2, %ecx
movl $0x2, %ebp
cmpl $0x9, %ecx
jb 0xbbff
movl $0xaaaaaaab, %eax       # imm = 0xAAAAAAAB
imulq %rcx, %rax
shrq $0x21, %rax
movl $0x1, %ecx
addl %ebp, %ebp
cmpl $0x1d, %ecx
ja 0xbbff
incl %ecx
cmpl %eax, %ebp
jb 0xbbf2
movl (%rdi), %edi
cmpl %edi, %ebp
jbe 0xbc3f
movq (%r14), %rdi
movl %ebp, %esi
shlq $0x3, %rsi
movq %rdx, %r13
movq %r11, %rbx
callq 0x3915
movq %rbx, %r11
movq 0xf8(%rsp), %rbx
movq %r13, %rdx
movq (%rsp), %r8
movq 0x8(%rsp), %r9
movq %rax, (%r14)
movq 0xb0(%rsp), %rax
movl %ebp, (%rax)
movl %ebp, %edi
testl %edi, %edi
je 0xbc69
movq %rdx, %r10
movl %edi, %eax
xorl %ecx, %ecx
movl 0x90(%rsp), %esi
movq (%r14), %rdx
movq $0x0, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0xbc51
movq %r10, %rdx
jmp 0xbc70
movl 0x90(%rsp), %esi
movq %rdi, 0x30(%rsp)
imull $0xfff0, %r11d, %eax    # imm = 0xFFF0
addl %edx, %eax
imull $0xfff0, %r8d, %ecx     # imm = 0xFFF0
addl %r9d, %ecx
imull $0xfff0, %r15d, %r15d   # imm = 0xFFF0
addl %esi, %r15d
cmpl %r15d, %ecx
cmovgl %ecx, %r15d
movq 0xc8(%rsp), %r13
cmpl %r15d, %eax
cmovgl %eax, %r15d
cmpl (%rbx), %r15d
jbe 0xbda7
movq 0xb8(%rsp), %r12
movq (%r12), %rdi
movl %r15d, %ebp
leaq (,%rbp,4), %rbx
movq %rbx, %rsi
movq %rdx, 0x18(%rsp)
movq %r11, 0x38(%rsp)
callq 0x3915
movq %rax, (%r12)
movq 0xc0(%rsp), %r12
movq (%r12), %rdi
movq %rbx, %rsi
callq 0x3915
movq %rax, (%r12)
movq (%r13), %rdi
movq %rbx, %rsi
callq 0x3915
movq %rax, (%r13)
movq 0xd0(%rsp), %rax
movq %r13, %r12
movq %rax, %r13
movq (%rax), %rdi
movq %rbx, %rsi
callq 0x3915
movq %rax, (%r13)
movq %r12, %r13
movb 0x130(%rsp), %r12b
movq 0xd8(%rsp), %rbx
movq (%rbx), %rdi
addq %rbp, %rbp
movq %rbp, %rsi
callq 0x3915
movq %rax, (%rbx)
movq 0xe0(%rsp), %rbx
movq (%rbx), %rdi
movq %rbp, %rsi
callq 0x3915
movq %rax, (%rbx)
movq 0xe8(%rsp), %rbx
movq (%rbx), %rdi
movq %rbp, %rsi
callq 0x3915
movq %rax, (%rbx)
movq 0xf0(%rsp), %rbx
movq (%rbx), %rdi
movq %rbp, %rsi
callq 0x3915
movq 0x38(%rsp), %r11
movq 0x18(%rsp), %rdx
movq (%rsp), %r8
movq 0x8(%rsp), %r9
movq %rax, (%rbx)
movq 0xf8(%rsp), %rax
movl %r15d, (%rax)
movb 0x1c8(%rsp), %r10b
movb 0x1a8(%rsp), %sil
movb 0x190(%rsp), %dil
movl 0x178(%rsp), %r15d
movl 0x170(%rsp), %ebx
movq 0x148(%rsp), %rbp
movq 0x138(%rsp), %rcx
movl %edx, %eax
orl %r11d, %eax
je 0xbf27
movq 0x108(%rsp), %r8
movq 0x100(%rsp), %rcx
movq %r14, %rax
movzbl %r10b, %r14d
movzbl %sil, %ebp
movzbl 0x1b0(%rsp), %ebx
movzbl 0x198(%rsp), %r15d
movq %r11, %rsi
movzbl %dil, %r11d
movzbl 0x180(%rsp), %r10d
movzbl 0x168(%rsp), %edi
movq %rdi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
movq 0x138(%rsp), %r9
movss 0x14(%rsp), %xmm0
pushq %r14
movq %rax, %r14
pushq 0x1c8(%rsp)
movq 0x100(%rsp), %rax
pushq (%rax)
movq 0x100(%rsp), %rax
pushq (%rax)
movq 0x100(%rsp), %rax
pushq (%rax)
movq 0x100(%rsp), %rax
pushq (%rax)
movq 0x100(%rsp), %rax
pushq (%rax)
pushq (%r13)
movq 0x100(%rsp), %rax
pushq (%rax)
movq 0x100(%rsp), %rax
pushq (%rax)
pushq %rbp
movq 0x1a0(%rsp), %rbp
pushq 0x1f8(%rsp)
pushq 0x90(%rsp)
pushq (%r14)
pushq 0x110(%rsp)
pushq 0x110(%rsp)
movl 0x238(%rsp), %eax
pushq %rax
pushq %rbx
movl 0x200(%rsp), %ebx
pushq %r15
movl 0x210(%rsp), %r15d
pushq %r11
pushq 0x228(%rsp)
pushq %r10
pushq %r15
pushq %rbx
pushq 0xd8(%rsp)
pushq %rbp
callq 0xaac5
movq 0x208(%rsp), %rcx
movb 0x260(%rsp), %dil
movb 0x298(%rsp), %r10b
movq 0xd0(%rsp), %r8
movq 0xd8(%rsp), %r9
addq $0xd0, %rsp
testb %r12b, %r12b
je 0xc249
movq %rcx, %rax
movq %rbp, %rcx
movb 0x150(%rsp), %bpl
cmpb $0x0, 0x160(%rsp)
je 0xbf7e
movsd (%rcx), %xmm0
movq (%rax), %rdi
movzbl %r10b, %esi
movl %r10d, %r12d
callq 0x8ad7
movb 0x190(%rsp), %dil
movl %r12d, %r10d
movq (%rsp), %r8
movq 0x8(%rsp), %r9
movq %rax, 0x20(%rsp)
testl %eax, %eax
setne %al
orb %al, %bpl
jmp 0xbf8a
movl 0x158(%rsp), %eax
movq %rax, 0x20(%rsp)
movq 0x140(%rsp), %rcx
movl %r9d, %eax
orl %r8d, %eax
movzbl %bpl, %r12d
je 0xc0f8
movq %r8, %rsi
movq 0x118(%rsp), %r8
movq 0x110(%rsp), %rcx
subq $0x8, %rsp
movq %rbx, %rax
movq %r13, %rbx
movq %r14, %r13
movzbl %r10b, %r14d
movzbl 0x1b0(%rsp), %r11d
movzbl 0x1b8(%rsp), %ebp
movq %r15, %r10
movzbl 0x1a0(%rsp), %r15d
movzbl %dil, %edx
movq %rdx, 0x20(%rsp)
movzbl 0x188(%rsp), %edx
movq %rdx, 0x8(%rsp)
movzbl 0x170(%rsp), %edx
movq %rdx, 0x10(%rsp)
movq 0x48(%rsp), %rdi
movl %r9d, %edx
movq 0x148(%rsp), %r9
movss 0x1c(%rsp), %xmm0
pushq %r14
movq %r13, %r14
pushq 0x1d0(%rsp)
movq 0x108(%rsp), %r13
pushq (%r13)
movq 0x108(%rsp), %r13
pushq (%r13)
movq 0x108(%rsp), %r13
pushq (%r13)
movq 0x108(%rsp), %r13
pushq (%r13)
movq 0x108(%rsp), %r13
pushq (%r13)
movq %rbx, %r13
pushq (%rbx)
movq 0x108(%rsp), %rbx
pushq (%rbx)
movq 0x108(%rsp), %rbx
pushq (%rbx)
movq %rax, %rbx
pushq %r11
pushq 0x200(%rsp)
pushq 0x98(%rsp)
pushq (%r14)
pushq 0x118(%rsp)
pushq 0x118(%rsp)
movl 0x240(%rsp), %eax
pushq %rax
pushq %rbp
pushq %r15
pushq 0xb8(%rsp)
pushq 0x230(%rsp)
pushq 0xb0(%rsp)
pushq %r10
pushq %rbx
pushq 0xd0(%rsp)
pushq 0xf0(%rsp)
pushq %r12
callq 0xb21e
movq 0x220(%rsp), %rcx
movb 0x270(%rsp), %dil
movb 0x2a8(%rsp), %r10b
addq $0xe0, %rsp
cmpl $0x0, 0x28(%rsp)
movq 0x188(%rsp), %rax
movb 0x1b0(%rsp), %dl
movb 0x198(%rsp), %sil
movb 0x1a8(%rsp), %r11b
je 0xc249
movq %rcx, %rbp
movq 0x128(%rsp), %r8
movq 0x120(%rsp), %rcx
movl %esi, %r9d
movl %edi, %esi
movq 0x80(%rsp), %rdi
subq $0x8, %rsp
movq %r13, %rbx
movq %r14, %r13
movzbl %r10b, %r14d
movq %r12, 0x10(%rsp)
movzbl %r11b, %r12d
movzbl %dl, %r10d
movzbl %r9b, %r15d
movzbl %sil, %r11d
movzbl 0x188(%rsp), %edx
movq %rdx, 0x30(%rsp)
movzbl 0x170(%rsp), %edx
movq %rdx, 0x8(%rsp)
movl 0x90(%rsp), %esi
movl 0x98(%rsp), %edx
movq %rbp, %r9
movss 0x1c(%rsp), %xmm0
pushq %r14
pushq 0x1d0(%rsp)
movq 0x108(%rsp), %r14
pushq (%r14)
movq 0x108(%rsp), %r14
pushq (%r14)
movq 0x108(%rsp), %r14
pushq (%r14)
movq 0x108(%rsp), %r14
pushq (%r14)
movq 0x108(%rsp), %r14
pushq (%r14)
pushq (%rbx)
movq 0x108(%rsp), %rbx
pushq (%rbx)
movq 0x108(%rsp), %rbx
pushq (%rbx)
pushq %r12
pushq 0x200(%rsp)
pushq 0x98(%rsp)
pushq (%r13)
movl 0x230(%rsp), %ebx
pushq %rbx
pushq %r10
pushq %r15
pushq %r11
pushq %rax
pushq 0xc8(%rsp)
movl 0x220(%rsp), %eax
pushq %rax
movl 0x220(%rsp), %eax
pushq %rax
pushq 0xb8(%rsp)
pushq 0xe0(%rsp)
pushq 0xd0(%rsp)
callq 0xb894
addq $0x118, %rsp            # imm = 0x118
jmp 0xc24d
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq