// File: /workspace/github_c_makefile_star2_O0/lh3[P]miniprot/sketch.c
// Function: mp_sketch_nt4
void mp_sketch_nt4(void *km, const uint8_t *seq, int64_t len, int32_t min_aa_len, int32_t kmer, int32_t mod_bit, int32_t bbit, int64_t boff, mp64_v *a)
{
	uint8_t codon, p, q;
	int64_t i, j, l, e[3], k[3];
	kv_resize(uint64_t, km, *a, len>>2);
	a->n = 0;
	for (p = 0; p < 3; ++p)
		e[p] = -1, k[p] = 0;
	for (i = 0, p = 1, codon = 0, l = 0; i < len; ++i, ++p) {
		if (p == 3) p = 0;
		if (seq[i] < 4) {
			codon = (codon << 2 | seq[i]) & 0x3f;
			if (++l >= 3) {
				uint8_t aa = ns_tab_codon[codon];
				if (aa >= 20) {
					if (k[p] >= min_aa_len)
						mp_sketch_clean_orf(km, seq, e[p] + 1 - k[p] * 3, e[p] + 1, kmer, mod_bit, bbit, boff, a);
					k[p] = 0, e[p] = -1;
				} else e[p] = i, ++k[p];
			}
		} else {
			for (q = 0; q < 3; ++q) {
				if (k[q] >= min_aa_len)
					mp_sketch_clean_orf(km, seq, e[q] + 1 - k[q] * 3, e[q] + 1, kmer, mod_bit, bbit, boff, a);
				k[q] = 0, e[q] = -1;
			}
			l = 0, codon = 0;
		}
	}
	for (p = 0; p < 3; ++p)
		if (k[p] >= min_aa_len)
			mp_sketch_clean_orf(km, seq, e[p] + 1 - k[p] * 3, e[p] + 1, kmer, mod_bit, bbit, boff, a);
	if (a->n <= 1) return; // the following loop doesn't work when a->n == 0
	radix_sort_mp64(a->a, a->a + a->n);
	for (i = 1, j = 0; i < a->n; ++i) // squeeze out identical entries
		if (a->a[j] != a->a[i])
			a->a[++j] = a->a[i];
	a->n = ++j;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movq 0x20(%rbp), %rax
movslq 0x4(%rax), %rax
movq -0x18(%rbp), %rcx
sarq $0x2, %rcx
cmpq %rcx, %rax
jge 0x185ac
movq -0x18(%rbp), %rax
sarq $0x2, %rax
movl %eax, %ecx
movq 0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
movq 0x20(%rbp), %rax
movl 0x4(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x4(%rax)
movq 0x20(%rbp), %rax
movl 0x4(%rax), %ecx
sarl %ecx
movq 0x20(%rbp), %rax
orl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movq 0x20(%rbp), %rax
movl 0x4(%rax), %ecx
sarl $0x2, %ecx
movq 0x20(%rbp), %rax
orl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movq 0x20(%rbp), %rax
movl 0x4(%rax), %ecx
sarl $0x4, %ecx
movq 0x20(%rbp), %rax
orl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movq 0x20(%rbp), %rax
movl 0x4(%rax), %ecx
sarl $0x8, %ecx
movq 0x20(%rbp), %rax
orl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movq 0x20(%rbp), %rax
movl 0x4(%rax), %ecx
sarl $0x10, %ecx
movq 0x20(%rbp), %rax
orl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movq 0x20(%rbp), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rdi
movq 0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movq 0x20(%rbp), %rax
movslq 0x4(%rax), %rdx
shlq $0x3, %rdx
callq 0xb100
movq %rax, %rcx
movq 0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x185ae
movq 0x20(%rbp), %rax
movl $0x0, (%rax)
movb $0x0, -0x26(%rbp)
movzbl -0x26(%rbp), %eax
cmpl $0x3, %eax
jge 0x185e9
movzbl -0x26(%rbp), %eax
movq $-0x1, -0x60(%rbp,%rax,8)
movzbl -0x26(%rbp), %eax
movq $0x0, -0x80(%rbp,%rax,8)
movb -0x26(%rbp), %al
addb $0x1, %al
movb %al, -0x26(%rbp)
jmp 0x185bc
movq $0x0, -0x30(%rbp)
movb $0x1, -0x26(%rbp)
movb $0x0, -0x25(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x18(%rbp), %rax
jge 0x187f9
movzbl -0x26(%rbp), %eax
cmpl $0x3, %eax
jne 0x1861c
movb $0x0, -0x26(%rbp)
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x4, %eax
jge 0x18732
movzbl -0x25(%rbp), %eax
shll $0x2, %eax
movq -0x10(%rbp), %rcx
movq -0x30(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
orl %ecx, %eax
andl $0x3f, %eax
movb %al, -0x25(%rbp)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
cmpq $0x3, %rax
jl 0x1872d
movzbl -0x25(%rbp), %eax
movl %eax, %ecx
leaq 0xe381(%rip), %rax      # 0x269f0
movb (%rax,%rcx), %al
movb %al, -0x81(%rbp)
movzbl -0x81(%rbp), %eax
cmpl $0x14, %eax
jl 0x1870c
movzbl -0x26(%rbp), %eax
movq -0x80(%rbp,%rax,8), %rax
movslq -0x1c(%rbp), %rcx
cmpq %rcx, %rax
jl 0x186f0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movzbl -0x26(%rbp), %eax
movq -0x60(%rbp,%rax,8), %rdx
addq $0x1, %rdx
movzbl -0x26(%rbp), %eax
imulq $0x3, -0x80(%rbp,%rax,8), %rax
subq %rax, %rdx
movzbl -0x26(%rbp), %eax
movq -0x60(%rbp,%rax,8), %rcx
addq $0x1, %rcx
movl -0x20(%rbp), %r8d
movl -0x24(%rbp), %r9d
movl 0x10(%rbp), %r11d
movq 0x18(%rbp), %r10
movq 0x20(%rbp), %rax
movl %r11d, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x18270
movzbl -0x26(%rbp), %eax
movq $0x0, -0x80(%rbp,%rax,8)
movzbl -0x26(%rbp), %eax
movq $-0x1, -0x60(%rbp,%rax,8)
jmp 0x1872b
movq -0x30(%rbp), %rcx
movzbl -0x26(%rbp), %eax
movq %rcx, -0x60(%rbp,%rax,8)
movzbl -0x26(%rbp), %eax
movq -0x80(%rbp,%rax,8), %rcx
addq $0x1, %rcx
movq %rcx, -0x80(%rbp,%rax,8)
jmp 0x1872d
jmp 0x187de
movb $0x0, -0x27(%rbp)
movzbl -0x27(%rbp), %eax
cmpl $0x3, %eax
jge 0x187d2
movzbl -0x27(%rbp), %eax
movq -0x80(%rbp,%rax,8), %rax
movslq -0x1c(%rbp), %rcx
cmpq %rcx, %rax
jl 0x187ab
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movzbl -0x27(%rbp), %eax
movq -0x60(%rbp,%rax,8), %rdx
addq $0x1, %rdx
movzbl -0x27(%rbp), %eax
imulq $0x3, -0x80(%rbp,%rax,8), %rax
subq %rax, %rdx
movzbl -0x27(%rbp), %eax
movq -0x60(%rbp,%rax,8), %rcx
addq $0x1, %rcx
movl -0x20(%rbp), %r8d
movl -0x24(%rbp), %r9d
movl 0x10(%rbp), %r11d
movq 0x18(%rbp), %r10
movq 0x20(%rbp), %rax
movl %r11d, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x18270
movzbl -0x27(%rbp), %eax
movq $0x0, -0x80(%rbp,%rax,8)
movzbl -0x27(%rbp), %eax
movq $-0x1, -0x60(%rbp,%rax,8)
movb -0x27(%rbp), %al
addb $0x1, %al
movb %al, -0x27(%rbp)
jmp 0x18736
movq $0x0, -0x40(%rbp)
movb $0x0, -0x25(%rbp)
jmp 0x187e0
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movb -0x26(%rbp), %al
addb $0x1, %al
movb %al, -0x26(%rbp)
jmp 0x18601
movb $0x0, -0x26(%rbp)
movzbl -0x26(%rbp), %eax
cmpl $0x3, %eax
jge 0x1887a
movzbl -0x26(%rbp), %eax
movq -0x80(%rbp,%rax,8), %rax
movslq -0x1c(%rbp), %rcx
cmpq %rcx, %rax
jl 0x1886e
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movzbl -0x26(%rbp), %eax
movq -0x60(%rbp,%rax,8), %rdx
addq $0x1, %rdx
movzbl -0x26(%rbp), %eax
imulq $0x3, -0x80(%rbp,%rax,8), %rax
subq %rax, %rdx
movzbl -0x26(%rbp), %eax
movq -0x60(%rbp,%rax,8), %rcx
addq $0x1, %rcx
movl -0x20(%rbp), %r8d
movl -0x24(%rbp), %r9d
movl 0x10(%rbp), %r11d
movq 0x18(%rbp), %r10
movq 0x20(%rbp), %rax
movl %r11d, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x18270
jmp 0x18870
movb -0x26(%rbp), %al
addb $0x1, %al
movb %al, -0x26(%rbp)
jmp 0x187fd
movq 0x20(%rbp), %rax
cmpl $0x1, (%rax)
jg 0x18888
jmp 0x1893d
movq 0x20(%rbp), %rax
movq 0x8(%rax), %rdi
movq 0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movq 0x20(%rbp), %rax
movslq (%rax), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x46c0
movq $0x1, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x30(%rbp), %rax
movq 0x20(%rbp), %rcx
movslq (%rcx), %rcx
cmpq %rcx, %rax
jge 0x18929
movq 0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x20(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq -0x30(%rbp), %rdx
cmpq (%rcx,%rdx,8), %rax
je 0x18919
movq 0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq 0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x38(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x38(%rbp)
movq %rdx, 0x8(%rax,%rcx,8)
jmp 0x1891b
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x188bb
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movl %eax, %ecx
movq 0x20(%rbp), %rax
movl %ecx, (%rax)
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)