// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap2/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->sum_len > p->batch_size) return 0;
        s = (step_t*)calloc(1, sizeof(step_t));
		s->seq = mm_bseq_read(p->fp, p->mini_batch_size, 0, &s->n_seq); // read a mini-batch
		if (s->seq) {
			uint32_t old_m, m;
			assert((uint64_t)p->mi->n_seq + s->n_seq <= UINT32_MAX); // to prevent integer overflow
			// make room for p->mi->seq
			old_m = p->mi->n_seq, m = p->mi->n_seq + s->n_seq;
			kroundup32(m); kroundup32(old_m);
			if (old_m != m)
				p->mi->seq = (mm_idx_seq_t*)krealloc(p->mi->km, p->mi->seq, m * sizeof(mm_idx_seq_t));
			// make room for p->mi->S
			if (!(p->mi->flag & MM_I_NO_SEQ)) {
				uint64_t sum_len, old_max_len, max_len;
				for (i = 0, sum_len = 0; i < s->n_seq; ++i) sum_len += s->seq[i].l_seq;
				old_max_len = (p->sum_len + 7) / 8;
				max_len = (p->sum_len + sum_len + 7) / 8;
				kroundup64(old_max_len); kroundup64(max_len);
				if (old_max_len != max_len) {
					p->mi->S = (uint32_t*)realloc(p->mi->S, max_len * 4);
					memset(&p->mi->S[old_max_len], 0, 4 * (max_len - old_max_len));
				}
			}
			// populate p->mi->seq
			for (i = 0; i < s->n_seq; ++i) {
				mm_idx_seq_t *seq = &p->mi->seq[p->mi->n_seq];
				uint32_t j;
				if (!(p->mi->flag & MM_I_NO_NAME)) {
					seq->name = (char*)kmalloc(p->mi->km, strlen(s->seq[i].name) + 1);
					strcpy(seq->name, s->seq[i].name);
				} else seq->name = 0;
				seq->len = s->seq[i].l_seq;
				seq->offset = p->sum_len;
				seq->is_alt = 0;
				// copy the sequence
				if (!(p->mi->flag & MM_I_NO_SEQ)) {
					for (j = 0; j < seq->len; ++j) { // TODO: this is not the fastest way, but let's first see if speed matters here
						uint64_t o = p->sum_len + j;
						int c = seq_nt4_table[(uint8_t)s->seq[i].seq[j]];
						mm_seq4_set(p->mi->S, o, c);
					}
				}
				// update p->sum_len and p->mi->n_seq
				p->sum_len += seq->len;
				s->seq[i].rid = p->mi->n_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) {
			mm_bseq1_t *t = &s->seq[i];
			if (t->l_seq > 0)
				mm_sketch(0, t->seq, t->l_seq, p->mi->w, p->mi->k, t->rid, p->mi->flag&MM_I_HPC, &s->a);
			else if (mm_verbose >= 2)
				fprintf(stderr, "[WARNING] the length database sequence '%s' is 0\n", t->name);
			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);
		kfree(0, s->a.a); free(s);
	}
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %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 0x9743
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jbe 0x91e7
movq $0x0, -0x8(%rbp)
jmp 0x98d5
movl $0x1, %edi
movl $0x28, %esi
callq 0x2220
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rax
movslq (%rax), %rsi
movq -0x38(%rbp), %rcx
xorl %edx, %edx
callq 0x1c2a0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x9735
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x10(%rax), %eax
movq -0x38(%rbp), %rcx
movslq (%rcx), %rcx
addq %rcx, %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
ja 0x924f
jmp 0x926e
leaq 0x4df52(%rip), %rdi     # 0x571a8
leaq 0x4dc44(%rip), %rsi     # 0x56ea1
movl $0x146, %edx            # imm = 0x146
leaq 0x4df6f(%rip), %rcx     # 0x571d8
callq 0x21a0
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x10(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x10(%rax), %eax
movq -0x38(%rbp), %rcx
addl (%rcx), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
shrl %eax
orl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
shrl $0x2, %eax
orl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
shrl $0x4, %eax
orl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
shrl $0x8, %eax
orl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
shrl $0x10, %eax
orl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
shrl %eax
orl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
shrl $0x2, %eax
orl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
shrl $0x4, %eax
orl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
shrl $0x8, %eax
orl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
shrl $0x10, %eax
orl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
je 0x9365
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x50(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x20(%rax), %rsi
movl -0x40(%rbp), %eax
imulq $0x18, %rax, %rdx
callq 0x1ad30
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq %rcx, 0x20(%rax)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl 0xc(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x9537
movl $0x0, -0x24(%rbp)
movq $0x0, -0x48(%rbp)
movl -0x24(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x93bf
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq (%rax), %rax
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x938b
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
addq $0x7, %rax
shrq $0x3, %rax
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
addq -0x48(%rbp), %rax
addq $0x7, %rax
shrq $0x3, %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
shrq %rax
orq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
shrq $0x2, %rax
orq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
shrq $0x4, %rax
orq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
shrq $0x8, %rax
orq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
shrq $0x10, %rax
orq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
shrq $0x20, %rax
orq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x58(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
shrq %rax
orq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
shrq $0x2, %rax
orq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
shrq $0x4, %rax
orq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
shrq $0x8, %rax
orq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
shrq $0x10, %rax
orq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
shrq $0x20, %rax
orq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x58(%rbp), %rax
je 0x9535
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x28(%rax), %rdi
movq -0x58(%rbp), %rsi
shlq $0x2, %rsi
callq 0x2310
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq %rcx, 0x28(%rax)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x28(%rax), %rdi
movq -0x50(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
movq -0x58(%rbp), %rdx
subq -0x50(%rbp), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x21b0
jmp 0x9537
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x9728
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x20(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x20(%rcx), %rcx
movl 0x10(%rcx), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl 0xc(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x95f3
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x50(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
callq 0x2130
movq -0x98(%rbp), %rdi
movq %rax, %rsi
addq $0x1, %rsi
callq 0x1aae0
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq %rcx, (%rax)
movq -0x60(%rbp), %rax
movq (%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x2090
jmp 0x95fe
movq -0x60(%rbp), %rax
movq $0x0, (%rax)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x60(%rbp), %rax
movl $0x0, 0x14(%rax)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl 0xc(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x96dc
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
movq -0x60(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x96da
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x64(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movl -0x64(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x55188(%rip), %rax     # 0x5e820
movzbl (%rax,%rcx), %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %edx
movq -0x70(%rbp), %rax
andq $0x7, %rax
shlq $0x2, %rax
movl %eax, %ecx
shll %cl, %edx
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x28(%rax), %rax
movq -0x70(%rbp), %rcx
shrq $0x3, %rcx
orl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x9653
jmp 0x96dc
movq -0x60(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %ecx
movq -0x30(%rbp), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x10(%rax), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, 0x10(%rax)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rdx
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x953e
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x98d5
movq -0x38(%rbp), %rdi
callq 0x2040
jmp 0x98cd
cmpl $0x1, -0x14(%rbp)
jne 0x9873
movq -0x20(%rbp), %rax
movq %rax, -0x80(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x80(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x9850
movq -0x80(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
cmpl $0x0, (%rax)
jle 0x97f1
movq -0x88(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x88(%rbp), %rax
movl (%rax), %edx
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x4(%rax), %ecx
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x8(%rax), %r8d
movq -0x88(%rbp), %rax
movl 0x4(%rax), %r9d
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl 0xc(%rax), %r10d
andl $0x1, %r10d
movq -0x80(%rbp), %rax
addq $0x10, %rax
xorl %edi, %edi
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x1c6c0
jmp 0x9822
leaq 0x54f18(%rip), %rax     # 0x5e710
cmpl $0x2, (%rax)
jl 0x9820
movq 0x547f4(%rip), %rax     # 0x5dff8
movq (%rax), %rdi
movq -0x88(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x4d9ea(%rip), %rsi     # 0x57203
movb $0x0, %al
callq 0x2250
jmp 0x9822
movq -0x88(%rbp), %rax
movq 0x10(%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 0x975c
movq -0x80(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2040
movq -0x80(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x80(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x98d5
cmpl $0x2, -0x14(%rbp)
jne 0x98c9
movq -0x20(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x90(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, %esi
movq -0x90(%rbp), %rax
movq 0x20(%rax), %rdx
callq 0x9d20
movq -0x90(%rbp), %rax
movq 0x20(%rax), %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x1a8c0
movq -0x90(%rbp), %rdi
callq 0x2040
jmp 0x98cb
jmp 0x98cd
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)