// File: /workspace/github_c_makefile_star2_O2/lh3[P]minigraph/gmap.c
// Function: worker_for
static void worker_for(void *_data, long i, int tid) // kt_for() callback
{
    step_t *s = (step_t*)_data;
	int qlens[MG_MAX_SEG], j, off = s->seg_off[i], pe_ori = s->p->opt->pe_ori;
	const char *qseqs[MG_MAX_SEG];
	mg_tbuf_t *b = s->buf[tid];
	assert(s->n_seg[i] <= MG_MAX_SEG);
	if (mg_dbg_flag & MG_DBG_QNAME)
		fprintf(stderr, "QR\t%s\t%d\t%d\n", s->seq[off].name, tid, s->seq[off].l_seq);
	for (j = 0; j < s->n_seg[i]; ++j) {
		if (s->n_seg[i] == 2 && ((j == 0 && (pe_ori>>1&1)) || (j == 1 && (pe_ori&1))))
			mg_revcomp_bseq(&s->seq[off + j]);
		qlens[j] = s->seq[off + j].l_seq;
		qseqs[j] = s->seq[off + j].seq;
	}
	if (s->p->opt->flag & MG_M_INDEPEND_SEG) {
		for (j = 0; j < s->n_seg[i]; ++j)
			mg_map_frag(s->p->gi, 1, &qlens[j], &qseqs[j], &s->gcs[off+j], b, s->p->opt, s->seq[off+j].name);
	} else {
		mg_map_frag(s->p->gi, s->n_seg[i], qlens, qseqs, &s->gcs[off], b, s->p->opt, s->seq[off].name);
	}
#if 0 // for paired-end reads
	for (j = 0; j < s->n_seg[i]; ++j) // flip the query strand and coordinate to the original read strand
		if (s->n_seg[i] == 2 && ((j == 0 && (pe_ori>>1&1)) || (j == 1 && (pe_ori&1)))) {
			int k, t;
			mg_revcomp_bseq(&s->seq[off + j]);
			for (k = 0; k < s->n_reg[off + j]; ++k) {
				mg_lchain_t *r = &s->reg[off + j][k];
				t = r->qs;
				r->qs = qlens[j] - r->qe;
				r->qe = qlens[j] - t;
				r->v ^= 1;
			}
		}
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc18, %rsp            # imm = 0xC18
movq 0x20(%rdi), %rax
cmpl $0x100, (%rax,%rsi,4)   # imm = 0x100
jge 0x1d8f2
movl %edx, %ecx
movq %rsi, %r15
movq %rdi, %rbx
movq (%rdi), %rax
movq 0x18(%rdi), %rdx
movslq (%rdx,%rsi,4), %r14
movq 0x18(%rax), %rax
movl 0x18(%rax), %ebp
movq 0x30(%rdi), %rax
movslq %ecx, %rdx
movq (%rax,%rdx,8), %rax
movq %rax, 0x10(%rsp)
leaq 0x10fbe(%rip), %rax     # 0x2e678
testb $0x2, (%rax)
jne 0x1d8c4
xorl %ecx, %ecx
imulq $0x28, %r14, %rax
movq %rax, 0x8(%rsp)
leaq 0x10b2b(%rip), %rdx     # 0x2e200
movq %r15, 0x18(%rsp)
movq 0x20(%rbx), %rsi
movslq (%rsi,%r15,4), %rsi
cmpq %rsi, %rcx
jge 0x1d7f9
cmpl $0x2, %esi
jne 0x1d7d1
testb $0x1, %bpl
sete %sil
testb $0x2, %bpl
sete %dil
testq %rcx, %rcx
setne %r8b
orb %dil, %r8b
cmpq $0x1, %rcx
setne %dil
cmpb $0x1, %r8b
jne 0x1d725
orb %sil, %dil
jne 0x1d7d1
imulq $0x28, %rcx, %r8
addq 0x10(%rbx), %r8
movq 0x8(%rsp), %rax
leaq (%r8,%rax), %rsi
movl (%rax,%r8), %r11d
movl %r11d, %r9d
sarl %r9d
testl %r9d, %r9d
movl $0x0, %edi
cmovgl %r9d, %edi
movq 0x10(%rax,%r8), %r10
leal -0x1(%r11), %r8d
movl %r8d, %r15d
xorl %r12d, %r12d
cmpq %r12, %rdi
je 0x1d784
movslq %r15d, %r15
movsbq (%r10,%r15), %r13
movzbl (%r10,%r12), %eax
movb (%rdx,%rax), %al
movb %al, (%r10,%r15)
movb (%rdx,%r13), %al
movb %al, (%r10,%r12)
incq %r12
decl %r15d
jmp 0x1d75b
testb $0x1, %r11b
je 0x1d79a
movslq %r9d, %rax
movzbl (%r10,%rax), %r9d
movb (%rdx,%r9), %r9b
movb %r9b, (%r10,%rax)
cmpq $0x0, 0x18(%rsi)
movq 0x18(%rsp), %r15
je 0x1d7d1
xorl %r9d, %r9d
cmpq %r9, %rdi
je 0x1d7d1
movq 0x18(%rsi), %rax
movslq %r8d, %r8
movb (%rax,%r8), %r10b
movb (%rax,%r9), %r11b
movb %r11b, (%rax,%r8)
movq 0x18(%rsi), %rax
movb %r10b, (%rax,%r9)
incq %r9
decl %r8d
jmp 0x1d7a9
movq 0x10(%rbx), %rax
leaq (%rcx,%r14), %rsi
imulq $0x28, %rsi, %rsi
movl (%rax,%rsi), %edi
movl %edi, 0x20(%rsp,%rcx,4)
movq 0x10(%rax,%rsi), %rax
movq %rax, 0x420(%rsp,%rcx,8)
incq %rcx
jmp 0x1d6da
movq (%rbx), %rcx
movq 0x18(%rcx), %r10
testb $0x2, 0x2(%r10)
jne 0x1d851
movq 0x28(%rcx), %rdi
shlq $0x3, %r14
addq 0x28(%rbx), %r14
movq 0x10(%rbx), %rax
leaq 0x20(%rsp), %rdx
leaq 0x420(%rsp), %rcx
movq %r14, %r8
movq 0x10(%rsp), %r9
movq 0x8(%rsp), %r11
pushq 0x8(%rax,%r11)
pushq %r10
callq 0x197f6
popq %rax
popq %rcx
addq $0xc18, %rsp            # imm = 0xC18
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
imulq $0xa, %r14, %r15
shlq $0x3, %r14
addq $0x2, %r15
leaq 0x420(%rsp), %r13
leaq 0x20(%rsp), %rbp
xorl %r12d, %r12d
movslq %esi, %rax
cmpq %rax, %r12
jge 0x1d83f
movq (%rbx), %rax
movq 0x10(%rbx), %r10
movq 0x28(%rax), %rdi
movq 0x28(%rbx), %r8
addq %r14, %r8
pushq $0x1
popq %rsi
movq %rbp, %rdx
movq %r13, %rcx
movq 0x10(%rsp), %r9
pushq (%r10,%r15,4)
pushq 0x18(%rax)
callq 0x197f6
popq %rax
popq %rcx
incq %r12
movq 0x20(%rbx), %rax
movq 0x18(%rsp), %rcx
movl (%rax,%rcx,4), %esi
addq $0x8, %r13
addq $0x4, %rbp
addq $0x8, %r14
addq $0xa, %r15
jmp 0x1d86d
movq 0x1072d(%rip), %rax     # 0x2dff8
movq (%rax), %rdi
movq 0x10(%rbx), %rax
imulq $0x28, %r14, %rsi
movq 0x8(%rax,%rsi), %rdx
movl (%rax,%rsi), %r8d
leaq 0x77d1(%rip), %rsi      # 0x250b7
xorl %eax, %eax
callq 0x2210
jmp 0x1d6c3
leaq 0x777a(%rip), %rdi      # 0x25073
leaq 0x778d(%rip), %rsi      # 0x2508d
leaq 0x778d(%rip), %rcx      # 0x25094
pushq $0x23
popq %rdx
callq 0x2160