// File: /workspace/github_cpp_makefile_star2_O1/readmapping[P]alfalfa/src/main.cpp
// Function: unpaired_thread(mapOptions_t const*)
void unpaired_thread(const mapOptions_t * opt) {
    long total_seq_cnt = 0;
    long seq_mapped = 0;
    long alignments_printed = 0;
#ifndef NDEBUG
    if (opt->alnOptions.debugFile != NULL)
        fprintf(opt->alnOptions.debugFile, "#ALN\n");
#endif
    //init fields
    vector<read_t> reads;
    int bpCount = opt->query_threads * BUFFER_SIZE;
    //read reads
    while(readBatch(bpCount, reads) > 0){// have reads
        //count reads, init fields
        int seq_cnt = reads.size();
        total_seq_cnt += seq_cnt;
        cerr << "Progress " << seq_cnt << " reads ..." << endl;
        clock_t start = clock();
        unpaired_data unpairedData(opt, sa, &reads);
        //parallel loop
        kt_for(opt->query_threads, seq_cnt, map_unpaired, &unpairedData);
        //output
        for(int i = 0; i < reads.size(); i++){
            if (reads[i].alignments.empty())
                fprintf(outfile, "%s", reads[i].emptyAlingment(false, false, true).c_str());
            else{
                seq_mapped++;
                alignments_printed += min(reads[i].alignmentCount(), opt->alnOptions.alignmentCount);
                for (int k = 0; k < min(reads[i].alignmentCount(), opt->alnOptions.alignmentCount); k++)
                    fprintf(outfile, "%s", reads[i].printUnpairedAlignment(k).c_str());
            }
        }
        reads.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
    reads.clear();
    //report statistics
    printf("sequences read: %ld\n", total_seq_cnt);
    printf("sequences mapped: %ld\n", seq_mapped);
    printf("alignments printed: %ld\n", alignments_printed);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %r12
xorpd %xmm0, %xmm0
movq %rsp, %rbx
movapd %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
imull $0x989680, 0x8(%rdi), %eax # imm = 0x989680
movl %eax, 0x34(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x4b392(%rip), %r14     # 0x53fe8
leaq 0x48(%rsp), %rbp
movq $0x0, 0x38(%rsp)
xorl %r13d, %r13d
movl 0x34(%rsp), %edi
movq %rbx, %rsi
callq 0x8b6c
testl %eax, %eax
jle 0x8f7f
movq 0x8(%rsp), %r15
subq (%rsp), %r15
movl $0x9, %edx
movq %r14, %rdi
leaq 0x373f1(%rip), %rsi     # 0x40084
callq 0x7340
movq %r15, %rsi
sarq $0x4, %rsi
movabsq $0x4ec4ec4ec4ec4ec5, %rax # imm = 0x4EC4EC4EC4EC4EC5
imulq %rax, %rsi
movq %r14, %rdi
movq %rsi, 0x28(%rsp)
callq 0x75d0
movq %rax, %r15
movl $0xa, %edx
movq %rax, %rdi
leaq 0x373c2(%rip), %rsi     # 0x4008e
callq 0x7340
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
callq 0x71b0
movq %rax, 0x20(%rsp)
movq 0x4b6ff(%rip), %rax     # 0x54408
movq %r12, 0x70(%rsp)
movq %rax, 0x78(%rsp)
movq %rbx, 0x80(%rsp)
movl 0x8(%r12), %edi
movq 0x28(%rsp), %rsi
leaq 0x2eb(%rip), %rdx       # 0x9017
leaq 0x70(%rsp), %rcx
callq 0x3f998
movq %r13, 0x68(%rsp)
movq (%rsp), %r15
movq 0x8(%rsp), %r14
cmpq %r15, %r14
je 0x8ea1
xorl %r13d, %r13d
imulq $0xd0, %r13, %r14
leaq (%r15,%r14), %rsi
movq 0xb0(%r15,%r14), %rax
cmpq 0xb8(%r15,%r14), %rax
je 0x8e32
incq 0x38(%rsp)
movq 0xb8(%rsi), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movl 0x150(%r12), %eax
cmpl %ecx, %eax
cmovll %eax, %ecx
movslq %ecx, %rcx
addq %rcx, 0x40(%rsp)
movq (%rsp), %rsi
movq 0xb8(%rsi,%r14), %rcx
subq 0xb0(%rsi,%r14), %rcx
shrq $0x3, %rcx
cmpl %ecx, %eax
cmovll %eax, %ecx
testl %ecx, %ecx
jle 0x8e74
addq %r14, %rsi
xorl %r15d, %r15d
movq 0x4b645(%rip), %rbx     # 0x54410
movq %rbp, %rdi
movl %r15d, %edx
callq 0xb31a
movq 0x48(%rsp), %rdi
movq %rbx, %rsi
callq 0x7330
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x8dff
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x72f0
movq (%rsp), %rsi
movq 0xb8(%rsi,%r14), %rax
subq 0xb0(%rsi,%r14), %rax
shrq $0x3, %rax
movl 0x150(%r12), %ecx
cmpl %eax, %ecx
jl 0x8e25
movl %eax, %ecx
incl %r15d
addq %r14, %rsi
cmpl %ecx, %r15d
jl 0x8dc4
jmp 0x8e74
movq 0x4b5d7(%rip), %r15     # 0x54410
movq %rbp, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0xb1cc
movq 0x48(%rsp), %rdi
movq %r15, %rsi
callq 0x7330
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x8e74
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x72f0
incq %r13
movq (%rsp), %r15
movq 0x8(%rsp), %r14
movq %r14, %rax
subq %r15, %rax
sarq $0x4, %rax
movabsq $0x4ec4ec4ec4ec4ec5, %rcx # imm = 0x4EC4EC4EC4EC4EC5
imulq %rcx, %rax
cmpq %r13, %rax
ja 0x8d50
cmpq %r15, %r14
movq 0x68(%rsp), %r13
je 0x8ec7
movq %r15, %rbx
movq %rbx, %rdi
callq 0xb024
addq $0xd0, %rbx
cmpq %r14, %rbx
jne 0x8eae
movq %r15, 0x8(%rsp)
callq 0x71b0
subq 0x20(%rsp), %rax
cvtsi2sd %rax, %xmm0
divsd 0x3712a(%rip), %xmm0    # 0x40008
movsd %xmm0, 0x20(%rsp)
movl $0x9, %edx
movq 0x4b0f8(%rip), %r14     # 0x53fe8
movq %r14, %rdi
leaq 0x3718a(%rip), %rsi     # 0x40084
callq 0x7340
movq %r14, %rdi
movq 0x28(%rsp), %rsi
callq 0x75d0
movq %rax, %r15
movl $0x10, %edx
movq %rax, %rdi
leaq 0x3717b(%rip), %rsi     # 0x40099
callq 0x7340
movq %r15, %rdi
movsd 0x20(%rsp), %xmm0
callq 0x7560
movq %rax, %r15
movl $0x8, %edx
movq %rax, %rdi
leaq 0x37167(%rip), %rsi     # 0x400aa
callq 0x7340
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movslq 0x28(%rsp), %rax
addq %rax, %r13
movq %rsp, %rbx
jmp 0x8c67
movq (%rsp), %r14
movq 0x8(%rsp), %r15
cmpq %r14, %r15
je 0x8fa9
movq %r14, %rbx
movq %rbx, %rdi
callq 0xb024
addq $0xd0, %rbx
cmpq %r15, %rbx
jne 0x8f90
movq %r14, 0x8(%rsp)
leaq 0x37103(%rip), %rdi     # 0x400b3
movq %r13, %rsi
xorl %eax, %eax
callq 0x7060
leaq 0x37107(%rip), %rdi     # 0x400c8
movq 0x38(%rsp), %rsi
xorl %eax, %eax
callq 0x7060
leaq 0x3710b(%rip), %rdi     # 0x400df
movq 0x40(%rsp), %rsi
xorl %eax, %eax
callq 0x7060
movq %rsp, %rdi
callq 0xb5ea
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9004
jmp 0x9004
jmp 0x9004
jmp 0x9004
jmp 0x9004
movq %rax, %rbx
movq %rsp, %rdi
callq 0xb5ea
movq %rbx, %rdi
callq 0x7600