// File: 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:
subq $0x158, %rsp            # imm = 0x158
movq %rdi, 0x150(%rsp)
movq $0x0, 0x148(%rsp)
movq $0x0, 0x140(%rsp)
movq $0x0, 0x138(%rsp)
leaq 0x120(%rsp), %rdi
callq 0xbdf0
movq 0x150(%rsp), %rax
imull $0x989680, 0x8(%rax), %eax # imm = 0x989680
movl %eax, 0x11c(%rsp)
movl 0x11c(%rsp), %edi
leaq 0x120(%rsp), %rsi
callq 0x8d20
movl %eax, 0x7c(%rsp)
jmp 0x8eb0
movl 0x7c(%rsp), %eax
cmpl $0x0, %eax
jle 0x9306
leaq 0x120(%rsp), %rdi
callq 0xbdd0
movl %eax, 0x108(%rsp)
movslq 0x108(%rsp), %rcx
movq 0x148(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x148(%rsp)
movq 0x8e0fd(%rip), %rdi     # 0x96ff0
leaq 0x7015a(%rip), %rsi     # 0x79054
callq 0x8360
movq %rax, 0x70(%rsp)
jmp 0x8f06
movq 0x70(%rsp), %rdi
movl 0x108(%rsp), %esi
callq 0x8710
movq %rax, 0x68(%rsp)
jmp 0x8f1e
movq 0x68(%rsp), %rdi
leaq 0x70134(%rip), %rsi     # 0x7905e
callq 0x8360
movq %rax, 0x60(%rsp)
jmp 0x8f36
movq 0x60(%rsp), %rdi
movq 0x8e06e(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x8f49
callq 0x8230
movq %rax, 0x100(%rsp)
movq 0x150(%rsp), %rsi
movq 0x8e573(%rip), %rdx     # 0x974d8
leaq 0xe8(%rsp), %rdi
leaq 0x120(%rsp), %rcx
callq 0xbe00
jmp 0x8f7c
movq 0x150(%rsp), %rax
movl 0x8(%rax), %edi
movl 0x108(%rsp), %esi
leaq 0x3eb(%rip), %rdx       # 0x9380
leaq 0xe8(%rsp), %rcx
callq 0x780a0
jmp 0x8fa4
movl $0x0, 0xe4(%rsp)
movslq 0xe4(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0x120(%rsp), %rdi
callq 0xbdd0
movq %rax, %rcx
movq 0x58(%rsp), %rax
cmpq %rcx, %rax
jae 0x922d
movslq 0xe4(%rsp), %rsi
leaq 0x120(%rsp), %rdi
callq 0xbe40
movq %rax, %rdi
addq $0xb0, %rdi
callq 0xbe60
testb $0x1, %al
jne 0x9007
jmp 0x909f
movq 0x8e4d2(%rip), %rax     # 0x974e0
movq %rax, 0x50(%rsp)
movslq 0xe4(%rsp), %rsi
leaq 0x120(%rsp), %rdi
callq 0xbe40
movq %rax, %rsi
leaq 0xc0(%rsp), %rdi
xorl %ecx, %ecx
movl $0x1, %r8d
movl %ecx, %edx
callq 0xbeb0
jmp 0x9044
leaq 0xc0(%rsp), %rdi
callq 0x8170
movq 0x50(%rsp), %rdi
movq %rax, %rdx
leaq 0x70009(%rip), %rsi     # 0x79069
movb $0x0, %al
callq 0x85c0
leaq 0xc0(%rsp), %rdi
callq 0x8858
jmp 0x9215
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x110(%rsp)
movl %eax, 0x10c(%rsp)
leaq 0x120(%rsp), %rdi
callq 0xc5a0
jmp 0x9370
movq 0x140(%rsp), %rax
incq %rax
movq %rax, 0x140(%rsp)
movslq 0xe4(%rsp), %rsi
leaq 0x120(%rsp), %rdi
callq 0xbe40
movq %rax, %rdi
callq 0xc0c0
movl %eax, 0x4c(%rsp)
jmp 0x90d5
movl 0x4c(%rsp), %eax
movl %eax, 0xbc(%rsp)
movq 0x150(%rsp), %rsi
addq $0x150, %rsi            # imm = 0x150
leaq 0xbc(%rsp), %rdi
callq 0xc080
movq %rax, 0x40(%rsp)
jmp 0x9103
movq 0x40(%rsp), %rax
movslq (%rax), %rax
addq 0x138(%rsp), %rax
movq %rax, 0x138(%rsp)
movl $0x0, 0xb8(%rsp)
movl 0xb8(%rsp), %eax
movl %eax, 0x38(%rsp)
movslq 0xe4(%rsp), %rsi
leaq 0x120(%rsp), %rdi
callq 0xbe40
movq %rax, %rdi
callq 0xc0c0
movl %eax, 0x3c(%rsp)
jmp 0x9154
movl 0x3c(%rsp), %eax
movl %eax, 0xb4(%rsp)
movq 0x150(%rsp), %rsi
addq $0x150, %rsi            # imm = 0x150
leaq 0xb4(%rsp), %rdi
callq 0xc080
movq %rax, 0x30(%rsp)
jmp 0x9182
movl 0x38(%rsp), %eax
movq 0x30(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x9213
movq 0x8e346(%rip), %rax     # 0x974e0
movq %rax, 0x28(%rsp)
movslq 0xe4(%rsp), %rsi
leaq 0x120(%rsp), %rdi
callq 0xbe40
movq %rax, %rsi
movl 0xb8(%rsp), %edx
leaq 0x90(%rsp), %rdi
callq 0xc0e0
jmp 0x91cd
leaq 0x90(%rsp), %rdi
callq 0x8170
movq 0x28(%rsp), %rdi
movq %rax, %rdx
leaq 0x6fe80(%rip), %rsi     # 0x79069
movb $0x0, %al
callq 0x85c0
leaq 0x90(%rsp), %rdi
callq 0x8858
movl 0xb8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xb8(%rsp)
jmp 0x9126
jmp 0x9215
jmp 0x9217
movl 0xe4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xe4(%rsp)
jmp 0x8faf
leaq 0x120(%rsp), %rdi
callq 0xc580
callq 0x8230
movq %rax, 0x88(%rsp)
movq 0x88(%rsp), %rax
movq 0x100(%rsp), %rcx
subq %rcx, %rax
cvtsi2sd %rax, %xmm0
movsd 0x6fda1(%rip), %xmm1    # 0x79008
divsd %xmm1, %xmm0
movsd %xmm0, 0x80(%rsp)
movq 0x8dd75(%rip), %rdi     # 0x96ff0
leaq 0x6fdd2(%rip), %rsi     # 0x79054
callq 0x8360
movq %rax, 0x20(%rsp)
jmp 0x928e
movq 0x20(%rsp), %rdi
movl 0x108(%rsp), %esi
callq 0x8710
movq %rax, 0x18(%rsp)
jmp 0x92a6
movq 0x18(%rsp), %rdi
leaq 0x6fdba(%rip), %rsi     # 0x7906c
callq 0x8360
movq %rax, 0x10(%rsp)
jmp 0x92be
movq 0x10(%rsp), %rdi
movsd 0x80(%rsp), %xmm0
callq 0x87e0
movq %rax, 0x8(%rsp)
jmp 0x92d8
movq 0x8(%rsp), %rdi
leaq 0x6fd99(%rip), %rsi     # 0x7907d
callq 0x8360
movq %rax, (%rsp)
jmp 0x92ef
movq (%rsp), %rdi
movq 0x8dcb6(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x9301
jmp 0x8e96
leaq 0x120(%rsp), %rdi
callq 0xc580
movq 0x148(%rsp), %rsi
leaq 0x6fd64(%rip), %rdi     # 0x79086
xorl %eax, %eax
callq 0x8070
jmp 0x932b
movq 0x140(%rsp), %rsi
leaq 0x6fd61(%rip), %rdi     # 0x7909b
xorl %eax, %eax
callq 0x8070
jmp 0x9343
movq 0x138(%rsp), %rsi
leaq 0x6fd60(%rip), %rdi     # 0x790b2
xorl %eax, %eax
callq 0x8070
jmp 0x935b
leaq 0x120(%rsp), %rdi
callq 0xc5a0
addq $0x158, %rsp            # imm = 0x158
retq
movq 0x110(%rsp), %rdi
callq 0x8730
nopl (%rax)