// File: /workspace/github_c_makefile_star2_O2/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 0x3e0e
cmpl $0x1, %esi
je 0x3df0
testl %esi, %esi
jne 0x3f03
pushq $0x1
popq %rdi
pushq $0x18
popq %rsi
callq 0x2120
movq %rax, %rbx
movq 0x38(%r14), %rdi
movl 0x4(%r14), %esi
movq %rax, %rdx
callq 0x2b8d
movq %rax, 0x8(%rbx)
testb $0x1, (%rbx)
jne 0x40cb
movq %r14, 0x10(%rbx)
testq %rax, %rax
jne 0x3f05
jmp 0x3efb
movl (%r14), %edi
movl (%rbx), %eax
sarl %eax
movslq %eax, %rcx
leaq 0x58e(%rip), %rsi       # 0x438f
movq %rbx, %rdx
callq 0x237c
jmp 0x3f05
cmpl $0x0, 0x28(%r14)
je 0x3f17
movq %rbx, %rcx
pushq $0x4
popq %rbx
xorl %r12d, %r12d
movq %rcx, 0x18(%rsp)
movslq (%rcx), %rax
cmpq %rax, %r12
jge 0x3e98
movq 0x8(%rcx), %r15
movq 0xc(%r15,%rbx), %rax
movq %rax, 0x20(%rsp)
movl (%r15,%rbx), %ebp
movl 0x4(%r15,%rbx), %eax
movl %eax, 0x14(%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 0x1426(%rip), %rdi      # 0x5297
movq 0x20(%rsp), %rsi
movl %ebp, %edx
movl 0x14(%rsp), %ecx
movl %r13d, %r8d
movq %r14, %r9
xorl %eax, %eax
callq 0x20d0
movq 0x18(%rsp), %rcx
addq $0x2, %r12
subq $-0x80, %rbx
jmp 0x3e27
movq %rcx, %rbx
pushq $0x38
popq %r15
xorl %r12d, %r12d
cltq
movq 0x8(%rbx), %r14
cmpq %rax, %r12
jge 0x3ef3
movq (%r14,%r15), %rdi
callq 0x2050
movq -0x10(%r14,%r15), %rdi
callq 0x2050
movq -0x8(%r14,%r15), %rdi
callq 0x2050
movq -0x20(%r14,%r15), %rdi
callq 0x2050
movq -0x18(%r14,%r15), %rdi
callq 0x2050
movq -0x28(%r14,%r15), %rdi
callq 0x2050
incq %r12
movl (%rbx), %eax
addq $0x40, %r15
jmp 0x3ea2
movq %r14, %rdi
callq 0x2050
movq %rbx, %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
pushq $0x38
popq %rbp
movq 0x309f(%rip), %r12      # 0x6fc0
leaq 0x139d(%rip), %r13      # 0x52c5
xorl %r15d, %r15d
movslq (%rbx), %rax
cmpq %rax, %r15
jge 0x3e9b
movq 0x8(%rbx), %r14
testl $0x7fffffff, -0x38(%r14,%rbp) # imm = 0x7FFFFFFF
je 0x40ad
movl -0x34(%r14,%rbp), %eax
cmpq $0x20, %rax
ja 0x40ad
movabsq $0x180600000, %rcx      # imm = 0x180600000
btq %rax, %rcx
jae 0x40b9
xorl %eax, %eax
cmpq $0x0, -0x18(%r14,%rbp)
setne %al
leal 0x3e(,%rax,2), %edi
callq 0x2060
movq -0x28(%r14,%rbp), %rdi
movq (%r12), %rsi
callq 0x2100
movl -0x34(%r14,%rbp), %esi
leal -0x1f(%rsi), %eax
cmpl $0x1, %eax
ja 0x3fc2
pushq $0x2f
popq %rdi
callq 0x2060
movl %r15d, %eax
andl $0x1, %eax
leaq 0x12f8(%rip), %rcx      # 0x52ac
movsbl (%rax,%rcx), %edi
callq 0x2060
movl -0x34(%r14,%rbp), %esi
leaq 0x12e6(%rip), %rdi      # 0x52af
xorl %eax, %eax
callq 0x20d0
cmpq $0x0, (%r14,%rbp)
movq (%r12), %rsi
je 0x3ff1
leaq 0x12d6(%rip), %rdi      # 0x52b8
callq 0x2100
movq (%r14,%rbp), %rdi
movq (%r12), %rsi
jmp 0x3ff8
leaq 0x12c7(%rip), %rdi      # 0x52bf
callq 0x2100
movl -0x30(%r14,%rbp), %esi
leaq 0x12be(%rip), %rdi      # 0x52c7
xorl %eax, %eax
callq 0x20d0
movl -0x2c(%r14,%rbp), %esi
leaq 0x12b4(%rip), %rdi      # 0x52d0
xorl %eax, %eax
callq 0x20d0
cmpq $0x0, -0x10(%r14,%rbp)
je 0x4050
movq (%r12), %rsi
leaq 0x12a3(%rip), %rdi      # 0x52d9
callq 0x2100
movq -0x10(%r14,%rbp), %rdi
cmpb $0x0, (%rdi)
cmoveq %r13, %rdi
movq (%r12), %rsi
callq 0x2100
cmpq $0x0, -0x8(%r14,%rbp)
je 0x407d
movq (%r12), %rsi
leaq 0x127d(%rip), %rdi      # 0x52e0
callq 0x2100
movq -0x8(%r14,%rbp), %rdi
cmpb $0x0, (%rdi)
cmoveq %r13, %rdi
movq (%r12), %rsi
callq 0x2100
pushq $0xa
popq %rdi
callq 0x2060
movq -0x20(%r14,%rbp), %rdi
callq 0x2090
cmpq $0x0, -0x18(%r14,%rbp)
je 0x40ad
leaq 0x1249(%rip), %rdi      # 0x52e7
callq 0x2090
movq -0x18(%r14,%rbp), %rdi
callq 0x2090
incq %r15
addq $0x40, %rbp
jmp 0x3f2b
cmpq $0x3, %rax
jne 0x40ad
testb $0x1, %r15b
je 0x3f6d
jmp 0x40ad
leaq 0x117a(%rip), %rdi      # 0x524c
leaq 0x1188(%rip), %rsi      # 0x5261
leaq 0x118c(%rip), %rcx      # 0x526c
movl $0x1d7, %edx            # imm = 0x1D7
callq 0x20f0