// File: /workspace/github_c_makefile_star2_O0/DReichLab[P]adna/trim.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];
				printf("%s\t%d\n", s->name, s->type);
			}
		} else { // FASTQ output (FASTA not supported yet)
			kstring_t pe[2] = {{0,0,0},{0,0,0}};
			for (i = 0; i < data->n_seqs; i += 2)
				++g->types[data->seqs[i].type];
			for (i = 0; i < data->n_seqs; ++i) {
				bseq1_t *s = &data->seqs[i];
				if (s->l_seq <= 0) continue;
				if (g->fp_pe[0] && g->fp_pe[1]) {
					if (s->type == AD_PARTIAL_MERGE || s->type == AD_COMPLETE_MERGE) {
						printf("%c%s_%d:%s\n%s\n", s->qual? '@' : '>', s->name, s->type, s->bc? s->bc : "*", s->seq);
						if (s->qual) { puts("+"); puts(s->qual); }
					} else if (s->type == AD_NO_MERGE || s->type == AD_AMBI_MERGE) {
						kstring_t *str = &pe[i&1];
						ksprintf(str, "%c%s_%d:%s\n%s\n", s->qual? '@' : '>', s->name, s->type, s->bc? s->bc : "*", s->seq);
						if (s->qual) { kputs("+\n", str); kputs(s->qual, str); kputc('\n', str); }
					}
				} else {
					if (s->type == AD_PARTIAL_MERGE || s->type == AD_COMPLETE_MERGE || s->type == AD_NO_MERGE || s->type == AD_AMBI_MERGE) {
						if (!g->opt.retain_pe && (s->type == AD_NO_MERGE || s->type == AD_AMBI_MERGE)) continue;
						printf("%c%s_%d:%s", s->qual? '@' : '>', s->name, s->type, s->bc? s->bc : "*");
						if (s->type != AD_PARTIAL_MERGE && s->type != AD_COMPLETE_MERGE) {
							putchar('/'); putchar("12"[i&1]);
						}
						putchar('\n');
						puts(s->seq);
						if (s->qual) { puts("+"); puts(s->qual); }
					}
				}
			}
			for (i = 0; i < 2; ++i) {
				gzwrite(g->fp_pe[i], pe[i].s, pe[i].l);
				free(pe[i].s);
			}
		}
		for (i = 0; i < data->n_seqs; ++i) { // deallocate
			bseq1_t *s = &data->seqs[i];
			free(s->bc); free(s->seq); free(s->qual); free(s->name);
		}
		free(data->seqs); free(data);
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x5ecf
movl $0x1, %edi
movl $0x18, %esi
callq 0x2120
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x30(%rbp), %rax
movl 0x4(%rax), %esi
movq -0x38(%rbp), %rdx
callq 0x3920
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x5e7e
jmp 0x5e9d
leaq 0x247a(%rip), %rdi      # 0x82ff
leaq 0x2488(%rip), %rsi      # 0x8314
movl $0x24e, %edx            # imm = 0x24E
leaq 0x2483(%rip), %rcx      # 0x831b
callq 0x2100
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x5ec1
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x6490
movq -0x38(%rbp), %rdi
callq 0x2040
jmp 0x6488
cmpl $0x1, -0x14(%rbp)
jne 0x5f0b
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %edi
movq -0x40(%rbp), %rdx
movq -0x40(%rbp), %rax
movl (%rax), %eax
sarl %eax
movslq %eax, %rcx
leaq 0xf47(%rip), %rsi       # 0x6e40
callq 0x23a0
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x6490
cmpl $0x2, -0x14(%rbp)
jne 0x6484
movq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, 0x2c(%rax)
je 0x5f7d
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x5f78
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x50(%rbp), %rax
movl 0x4(%rax), %edx
leaq 0x23e0(%rip), %rdi      # 0x8346
movb $0x0, %al
callq 0x20e0
movl -0x24(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x24(%rbp)
jmp 0x5f2e
jmp 0x63f7
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x2110
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x5fd2
movq -0x30(%rbp), %rax
movq -0x48(%rbp), %rcx
movq 0x8(%rcx), %rcx
movslq -0x24(%rbp), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
movq 0x50(%rax,%rcx,8), %rdx
addq $0x1, %rdx
movq %rdx, 0x50(%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x24(%rbp)
jmp 0x5f94
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x638f
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpl $0x0, %eax
jg 0x6014
jmp 0x6381
movq -0x30(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x622b
movq -0x30(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x622b
movq -0x78(%rbp), %rax
cmpl $0x16, 0x4(%rax)
je 0x604a
movq -0x78(%rbp), %rax
cmpl $0x15, 0x4(%rax)
jne 0x610a
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rdx
movl $0x3e, %eax
movl $0x40, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x9c(%rbp)
movq -0x78(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x78(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x8c(%rbp)
movq -0x78(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x60a1
movq -0x78(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xa8(%rbp)
jmp 0x60b1
leaq 0x22b4(%rip), %rax      # 0x835c
movq %rax, -0xa8(%rbp)
jmp 0x60b1
movl -0x8c(%rbp), %ecx
movq -0x98(%rbp), %rdx
movl -0x9c(%rbp), %esi
movq -0xa8(%rbp), %r8
movq -0x78(%rbp), %rax
movq 0x10(%rax), %r9
leaq 0x2273(%rip), %rdi      # 0x834d
movb $0x0, %al
callq 0x20e0
movq -0x78(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x6105
leaq 0x226b(%rip), %rdi      # 0x835e
callq 0x2090
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x2090
jmp 0x6226
movq -0x78(%rbp), %rax
cmpl $0x20, 0x4(%rax)
je 0x6122
movq -0x78(%rbp), %rax
cmpl $0x1f, 0x4(%rax)
jne 0x6224
movl -0x24(%rbp), %eax
andl $0x1, %eax
movslq %eax, %rcx
leaq -0x70(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rdx
movl $0x3e, %eax
movl $0x40, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0xbc(%rbp)
movq -0x78(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xb8(%rbp)
movq -0x78(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0xac(%rbp)
movq -0x78(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x619c
movq -0x78(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xd0(%rbp)
jmp 0x61ac
leaq 0x21b9(%rip), %rax      # 0x835c
movq %rax, -0xd0(%rbp)
jmp 0x61ac
movl -0xac(%rbp), %r8d
movq -0xb8(%rbp), %rcx
movl -0xbc(%rbp), %edx
movq -0xc8(%rbp), %rdi
movq -0xd0(%rbp), %r9
movq -0x78(%rbp), %rax
movq 0x10(%rax), %rax
leaq 0x2170(%rip), %rsi      # 0x834d
movq %rax, (%rsp)
movb $0x0, %al
callq 0x5c10
movq -0x78(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x6222
movq -0x80(%rbp), %rsi
leaq 0x2162(%rip), %rdi      # 0x8360
callq 0x6e90
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x80(%rbp), %rsi
callq 0x6e90
movq -0x80(%rbp), %rsi
movl $0xa, %edi
callq 0x6ed0
jmp 0x6224
jmp 0x6226
jmp 0x637f
movq -0x78(%rbp), %rax
cmpl $0x16, 0x4(%rax)
je 0x6257
movq -0x78(%rbp), %rax
cmpl $0x15, 0x4(%rax)
je 0x6257
movq -0x78(%rbp), %rax
cmpl $0x20, 0x4(%rax)
je 0x6257
movq -0x78(%rbp), %rax
cmpl $0x1f, 0x4(%rax)
jne 0x637d
movq -0x30(%rbp), %rax
cmpl $0x0, 0x30(%rax)
jne 0x627a
movq -0x78(%rbp), %rax
cmpl $0x20, 0x4(%rax)
je 0x6275
movq -0x78(%rbp), %rax
cmpl $0x1f, 0x4(%rax)
jne 0x627a
jmp 0x6381
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rdx
movl $0x3e, %eax
movl $0x40, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0xe4(%rbp)
movq -0x78(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xe0(%rbp)
movq -0x78(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0xd4(%rbp)
movq -0x78(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x62d1
movq -0x78(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xf0(%rbp)
jmp 0x62e1
leaq 0x2084(%rip), %rax      # 0x835c
movq %rax, -0xf0(%rbp)
jmp 0x62e1
movl -0xd4(%rbp), %ecx
movq -0xe0(%rbp), %rdx
movl -0xe4(%rbp), %esi
movq -0xf0(%rbp), %r8
leaq 0x2061(%rip), %rdi      # 0x8363
movb $0x0, %al
callq 0x20e0
movq -0x78(%rbp), %rax
cmpl $0x16, 0x4(%rax)
je 0x6340
movq -0x78(%rbp), %rax
cmpl $0x15, 0x4(%rax)
je 0x6340
movl $0x2f, %edi
callq 0x2050
movl -0x24(%rbp), %eax
andl $0x1, %eax
movslq %eax, %rcx
leaq 0x2037(%rip), %rax      # 0x836e
movsbl (%rax,%rcx), %edi
callq 0x2050
movl $0xa, %edi
callq 0x2050
movq -0x78(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2090
movq -0x78(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x637b
leaq 0x1ff5(%rip), %rdi      # 0x835e
callq 0x2090
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x2090
jmp 0x637d
jmp 0x637f
jmp 0x6381
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x5fd9
movl $0x0, -0x24(%rbp)
cmpl $0x2, -0x24(%rbp)
jge 0x63f5
movq -0x30(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq 0x40(%rax,%rcx,8), %rdi
movslq -0x24(%rbp), %rcx
leaq -0x70(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
movslq -0x24(%rbp), %rcx
leaq -0x70(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %edx
callq 0x21d0
movslq -0x24(%rbp), %rcx
leaq -0x70(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
callq 0x2040
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x6396
jmp 0x63f7
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x646e
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x2040
movq -0x88(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2040
movq -0x88(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x2040
movq -0x88(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2040
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x63fe
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2040
movq -0x48(%rbp), %rdi
callq 0x2040
jmp 0x6486
jmp 0x6488
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopl (%rax)