// File: /workspace/github_c_makefile_star2_O1/lh3[P]pre-pe/pre-meta.c
// Function: worker_pipeline
static void *worker_pipeline(void *shared, int step, void *_data)
{
	int i;
	lt_global_t *g = (lt_global_t*)shared;
	if (step == 0) {
		data_for_t *ret;
		ret = calloc(1, sizeof(data_for_t));
		ret->seqs = bseq_read(g->ks, g->opt.chunk_size, &ret->n_seqs);
		assert((ret->n_seqs&1) == 0);
		ret->g = g;
		if (ret->seqs) return ret;
		else free(ret);
	} else if (step == 1) {
		data_for_t *data = (data_for_t*)_data;
		kt_for(g->opt.n_threads, worker_for, data, data->n_seqs>>1);
		return data;
	} else if (step == 2) {
		data_for_t *data = (data_for_t*)_data;
		if (g->opt.tab_out) { // tabular output
			for (i = 0; i < data->n_seqs; i += 2) {
				bseq1_t *s = &data->seqs[i];
				bseq1_t *s_r = &data->seqs[i+1];        
				printf("%s\t%d\t%d\t%d\t%zd\t%zd\n", s->name, s->type, s->olig_pos_f, s->olig_pos_r, strlen(s->seq),strlen(s_r->seq));
			}
		} else { // FASTQ output (FASTA not supported yet)
			for (i = 0; i < data->n_seqs; ++i) {
				bseq1_t *s = &data->seqs[i];
				if (s->l_seq > 0 && (s->type == LT_NO_MERGE || s->type == LT_MERGE_AMBIGUOUS || s->type == LT_MERGE_PARTIAL || s->type == LT_MERGE_COMPLETE || (s->type == LT_SHORT_PE && ~i&1)) ) {
					putchar(s->qual? '@' : '>'); fputs(s->name, stdout);
					if (s->type == LT_NO_MERGE || s->type == LT_MERGE_AMBIGUOUS) {
						putchar('/'); putchar("12"[i&1]);
					}
					printf(" YT:i:%d", s->type);
					if (s->bc_cat) { fputs("\tBC:Z:", stdout); fputs(s->bc_cat, stdout); }
					else fputs("\tBC:Z:*", stdout);
					printf("\tPF:i:%d", s->olig_pos_f);
					printf("\tPR:i:%d", s->olig_pos_r);
					if (s->bc_f) { fputs("\tBF:Z:", stdout); fputs(s->bc_f[0] == 0? "*" : s->bc_f, stdout); }
					if (s->bc_r) { fputs("\tBR:Z:", stdout); fputs(s->bc_r[0] == 0? "*" :s->bc_r, stdout); }
					putchar('\n');
					puts(s->seq);
					if (s->qual) { puts("+"); puts(s->qual); }
				}
			}
		}
		for (i = 0; i < data->n_seqs; ++i) { // deallocate
			bseq1_t *s = &data->seqs[i];
			free(s->bc_cat); free(s->bc_f); free(s->bc_r); free(s->seq); free(s->qual); free(s->name);
		}
		free(data->seqs); free(data);
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbx
movq %rdi, %r14
cmpl $0x2, %esi
je 0x456a
cmpl $0x1, %esi
je 0x454c
testl %esi, %esi
jne 0x4838
movl $0x1, %edi
movl $0x18, %esi
callq 0x2120
movq %rax, %rbx
movq 0x38(%r14), %rdi
movl 0x4(%r14), %esi
movq %rax, %rdx
callq 0x2cee
movq %rax, 0x8(%rbx)
testb $0x1, (%rbx)
jne 0x484c
movq %r14, 0x10(%rbx)
testq %rax, %rax
jne 0x483a
movq %rbx, %rdi
jmp 0x4833
movl (%r14), %edi
movl (%rbx), %eax
sarl %eax
movslq %eax, %rcx
leaq 0x532(%rip), %rsi       # 0x4a8f
movq %rbx, %rdx
callq 0x245c
jmp 0x483a
cmpl $0x0, 0x28(%r14)
movq %rbx, 0x10(%rsp)
movl (%rbx), %eax
je 0x4603
testl %eax, %eax
movq 0x10(%rsp), %r12
jle 0x47c7
movl $0x4, %ebx
xorl %ebp, %ebp
movq 0x8(%r12), %r15
movq 0xc(%r15,%rbx), %rax
movq %rax, 0x20(%rsp)
movl (%r15,%rbx), %eax
movl %eax, 0x1c(%rsp)
movl 0x4(%r15,%rbx), %eax
movl %eax, 0x18(%rsp)
movl 0x8(%r15,%rbx), %r13d
movq 0x14(%r15,%rbx), %rdi
callq 0x20c0
movq %rax, %r14
movq 0x54(%r15,%rbx), %rdi
callq 0x20c0
movq %rax, (%rsp)
leaq 0xcb2(%rip), %rdi       # 0x5289
movq 0x20(%rsp), %rsi
movl 0x1c(%rsp), %edx
movl 0x18(%rsp), %ecx
movl %r13d, %r8d
movq %r14, %r9
xorl %eax, %eax
callq 0x20d0
subq $-0x80, %rbx
addl $0x2, %ebp
cmpl %ebp, (%r12)
jg 0x4590
jmp 0x47c7
testl %eax, %eax
movq 0x10(%rsp), %r12
jle 0x47c7
movl $0x38, %ebp
movq 0x29a4(%rip), %r14      # 0x6fc0
leaq 0xc94(%rip), %rbx       # 0x52b7
xorl %r13d, %r13d
movq 0x8(%r12), %r15
testl $0x7fffffff, -0x38(%r15,%rbp) # imm = 0x7FFFFFFF
je 0x479a
movl -0x34(%r15,%rbp), %eax
cmpq $0x20, %rax
ja 0x479a
movabsq $0x180600000, %rcx      # imm = 0x180600000
btq %rax, %rcx
jae 0x47b5
xorl %eax, %eax
cmpq $0x0, -0x18(%r15,%rbp)
setne %al
leal 0x3e(,%rax,2), %edi
callq 0x2060
movq -0x28(%r15,%rbp), %rdi
movq (%r14), %rsi
callq 0x2100
movl -0x34(%r15,%rbp), %eax
addl $-0x1f, %eax
cmpl $0x1, %eax
ja 0x46ae
movl $0x2f, %edi
callq 0x2060
movl %r13d, %eax
andl $0x1, %eax
leaq 0xbf9(%rip), %rcx       # 0x529e
movsbl (%rax,%rcx), %edi
callq 0x2060
movl -0x34(%r15,%rbp), %esi
leaq 0xbe7(%rip), %rdi       # 0x52a1
xorl %eax, %eax
callq 0x20d0
cmpq $0x0, (%r15,%rbp)
movq (%r14), %rsi
je 0x46e0
leaq 0xbd8(%rip), %rdi       # 0x52aa
callq 0x2100
movq (%r15,%rbp), %rdi
movq (%r14), %rsi
jmp 0x46e7
leaq 0xbca(%rip), %rdi       # 0x52b1
callq 0x2100
movl -0x30(%r15,%rbp), %esi
leaq 0xbc1(%rip), %rdi       # 0x52b9
xorl %eax, %eax
callq 0x20d0
movl -0x2c(%r15,%rbp), %esi
leaq 0xbb7(%rip), %rdi       # 0x52c2
xorl %eax, %eax
callq 0x20d0
cmpq $0x0, -0x10(%r15,%rbp)
je 0x473d
movq (%r14), %rsi
leaq 0xba7(%rip), %rdi       # 0x52cb
callq 0x2100
movq -0x10(%r15,%rbp), %rdi
cmpb $0x0, (%rdi)
cmoveq %rbx, %rdi
movq (%r14), %rsi
callq 0x2100
cmpq $0x0, -0x8(%r15,%rbp)
je 0x4768
movq (%r14), %rsi
leaq 0xb83(%rip), %rdi       # 0x52d2
callq 0x2100
movq -0x8(%r15,%rbp), %rdi
cmpb $0x0, (%rdi)
cmoveq %rbx, %rdi
movq (%r14), %rsi
callq 0x2100
movl $0xa, %edi
callq 0x2060
movq -0x20(%r15,%rbp), %rdi
callq 0x2090
cmpq $0x0, -0x18(%r15,%rbp)
je 0x479a
leaq 0xb4e(%rip), %rdi       # 0x52d9
callq 0x2090
movq -0x18(%r15,%rbp), %rdi
callq 0x2090
incq %r13
movq 0x10(%rsp), %r12
movslq (%r12), %rax
addq $0x40, %rbp
cmpq %rax, %r13
jl 0x4626
jmp 0x47c7
cmpq $0x3, %rax
jne 0x479a
testb $0x1, %r13b
je 0x465d
jmp 0x479a
cmpl $0x0, (%r12)
jle 0x4826
movl $0x38, %r14d
xorl %ebx, %ebx
movq 0x8(%r12), %r15
movq (%r15,%r14), %rdi
callq 0x2050
movq -0x10(%r15,%r14), %rdi
callq 0x2050
movq -0x8(%r15,%r14), %rdi
callq 0x2050
movq -0x20(%r15,%r14), %rdi
callq 0x2050
movq -0x18(%r15,%r14), %rdi
callq 0x2050
movq -0x28(%r15,%r14), %rdi
callq 0x2050
incq %rbx
movslq (%r12), %rax
addq $0x40, %r14
cmpq %rax, %rbx
jl 0x47d6
movq 0x8(%r12), %rdi
callq 0x2050
movq %r12, %rdi
callq 0x2050
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9eb(%rip), %rdi       # 0x523e
leaq 0x9f9(%rip), %rsi       # 0x5253
leaq 0x9fd(%rip), %rcx       # 0x525e
movl $0x1d7, %edx            # imm = 0x1D7
callq 0x20f0