// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap/map.c
// Function: worker_pipeline
static void *worker_pipeline(void *shared, int step, void *in)
{
	int i, j;
    pipeline_t *p = (pipeline_t*)shared;
    if (step == 0) { // step 0: read sequences
        step_t *s;
        s = (step_t*)calloc(1, sizeof(step_t));
		s->seq = bseq_read(p->fp, p->batch_size, &s->n_seq);
		if (s->seq) {
			s->p = p;
			for (i = 0; i < s->n_seq; ++i)
				s->seq[i].rid = p->n_processed++;
			s->buf = (mm_tbuf_t**)calloc(p->n_threads, sizeof(mm_tbuf_t*));
			for (i = 0; i < p->n_threads; ++i)
				s->buf[i] = mm_tbuf_init();
			s->n_reg = (int*)calloc(s->n_seq, sizeof(int));
			s->reg = (mm_reg1_t**)calloc(s->n_seq, sizeof(mm_reg1_t*));
			return s;
		} else free(s);
    } else if (step == 1) { // step 1: map
		kt_for(p->n_threads, worker_for, in, ((step_t*)in)->n_seq);
		return in;
    } else if (step == 2) { // step 2: output
        step_t *s = (step_t*)in;
		const mm_idx_t *mi = p->mi;
		for (i = 0; i < p->n_threads; ++i) mm_tbuf_destroy(s->buf[i]);
		free(s->buf);
		for (i = 0; i < s->n_seq; ++i) {
			bseq1_t *t = &s->seq[i];
			for (j = 0; j < s->n_reg[i]; ++j) {
				mm_reg1_t *r = &s->reg[i][j];
				if (r->len < p->opt->min_match) continue;
				printf("%s\t%d\t%d\t%d\t%c\t", t->name, t->l_seq, r->qs, r->qe, "+-"[r->rev]);
				if (mi->name) fputs(mi->name[r->rid], stdout);
				else printf("%d", r->rid + 1);
				printf("\t%d\t%d\t%d\t%d\t%d\t255\tcm:i:%d\n", mi->len[r->rid], r->rs, r->re, r->len,
						r->re - r->rs > r->qe - r->qs? r->re - r->rs : r->qe - r->qs, r->cnt);
			}
			free(s->reg[i]);
			free(s->seq[i].seq); free(s->seq[i].name);
		}
		free(s->reg); free(s->n_reg); free(s->seq);
		free(s);
	}
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
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 0x81c6
movl $0x1, %edi
movl $0x30, %esi
callq 0x2150
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rax
movl (%rax), %esi
movq -0x38(%rbp), %rdx
addq $0x8, %rdx
callq 0x3a80
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x81b8
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x811e
movq -0x30(%rbp), %rax
movl 0x4(%rax), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, 0x4(%rax)
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x80e2
movq -0x30(%rbp), %rax
movslq 0x8(%rax), %rdi
movl $0x8, %esi
callq 0x2150
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x28(%rax)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x8171
callq 0x66a0
movq %rax, %rdx
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x24(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x8142
movq -0x38(%rbp), %rax
movslq 0x8(%rax), %rdi
movl $0x4, %esi
callq 0x2150
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x38(%rbp), %rax
movslq 0x8(%rax), %rdi
movl $0x8, %esi
callq 0x2150
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x84dd
movq -0x38(%rbp), %rdi
callq 0x2040
jmp 0x84d5
cmpl $0x1, -0x14(%rbp)
jne 0x81f8
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edi
movq -0x20(%rbp), %rdx
movq -0x20(%rbp), %rax
movslq 0x8(%rax), %rcx
leaq 0x11fa(%rip), %rsi      # 0x93e0
callq 0x94d0
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x84dd
cmpl $0x2, -0x14(%rbp)
jne 0x84d1
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x8249
movq -0x40(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x66e0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x821d
movq -0x40(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x2040
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x40(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x84a1
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x40(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq -0x24(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x8446
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x28(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x30(%rbp), %rcx
movq 0x10(%rcx), %rcx
cmpl 0xc(%rcx), %eax
jae 0x82db
jmp 0x8438
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x50(%rbp), %rax
movl (%rax), %edx
movq -0x58(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x58(%rbp), %rax
movl 0x10(%rax), %r8d
movq -0x58(%rbp), %rax
movq (%rax), %rax
shrq $0x1f, %rax
andq $0x1, %rax
movl %eax, %eax
movl %eax, %edi
leaq 0x4546(%rip), %rax      # 0xc858
movsbl (%rax,%rdi), %r9d
leaq 0x452a(%rip), %rdi      # 0xc848
movb $0x0, %al
callq 0x20f0
movq -0x48(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x8361
movq -0x48(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
andq $0x7fffffff, %rcx       # imm = 0x7FFFFFFF
movl %ecx, %ecx
movq (%rax,%rcx,8), %rdi
movq 0x6c69(%rip), %rax      # 0xefc0
movq (%rax), %rsi
callq 0x2130
jmp 0x8385
movq -0x58(%rbp), %rax
movq (%rax), %rax
shrq $0x20, %rax
andq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
movl %eax, %esi
addl $0x1, %esi
leaq 0x44dd(%rip), %rdi      # 0xc85b
movb $0x0, %al
callq 0x20f0
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
andq $0x7fffffff, %rcx       # imm = 0x7FFFFFFF
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x68(%rbp)
movq -0x58(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x64(%rbp)
movq -0x58(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x60(%rbp)
movq -0x58(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x5c(%rbp)
movq -0x58(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x58(%rbp), %rcx
subl 0x14(%rcx), %eax
movq -0x58(%rbp), %rcx
movl 0x10(%rcx), %ecx
movq -0x58(%rbp), %rdx
subl 0xc(%rdx), %ecx
cmpl %ecx, %eax
jle 0x83f8
movq -0x58(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x58(%rbp), %rcx
subl 0x14(%rcx), %eax
movl %eax, -0x6c(%rbp)
jmp 0x8409
movq -0x58(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x58(%rbp), %rcx
subl 0xc(%rcx), %eax
movl %eax, -0x6c(%rbp)
movl -0x5c(%rbp), %r8d
movl -0x60(%rbp), %ecx
movl -0x64(%rbp), %edx
movl -0x68(%rbp), %esi
movl -0x6c(%rbp), %r9d
movq -0x58(%rbp), %rax
movq (%rax), %rax
andq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
leaq 0x4430(%rip), %rdi      # 0xc85e
movl %eax, (%rsp)
movb $0x0, %al
callq 0x20f0
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x828b
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2040
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
callq 0x2040
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
callq 0x2040
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x825d
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x2040
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x2040
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2040
movq -0x40(%rbp), %rdi
callq 0x2040
jmp 0x84d3
jmp 0x84d5
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)