// File: /workspace/github_c_makefile_star2_O3/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 $0x68, %rsp
movq %rsi, %rax
movq 0x20(%rdi), %rcx
movq 0x28(%rdi), %rbp
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(%rbp,%r14)
movq %rsi, 0x108(%rbp,%r14)
movl $0x0, 0xec(%rbp,%r14)
movq 0x78(%rbp,%r14), %rax
movq %rdx, %rcx
sarq $0x6, %rcx
movq (%rax,%rcx,8), %rax
btq %rdx, %rax
jb 0x17108
movq %rdi, %rbx
leaq (%r14,%rbp), %r13
leaq (%r14,%rbp), %rax
addq $0xb8, %rax
movq 0x8(%r13), %rdi
leaq 0x40(%rsp), %r12
leaq 0x24(%rsp), %r8
movq %rdx, %rsi
movq %rax, 0x8(%rsp)
movq %rax, %rdx
movq %r12, %rcx
callq 0x14f37
movq %rax, %r15
movl 0xb8(%r13), %edi
movq 0xc0(%r13), %rsi
callq 0xe289
movl 0xb8(%r13), %r8d
movq 0x10(%r12), %rax
cmpq $0x2, %rax
jb 0x16d6a
cmpq 0x40(%rsp), %r15
jne 0x17108
testq %rax, %rax
je 0x16db7
movq 0x78(%r13), %rax
xorl %edx, %edx
movq 0x40(%rsp), %rcx
addq %rdx, %rcx
movq %rcx, %rsi
movl $0x1, %edi
shlq %cl, %rdi
shrq $0x6, %rsi
lock
orq %rdi, (%rax,%rsi,8)
movq 0x48(%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 0x50(%rsp), %rdx
jb 0x16d75
cmpl $0x0, 0x24(%rsp)
jne 0x17108
movl 0x10(%r13), %esi
cmpl %esi, 0xb8(%r13)
jbe 0x17108
movl %r8d, 0x20(%rsp)
leaq (%r14,%rbp), %rax
addq $0xc8, %rax
movq %rax, 0x18(%rsp)
movq 0x8(%r13), %rdi
leaq 0x18(%r13), %r8
leaq 0x40(%rsp), %rcx
movq 0x8(%rsp), %rdx
callq 0x15dd5
movl $0x1, 0xec(%r13)
movl 0xbc(%r13), %esi
cmpl %esi, 0xcc(%r13)
jae 0x16e23
movq 0x18(%rsp), %rdi
callq 0x1724a
movl 0xb8(%r13), %eax
movl %eax, 0xc8(%r13)
movq 0xd0(%r13), %rcx
movb $0x0, (%rcx,%rax)
cmpl $0x0, 0xc8(%r13)
je 0x16e62
xorl %eax, %eax
movq 0xd0(%r13), %rcx
movb $0x22, (%rcx,%rax)
incq %rax
movl 0xc8(%r13), %ecx
cmpq %rcx, %rax
jb 0x16e48
leaq (%r14,%rbp), %rax
addq $0x8, %rax
movq %rax, 0x38(%rsp)
leaq 0xf8(%rbp,%r14), %r9
leaq 0x120(%rbp,%r14), %rax
movq %rax, 0x28(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0xf8(%r13)
movq 0x40(%rsp), %r8
leaq 0x100(%r13), %rax
movq %rax, 0x30(%rsp)
movq %r8, 0x100(%r13)
cmpq $0x0, 0x18(%r13)
je 0x16f6a
leaq (%r14,%rbp), %r15
addq $0x108, %r15            # imm = 0x108
leaq 0x14(%rsp), %rax
movq %rax, (%rsp)
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x18(%rsp), %rdx
xorl %ecx, %ecx
movq %r9, %r12
callq 0x1728e
addl %eax, 0xec(%r13)
leaq 0x48(%r13), %rsi
movq %r15, %rdi
callq 0x1791d
movq %r12, %r9
leaq 0x14(%rsp), %rax
cmpl $0x0, (%rax)
je 0x16f6a
movq 0x58(%r13), %rax
movq 0xf8(%r13), %r15
movq 0x18(%rax), %rdi
movq 0x120(%r13), %rcx
cmpq 0x128(%r13), %rcx
jne 0x16ffa
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %esi
cmovneq %rax, %rsi
movq %rsi, 0x128(%r13)
movq %rdi, 0x8(%rsp)
movq 0x130(%r13), %rdi
shlq $0x4, %rsi
callq 0x2260
movq 0x8(%rsp), %rdi
movq %r12, %r9
movq %rax, 0x130(%r13)
movq 0x120(%r13), %rcx
jmp 0x17001
leaq 0x48(%r13), %rax
movq %rax, 0x60(%rsp)
xorl %eax, %eax
movq %rax, 0x48(%r13)
movq %rax, 0x30(%r13)
movq %rax, 0x18(%r13)
movl 0xb8(%r13), %edi
movq 0xc0(%r13), %rsi
movq %r9, %r15
callq 0xe2e1
movl 0xc8(%r13), %edi
movq 0xd0(%r13), %rsi
callq 0xe289
movl 0xb8(%r13), %ecx
subl 0x20(%rsp), %ecx
movq 0x48(%rsp), %r8
leaq 0x14(%rsp), %rax
movq %rax, (%rsp)
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x30(%rsp), %r12
movq %r12, %r9
callq 0x1728e
addl %eax, 0xec(%r13)
movq 0x28(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x1791d
movq %r15, %r9
jmp 0x1701f
movq 0x130(%r13), %rax
leaq 0x1(%rcx), %rdx
movq 0x28(%rsp), %rsi
movq %rdx, (%rsi)
shlq $0x4, %rcx
movq %r15, (%rax,%rcx)
movq %rdi, 0x8(%rax,%rcx)
movq 0x30(%rsp), %r12
movq 0x18(%rbx), %rax
movq (%r9), %rdx
movq %rdx, %rsi
shrq $0x6, %rsi
andl $0x3f, %edx
movq (%r12), %rcx
lock
btsq %rdx, (%rax,%rsi,8)
jb 0x17108
movl %ecx, %edx
andl $0x3f, %edx
shrq $0x6, %rcx
lock
btsq %rdx, (%rax,%rcx,8)
jb 0x17108
leaq (%r14,%rbp), %rbx
addq $0xe8, %rbx
movl 0xb8(%r13), %eax
movl %eax, 0xe8(%r13)
movl 0xbc(%r13), %esi
cmpq %rsi, (%r13)
jge 0x170b0
movq %rsi, (%r13)
movq 0x138(%r13), %rdi
callq 0x2260
movq %rax, 0x138(%r13)
movq (%r13), %rsi
movq 0x140(%r13), %rdi
callq 0x2260
movq %rax, 0x140(%r13)
movl 0xe8(%r13), %eax
movq 0xc0(%r13), %rsi
movq 0x138(%r13), %rdi
movslq %eax, %rdx
callq 0x21f0
movq 0xd0(%r13), %rsi
movq 0x140(%r13), %rdi
movslq 0xe8(%r13), %rdx
incq %rdx
callq 0x21f0
leaq 0xd8(%r13), %rsi
movq %rbx, %rdi
callq 0x10f25
movq 0xe0(%r13), %rdi
movq 0xdec0(%rip), %rax      # 0x24fc0
movq (%rax), %rsi
callq 0x2130
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq