// File: /workspace/github_c_makefile_star2_O1/lh3[P]fermi2/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];
		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);
		mag_v_write(&d->z, &d->out);
		fputs(d->out.s, stdout);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %rax
movq 0x20(%rdi), %rcx
movq 0x28(%rdi), %r13
movslq %edx, %rdx
imulq (%rdi), %rax
imulq $0x150, %rdx, %r14      # imm = 0x150
movq 0x28(%rcx), %rcx
xorl %esi, %esi
xorl %edx, %edx
divq 0x8(%rcx)
movq %rsi, 0x120(%r13,%r14)
movq %rsi, 0x108(%r13,%r14)
movl $0x0, 0xec(%r13,%r14)
movq 0x78(%r13,%r14), %rax
movq %rdx, %rcx
sarq $0x6, %rcx
movq (%rax,%rcx,8), %rax
btq %rdx, %rax
jb 0x16657
movq %rdi, %rbx
leaq (%r14,%r13), %rbp
leaq (%r14,%r13), %rax
addq $0xb8, %rax
movq 0x8(%rbp), %rdi
leaq 0x28(%rsp), %r12
leaq 0x24(%rsp), %r8
movq %rdx, %rsi
movq %rax, 0x18(%rsp)
movq %rax, %rdx
movq %r12, %rcx
callq 0x144f7
movq %rax, %r15
movl 0xb8(%rbp), %edi
movq 0xc0(%rbp), %rsi
callq 0xdcde
movl 0xb8(%rbp), %r8d
movq 0x10(%r12), %rax
cmpq $0x2, %rax
jb 0x162fc
cmpq 0x28(%rsp), %r15
jne 0x16657
testq %rax, %rax
je 0x16349
movq 0x78(%rbp), %rax
xorl %edx, %edx
movq 0x28(%rsp), %rcx
addq %rdx, %rcx
movq %rcx, %rsi
movl $0x1, %edi
shlq %cl, %rdi
shrq $0x6, %rsi
lock
orq %rdi, (%rax,%rsi,8)
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)
incq %rdx
cmpq 0x38(%rsp), %rdx
jb 0x16307
cmpl $0x0, 0x24(%rsp)
jne 0x16657
movl 0x10(%rbp), %esi
cmpl %esi, 0xb8(%rbp)
jbe 0x16657
movl %r8d, 0x20(%rsp)
leaq (%r14,%r13), %rax
addq $0xc8, %rax
movq %rax, 0x10(%rsp)
movq 0x8(%rbp), %rdi
leaq 0x18(%rbp), %r8
leaq 0x28(%rsp), %rcx
movq 0x18(%rsp), %rdx
callq 0x1534d
movl $0x1, 0xec(%rbp)
movl 0xbc(%rbp), %esi
cmpl %esi, 0xcc(%rbp)
jae 0x163b0
movq 0x10(%rsp), %rdi
callq 0x16782
movl 0xb8(%rbp), %eax
movl %eax, 0xc8(%rbp)
movq 0xd0(%rbp), %rcx
movb $0x0, (%rcx,%rax)
cmpl $0x0, 0xc8(%rbp)
je 0x163eb
xorl %eax, %eax
movq 0xd0(%rbp), %rcx
movb $0x22, (%rcx,%rax)
incq %rax
movl 0xc8(%rbp), %ecx
cmpq %rcx, %rax
jb 0x163d2
leaq (%r14,%r13), %r12
addq $0x8, %r12
movq 0x30(%rsp), %rax
movq %rax, 0xf8(%rbp)
movq 0x28(%rsp), %r8
movq %r8, 0x100(%rbp)
cmpq $0x0, 0x18(%rbp)
je 0x164da
leaq (%r14,%r13), %r9
addq $0xf8, %r9
leaq 0x108(%r13,%r14), %r15
leaq 0xc(%rsp), %rax
movq %rax, (%rsp)
movq %r12, %rdi
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x167c6
addl %eax, 0xec(%rbp)
leaq 0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x16e05
leaq 0xc(%rsp), %rax
cmpl $0x0, (%rax)
je 0x164da
movq 0x58(%rbp), %rax
movq 0xf8(%rbp), %r15
movq 0x18(%rax), %r12
movq 0x128(%rbp), %rax
cmpq %rax, 0x120(%rbp)
jne 0x164af
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %esi
cmovneq %rcx, %rsi
movq %rsi, 0x128(%rbp)
movq 0x130(%rbp), %rdi
shlq $0x4, %rsi
callq 0x2260
movq %rax, 0x130(%rbp)
movq 0x120(%rbp), %rax
movq 0x130(%rbp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x120(%rbp)
shlq $0x4, %rax
movq %r15, (%rcx,%rax)
movq %r12, 0x8(%rcx,%rax)
jmp 0x1656d
leaq (%r14,%r13), %rax
addq $0x120, %rax            # imm = 0x120
movq %rax, 0x50(%rsp)
leaq 0x100(%rbp), %r15
leaq 0x48(%rbp), %rax
movq %rax, 0x48(%rsp)
xorl %eax, %eax
movq %rax, 0x48(%rbp)
movq %rax, 0x30(%rbp)
movq %rax, 0x18(%rbp)
movl 0xb8(%rbp), %edi
movq 0xc0(%rbp), %rsi
callq 0xdd36
movl 0xc8(%rbp), %edi
movq 0xd0(%rbp), %rsi
callq 0xdcde
movl 0xb8(%rbp), %ecx
subl 0x20(%rsp), %ecx
movq 0x30(%rsp), %r8
leaq 0xc(%rsp), %rax
movq %rax, (%rsp)
movq %r12, %rdi
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r15, %r9
callq 0x167c6
addl %eax, 0xec(%rbp)
movq 0x50(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0x16e05
movq 0x18(%rbx), %rax
movq 0xf8(%rbp), %rdx
movq 0x100(%rbp), %rcx
movq %rdx, %rsi
shrq $0x6, %rsi
andl $0x3f, %edx
lock
btsq %rdx, (%rax,%rsi,8)
jb 0x16657
movl %ecx, %edx
andl $0x3f, %edx
shrq $0x6, %rcx
lock
btsq %rdx, (%rax,%rcx,8)
jb 0x16657
leaq (%r14,%r13), %rbx
addq $0xe8, %rbx
movl 0xb8(%rbp), %eax
movl %eax, 0xe8(%rbp)
movl 0xbc(%rbp), %esi
cmpq %rsi, (%rbp)
jge 0x165fb
movq %rsi, (%rbp)
movq 0x138(%rbp), %rdi
callq 0x2260
movq %rax, 0x138(%rbp)
movq (%rbp), %rsi
movq 0x140(%rbp), %rdi
callq 0x2260
movq %rax, 0x140(%rbp)
movq 0xc0(%rbp), %rsi
movq 0x138(%rbp), %rdi
movslq 0xe8(%rbp), %rdx
callq 0x21f0
movq 0xd0(%rbp), %rsi
movq 0x140(%rbp), %rdi
movslq 0xe8(%rbp), %rdx
incq %rdx
callq 0x21f0
leaq 0xd8(%rbp), %rsi
movq %rbx, %rdi
callq 0x108f5
movq 0xe0(%rbp), %rdi
movq 0xd971(%rip), %rax      # 0x23fc0
movq (%rax), %rsi
callq 0x2130
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq