// File: /workspace/github_cpp_makefile_star2_O3/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, %rbx
movslq %edx, %r13
movq %r13, %rbp
shlq $0x5, %rbp
movq 0x28(%rdi), %r15
movq 0x30(%rdi), %rsi
leaq (%r15,%rbp), %r14
movq %r14, %rdi
movq %rax, (%rsp)
movq %rax, %rdx
callq 0x333e0
movq 0x20(%rbx), %rax
shlq $0x4, %r13
pxor %xmm0, %xmm0
movdqu %xmm0, 0x9c(%rsp)
movdqa %xmm0, 0x90(%rsp)
movdqa %xmm0, 0x80(%rsp)
movdqa %xmm0, 0x70(%rsp)
movdqa %xmm0, 0x60(%rsp)
movq %rbx, 0x28(%rsp)
movq 0x18(%rbx), %rcx
movl (%rcx), %edx
leal -0x1(%rdx), %ecx
cmpl $0x20, %edx
leal -0x2(%rdx,%rdx), %ebx
cmovgel %ecx, %ebx
leal (%rdx,%rdx), %ecx
cmovgel %edx, %ecx
movq $-0x1, %r12
shlq %cl, %r12
leaq (%rax,%r13), %r8
movq 0x8(%r15,%rbp), %rdx
movslq (%rax,%r13), %rax
cmpq %rax, %rdx
movq %r8, 0x20(%rsp)
jle 0x108810
decl %edx
movl %edx, %eax
sarl %eax
orl %edx, %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, (%r8)
movq 0x8(%r8), %rdi
cltq
leaq 0x4(,%rax,4), %rsi
movq %r8, %r15
callq 0x2370
movq %rax, %rdi
movq %rax, 0x8(%r15)
movq 0x8(%r14), %rdx
jmp 0x108814
movq 0x8(%r8), %rdi
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x20e0
movq 0x8(%r14), %rdx
testq %rdx, %rdx
movq 0x28(%rsp), %rbp
jle 0x108be1
movq %r12, %r8
notq %r8
movq (%r14), %r9
movl %ebx, %ecx
leaq 0x1313dd(%rip), %r11    # 0x239c20
pcmpeqd %xmm0, %xmm0
movdqa 0x130b51(%rip), %xmm1   # 0x2393a0
movdqa 0x130b59(%rip), %xmm2   # 0x2393b0
xorps %xmm3, %xmm3
xorl %r15d, %r15d
xorl %edi, %edi
xorl %esi, %esi
xorl %r14d, %r14d
xorl %ebx, %ebx
xorl %r10d, %r10d
movq %r8, 0x30(%rsp)
movq %r9, 0x58(%rsp)
movq %rcx, 0x50(%rsp)
movzbl (%r9,%r15), %eax
movzbl (%r11,%rax), %r13d
cmpl $0x3, %r13d
ja 0x1088cc
movq 0x18(%rbp), %r12
cmpl $0x1f, (%r12)
jg 0x1088e7
movl %r13d, %eax
leaq (%rax,%r10,4), %r10
andq %r8, %r10
movq %r10, 0x10(%rsp)
movq %rbx, %rax
shrq $0x2, %rax
movl $0x3, %ebx
subq %r13, %rbx
shlq %cl, %rbx
orq %rax, %rbx
movq %rbx, 0x18(%rsp)
incl %edi
cmpl (%rbp), %edi
jge 0x108954
jmp 0x108b76
movaps %xmm3, 0x10(%rsp)
movaps %xmm3, 0x40(%rsp)
xorl %r10d, %r10d
xorl %ebx, %ebx
xorl %r14d, %r14d
xorl %esi, %esi
xorl %edi, %edi
jmp 0x108b76
movq %r14, %rax
movq %r8, %r14
movl %edi, %r8d
movl %r13d, %edi
andl $0x1, %edi
leaq (%rdi,%r10,2), %r10
andq %r14, %r10
movq %r10, 0x10(%rsp)
addq %rbx, %rbx
shrl %r13d
orq %r13, %rbx
andq %r14, %rbx
movq %rbx, 0x18(%rsp)
shrq %rax
xorl $0x1, %edi
shlq %cl, %rdi
movq %rdi, %r14
movl %r8d, %edi
orq %rax, %r14
movq %r14, 0x40(%rsp)
movq %rsi, %rax
shrq %rax
movl $0x1, %esi
subl %r13d, %esi
shlq %cl, %rsi
orq %rax, %rsi
movq %rsi, 0x48(%rsp)
incl %edi
cmpl (%rbp), %edi
jge 0x1089c2
movq 0x30(%rsp), %r8
jmp 0x108b76
movq %r14, 0x38(%rsp)
movl %edi, 0xc(%rsp)
incl 0xa8(%rsp)
cmpq %rbx, %r10
movq %rbx, %rax
cmovbq %r10, %rax
movq %rax, %rcx
notq %rcx
shlq $0x15, %rax
addq %rcx, %rax
andq %r8, %rax
movq %rax, %rcx
shrq $0x18, %rcx
xorq %rax, %rcx
imulq $0x109, %rcx, %rax      # imm = 0x109
andq %r8, %rax
movq %rax, %rcx
shrq $0xe, %rcx
xorq %rax, %rcx
leaq (%rcx,%rcx,4), %rax
leaq (%rcx,%rax,4), %rax
andq %r8, %rax
movq %rax, %r14
shrq $0x1c, %r14
xorq %rax, %r14
movl $0x80000001, %eax       # imm = 0x80000001
imulq %rax, %r14
andq %r8, %r14
jmp 0x108a6a
movq %r14, 0x38(%rsp)
movl %edi, 0xc(%rsp)
incl 0xa8(%rsp)
cmpq %rsi, %rbx
leaq 0x40(%rsp), %rax
leaq 0x10(%rsp), %rcx
cmovbq %rcx, %rax
movdqa (%rax), %xmm4
movdqa %xmm4, %xmm5
pxor %xmm0, %xmm5
psllq $0x15, %xmm4
paddq %xmm5, %xmm4
movdqa %xmm4, %xmm5
psrlq $0x18, %xmm5
pxor %xmm4, %xmm5
movdqa %xmm5, %xmm4
pmuludq %xmm2, %xmm4
psrlq $0x20, %xmm5
pmuludq %xmm2, %xmm5
psllq $0x20, %xmm5
paddq %xmm4, %xmm5
movdqa %xmm5, %xmm4
psrlq $0xe, %xmm4
pxor %xmm5, %xmm4
movdqa %xmm4, %xmm5
pmuludq %xmm1, %xmm5
psrlq $0x20, %xmm4
pmuludq %xmm1, %xmm4
psllq $0x20, %xmm4
paddq %xmm5, %xmm4
movdqa %xmm4, %xmm5
psrlq $0x1c, %xmm5
pxor %xmm4, %xmm5
pshufd $0xee, %xmm5, %xmm4     # xmm4 = xmm5[2,3,2,3]
paddq %xmm5, %xmm4
movq %xmm4, %r14
movl $0x80000001, %eax       # imm = 0x80000001
imulq %rax, %r14
movb 0x4(%r12), %cl
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
shll %cl, %eax
movq 0x18(%r12), %rdi
notl %eax
andl %r14d, %eax
shrq %cl, %r14
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
movq (%rdi,%rax,8), %r12
movq 0x10(%r12), %r8
testq %r8, %r8
je 0x108b01
movb (%r12), %cl
movl $0x1, %eax
shll %cl, %eax
movq %r14, %r13
imull $0x9e3779b9, %r14d, %edi # imm = 0x9E3779B9
negb %cl
shrl %cl, %edi
shlq $0xa, %r13
leal -0x1(%rax), %ecx
movq 0x8(%r12), %r12
movl %edi, %r14d
movl %r14d, %ebp
shrl $0x5, %ebp
movl (%r12,%rbp,4), %ebp
btl %r14d, %ebp
jae 0x108b01
movl %r14d, %ebp
movq (%r8,%rbp,8), %r9
movq %r9, %rbp
xorq %r13, %rbp
cmpq $0x400, %rbp            # imm = 0x400
jb 0x108af2
incl %r14d
andl %ecx, %r14d
cmpl %edi, %r14d
jne 0x108abf
jmp 0x108b01
cmpl %eax, %r14d
je 0x108b01
andl $0x3ff, %r9d            # imm = 0x3FF
movl %r9d, %r11d
testl %r11d, %r11d
movl $0x0, %eax
cmovlel %eax, %r11d
movl %r11d, %eax
andl $0x3, %eax
movl %r11d, %ecx
shrl $0x2, %ecx
andl $0x3, %ecx
movl %eax, %edi
xorl $0x2, %edi
movl %ecx, %r8d
xorl $0x2, %r8d
xorl %r9d, %r9d
orl %eax, %r8d
sete %r9b
addl %r9d, %r9d
orl %ecx, %edi
movl $0x1, %eax
cmovel %eax, %r9d
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movl %r9d, (%rax,%r15,4)
incl 0x60(%rsp,%r11,4)
movq 0x28(%rsp), %rbp
movq 0x30(%rsp), %r8
movq 0x58(%rsp), %r9
movq 0x50(%rsp), %rcx
leaq 0x1310b3(%rip), %r11    # 0x239c20
movl 0xc(%rsp), %edi
movq 0x38(%rsp), %r14
incq %r15
cmpq %rdx, %r15
jne 0x108878
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
xorl %esi, %esi
movl $0x1, %ecx
movslq %esi, %rdi
cmpq $0x1, %rdx
jne 0x108ba0
movl (%rax,%rdi,4), %edi
jmp 0x108ba8
movl (%rax,%rdi,4), %edi
cmpl %edi, (%rax,%rcx,4)
je 0x108bd9
testl %edi, %edi
je 0x108bd7
movl %ecx, %r8d
subl %esi, %r8d
movl (%rbp), %r9d
addl $-0x4, %r9d
cmpl %r9d, %r8d
jl 0x108bd7
decl %edi
movl 0xa0(%rsp,%rdi,4), %r8d
subl %esi, %r8d
addl %ecx, %r8d
movl %r8d, 0xa0(%rsp,%rdi,4)
movl %ecx, %esi
incq %rcx
decq %rdx
jne 0x108b92
movl (%rbp), %edx
movl 0xa0(%rsp), %edi
movl 0xa4(%rsp), %r8d
movl 0x68(%rsp), %eax
movl 0x80(%rsp), %ecx
movl %edi, %esi
orl %r8d, %esi
jne 0x108c59
cmpl %ecx, %eax
je 0x108cf9
leal (%rcx,%rdx), %esi
addl $-0x4, %esi
cmpl %eax, %esi
jle 0x108d01
addl $-0x4, %edx
addl %eax, %edx
cmpl %ecx, %edx
jg 0x108cf9
movb $0x2, %sil
cmpl $0x2, %eax
jl 0x108d29
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
mulsd 0x128985(%rip), %xmm0   # 0x2315c8
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x108cf9
jmp 0x108d29
cmpl %edx, %edi
setg %sil
cmpl %edx, %r8d
setg %r9b
testb %r9b, %sil
jne 0x108cf9
movsd 0x10(%rbp), %xmm0
leal (%r8,%rdx), %esi
addl $-0x4, %esi
cmpl %edi, %esi
jg 0x108cb7
xorps %xmm1, %xmm1
cvtsi2sd %edi, %xmm1
mulsd 0x12893a(%rip), %xmm1   # 0x2315c8
xorps %xmm2, %xmm2
cvtsi2sd %r8d, %xmm2
ucomisd %xmm2, %xmm1
jb 0x108cb7
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %ecx, %xmm2
mulsd %xmm0, %xmm1
movb $0x1, %sil
ucomisd %xmm2, %xmm1
ja 0x108d29
addl $-0x4, %edx
addl %edi, %edx
cmpl %r8d, %edx
jg 0x108cf9
xorps %xmm1, %xmm1
cvtsi2sd %r8d, %xmm1
mulsd 0x1288f7(%rip), %xmm1   # 0x2315c8
xorps %xmm2, %xmm2
cvtsi2sd %edi, %xmm2
ucomisd %xmm2, %xmm1
jb 0x108cf9
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %eax, %xmm2
mulsd %xmm1, %xmm0
movb $0x2, %sil
ucomisd %xmm2, %xmm0
ja 0x108d29
xorl %esi, %esi
movq (%rsp), %rcx
jmp 0x108d39
movb $0x1, %sil
cmpl $0x2, %ecx
jl 0x108d29
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x1288b0(%rip), %xmm0   # 0x2315c8
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x108c1b
movq 0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rsp), %rcx
movb $0x0, (%rax,%rcx)
movq 0x30(%rbp), %rax
movq 0x28(%rax), %rax
movb %sil, (%rax,%rcx)
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq