// File: /workspace/github_c_makefile_star2_O1/lh3[P]fermi-lite/unitig.c
// Function: worker
static void worker(void *data, long _i, int tid)
{
	worker_t *w = (worker_t*)data;
	thrdat_t *d = &w->d[tid];
	uint64_t i = (w->prime * _i) % w->e->mcnt[1];
	if (unitig1(&d->a, i, &d->str, &d->cov, d->z.k, d->z.nei, &d->z.nsr) >= 0) { // then we keep the unitig
		uint64_t *p[2], x[2];
		magv_t *q;
		p[0] = w->visited + (d->z.k[0]>>6); x[0] = 1LLU<<(d->z.k[0]&0x3f);
		p[1] = w->visited + (d->z.k[1]>>6); x[1] = 1LLU<<(d->z.k[1]&0x3f);
		if ((__sync_fetch_and_or(p[0], x[0])&x[0]) || (__sync_fetch_and_or(p[1], x[1])&x[1])) return;
		d->z.len = d->str.l;
		if (d->max_l < d->str.m) {
			d->max_l = d->str.m;
			d->z.seq = realloc(d->z.seq, d->max_l);
			d->z.cov = realloc(d->z.cov, d->max_l);
		}
		memcpy(d->z.seq, d->str.s, d->z.len);
		memcpy(d->z.cov, d->cov.s, d->z.len + 1);
		kv_pushp(magv_t, d->v, &q);
		mag_v_copy_to_empty(q, &d->z);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %rax
movq 0x20(%rdi), %rcx
movq 0x28(%rdi), %r13
movslq %edx, %rdx
imulq (%rdi), %rax
imulq $0x170, %rdx, %r14      # imm = 0x170
movq 0x28(%rcx), %rcx
xorl %esi, %esi
xorl %edx, %edx
divq 0x8(%rcx)
movq %rsi, 0x128(%r13,%r14)
movq %rsi, 0x110(%r13,%r14)
movl $0x0, 0xf4(%r13,%r14)
movq 0x78(%r13,%r14), %rax
movq %rdx, %rcx
sarq $0x6, %rcx
movq (%rax,%rcx,8), %rax
btq %rdx, %rax
jb 0xc0c1
movq %rdi, %rbx
leaq (%r14,%r13), %rbp
leaq (%r14,%r13), %rax
addq $0xc0, %rax
movq 0x8(%rbp), %rdi
leaq 0x30(%rsp), %r12
leaq 0x2c(%rsp), %r8
movq %rdx, %rsi
movq %rax, 0x20(%rsp)
movq %rax, %rdx
movq %r12, %rcx
callq 0x9e53
movq %rax, %r15
movl 0xc0(%rbp), %edi
movq 0xd0(%rbp), %rsi
callq 0x41db
movq 0xc0(%rbp), %r8
movq 0x10(%r12), %rax
cmpq $0x2, %rax
jb 0xbd22
cmpq 0x30(%rsp), %r15
jne 0xc0c1
testq %rax, %rax
je 0xbd6f
movq 0x78(%rbp), %rax
xorl %edx, %edx
movq 0x30(%rsp), %rcx
addq %rdx, %rcx
movq %rcx, %rsi
movl $0x1, %edi
shlq %cl, %rdi
shrq $0x6, %rsi
lock
orq %rdi, (%rax,%rsi,8)
movq 0x38(%rsp), %rcx
addq %rdx, %rcx
movq %rcx, %rsi
movl $0x1, %edi
shlq %cl, %rdi
shrq $0x6, %rsi
lock
orq %rdi, (%rax,%rsi,8)
incq %rdx
cmpq 0x40(%rsp), %rdx
jb 0xbd2d
cmpl $0x0, 0x2c(%rsp)
jne 0xc0c1
movslq 0x10(%rbp), %rsi
cmpq %rsi, 0xc0(%rbp)
jbe 0xc0c1
movq %r8, 0x60(%rsp)
leaq (%r14,%r13), %rax
addq $0xd8, %rax
movq %rax, 0x18(%rsp)
movq 0x8(%rbp), %rdi
leaq 0x18(%rbp), %r8
leaq 0x30(%rsp), %rcx
movq 0x20(%rsp), %rdx
callq 0xacc2
movl $0x1, 0xf4(%rbp)
movq 0xc8(%rbp), %rsi
cmpq %rsi, 0xe0(%rbp)
jae 0xbdda
movq 0x18(%rsp), %rdi
callq 0xc0fd
movq 0xc0(%rbp), %rax
movq 0xe8(%rbp), %rcx
movq %rax, 0xd8(%rbp)
movb $0x0, (%rcx,%rax)
cmpq $0x0, 0xd8(%rbp)
je 0xbe16
xorl %eax, %eax
movq 0xe8(%rbp), %rcx
movb $0x22, (%rcx,%rax)
incq %rax
cmpq 0xd8(%rbp), %rax
jb 0xbdff
leaq (%r14,%r13), %r12
addq $0x8, %r12
movq 0x38(%rsp), %rax
movq %rax, 0x100(%rbp)
movq 0x30(%rsp), %r8
movq %r8, 0x108(%rbp)
cmpq $0x0, 0x18(%rbp)
je 0xbf05
leaq (%r14,%r13), %r9
addq $0x100, %r9             # imm = 0x100
leaq 0x110(%r13,%r14), %r15
leaq 0x14(%rsp), %rax
movq %rax, (%rsp)
movq %r12, %rdi
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
xorl %ecx, %ecx
callq 0xc151
addl %eax, 0xf4(%rbp)
leaq 0x48(%rbp), %rsi
movq %r15, %rdi
callq 0xc7c8
leaq 0x14(%rsp), %rax
cmpl $0x0, (%rax)
je 0xbf05
movq 0x58(%rbp), %rax
movq 0x100(%rbp), %r15
movq 0x18(%rax), %r12
movq 0x130(%rbp), %rax
cmpq %rax, 0x128(%rbp)
jne 0xbeda
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %esi
cmovneq %rcx, %rsi
movq %rsi, 0x130(%rbp)
movq 0x138(%rbp), %rdi
shlq $0x4, %rsi
callq 0x21d0
movq %rax, 0x138(%rbp)
movq 0x128(%rbp), %rax
movq 0x138(%rbp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x128(%rbp)
shlq $0x4, %rax
movq %r15, (%rcx,%rax)
movq %r12, 0x8(%rcx,%rax)
jmp 0xbf98
leaq (%r14,%r13), %rax
addq $0x128, %rax            # imm = 0x128
movq %rax, 0x58(%rsp)
leaq 0x108(%rbp), %r15
leaq 0x48(%rbp), %rax
movq %rax, 0x50(%rsp)
xorl %eax, %eax
movq %rax, 0x48(%rbp)
movq %rax, 0x30(%rbp)
movq %rax, 0x18(%rbp)
movl 0xc0(%rbp), %edi
movq 0xd0(%rbp), %rsi
callq 0x4205
movl 0xd8(%rbp), %edi
movq 0xe8(%rbp), %rsi
callq 0x41db
movl 0xc0(%rbp), %ecx
subl 0x60(%rsp), %ecx
movq 0x38(%rsp), %r8
leaq 0x14(%rsp), %rax
movq %rax, (%rsp)
movq %r12, %rdi
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r15, %r9
callq 0xc151
addl %eax, 0xf4(%rbp)
movq 0x58(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0xc7c8
movq 0x18(%rbx), %rax
movq 0x100(%rbp), %rdx
movq 0x108(%rbp), %rcx
movq %rdx, %rsi
shrq $0x6, %rsi
andl $0x3f, %edx
lock
btsq %rdx, (%rax,%rsi,8)
jb 0xc0c1
movl %ecx, %edx
andl $0x3f, %edx
shrq $0x6, %rcx
lock
btsq %rdx, (%rax,%rcx,8)
jb 0xc0c1
movl 0xc0(%rbp), %eax
movl %eax, 0xf0(%rbp)
movq 0xc8(%rbp), %rsi
cmpq %rsi, (%rbp)
jae 0xc01c
movq %rsi, (%rbp)
movq 0x140(%rbp), %rdi
callq 0x21d0
movq %rax, 0x140(%rbp)
movq (%rbp), %rsi
movq 0x148(%rbp), %rdi
callq 0x21d0
movq %rax, 0x148(%rbp)
leaq (%r14,%r13), %rbx
addq $0xf0, %rbx
movq 0xd0(%rbp), %rsi
movq 0x140(%rbp), %rdi
movslq 0xf0(%rbp), %rdx
callq 0x2180
movq 0xe8(%rbp), %rsi
movq 0x148(%rbp), %rdi
movslq 0xf0(%rbp), %rdx
incq %rdx
callq 0x2180
movq 0x160(%rbp), %rax
cmpq %rax, 0x158(%rbp)
jne 0xc09c
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmovneq %rcx, %rax
movq %rax, 0x160(%rbp)
movq 0x168(%rbp), %rdi
imulq $0x68, %rax, %rsi
callq 0x21d0
movq %rax, 0x168(%rbp)
movq 0x158(%rbp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x158(%rbp)
imulq $0x68, %rax, %rdi
addq 0x168(%rbp), %rdi
movq %rbx, %rsi
callq 0xf7de
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq