// File: /workspace/github_c_makefile_star2_O3/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, 0x24(%rsp)
movq %rcx, 0x40(%rsp)
movl %edx, %r10d
movl %esi, %r12d
movq 0xf8(%rsp), %r11
movq 0xa8(%rsp), %r14
movl 0x90(%rsp), %esi
movl 0x88(%rsp), %edx
movl %esi, %eax
orl %edx, %eax
movl %eax, 0x3c(%rsp)
setne %al
testb %al, 0x130(%rsp)
movq %r9, 0x10(%rsp)
movq %r8, 0x8(%rsp)
je 0xbea4
movq 0xb0(%rsp), %rbx
leal (%r8,%r12), %eax
imull $0xfff0, %eax, %eax     # imm = 0xFFF0
addl %r9d, %eax
addl %r10d, %eax
imull $0xfff0, %edx, %r15d    # imm = 0xFFF0
leal (%r15,%rax,2), %ecx
addl %esi, %ecx
shll $0x2, %ecx
movl $0x2, %ebp
cmpl $0x9, %ecx
jb 0xbe5a
movl $0xaaaaaaab, %eax       # imm = 0xAAAAAAAB
imulq %rcx, %rax
shrq $0x21, %rax
movl $0x1, %ecx
addl %ebp, %ebp
cmpl $0x1d, %ecx
ja 0xbe5a
incl %ecx
cmpl %eax, %ebp
jb 0xbe4d
movl (%rbx), %eax
cmpl %eax, %ebp
jbe 0xbeb6
movq %rdi, %r13
movq (%r14), %rdi
movl %ebp, %esi
shlq $0x3, %rsi
movq %r10, %rbx
callq 0x3925
movq 0xf8(%rsp), %r11
movq %r13, %rdi
movq %rbx, %r10
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %r9
movq %rax, (%r14)
movq 0xb0(%rsp), %rax
movl %ebp, (%rax)
movl %ebp, %eax
movl 0x90(%rsp), %esi
jmp 0xbec1
imull $0xfff0, %edx, %r15d    # imm = 0xFFF0
movq $0x0, 0x28(%rsp)
jmp 0xbedd
testl %eax, %eax
movl 0x90(%rsp), %esi
je 0xbeab
movq %rax, 0x28(%rsp)
movl %eax, %eax
xorl %ecx, %ecx
movq (%r14), %rdx
movq $0x0, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0xbeca
imull $0xfff0, %r12d, %eax    # imm = 0xFFF0
addl %r10d, %eax
imull $0xfff0, %r8d, %ecx     # imm = 0xFFF0
addl %r9d, %ecx
addl %esi, %r15d
cmpl %r15d, %ecx
cmovgl %ecx, %r15d
cmpl %r15d, %eax
cmovgl %eax, %r15d
cmpl (%r11), %r15d
jbe 0xc002
movq 0xb8(%rsp), %r13
movq %rdi, 0x30(%rsp)
movq (%r13), %rdi
movl %r15d, %ebx
leaq (,%rbx,4), %rbp
movq %rbp, %rsi
movq %r10, 0x18(%rsp)
callq 0x3925
movq %rax, (%r13)
movq 0xc0(%rsp), %r13
movq (%r13), %rdi
movq %rbp, %rsi
callq 0x3925
movq %rax, (%r13)
movq 0xc8(%rsp), %r13
movq (%r13), %rdi
movq %rbp, %rsi
callq 0x3925
movq %rax, (%r13)
movq 0xd0(%rsp), %r13
movq (%r13), %rdi
movq %rbp, %rsi
callq 0x3925
movq %rax, (%r13)
movq 0xd8(%rsp), %r13
movq (%r13), %rdi
addq %rbx, %rbx
movq %rbx, %rsi
callq 0x3925
movq %rax, (%r13)
movq 0xe0(%rsp), %r13
movq (%r13), %rdi
movq %rbx, %rsi
callq 0x3925
movq %rax, (%r13)
movq 0xe8(%rsp), %r13
movq (%r13), %rdi
movq %rbx, %rsi
callq 0x3925
movq %rax, (%r13)
movq 0xf0(%rsp), %r13
movq (%r13), %rdi
movq %rbx, %rsi
callq 0x3925
movq 0x30(%rsp), %rdi
movq 0x18(%rsp), %r10
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %r9
movq %rax, (%r13)
movq 0xf8(%rsp), %rax
movl %r15d, (%rax)
movb 0x1c8(%rsp), %dl
movb 0x1b0(%rsp), %r11b
movb 0x1a8(%rsp), %r13b
movl 0x178(%rsp), %ebp
movl 0x170(%rsp), %r15d
movq 0x148(%rsp), %rbx
movq 0x138(%rsp), %rcx
movl %r10d, %eax
orl %r12d, %eax
je 0xc180
movq 0x108(%rsp), %r8
movq 0x100(%rsp), %rcx
movzbl %dl, %eax
movzbl %r13b, %ebx
movzbl %r11b, %r15d
movzbl 0x198(%rsp), %ebp
movzbl 0x190(%rsp), %r11d
movq %r10, %rdx
movzbl 0x180(%rsp), %r10d
movzbl 0x168(%rsp), %r9d
movq %r9, 0x18(%rsp)
movl %r12d, %esi
movq 0x138(%rsp), %r9
movss 0x24(%rsp), %xmm0
pushq %rax
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)
movq 0x100(%rsp), %rax
pushq (%rax)
movq 0x100(%rsp), %rax
pushq (%rax)
movq 0x100(%rsp), %rax
pushq (%rax)
pushq %rbx
movq 0x1e0(%rsp), %rbx
pushq 0x1f8(%rsp)
pushq 0x88(%rsp)
pushq (%r14)
pushq 0x110(%rsp)
pushq 0x110(%rsp)
movl 0x238(%rsp), %eax
pushq %rax
pushq %r15
movl 0x200(%rsp), %r15d
pushq %rbp
movl 0x210(%rsp), %ebp
pushq %r11
pushq %rbx
movq 0x1f0(%rsp), %rbx
pushq %r10
pushq %rbp
pushq %r15
pushq 0xd8(%rsp)
pushq %rbx
callq 0xac85
movq 0x208(%rsp), %rcx
movb 0x280(%rsp), %r11b
movb 0x298(%rsp), %dl
movq 0xd8(%rsp), %r8
movq 0xe0(%rsp), %r9
addq $0xd0, %rsp
cmpb $0x0, 0x130(%rsp)
je 0xc478
movq %rcx, %rax
movq %rbx, %rcx
movb 0x150(%rsp), %bl
cmpb $0x0, 0x160(%rsp)
je 0xc1e0
movsd (%rcx), %xmm0
movq (%rax), %rdi
movzbl %dl, %esi
movl %edx, %r12d
movl %r11d, %r13d
callq 0x8bb4
movl %r13d, %r11d
movb 0x1a8(%rsp), %r13b
movl %r12d, %edx
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %r9
movq %rax, 0x18(%rsp)
testl %eax, %eax
setne %al
orb %al, %bl
jmp 0xc1ec
movl 0x158(%rsp), %eax
movq %rax, 0x18(%rsp)
movq 0x140(%rsp), %r10
movl %r9d, %eax
orl %r8d, %eax
movzbl %bl, %ebx
je 0xc346
movq %r8, %rsi
movq 0x118(%rsp), %r8
movq 0x110(%rsp), %rcx
subq $0x8, %rsp
movq %rbx, %r10
movzbl %dl, %ebx
movzbl %r13b, %r12d
movq %rbp, %rax
movzbl %r11b, %ebp
movq %r15, %r11
movzbl 0x1a0(%rsp), %r15d
movzbl 0x198(%rsp), %edx
movq %rdx, 0x38(%rsp)
movzbl 0x188(%rsp), %edx
movq %rdx, 0x10(%rsp)
movzbl 0x170(%rsp), %edx
movq %rdx, 0x18(%rsp)
movq 0x48(%rsp), %rdi
movl %r9d, %edx
movq 0x148(%rsp), %r9
movss 0x2c(%rsp), %xmm0
pushq %rbx
pushq 0x1d0(%rsp)
movq 0x108(%rsp), %rbx
pushq (%rbx)
movq 0x108(%rsp), %rbx
pushq (%rbx)
movq 0x108(%rsp), %rbx
pushq (%rbx)
movq 0x108(%rsp), %rbx
pushq (%rbx)
movq 0x108(%rsp), %rbx
pushq (%rbx)
movq 0x108(%rsp), %rbx
pushq (%rbx)
movq 0x108(%rsp), %rbx
pushq (%rbx)
movq 0x108(%rsp), %rbx
pushq (%rbx)
pushq %r12
pushq 0x200(%rsp)
pushq 0x90(%rsp)
pushq (%r14)
pushq 0x118(%rsp)
pushq 0x118(%rsp)
movl 0x240(%rsp), %ebx
pushq %rbx
movq %r10, %rbx
pushq %rbp
pushq %r15
pushq 0xd0(%rsp)
pushq 0x230(%rsp)
pushq 0xb8(%rsp)
pushq %rax
pushq %r11
pushq 0xd8(%rsp)
pushq 0xe8(%rsp)
pushq %r10
callq 0xb432
movq 0x220(%rsp), %r10
movb 0x290(%rsp), %r11b
movb 0x2a8(%rsp), %dl
addq $0xe0, %rsp
cmpl $0x0, 0x3c(%rsp)
movq 0x188(%rsp), %r12
movb 0x190(%rsp), %sil
movb 0x198(%rsp), %r9b
je 0xc478
movq 0x128(%rsp), %r8
movq 0x120(%rsp), %rcx
movq 0x80(%rsp), %rdi
subq $0x8, %rsp
movq %rbx, 0x18(%rsp)
movzbl %dl, %ebx
movzbl %r13b, %eax
movzbl %r11b, %ebp
movzbl %r9b, %r15d
movzbl %sil, %r11d
movzbl 0x188(%rsp), %r13d
movzbl 0x170(%rsp), %edx
movq %rdx, 0x10(%rsp)
movl 0x90(%rsp), %esi
movl 0x98(%rsp), %edx
movq %r10, %r9
movss 0x2c(%rsp), %xmm0
pushq %rbx
pushq 0x1d0(%rsp)
movq 0x108(%rsp), %rbx
pushq (%rbx)
movq 0x108(%rsp), %rbx
pushq (%rbx)
movq 0x108(%rsp), %rbx
pushq (%rbx)
movq 0x108(%rsp), %rbx
pushq (%rbx)
movq 0x108(%rsp), %rbx
pushq (%rbx)
movq 0x108(%rsp), %rbx
pushq (%rbx)
movq 0x108(%rsp), %rbx
pushq (%rbx)
movq 0x108(%rsp), %rbx
pushq (%rbx)
pushq %rax
pushq 0x200(%rsp)
pushq 0x90(%rsp)
pushq (%r14)
movl 0x230(%rsp), %ebx
pushq %rbx
pushq %rbp
pushq %r15
pushq %r11
pushq %r12
pushq %r13
movl 0x220(%rsp), %eax
pushq %rax
movl 0x220(%rsp), %eax
pushq %rax
pushq 0xc0(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
callq 0xbafa
addq $0x118, %rsp            # imm = 0x118
jmp 0xc47c
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq