// File: /workspace/github_c_makefile_star2_O2/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 0x3df3
movq %rdx, %rbx
cmpl $0x2, %esi
je 0x3d43
cmpl $0x1, %esi
jne 0x3dfd
leaq 0x10(%rbx), %r15
pushq $0x10
popq %r13
xorl %ebp, %ebp
movslq (%rbx), %rax
movq 0x8(%rbx), %r12
cmpq %rax, %rbp
jge 0x3e01
movq (%r12,%r13), %rdi
movq 0x28(%r14), %rax
movl 0x4(%rax), %edx
movl 0x8(%rax), %ecx
movl -0x10(%r12,%r13), %esi
movl -0xc(%r12,%r13), %r8d
movq %r15, %r9
callq 0x64d4
movq (%r12,%r13), %rdi
callq 0x2040
movq -0x8(%r12,%r13), %rdi
callq 0x2040
incq %rbp
addq $0x18, %r13
jmp 0x3cf7
movq 0x28(%r14), %r12
movl 0x10(%rbx), %r13d
movb (%r12), %cl
pushq $-0x1
popq %r15
shll %cl, %r15d
movq 0x20(%rbx), %r14
notl %r15d
xorl %ebp, %ebp
testl %r13d, %r13d
cmovlel %ebp, %r13d
shlq $0x4, %r13
movq %rbx, (%rsp)
cmpq %rbp, %r13
je 0x3de0
movq 0x10(%r12), %rax
movl (%r14,%rbp), %ecx
andl %r15d, %ecx
imulq $0x30, %rcx, %rdx
leaq (%rax,%rdx), %rbx
movq (%rax,%rdx), %rcx
cmpq 0x8(%rax,%rdx), %rcx
jne 0x3dba
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rax
cmoveq %rax, %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
shlq $0x4, %rsi
callq 0x2200
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
jmp 0x3dbe
movq 0x10(%rbx), %rax
leaq (%r14,%rbp), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rbx)
shlq $0x4, %rcx
movdqu (%rdx), %xmm0
movdqu %xmm0, (%rax,%rcx)
addq $0x10, %rbp
movq (%rsp), %rbx
jmp 0x3d6e
movq 0x20(%rbx), %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2040
jmp 0x3dfd
movq 0x20(%r14), %rax
cmpq 0x18(%r14), %rax
jbe 0x3e20
xorl %ebx, %ebx
jmp 0x3e0e
movq %r12, %rdi
callq 0x2040
andq $0x0, 0x8(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rdi
pushq $0x28
popq %rsi
callq 0x2150
movq %rax, %rbx
movq 0x10(%r14), %rdi
movl (%r14), %esi
movq %rax, %rdx
callq 0x325c
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x3de9
movslq 0x4(%r14), %rcx
movslq (%rbx), %rax
addq %rax, %rcx
shrq $0x1f, %rcx
jne 0x3fbc
movq 0x28(%r14), %r12
decl %eax
movd %eax, %xmm0
movdqa 0x4904(%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, %eax
movd %xmm1, %ecx
cmpl %eax, %ecx
je 0x3f18
incl %eax
cmpl $0x0, 0x8(%r14)
je 0x3efb
movq 0x28(%r12), %rdi
movl %eax, %r15d
leaq (,%r15,8), %rsi
callq 0x2200
movq 0x28(%r14), %r12
movq %rax, 0x28(%r12)
jmp 0x3efe
movl %eax, %r15d
movq 0x20(%r12), %rdi
shlq $0x2, %r15
movq %r15, %rsi
callq 0x2200
movq 0x28(%r14), %r12
movq %rax, 0x20(%r12)
xorl %r13d, %r13d
xorl %ebp, %ebp
movslq (%rbx), %rax
cmpq %rax, %rbp
jge 0x3e0e
cmpl $0x0, 0x8(%r14)
movq 0x8(%rbx), %rax
je 0x3f67
movq 0x8(%rax,%r13), %r15
movq %r15, %rdi
callq 0x20d0
cmpq $0xff, %rax
jae 0x3f9d
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
addq $0x18, %r13
jmp 0x3f1d
leaq 0x48c4(%rip), %rdi      # 0x8868
leaq 0x483b(%rip), %rsi      # 0x87e6
leaq 0x488b(%rip), %rcx      # 0x883d
movl $0xcd, %edx
callq 0x2110
leaq 0x4849(%rip), %rdi      # 0x880c
leaq 0x481c(%rip), %rsi      # 0x87e6
leaq 0x486c(%rip), %rcx      # 0x883d
movl $0xc3, %edx
callq 0x2110