// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Trio.cpp
// Function: tb_worker(void*, long, int)
static void tb_worker(void *_data, long k, int tid)
{
	tb_shared_t *aux = (tb_shared_t*)_data;
	UC_Read *s = &aux->bseq[tid]; 
	recover_UC_Read(s, aux->seq, k);
	tb_buf_t *b = &aux->buf[tid];
	tb_cnt_t cnt; memset(&cnt, 0, sizeof(tb_cnt_t));
	uint64_t x[4], mask;
	int i, l, shift;
	if (aux->ch->k < 32) {
		mask = (1ULL<<2*aux->ch->k) - 1;
		shift = 2 * (aux->ch->k - 1);
	} else {
		mask = (1ULL<<aux->ch->k) - 1;
		shift = aux->ch->k - 1;
	}
	if (s->length > b->max) {
		b->max = s->length;
		kroundup32(b->max);
		b->s = (uint32_t*)realloc(b->s, b->max * sizeof(uint32_t));
	}
	memset(b->s, 0, s->length * sizeof(uint32_t));
	for (i = l = 0, x[0] = x[1] = x[2] = x[3] = 0; i < s->length; ++i) {
		int flag, c = seq_nt4_table[(uint8_t)s->seq[i]];
		if (c < 4) {
			if (aux->ch->k < 32) {
				x[0] = (x[0] << 2 | c) & mask;
				x[1] = x[1] >> 2 | (uint64_t)(3 - c) << shift;
			} else {
				x[0] = (x[0] << 1 | (c&1))  & mask;
				x[1] = (x[1] << 1 | (c>>1)) & mask;
				x[2] = x[2] >> 1 | (uint64_t)(1 - (c&1))  << shift;
				x[3] = x[3] >> 1 | (uint64_t)(1 - (c>>1)) << shift;
			}
			if (++l >= aux->k) {
				int type = 0, c1, c2;
				uint64_t y;
				++cnt.nk;
				if (aux->ch->k < 32)
					y = yak_hash64(x[0] < x[1]? x[0] : x[1], mask);
				else
					y = yak_hash_long(x);
				flag = yak_ch_get(aux->ch, y);
				if (flag < 0) flag = 0;
				c1 = flag&3, c2 = flag>>2&3;
				if (c1 == 2 && c2 == 0) type = 1;
				else if (c2 == 2 && c1 == 0) type = 2;
				b->s[i] = type;
				++cnt.c[flag];
			}
		} else l = 0, x[0] = x[1] = x[2] = x[3] = 0;
	}
	for (l = 0, i = 1; i <= s->length; ++i) {
		if (i == s->length || b->s[i] != b->s[l]) {
			if (b->s[l] > 0 && i - l >= aux->k - 4)
				cnt.sc[b->s[l] - 1] += i - l;
			l = i;
		}
	}

	int *c = cnt.c;
	char type;
	type = tb_classify(cnt.sc, c, aux->k, aux->ratio_thres);
	aux->seq->trio_flag[k] = AMBIGU;
	if(type == 'p') aux->seq->trio_flag[k] = FATHER;
	if(type == 'm') aux->seq->trio_flag[k] = MOTHER;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, %rax
movq %rdi, %r12
movslq %edx, %r14
movq %r14, %rbp
shlq $0x5, %rbp
movq 0x28(%rdi), %rbx
movq 0x30(%rdi), %rsi
leaq (%rbx,%rbp), %r15
movq %r15, %rdi
movq %rax, 0xa8(%rsp)
movq %rax, %rdx
callq 0x33cf8
movq 0x20(%r12), %rax
shlq $0x4, %r14
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8c(%rsp)
movapd %xmm0, 0x80(%rsp)
movapd %xmm0, 0x70(%rsp)
movapd %xmm0, 0x60(%rsp)
movapd %xmm0, 0x50(%rsp)
movq 0x18(%r12), %rcx
movl (%rcx), %edx
leal -0x1(%rdx), %ecx
cmpl $0x20, %edx
leal -0x2(%rdx,%rdx), %esi
cmovgel %ecx, %esi
movl %esi, (%rsp)
leal (%rdx,%rdx), %ecx
cmovgel %edx, %ecx
movq $-0x1, %rdx
shlq %cl, %rdx
movq %rdx, 0x40(%rsp)
leaq (%rax,%r14), %r13
movq 0x8(%rbx,%rbp), %rcx
movslq (%rax,%r14), %rax
cmpq %rax, %rcx
jle 0x104054
decl %ecx
movl %ecx, %eax
sarl %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x2, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x4, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x8, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x10, %eax
orl %ecx, %eax
leal 0x1(%rax), %ecx
movl %ecx, (%r13)
movq 0x8(%r13), %rdi
cltq
leaq 0x4(,%rax,4), %rsi
callq 0x2370
movq %rax, 0x8(%r13)
movq 0x8(%r13), %rdi
movq 0x8(%r15), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x20e0
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movapd %xmm0, 0x20(%rsp)
movq 0x8(%r15), %rdx
testq %rdx, %rdx
movq 0x40(%rsp), %r14
jle 0x1043eb
notq %r14
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rbp
movq 0x20(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x28(%rsp), %rax
movq %rax, 0x8(%rsp)
movq (%r15), %r11
movl (%rsp), %eax
movq %rax, (%rsp)
leaq 0x129955(%rip), %rcx    # 0x22da10
xorl %ebx, %ebx
xorl %esi, %esi
movq %r14, 0x40(%rsp)
movq %r11, 0xb0(%rsp)
movq %r12, 0x38(%rsp)
movq %r13, 0x30(%rsp)
movzbl (%r11,%rbx), %eax
movzbl (%rcx,%rax), %eax
cmpl $0x3, %eax
ja 0x104121
movq 0x18(%r12), %r15
movl (%r15), %r9d
cmpl $0x1f, %r9d
jg 0x10414a
movl %eax, %ecx
leaq (%rcx,%rdi,4), %rdi
andq %r14, %rdi
movl $0x3, %r8d
subq %rax, %r8
movq (%rsp), %rcx
shlq %cl, %r8
movq %rdi, 0x10(%rsp)
shrq $0x2, %rbp
orq %r8, %rbp
movq %rbp, 0x18(%rsp)
jmp 0x1041b4
movapd %xmm0, 0x20(%rsp)
movapd %xmm0, 0x10(%rsp)
xorl %edi, %edi
xorl %ebp, %ebp
movq $0x0, 0x48(%rsp)
movq $0x0, 0x8(%rsp)
xorl %esi, %esi
jmp 0x1043df
movl %eax, %r8d
andl $0x1, %r8d
leaq (%r8,%rdi,2), %rdi
andq %r14, %rdi
movq %rdi, 0x10(%rsp)
addq %rbp, %rbp
shrl %eax
movq %rax, %r10
orq %rbp, %r10
andq %r14, %r10
movq %r10, 0x18(%rsp)
movq 0x48(%rsp), %rbp
shrq %rbp
xorl $0x1, %r8d
movq (%rsp), %rcx
shlq %cl, %r8
orq %r8, %rbp
movq %rbp, 0x48(%rsp)
movq %rbp, 0x20(%rsp)
movl $0x1, %r8d
subl %eax, %r8d
shlq %cl, %r8
movq 0x8(%rsp), %rcx
shrq %rcx
orq %r8, %rcx
movq %rcx, 0x8(%rsp)
movq %rcx, 0x28(%rsp)
movq %r10, %rbp
incl %esi
cmpl (%r12), %esi
jl 0x1043d8
incl 0x98(%rsp)
cmpl $0x1f, %r9d
jg 0x10422e
cmpq %rbp, %rdi
movq %rbp, %rax
cmovbq %rdi, %rax
movq %rax, %rcx
notq %rcx
shlq $0x15, %rax
addq %rcx, %rax
andq %r14, %rax
movq %rax, %rcx
shrq $0x18, %rcx
xorq %rax, %rcx
imulq $0x109, %rcx, %rax      # imm = 0x109
andq %r14, %rax
movq %rax, %rcx
shrq $0xe, %rcx
xorq %rax, %rcx
leaq (%rcx,%rcx,4), %rax
leaq (%rcx,%rax,4), %rax
andq %r14, %rax
movq %r14, %rcx
movq %rax, %r14
shrq $0x1c, %r14
xorq %rax, %r14
movl $0x80000001, %eax       # imm = 0x80000001
imulq %rax, %r14
andq %rcx, %r14
jmp 0x1042c5
xorl %eax, %eax
cmpq 0x8(%rsp), %rbp
setae %al
shll $0x4, %eax
movq 0x10(%rsp,%rax), %rcx
movq 0x18(%rsp,%rax), %rax
movq %rcx, %r8
notq %r8
shlq $0x15, %rcx
addq %r8, %rcx
movq %rcx, %r8
shrq $0x18, %r8
xorq %rcx, %r8
imulq $0x109, %r8, %rcx       # imm = 0x109
movq %rcx, %r8
shrq $0xe, %r8
xorq %rcx, %r8
leaq (%r8,%r8,4), %rcx
leaq (%r8,%rcx,4), %rcx
movq %rcx, %r8
shrq $0x1c, %r8
xorq %rcx, %r8
movq %rax, %rcx
notq %rcx
shlq $0x15, %rax
addq %rcx, %rax
movq %rax, %rcx
shrq $0x18, %rcx
xorq %rax, %rcx
imulq $0x109, %rcx, %rax      # imm = 0x109
movq %rax, %rcx
shrq $0xe, %rcx
xorq %rax, %rcx
leaq (%rcx,%rcx,4), %rax
leaq (%rcx,%rax,4), %rax
movq %rax, %r14
shrq $0x1c, %r14
xorq %rax, %r14
addq %r8, %r14
movl $0x80000001, %eax       # imm = 0x80000001
imulq %rax, %r14
movb 0x4(%r15), %cl
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
shll %cl, %eax
notl %eax
movq 0x18(%r15), %r8
andl %r14d, %eax
movq (%r8,%rax,8), %r8
shrq %cl, %r14
movq 0x10(%r8), %r9
xorl %r15d, %r15d
movl $0x0, %eax
testq %r9, %r9
je 0x104356
movb (%r8), %cl
movl $0x1, %eax
shll %cl, %eax
movq %r14, %r13
imull $0x9e3779b9, %r14d, %r12d # imm = 0x9E3779B9
negb %cl
shrl %cl, %r12d
shlq $0xa, %r13
leal -0x1(%rax), %ecx
movq 0x8(%r8), %r10
movl %r12d, %r14d
movl %r14d, %r11d
shrl $0x5, %r11d
movl (%r10,%r11,4), %r11d
btl %r14d, %r11d
jae 0x10434c
movl %r14d, %r11d
movq (%r9,%r11,8), %r11
xorq %r13, %r11
cmpq $0x400, %r11            # imm = 0x400
jb 0x104349
incl %r14d
andl %ecx, %r14d
cmpl %r12d, %r14d
jne 0x104318
jmp 0x10434c
movl %r14d, %eax
movq 0x38(%rsp), %r12
movq 0x30(%rsp), %r13
testq %r9, %r9
je 0x104367
movb (%r8), %cl
movl $0x1, %r15d
shll %cl, %r15d
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl %r15d, %eax
movq 0x40(%rsp), %r14
je 0x104383
movl %eax, %eax
movl (%r9,%rax,8), %ecx
movl $0x3ff, %eax            # imm = 0x3FF
andl %eax, %ecx
testl %ecx, %ecx
movl $0x0, %eax
cmovlel %eax, %ecx
movl %ecx, %eax
andl $0x3, %eax
movl %ecx, %r8d
shrl $0x2, %r8d
andl $0x3, %r8d
movl %eax, %r9d
xorl $0x2, %r9d
movl %r8d, %r10d
xorl $0x2, %r10d
xorl %r11d, %r11d
orl %eax, %r10d
sete %r11b
addl %r11d, %r11d
orl %r8d, %r9d
movl $0x1, %eax
cmovel %eax, %r11d
movq 0x8(%r13), %rax
movl %r11d, (%rax,%rbx,4)
incl 0x50(%rsp,%rcx,4)
movq 0xb0(%rsp), %r11
leaq 0x129631(%rip), %rcx    # 0x22da10
incq %rbx
cmpq %rdx, %rbx
jne 0x1040d6
testq %rdx, %rdx
jle 0x104448
xorl %ecx, %ecx
movl $0x1, %eax
movslq %ecx, %rsi
cmpq $0x1, %rdx
je 0x10440e
movq 0x8(%r13), %rdi
movl (%rdi,%rax,4), %r8d
cmpl (%rdi,%rsi,4), %r8d
je 0x104440
movq 0x8(%r13), %rdi
movl (%rdi,%rsi,4), %esi
testl %esi, %esi
je 0x10443e
movl %eax, %edi
subl %ecx, %edi
movl (%r12), %r8d
addl $-0x4, %r8d
cmpl %r8d, %edi
jl 0x10443e
decl %esi
movl 0x90(%rsp,%rsi,4), %edi
subl %ecx, %edi
addl %eax, %edi
movl %edi, 0x90(%rsp,%rsi,4)
movl %eax, %ecx
incq %rax
decq %rdx
jne 0x1043f7
movl (%r12), %eax
movl 0x90(%rsp), %edx
movl 0x94(%rsp), %ecx
orl %edx, %ecx
jne 0x104492
movl 0x58(%rsp), %edx
movl 0x70(%rsp), %esi
movb $0x30, %cl
cmpl %esi, %edx
je 0x104589
leal (%rsi,%rax), %ecx
addl $-0x4, %ecx
cmpl %ecx, %edx
jge 0x10453c
addl $-0x4, %eax
addl %edx, %eax
cmpl %eax, %esi
jge 0x104562
movb $0x30, %cl
jmp 0x104589
movsd 0x10(%r12), %xmm0
movb $0x61, %cl
cmpl %eax, %edx
jle 0x1044ac
cmpl %eax, 0x94(%rsp)
jg 0x104589
movl 0x94(%rsp), %esi
leal (%rsi,%rax), %ecx
addl $-0x4, %ecx
cmpl %ecx, %edx
jl 0x1044f5
cvtsi2sd %edx, %xmm1
mulsd 0x120fff(%rip), %xmm1   # 0x2254c8
cvtsi2sd %esi, %xmm2
ucomisd %xmm2, %xmm1
jb 0x1044f5
xorps %xmm1, %xmm1
cvtsi2sdl 0x58(%rsp), %xmm1
xorps %xmm2, %xmm2
cvtsi2sdl 0x70(%rsp), %xmm2
mulsd %xmm0, %xmm1
movb $0x70, %cl
ucomisd %xmm2, %xmm1
ja 0x104589
addl $-0x4, %eax
addl %edx, %eax
cmpl %eax, %esi
jl 0x104538
xorps %xmm1, %xmm1
cvtsi2sd %esi, %xmm1
mulsd 0x120fbb(%rip), %xmm1   # 0x2254c8
xorps %xmm2, %xmm2
cvtsi2sd %edx, %xmm2
ucomisd %xmm2, %xmm1
jb 0x104538
xorps %xmm1, %xmm1
cvtsi2sdl 0x70(%rsp), %xmm1
xorps %xmm2, %xmm2
cvtsi2sdl 0x58(%rsp), %xmm2
mulsd %xmm1, %xmm0
movb $0x6d, %cl
ucomisd %xmm2, %xmm0
ja 0x104589
movb $0x61, %cl
jmp 0x104589
movb $0x70, %cl
cmpl $0x2, %esi
jl 0x104589
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
mulsd 0x120f76(%rip), %xmm0   # 0x2254c8
cvtsi2sd %esi, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x10447e
jmp 0x104589
movb $0x6d, %cl
cmpl $0x2, %edx
jl 0x104589
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
mulsd 0x120f50(%rip), %xmm0   # 0x2254c8
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x10448b
movq 0x30(%r12), %rax
movq 0x28(%rax), %rax
movq 0xa8(%rsp), %rdx
movb $0x0, (%rax,%rdx)
cmpb $0x70, %cl
je 0x1045af
movzbl %cl, %eax
cmpl $0x6d, %eax
jne 0x1045bd
movb $0x2, %al
jmp 0x1045b1
movb $0x1, %al
movq 0x30(%r12), %rcx
movq 0x28(%rcx), %rcx
movb %al, (%rcx,%rdx)
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq