// File: /workspace/github_c_makefile_star2_O0/lh3[P]fermi2/match.c
// Function: worker
static void worker(void *data, long jid, int tid)
{
	global_t *g = (global_t*)data;
	thrmem_t *m = &g->mem[tid];
	char *seq = g->seq[jid], *qual = g->qual? g->qual[jid] : 0;
	int l_seq;

	l_seq = strlen(seq);
	seq_char2nt6(l_seq, (uint8_t*)seq);
	m->str.l = 0;
	ksprintf(&m->str, "SQ\t%s\t%d\n", g->name[jid], l_seq);
	if (!g->partial) { // full-length match
		int64_t k, l, u;
		fm_exact(g->e, seq, &l, &u);
		if (l < u) {
			ksprintf(&m->str, "EM\t0\t%d\t%ld", l_seq, (long)(u - l));
			if (g->sa && u - l <= g->max_sa_occ) {
				for (k = l; k < u; ++k) {
					int64_t idx, i;
					i = fm_sa(g->e, g->sa, k, &idx);
					ksprintf(&m->str, "\t%ld:%ld", (long)idx, (long)i);
				}
			}
			kputc('\n', &m->str);
		}
	} else { // SMEM
		size_t i;
		int64_t k;
		fmd_smem(g->e, (uint8_t*)seq, &m->smem, g->min_occ, &m->curr, &m->prev);
		if (g->discovery) {
			int pre;
			for (i = 0, pre = -1; i < m->smem.n; ++i) {
				fmdsmem_t *p = &m->smem.a[i];
				int start = p->ik.info>>32, end = (uint32_t)p->ik.info;
				if (end - start < g->kmer) continue; // skip short SMEMs
				rld_extend(g->e, &p->ik, p->ok[1], 0);
				discover(g->e, pre < 0? 0 : &m->smem.a[pre], p, l_seq, seq, qual, &m->str, m->cmp);
				pre = i;
			}
			discover(g->e, pre < 0? 0 : &m->smem.a[pre], 0, l_seq, seq, qual, &m->str, m->cmp);
		} else {
			for (i = 0; i < m->smem.n; ++i) {
				fmdsmem_t *p = &m->smem.a[i];
				uint32_t st = (uint32_t)(p->ik.info>>32), en = (uint32_t)p->ik.info;
				if (en - st < g->min_len) continue;
				ksprintf(&m->str, "EM\t%u\t%u\t%ld", st, en, (long)p->ik.x[2]);
				if (g->sa && p->ik.x[2] < g->max_sa_occ) {
					for (k = 0; k < p->ik.x[2]; ++k) {
						int64_t idx, j;
						j = fm_sa(g->e, g->sa, p->ik.x[0] + k, &idx);
						ksprintf(&m->str, "\t%ld:%ld", (long)idx, (long)j);
					}
				}
				kputc('\n', &m->str);
			}
		}
	}
	kputsn("//", 2, &m->str);
	free(g->qual[jid]); free(g->seq[jid]); free(g->name[jid]);
	g->out[jid] = strdup(m->str.s);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x50(%rax)
je 0x2894d
movq -0x20(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xb8(%rbp)
jmp 0x28958
xorl %eax, %eax
movq %rax, -0xb8(%rbp)
jmp 0x28958
movq -0xb8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0x20f0
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %edi
movq -0x30(%rbp), %rsi
callq 0x14200
movq -0x28(%rbp), %rax
movl $0x0, 0x48(%rax)
movq -0x28(%rbp), %rdi
addq $0x48, %rdi
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movl -0x3c(%rbp), %ecx
leaq 0x567f(%rip), %rsi      # 0x2e027
movb $0x0, %al
callq 0x273f0
movq -0x20(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jne 0x28a9b
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x30(%rbp), %rsi
leaq -0x50(%rbp), %rdx
leaq -0x58(%rbp), %rcx
callq 0x27f40
movq -0x50(%rbp), %rax
cmpq -0x58(%rbp), %rax
jge 0x28a96
movq -0x28(%rbp), %rdi
addq $0x48, %rdi
movl -0x3c(%rbp), %edx
movq -0x58(%rbp), %rcx
subq -0x50(%rbp), %rcx
leaq 0x5634(%rip), %rsi      # 0x2e031
movb $0x0, %al
callq 0x273f0
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x28a84
movq -0x58(%rbp), %rax
subq -0x50(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq 0x10(%rcx), %rcx
cmpq %rcx, %rax
jg 0x28a84
movq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x58(%rbp), %rax
jge 0x28a82
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x48(%rbp), %rdx
leaq -0x60(%rbp), %rcx
callq 0x26990
movq %rax, -0x68(%rbp)
movq -0x28(%rbp), %rdi
addq $0x48, %rdi
movq -0x60(%rbp), %rdx
movq -0x68(%rbp), %rcx
leaq 0x55d0(%rip), %rsi      # 0x2e03d
movb $0x0, %al
callq 0x273f0
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x28a2c
jmp 0x28a84
movq -0x28(%rbp), %rsi
addq $0x48, %rsi
movl $0xa, %edi
callq 0x28e70
jmp 0x28dee
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
addq $0x30, %rdx
movq -0x20(%rbp), %rax
movl 0x14(%rax), %ecx
movq -0x28(%rbp), %r8
movq -0x28(%rbp), %r9
addq $0x18, %r9
callq 0x27eb0
movq -0x20(%rbp), %rax
cmpl $0x0, 0x20(%rax)
je 0x28c82
movq $0x0, -0x70(%rbp)
movl $0xffffffff, -0x7c(%rbp) # imm = 0xFFFFFFFF
movq -0x70(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq 0x30(%rcx), %rax
jae 0x28c08
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rax
imulq $0x1a0, -0x70(%rbp), %rcx # imm = 0x1A0
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
movl %eax, -0x8c(%rbp)
movq -0x88(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %eax
subl -0x8c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x24(%rcx), %eax
jge 0x28b4f
jmp 0x28bf7
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x88(%rbp), %rsi
movq -0x88(%rbp), %rdx
addq $0x20, %rdx
addq $0xc0, %rdx
xorl %ecx, %ecx
callq 0x49a0
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
cmpl $0x0, -0x7c(%rbp)
jge 0x28b95
xorl %eax, %eax
movq %rax, -0xc8(%rbp)
jmp 0x28bb2
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x7c(%rbp), %rcx
imulq $0x1a0, %rcx, %rcx      # imm = 0x1A0
addq %rcx, %rax
movq %rax, -0xc8(%rbp)
movq -0xc0(%rbp), %rdi
movq -0xc8(%rbp), %rsi
movq -0x88(%rbp), %rdx
movl -0x3c(%rbp), %ecx
movq -0x30(%rbp), %r8
movq -0x38(%rbp), %r9
movq -0x28(%rbp), %r10
addq $0x48, %r10
movq -0x28(%rbp), %rax
addq $0x58, %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x28f80
movq -0x70(%rbp), %rax
movl %eax, -0x7c(%rbp)
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x28ae3
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
cmpl $0x0, -0x7c(%rbp)
jge 0x28c27
xorl %eax, %eax
movq %rax, -0xd8(%rbp)
jmp 0x28c44
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x7c(%rbp), %rcx
imulq $0x1a0, %rcx, %rcx      # imm = 0x1A0
addq %rcx, %rax
movq %rax, -0xd8(%rbp)
movq -0xd0(%rbp), %rdi
movq -0xd8(%rbp), %rsi
movl -0x3c(%rbp), %ecx
movq -0x30(%rbp), %r8
movq -0x38(%rbp), %r9
movq -0x28(%rbp), %r10
addq $0x48, %r10
movq -0x28(%rbp), %rax
addq $0x58, %rax
xorl %edx, %edx
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x28f80
jmp 0x28dec
movq $0x0, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq 0x30(%rcx), %rax
jae 0x28dea
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rax
imulq $0x1a0, -0x70(%rbp), %rcx # imm = 0x1A0
addq %rcx, %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
movl %eax, -0x9c(%rbp)
movq -0x98(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, -0xa0(%rbp)
movl -0xa0(%rbp), %eax
subl -0x9c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jae 0x28cf6
jmp 0x28dd9
movq -0x28(%rbp), %rdi
addq $0x48, %rdi
movl -0x9c(%rbp), %edx
movl -0xa0(%rbp), %ecx
movq -0x98(%rbp), %rax
movq 0x10(%rax), %r8
leaq 0x532a(%rip), %rsi      # 0x2e046
movb $0x0, %al
callq 0x273f0
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x28dc7
movq -0x98(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rcx
movslq 0x10(%rcx), %rcx
cmpq %rcx, %rax
jae 0x28dc7
movq $0x0, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq -0x98(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x28dc5
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x98(%rbp), %rax
movq (%rax), %rdx
addq -0x78(%rbp), %rdx
leaq -0xa8(%rbp), %rcx
callq 0x26990
movq %rax, -0xb0(%rbp)
movq -0x28(%rbp), %rdi
addq $0x48, %rdi
movq -0xa8(%rbp), %rdx
movq -0xb0(%rbp), %rcx
leaq 0x528d(%rip), %rsi      # 0x2e03d
movb $0x0, %al
callq 0x273f0
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x28d52
jmp 0x28dc7
movq -0x28(%rbp), %rsi
addq $0x48, %rsi
movl $0xa, %edi
callq 0x28e70
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x28c8a
jmp 0x28dec
jmp 0x28dee
movq -0x28(%rbp), %rdx
addq $0x48, %rdx
leaq 0x5256(%rip), %rdi      # 0x2e053
movl $0x2, %esi
callq 0x29790
movq -0x20(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2040
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2040
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2040
movq -0x28(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x2350
movq %rax, %rdx
movq -0x20(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x10(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
addq $0xf0, %rsp
popq %rbp
retq
nop