// File: /workspace/github_cpp_makefile_star2_O2/readmapping[P]alfalfa/src/main.cpp
// Function: paired_thread1(mapOptions_t const*)
void paired_thread1(const mapOptions_t * opt) {
    long total_seq_cnt = 0;
    long seq_mapped1 = 0;
    long alignments_printed1 = 0;
    long seq_mapped2 = 0;
    long alignments_printed2 = 0;
#ifndef NDEBUG
    if (opt->alnOptions.debugFile != NULL)
        fprintf(opt->alnOptions.debugFile, "#ALN\n");
#endif
    //init fields
    vector<read_t> mates1;
    vector<read_t> mates2;
    int bpCount = opt->query_threads * BUFFER_SIZE;
    //read reads
    while (readBatchPaired(bpCount, mates1, mates2) > 0) {
        //count reads, init fields
        int seq_cnt = mates1.size();
        total_seq_cnt += seq_cnt;
        cerr << "Progress " << seq_cnt << " reads ..." << endl;
        clock_t start = clock();
        paired_data pairedData(opt, sa, &mates1, &mates2);
        //parallel loop
        kt_for(opt->query_threads, seq_cnt, map_paired, &pairedData);
        //output
        for(int i = 0; i < mates1.size(); i++){
            if (mates1[i].alignments.empty())
                fprintf(outfile, "%s", mates1[i].emptyAlingment(true, mates2[i].alignments.empty(), true).c_str());
            else{
                seq_mapped1++;
                int mate1AlnCount;
                if (opt->pairedOpt.mixed)
                    mate1AlnCount = min(mates1[i].alignmentCount(), opt->alnOptions.alignmentCount);
                else
                    mate1AlnCount = min(mates1[i].pairedAlignmentCount, opt->alnOptions.alignmentCount);
                alignments_printed1 += mate1AlnCount;
                for (int k = 0; k < mate1AlnCount; k++)
                    fprintf(outfile, "%s", mates1[i].printPairedAlignments(k, true).c_str());
            }
            if (mates2[i].alignments.empty())
                fprintf(outfile, "%s", mates2[i].emptyAlingment(true, mates1[i].alignments.empty(), false).c_str());
            else {
                seq_mapped2++;
                int mate2AlnCount;
                if (opt->pairedOpt.mixed)
                    mate2AlnCount = min(mates2[i].alignmentCount(), opt->alnOptions.alignmentCount);
                else
                    mate2AlnCount = min(mates2[i].pairedAlignmentCount, opt->alnOptions.alignmentCount);
                alignments_printed2 += mate2AlnCount;
                for (int k = 0; k < mate2AlnCount; k++)
                    fprintf(outfile, "%s", mates2[i].printPairedAlignments(k, false).c_str());
            }
        }
        mates1.clear(); mates2.clear();
        clock_t end = clock();
        double cpu_time = (double) (end - start) / CLOCKS_PER_SEC;
        cerr << "Progress " << seq_cnt << " reads: done in " << cpu_time << " seconds" << endl;
    }
    //clean up
    mates1.clear();
    mates2.clear();
    //report statistics
    printf("sequences read: %ld\n", total_seq_cnt);
    printf("sequences mapped (mate1): %ld\n", seq_mapped1);
    printf("sequences mapped (mate2): %ld\n", seq_mapped2);
    printf("alignments printed (mate1): %ld\n", alignments_printed1);
    printf("alignments printed (mate2): %ld\n", alignments_printed2);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdi, %r15
xorpd %xmm0, %xmm0
movq %rsp, %rax
andq $0x0, 0x10(%rax)
leaq 0x30(%rsp), %rcx
andq $0x0, 0x10(%rcx)
movapd %xmm0, (%rax)
movapd %xmm0, (%rcx)
imull $0x989680, 0x8(%rdi), %eax # imm = 0x989680
movl %eax, 0x2c(%rsp)
movq $0x0, 0x58(%rsp)
leaq 0x88(%rsp), %r13
pushq $0x1
popq %rbx
movq $0x0, 0x50(%rsp)
movq $0x0, 0x68(%rsp)
movq $0x0, 0x60(%rsp)
movq $0x0, 0x48(%rsp)
movq %rdi, 0x70(%rsp)
movl 0x2c(%rsp), %edi
movq %rsp, %rsi
leaq 0x30(%rsp), %rdx
callq 0x7e00
testl %eax, %eax
jle 0x82f1
movq 0x8(%rsp), %rax
subq (%rsp), %rax
cqto
movl $0xd0, %ecx
idivq %rcx
movq %rax, %r14
movq 0x42020(%rip), %rdi     # 0x49fe8
leaq 0x2a0b5(%rip), %rsi     # 0x32084
callq 0x72b0
movq %rax, %rdi
movl %r14d, %esi
callq 0x75c0
movq %rax, %rdi
leaq 0x2a0a5(%rip), %rsi     # 0x3208e
callq 0x72b0
movq %rax, %rdi
callq 0x7160
callq 0x71c0
movq %rax, 0x78(%rsp)
movq 0x423f9(%rip), %rax     # 0x4a400
movq %r15, 0xa8(%rsp)
movq %rax, 0xb0(%rsp)
movq %rsp, %rax
movq %rax, 0xb8(%rsp)
leaq 0x30(%rsp), %rax
movq %rax, 0xc0(%rsp)
movl 0x8(%r15), %edi
movl %r14d, %esi
leaq 0x378(%rip), %rdx       # 0x83b5
leaq 0xa8(%rsp), %rcx
callq 0x3190c
movslq %r14d, %rax
addq %rax, 0x48(%rsp)
xorl %edi, %edi
movq %r14, 0x80(%rsp)
movq (%rsp), %rcx
movq 0x8(%rsp), %rax
subq %rcx, %rax
cqto
movl $0xd0, %esi
idivq %rsi
cmpq %rdi, %rax
jbe 0x826b
movq %rdi, 0x20(%rsp)
imulq $0xd0, %rdi, %r12
leaq (%rcx,%r12), %rsi
movq 0xb0(%rcx,%r12), %rdx
movq 0xb8(%rcx,%r12), %rax
cmpq %rax, %rdx
je 0x80ba
cmpb $0x1, 0x1a0(%r15)
jne 0x8102
subq %rdx, %rax
shrq $0x3, %rax
movl 0x150(%r15), %ecx
jmp 0x810f
movq 0x42347(%rip), %r14     # 0x4a408
movq 0x30(%rsp), %rax
movq 0xb0(%rax,%r12), %rdx
xorl %ecx, %ecx
cmpq 0xb8(%rax,%r12), %rdx
sete %cl
movq %r13, %rdi
movl %ebx, %edx
movl %ebx, %r8d
callq 0x93e4
movq 0x88(%rsp), %rdi
movq %r14, %rsi
callq 0x7320
movq %r13, %rdi
callq 0x76a8
jmp 0x816c
movl 0x150(%r15), %ecx
movl 0xc8(%rsi), %eax
cmpl %eax, %ecx
cmovll %ecx, %eax
incq 0x60(%rsp)
movslq %eax, %rbp
addq %rbp, 0x68(%rsp)
xorl %r14d, %r14d
testl %ebp, %ebp
cmovlel %r14d, %ebp
cmpl %r14d, %ebp
je 0x8167
movq 0x422d2(%rip), %r15     # 0x4a408
movq (%rsp), %rsi
addq %r12, %rsi
movq %r13, %rdi
movl %r14d, %edx
movl %ebx, %ecx
callq 0x970a
movq 0x88(%rsp), %rdi
movq %r15, %rsi
callq 0x7320
movq %r13, %rdi
callq 0x76a8
incl %r14d
jmp 0x812a
movq 0x70(%rsp), %r15
movq 0x30(%rsp), %rax
leaq (%rax,%r12), %rsi
movq 0xb0(%rax,%r12), %rcx
movq 0xb8(%rax,%r12), %rax
cmpq %rax, %rcx
je 0x81a4
cmpb $0x1, 0x1a0(%r15)
jne 0x81eb
subq %rcx, %rax
shrq $0x3, %rax
movl 0x150(%r15), %ecx
jmp 0x81f8
movq 0x4225d(%rip), %r14     # 0x4a408
movq (%rsp), %rax
movq 0xb0(%rax,%r12), %rdx
xorl %ecx, %ecx
cmpq 0xb8(%rax,%r12), %rdx
sete %cl
movq %r13, %rdi
movl %ebx, %edx
xorl %r8d, %r8d
callq 0x93e4
movq 0x88(%rsp), %rdi
movq %r14, %rsi
callq 0x7320
movq %r13, %rdi
callq 0x76a8
jmp 0x8256
movl 0x150(%r15), %ecx
movl 0xc8(%rsi), %eax
cmpl %eax, %ecx
cmovll %ecx, %eax
incq 0x50(%rsp)
movslq %eax, %rbp
addq %rbp, 0x58(%rsp)
xorl %r14d, %r14d
testl %ebp, %ebp
cmovlel %r14d, %ebp
cmpl %r14d, %ebp
je 0x8251
movq 0x421e9(%rip), %r15     # 0x4a408
movq 0x30(%rsp), %rsi
addq %r12, %rsi
movq %r13, %rdi
movl %r14d, %edx
xorl %ecx, %ecx
callq 0x970a
movq 0x88(%rsp), %rdi
movq %r15, %rsi
callq 0x7320
movq %r13, %rdi
callq 0x76a8
incl %r14d
jmp 0x8213
movq 0x70(%rsp), %r15
movq 0x20(%rsp), %rdi
incq %rdi
movq 0x80(%rsp), %r14
jmp 0x805c
movq %rsp, %rdi
callq 0x96e0
leaq 0x30(%rsp), %rdi
callq 0x96e0
callq 0x71c0
subq 0x78(%rsp), %rax
cvtsi2sd %rax, %xmm0
divsd 0x29d74(%rip), %xmm0    # 0x32008
movsd %xmm0, 0x20(%rsp)
movq 0x41d47(%rip), %rdi     # 0x49fe8
leaq 0x29ddc(%rip), %rsi     # 0x32084
callq 0x72b0
movq %rax, %rdi
movl %r14d, %esi
callq 0x75c0
movq %rax, %rdi
leaq 0x29dd7(%rip), %rsi     # 0x32099
callq 0x72b0
movq %rax, %rdi
movsd 0x20(%rsp), %xmm0
callq 0x7560
movq %rax, %rdi
leaq 0x29dcb(%rip), %rsi     # 0x320aa
callq 0x72b0
movq %rax, %rdi
callq 0x7160
jmp 0x7f92
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x96e0
leaq 0x30(%rsp), %r12
movq %r12, %rdi
callq 0x96e0
leaq 0x29da3(%rip), %rdi     # 0x320b3
movq 0x48(%rsp), %rsi
xorl %eax, %eax
callq 0x7050
leaq 0x29dd5(%rip), %rdi     # 0x320f8
movq 0x60(%rsp), %rsi
xorl %eax, %eax
callq 0x7050
leaq 0x29de1(%rip), %rdi     # 0x32117
movq 0x50(%rsp), %rsi
xorl %eax, %eax
callq 0x7050
leaq 0x29ded(%rip), %rdi     # 0x32136
movq 0x68(%rsp), %rsi
xorl %eax, %eax
callq 0x7050
leaq 0x29dfb(%rip), %rdi     # 0x32157
movq 0x58(%rsp), %rsi
xorl %eax, %eax
callq 0x7050
movq %r12, %rdi
callq 0x96e8
movq %rbx, %rdi
callq 0x96e8
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8398
jmp 0x8398
jmp 0x8398
jmp 0x8398
jmp 0x8398
jmp 0x8398
jmp 0x8398
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x96e8
movq %rsp, %rdi
callq 0x96e8
movq %rbx, %rdi
callq 0x75e0