// File: /workspace/github_c_makefile_star2_O1/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 0x40fe
movq %rdx, %rbx
cmpl $0x2, %esi
je 0x4050
cmpl $0x1, %esi
jne 0x428a
cmpl $0x0, (%rbx)
jle 0x403a
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 0x6c04
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 0x3ff2
movq 0x8(%rbx), %rdi
callq 0x2040
movq $0x0, 0x8(%rbx)
jmp 0x428c
movq 0x10(%rbx), %r15
testl %r15d, %r15d
jle 0x40e8
movq 0x28(%r14), %r14
movb (%r14), %cl
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
shll %cl, %r12d
movq 0x20(%rbx), %r13
notl %r12d
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
movq 0x10(%r14), %rcx
movl (%r13), %eax
andl %r12d, %eax
leaq (%rax,%rax,2), %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rbp
movq 0x8(%rcx,%rdx), %rax
cmpq %rax, (%rcx,%rdx)
jne 0x40c2
leaq (%rax,%rax), %rsi
testq %rax, %rax
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), %rax
movq 0x10(%rbp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rbp)
shlq $0x4, %rax
movups (%r13), %xmm0
movups %xmm0, (%rcx,%rax)
addq $0x10, %r13
decq %r15
jne 0x407b
movq 0x20(%rbx), %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2040
jmp 0x428a
movq 0x20(%r14), %rax
cmpq 0x18(%r14), %rax
jbe 0x4111
xorl %eax, %eax
xorl %ebx, %ebx
jmp 0x4286
movl $0x1, %edi
movl $0x28, %esi
callq 0x2150
movq %rax, %rbx
movq 0x10(%r14), %rdi
movl (%r14), %esi
movq %rax, %rdx
callq 0x34f7
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x427c
movslq 0x4(%r14), %rax
movslq (%rbx), %rcx
addq %rcx, %rax
shrq $0x1f, %rax
jne 0x42bd
movq 0x28(%r14), %rax
movl 0xc(%rax), %edx
addl %edx, %ecx
decl %ecx
movl %ecx, %esi
shrl %esi
orl %ecx, %esi
movl %esi, %ecx
shrl $0x2, %ecx
orl %esi, %ecx
movl %ecx, %esi
shrl $0x4, %esi
orl %ecx, %esi
movl %esi, %edi
shrl $0x8, %edi
orl %esi, %edi
movl %edi, %ecx
shrl $0x10, %ecx
orl %edi, %ecx
decl %edx
movl %edx, %esi
shrl %esi
orl %edx, %esi
movl %esi, %edx
shrl $0x2, %edx
orl %esi, %edx
movl %edx, %esi
shrl $0x4, %esi
orl %edx, %esi
movl %esi, %edx
shrl $0x8, %edx
orl %esi, %edx
movl %edx, %esi
shrl $0x10, %esi
orl %edx, %esi
cmpl %ecx, %esi
je 0x41e9
incl %ecx
cmpl $0x0, 0x8(%r14)
movl %ecx, %r15d
je 0x41cd
movq 0x28(%rax), %rdi
leaq (,%r15,8), %rsi
callq 0x2200
movq 0x28(%r14), %rcx
movq %rax, 0x28(%rcx)
movq 0x28(%r14), %rax
movq 0x20(%rax), %rdi
shlq $0x2, %r15
movq %r15, %rsi
callq 0x2200
movq 0x28(%r14), %rcx
movq %rax, 0x20(%rcx)
cmpl $0x0, (%rbx)
jle 0x4278
xorl %r12d, %r12d
xorl %r13d, %r13d
cmpl $0x0, 0x8(%r14)
je 0x4233
movq 0x8(%rbx), %rax
movq 0x8(%rax,%r12), %r15
movq %r15, %rdi
callq 0x20d0
cmpq $0xff, %rax
jae 0x429e
movq %r15, %rdi
callq 0x22c0
movq 0x28(%r14), %rcx
movq 0x28(%rcx), %rdx
movl 0xc(%rcx), %ecx
movq %rax, (%rdx,%rcx,8)
movq 0x8(%rbx), %rax
movl (%rax,%r12), %ecx
movq 0x28(%r14), %rdx
movq 0x20(%rdx), %rsi
movl 0xc(%rdx), %edi
leal 0x1(%rdi), %r8d
movl %r8d, 0xc(%rdx)
movl %ecx, (%rsi,%rdi,4)
movl 0x4(%r14), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x4(%r14)
movl %ecx, 0x4(%rax,%r12)
movslq (%rax,%r12), %rax
addq %rax, 0x20(%r14)
incq %r13
movslq (%rbx), %rax
addq $0x18, %r12
cmpq %rax, %r13
jl 0x41f8
xorl %eax, %eax
jmp 0x4286
movq %rbx, %rdi
callq 0x2040
movb $0x1, %al
testb %al, %al
je 0x428c
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x45f3(%rip), %rdi      # 0x8898
leaq 0x456a(%rip), %rsi      # 0x8816
leaq 0x45ba(%rip), %rcx      # 0x886d
movl $0xcd, %edx
callq 0x2110
leaq 0x4578(%rip), %rdi      # 0x883c
leaq 0x454b(%rip), %rsi      # 0x8816
leaq 0x459b(%rip), %rcx      # 0x886d
movl $0xc3, %edx
callq 0x2110