// File: /workspace/github_c_makefile_star2_O2/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), %r13
movslq %edx, %rsi
imulq (%rdi), %rax
movq 0x28(%rcx), %rcx
xorl %edx, %edx
divq 0x8(%rcx)
imulq $0x150, %rsi, %r15      # imm = 0x150
andq $0x0, 0x120(%r13,%r15)
andq $0x0, 0x108(%r13,%r15)
andl $0x0, 0xec(%r13,%r15)
movq 0x78(%r13,%r15), %rax
movq %rdx, %rcx
sarq $0x6, %rcx
movq (%rax,%rcx,8), %rax
btq %rdx, %rax
jb 0x143a4
movq %rdi, %rbx
leaq (%r15,%r13), %rbp
leaq (%r15,%r13), %rax
addq $0xb8, %rax
movq 0x8(%rbp), %rdi
leaq 0x48(%rsp), %r12
leaq 0x20(%rsp), %r8
movq %rdx, %rsi
movq %rax, 0x10(%rsp)
movq %rax, %rdx
movq %r12, %rcx
callq 0x1242b
movq %rax, %r14
movl 0xb8(%rbp), %edi
movq 0xc0(%rbp), %rsi
callq 0xc546
movl 0xb8(%rbp), %eax
movl %eax, 0x1c(%rsp)
cmpq $0x2, 0x10(%r12)
jb 0x1408e
cmpq 0x48(%rsp), %r14
jne 0x143a4
movq 0x78(%rbp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x13ce0
cmpl $0x0, 0x20(%rsp)
jne 0x143a4
movl 0x10(%rbp), %esi
cmpl %esi, 0xb8(%rbp)
jbe 0x143a4
leaq (%r15,%r13), %r14
addq $0xc8, %r14
movq 0x8(%rbp), %rdi
leaq 0x18(%rbp), %r8
leaq 0x48(%rsp), %rcx
movq 0x10(%rsp), %rdx
callq 0x13209
movl $0x1, 0xec(%rbp)
movl 0xbc(%rbp), %esi
cmpl %esi, 0xcc(%rbp)
jae 0x140f8
movq %r14, %rdi
callq 0x14512
leaq (%r15,%r13), %rax
addq $0x8, %rax
movq %rax, 0x38(%rsp)
leaq 0xe8(%r13,%r15), %rax
movq %rax, 0x40(%rsp)
leaq 0xf8(%r13,%r15), %rdx
leaq 0x108(%r13,%r15), %r12
leaq 0x120(%r13,%r15), %rax
movq %rax, 0x30(%rsp)
movl 0xb8(%rbp), %eax
movl %eax, 0xc8(%rbp)
movq 0xd0(%rbp), %rcx
movb $0x0, (%rcx,%rax)
xorl %eax, %eax
movl (%r14), %ecx
cmpq %rcx, %rax
jae 0x14160
movq 0xd0(%rbp), %rcx
movb $0x22, (%rcx,%rax)
incq %rax
jmp 0x14148
movq 0x50(%rsp), %rax
movq %rax, 0xf8(%rbp)
movq 0x48(%rsp), %r8
leaq 0x100(%rbp), %rax
movq %rax, 0x28(%rsp)
movq %r8, 0x100(%rbp)
cmpq $0x0, 0x18(%rbp)
movq %rdx, %r13
je 0x14225
leaq 0x24(%rsp), %r15
movq %r15, (%rsp)
movq 0x38(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r14, %rdx
xorl %ecx, %ecx
movq %r13, %r9
callq 0x14556
addl %eax, 0xec(%rbp)
leaq 0x48(%rbp), %rsi
movq %r12, %rdi
callq 0x14a4e
cmpl $0x0, (%r15)
je 0x14225
movq 0x58(%rbp), %rax
movq 0xf8(%rbp), %r14
movq 0x18(%rax), %r15
movq 0x120(%rbp), %rcx
cmpq 0x128(%rbp), %rcx
jne 0x142a3
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
pushq $0x2
popq %rsi
cmovneq %rax, %rsi
movq %rsi, 0x128(%rbp)
movq 0x130(%rbp), %rdi
shlq $0x4, %rsi
callq 0x2260
movq %rax, 0x130(%rbp)
movq 0x120(%rbp), %rcx
jmp 0x142aa
andq $0x0, 0x48(%rbp)
andq $0x0, 0x30(%rbp)
andq $0x0, 0x18(%rbp)
leaq 0x48(%rbp), %r12
movl 0xb8(%rbp), %edi
movq 0xc0(%rbp), %rsi
callq 0xc599
movl 0xc8(%rbp), %edi
movq 0xd0(%rbp), %rsi
callq 0xc546
movl 0xb8(%rbp), %ecx
subl 0x1c(%rsp), %ecx
movq 0x50(%rsp), %r8
leaq 0x24(%rsp), %rax
movq %rax, (%rsp)
movq 0x38(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r14, %rdx
movq 0x28(%rsp), %r14
movq %r14, %r9
callq 0x14556
addl %eax, 0xec(%rbp)
movq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0x14a4e
jmp 0x142c8
movq 0x130(%rbp), %rax
leaq 0x1(%rcx), %rdx
movq 0x30(%rsp), %rsi
movq %rdx, (%rsi)
shlq $0x4, %rcx
movq %r14, (%rax,%rcx)
movq %r15, 0x8(%rax,%rcx)
movq 0x28(%rsp), %r14
movq 0x18(%rbx), %rax
movq (%r13), %rdx
movq %rdx, %rsi
shrq $0x6, %rsi
andl $0x3f, %edx
movq (%r14), %rcx
lock
btsq %rdx, (%rax,%rsi,8)
jb 0x143a4
movl %ecx, %edx
andl $0x3f, %edx
shrq $0x6, %rcx
lock
btsq %rdx, (%rax,%rcx,8)
jb 0x143a4
movl 0xb8(%rbp), %eax
movl %eax, 0xe8(%rbp)
movl 0xbc(%rbp), %esi
cmpq %rsi, (%rbp)
jge 0x1434a
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)
movl 0xe8(%rbp), %eax
movq 0xc0(%rbp), %rsi
movq 0x138(%rbp), %rdi
movslq %eax, %rdx
callq 0x21f0
movq 0xd0(%rbp), %rsi
movq 0x140(%rbp), %rdi
movslq 0xe8(%rbp), %rdx
incq %rdx
callq 0x21f0
leaq 0xd8(%rbp), %rsi
movq 0x40(%rsp), %rdi
callq 0xecf8
movq 0xe0(%rbp), %rdi
movq 0xdc24(%rip), %rax      # 0x21fc0
movq (%rax), %rsi
callq 0x2130
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq