// File: /workspace/github_c_makefile_star2_O3/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 0x45d1
cmpl $0x1, %esi
je 0x45b3
testl %esi, %esi
jne 0x4896
movl $0x1, %edi
movl $0x18, %esi
callq 0x2120
movq %rax, %rbx
movq 0x38(%r14), %rdi
movl 0x4(%r14), %esi
movq %rax, %rdx
callq 0x2ca8
movq %rax, 0x8(%rbx)
testb $0x1, (%rbx)
jne 0x48aa
movq %r14, 0x10(%rbx)
testq %rax, %rax
jne 0x4898
movq %rbx, %rdi
jmp 0x4891
movl (%r14), %edi
movl (%rbx), %eax
sarl %eax
movslq %eax, %rcx
leaq 0x56c(%rip), %rsi       # 0x4b30
movq %rbx, %rdx
callq 0x244c
jmp 0x4898
cmpl $0x0, 0x28(%r14)
movq %rbx, %r12
movl (%rbx), %eax
je 0x466a
testl %eax, %eax
jle 0x4884
movl $0x4, %ebx
xorl %ebp, %ebp
movq %r12, 0x18(%rsp)
movq 0x8(%r12), %r15
movq 0xc(%r15,%rbx), %rax
movq %rax, 0x20(%rsp)
movl (%r15,%rbx), %eax
movl %eax, 0x14(%rsp)
movl 0x4(%r15,%rbx), %r12d
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 0xc7f(%rip), %rdi       # 0x52b7
movq 0x20(%rsp), %rsi
movl 0x14(%rsp), %edx
movl %r12d, %ecx
movq 0x18(%rsp), %r12
movl %r13d, %r8d
movq %r14, %r9
xorl %eax, %eax
callq 0x20d0
movl (%r12), %eax
subq $-0x80, %rbx
addl $0x2, %ebp
cmpl %ebp, %eax
jg 0x45f5
jmp 0x4828
testl %eax, %eax
jle 0x4884
movl $0x38, %ebp
movq 0x2942(%rip), %r14      # 0x6fc0
movq %r12, %rbx
leaq 0xc5d(%rip), %r12       # 0x52e5
xorl %r13d, %r13d
movq 0x8(%rbx), %r15
testl $0x7fffffff, -0x38(%r15,%rbp) # imm = 0x7FFFFFFF
je 0x47fe
movl -0x34(%r15,%rbp), %eax
cmpq $0x20, %rax
ja 0x47fe
movabsq $0x180600000, %rcx      # imm = 0x180600000
btq %rax, %rcx
jae 0x4813
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), %esi
leal -0x1f(%rsi), %eax
cmpl $0x1, %eax
ja 0x4717
movl $0x2f, %edi
callq 0x2060
movl %r13d, %eax
andl $0x1, %eax
leaq 0xbc3(%rip), %rcx       # 0x52cc
movsbl (%rax,%rcx), %edi
callq 0x2060
movl -0x34(%r15,%rbp), %esi
leaq 0xbb1(%rip), %rdi       # 0x52cf
xorl %eax, %eax
callq 0x20d0
cmpq $0x0, (%r15,%rbp)
movq (%r14), %rsi
je 0x4744
leaq 0xba2(%rip), %rdi       # 0x52d8
callq 0x2100
movq (%r15,%rbp), %rdi
movq (%r14), %rsi
jmp 0x474b
leaq 0xb94(%rip), %rdi       # 0x52df
callq 0x2100
movl -0x30(%r15,%rbp), %esi
leaq 0xb8b(%rip), %rdi       # 0x52e7
xorl %eax, %eax
callq 0x20d0
movl -0x2c(%r15,%rbp), %esi
leaq 0xb81(%rip), %rdi       # 0x52f0
xorl %eax, %eax
callq 0x20d0
cmpq $0x0, -0x10(%r15,%rbp)
je 0x47a1
movq (%r14), %rsi
leaq 0xb71(%rip), %rdi       # 0x52f9
callq 0x2100
movq -0x10(%r15,%rbp), %rdi
cmpb $0x0, (%rdi)
cmoveq %r12, %rdi
movq (%r14), %rsi
callq 0x2100
cmpq $0x0, -0x8(%r15,%rbp)
je 0x47cc
movq (%r14), %rsi
leaq 0xb4d(%rip), %rdi       # 0x5300
callq 0x2100
movq -0x8(%r15,%rbp), %rdi
cmpb $0x0, (%rdi)
cmoveq %r12, %rdi
movq (%r14), %rsi
callq 0x2100
movl $0xa, %edi
callq 0x2060
movq -0x20(%r15,%rbp), %rdi
callq 0x2090
cmpq $0x0, -0x18(%r15,%rbp)
je 0x47fe
leaq 0xb18(%rip), %rdi       # 0x5307
callq 0x2090
movq -0x18(%r15,%rbp), %rdi
callq 0x2090
incq %r13
movslq (%rbx), %rax
addq $0x40, %rbp
cmpq %rax, %r13
jl 0x468b
jmp 0x4825
cmpq $0x3, %rax
jne 0x47fe
testb $0x1, %r13b
je 0x46c1
jmp 0x47fe
movq %rbx, %r12
testl %eax, %eax
jle 0x4884
movl $0x38, %ebx
xorl %r14d, %r14d
movq 0x8(%r12), %r15
movq (%r15,%rbx), %rdi
callq 0x2050
movq -0x10(%r15,%rbx), %rdi
callq 0x2050
movq -0x8(%r15,%rbx), %rdi
callq 0x2050
movq -0x20(%r15,%rbx), %rdi
callq 0x2050
movq -0x18(%r15,%rbx), %rdi
callq 0x2050
movq -0x28(%r15,%rbx), %rdi
callq 0x2050
incq %r14
movslq (%r12), %rax
addq $0x40, %rbx
cmpq %rax, %r14
jl 0x4834
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 0x9bb(%rip), %rdi       # 0x526c
leaq 0x9c9(%rip), %rsi       # 0x5281
leaq 0x9cd(%rip), %rcx       # 0x528c
movl $0x1d7, %edx            # imm = 0x1D7
callq 0x20f0