// File: /workspace/github_c_makefile_star2_O3/lh3[P]minimap/index.c
// Function: worker_pipeline
static void *worker_pipeline(void *shared, int step, void *in)
{
	int i;
    pipeline_t *p = (pipeline_t*)shared;
    if (step == 0) { // step 0: read sequences
        step_t *s;
		if (p->n_read > p->ibatch_size) return 0;
        s = (step_t*)calloc(1, sizeof(step_t));
		s->seq = bseq_read(p->fp, p->tbatch_size, &s->n_seq);
		if (s->seq) {
			uint32_t old_m = p->mi->n, m, n;
			assert((uint64_t)p->n_processed + s->n_seq <= INT32_MAX);
			m = n = p->mi->n + s->n_seq;
			kroundup32(m); kroundup32(old_m);
			if (old_m != m) {
				if (p->keep_name)
					p->mi->name = (char**)realloc(p->mi->name, m * sizeof(char*));
				p->mi->len = (int*)realloc(p->mi->len, m * sizeof(int));
			}
			for (i = 0; i < s->n_seq; ++i) {
				if (p->keep_name) {
					assert(strlen(s->seq[i].name) <= 254);
					p->mi->name[p->mi->n] = strdup(s->seq[i].name);
				}
				p->mi->len[p->mi->n++] = s->seq[i].l_seq;
				s->seq[i].rid = p->n_processed++;
				p->n_read += s->seq[i].l_seq;
			}
			return s;
		} else free(s);
    } else if (step == 1) { // step 1: compute sketch
        step_t *s = (step_t*)in;
		for (i = 0; i < s->n_seq; ++i) {
			bseq1_t *t = &s->seq[i];
			mm_sketch(t->seq, t->l_seq, p->mi->w, p->mi->k, t->rid, &s->a);
			free(t->seq); free(t->name);
		}
		free(s->seq); s->seq = 0;
		return s;
    } else if (step == 2) { // dispatch sketch to buckets
        step_t *s = (step_t*)in;
		mm_idx_add(p->mi, s->a.n, s->a.a);
		free(s->a.a); free(s);
	}
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
testl %esi, %esi
je 0x4172
movq %rdx, %rbx
cmpl $0x2, %esi
je 0x40c2
cmpl $0x1, %esi
jne 0x417c
cmpl $0x0, (%rbx)
jle 0x40ac
leaq 0x10(%rbx), %r15
movl $0x10, %r12d
xorl %r13d, %r13d
movq 0x8(%rbx), %rbp
movq (%rbp,%r12), %rdi
movq 0x28(%r14), %rax
movl 0x4(%rax), %edx
movl 0x8(%rax), %ecx
movl -0x10(%rbp,%r12), %esi
movl -0xc(%rbp,%r12), %r8d
movq %r15, %r9
callq 0x6c40
movq (%rbp,%r12), %rdi
callq 0x2040
movq -0x8(%rbp,%r12), %rdi
callq 0x2040
incq %r13
movslq (%rbx), %rax
addq $0x18, %r12
cmpq %rax, %r13
jl 0x4064
movq 0x8(%rbx), %rdi
callq 0x2040
movq $0x0, 0x8(%rbx)
jmp 0x417e
movq 0x10(%rbx), %r12
movq 0x20(%rbx), %r15
testl %r12d, %r12d
jle 0x4160
movq 0x28(%r14), %r14
movb (%r14), %cl
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
shll %cl, %r13d
notl %r13d
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
movq 0x10(%r14), %rax
movl (%r15), %ecx
andl %r13d, %ecx
leaq (%rcx,%rcx,2), %rdx
shlq $0x4, %rdx
leaq (%rax,%rdx), %rbp
movq (%rax,%rdx), %rcx
cmpq 0x8(%rax,%rdx), %rcx
jne 0x4139
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%rbp)
movq 0x10(%rbp), %rdi
shlq $0x4, %rsi
callq 0x2200
movq %rax, 0x10(%rbp)
movq (%rbp), %rcx
jmp 0x413d
movq 0x10(%rbp), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbp)
shlq $0x4, %rcx
movdqu (%r15), %xmm0
movdqu %xmm0, (%rax,%rcx)
addq $0x10, %r15
decq %r12
jne 0x40ed
movq 0x20(%rbx), %r15
movq %r15, %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2040
jmp 0x417c
movq 0x20(%r14), %rax
cmpq 0x18(%r14), %rax
jbe 0x4190
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %edi
movl $0x28, %esi
callq 0x2150
movq %rax, %rbx
movq 0x10(%r14), %rdi
movl (%r14), %esi
movq %rax, %rdx
callq 0x34dc
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x4168
movslq 0x4(%r14), %rcx
movslq (%rbx), %rax
addq %rax, %rcx
shrq $0x1f, %rcx
jne 0x433a
movq 0x28(%r14), %r12
leal -0x1(%rax), %ecx
movd %ecx, %xmm0
movdqa 0x458f(%rip), %xmm1     # 0x8770
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movd 0xc(%r12), %xmm0
pshufd $0x50, %xmm0, %xmm0     # xmm0 = xmm0[0,0,1,1]
paddd %xmm1, %xmm0
movdqa %xmm0, %xmm1
psrld $0x1, %xmm1
por %xmm0, %xmm1
movdqa %xmm1, %xmm0
psrld $0x2, %xmm0
por %xmm1, %xmm0
movdqa %xmm0, %xmm1
psrld $0x4, %xmm1
por %xmm0, %xmm1
movdqa %xmm1, %xmm0
psrld $0x8, %xmm0
por %xmm1, %xmm0
movdqa %xmm0, %xmm1
psrld $0x10, %xmm1
por %xmm0, %xmm1
pshufd $0x55, %xmm1, %xmm0     # xmm0 = xmm1[1,1,1,1]
movd %xmm0, %ecx
movd %xmm1, %edx
cmpl %ecx, %edx
je 0x428f
incl %ecx
cmpl $0x0, 0x8(%r14)
je 0x4270
movq 0x28(%r12), %rdi
movl %ecx, %r15d
leaq (,%r15,8), %rsi
callq 0x2200
movq 0x28(%r14), %r12
movq %rax, 0x28(%r12)
jmp 0x4273
movl %ecx, %r15d
movq 0x20(%r12), %rdi
shlq $0x2, %r15
movq %r15, %rsi
callq 0x2200
movq 0x28(%r14), %r12
movq %rax, 0x20(%r12)
movl (%rbx), %eax
testl %eax, %eax
jle 0x417e
movq 0x8(%rbx), %rax
xorl %r13d, %r13d
xorl %ebp, %ebp
cmpl $0x0, 0x8(%r14)
je 0x42da
movq 0x8(%rax,%r13), %r15
movq %r15, %rdi
callq 0x20d0
cmpq $0xff, %rax
jae 0x431b
movq %r15, %rdi
callq 0x22c0
movq 0x28(%r12), %rcx
movl 0xc(%r12), %edx
movq %rax, (%rcx,%rdx,8)
movq 0x8(%rbx), %rax
movq 0x28(%r14), %r12
movslq (%rax,%r13), %rcx
movq 0x20(%r12), %rdx
movl 0xc(%r12), %esi
leal 0x1(%rsi), %edi
movl %edi, 0xc(%r12)
movl %ecx, (%rdx,%rsi,4)
movl 0x4(%r14), %edx
leal 0x1(%rdx), %esi
movl %esi, 0x4(%r14)
movl %edx, 0x4(%rax,%r13)
addq %rcx, 0x20(%r14)
incq %rbp
movslq (%rbx), %rcx
addq $0x18, %r13
cmpq %rcx, %rbp
jl 0x42a0
jmp 0x417e
leaq 0x4546(%rip), %rdi      # 0x8868
leaq 0x44bd(%rip), %rsi      # 0x87e6
leaq 0x450d(%rip), %rcx      # 0x883d
movl $0xcd, %edx
callq 0x2110
leaq 0x44cb(%rip), %rdi      # 0x880c
leaq 0x449e(%rip), %rsi      # 0x87e6
leaq 0x44ee(%rip), %rcx      # 0x883d
movl $0xc3, %edx
callq 0x2110