// File: /workspace/github_c_makefile_star2_O3/lh3[P]minimap/sdust.c
// Function: sdust_core
const uint64_t *sdust_core(const uint8_t *seq, int l_seq, int T, int W, int *n, sdust_buf_t *buf)
{
	int rv = 0, rw = 0, L = 0, cv[SD_WTOT], cw[SD_WTOT];
	int i, start, l; // _start_: start of the current window; _l_: length of a contiguous A/C/G/T (sub)sequence
	unsigned t; // current word

	buf->P.n = buf->res.n = 0;
	buf->w->front = buf->w->count = 0;
	memset(cv, 0, SD_WTOT * sizeof(int));
	memset(cw, 0, SD_WTOT * sizeof(int));
	if (l_seq < 0) l_seq = strlen((const char*)seq);
	for (i = l = t = 0; i <= l_seq; ++i) {
		int b = i < l_seq? seq_nt4_table[seq[i]] : 4;
		if (b < 4) { // an A/C/G/T base
			++l, t = (t<<2 | b) & SD_WMSK;
			if (l >= SD_WLEN) { // we have seen a word
				start = (l - W > 0? l - W : 0) + (i + 1 - l); // set the start of the current window
				save_masked_regions(&buf->res, &buf->P, start); // save intervals falling out of the current window?
				shift_window(t, buf->w, T, W, &L, &rw, &rv, cw, cv);
				if (rw * 10 > L * T)
					find_perfect(&buf->P, buf->w, T, start, L, rv, cv);
			}
		} else { // N or the end of sequence; N effectively breaks input into pieces of independent sequences
			start = (l - W + 1 > 0? l - W + 1 : 0) + (i + 1 - l);
			while (buf->P.n) save_masked_regions(&buf->res, &buf->P, start++); // clear up unsaved perfect intervals
			l = t = 0;
		}
	}
	*n = buf->res.n;
	return buf->res.a;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x388, %rsp            # imm = 0x388
movq %r9, %rbx
movq %r8, 0x58(%rsp)
movq %rcx, 0x30(%rsp)
movq %rdx, 0x38(%rsp)
movl %esi, %r14d
movq %rdi, 0x50(%rsp)
movabsq $-0x400000000000000, %rcx # imm = 0xFC00000000000000
xorl %edx, %edx
movq %rdx, 0x20(%r9)
movq %rdx, 0x8(%r9)
movq (%r9), %rax
movq %rdx, 0x8(%rax)
andq %rcx, (%rax)
leaq 0x80(%rsp), %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x2130
leaq 0x180(%rsp), %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x2130
movq %r14, %rcx
testl %r14d, %r14d
jns 0x7422
movq 0x50(%rsp), %rdi
callq 0x20d0
movq %rax, %rcx
testl %eax, %eax
js 0x7c35
movabsq $0x3ffffffffffffff, %r15 # imm = 0x3FFFFFFFFFFFFFF
movq 0x30(%rsp), %rax
addl $-0x2, %eax
cltq
movq %rax, 0x68(%rsp)
movq 0x38(%rsp), %rax
addl %eax, %eax
movl %eax, 0x44(%rsp)
movl %ecx, %eax
movq %rax, 0x70(%rsp)
incl %ecx
movq %rcx, 0x78(%rsp)
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %esi, %esi
xorl %r9d, %r9d
xorl %eax, %eax
xorl %r13d, %r13d
xorl %edi, %edi
xorl %r12d, %r12d
cmpq 0x70(%rsp), %rsi
jae 0x7553
movq 0x50(%rsp), %rcx
movzbl (%rcx,%rsi), %ecx
leaq 0x3d1c(%rip), %rdx      # 0xb1a0
movzbl (%rdx,%rcx), %ecx
cmpl $0x3, %ecx
ja 0x7553
leal 0x1(%rax), %edx
andl $0xf, %r9d
leal (%rcx,%r9,4), %r9d
cmpl $0x2, %eax
jl 0x769f
movl %edi, 0x8(%rsp)
movq %r9, 0x10(%rsp)
movl %edx, 0x24(%rsp)
movl %edx, %ecx
subl 0x30(%rsp), %ecx
testl %ecx, %ecx
movl $0x0, %edx
cmovlel %edx, %ecx
movq %rsi, 0x48(%rsp)
subl %eax, %esi
addl %ecx, %esi
movq %rsi, 0x18(%rsp)
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x772d
movq 0x18(%rbx), %r14
shlq $0x4, %rax
movl -0x10(%r14,%rax), %edx
cmpl 0x18(%rsp), %edx
jge 0x772d
addq %rax, %r14
movq 0x20(%rbx), %rcx
testq %rcx, %rcx
je 0x7511
movq 0x30(%rbx), %rax
movq -0x8(%rax,%rcx,8), %rsi
cmpl %esi, %edx
jle 0x76c4
cmpq 0x28(%rbx), %rcx
jne 0x76a7
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x28(%rbx)
movq 0x30(%rbx), %rdi
shlq $0x3, %rsi
callq 0x2200
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq %rax, 0x30(%rbx)
movl -0x10(%r14), %edx
movq 0x20(%rbx), %rcx
jmp 0x76ab
movq 0x8(%rbx), %rcx
xorl %edx, %edx
testq %rcx, %rcx
je 0x7694
movl %edi, 0x8(%rsp)
movl %r12d, (%rsp)
movl %r13d, %r12d
movq %rsi, %r13
movl %esi, %edx
subl %eax, %edx
subl 0x30(%rsp), %eax
cmovsl %r8d, %eax
leal (%rdx,%rax), %ebp
addl $0x2, %ebp
movq 0x18(%rbx), %r14
movq %rcx, %rax
shlq $0x4, %rax
movl -0x10(%r14,%rax), %edx
cmpl %ebp, %edx
jge 0x766e
addq %rax, %r14
movq 0x20(%rbx), %rcx
testq %rcx, %rcx
je 0x75b3
movq 0x30(%rbx), %rax
movq -0x8(%rax,%rcx,8), %rsi
cmpl %esi, %edx
jle 0x760b
cmpq 0x28(%rbx), %rcx
jne 0x75ee
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x28(%rbx)
movq 0x30(%rbx), %rdi
shlq $0x3, %rsi
callq 0x2200
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq %rax, 0x30(%rbx)
movl -0x10(%r14), %edx
movq 0x20(%rbx), %rcx
jmp 0x75f2
movq 0x30(%rbx), %rax
shlq $0x20, %rdx
movslq -0xc(%r14), %rsi
orq %rdx, %rsi
leaq 0x1(%rcx), %rdx
movq %rdx, 0x20(%rbx)
movq %rsi, (%rax,%rcx,8)
jmp 0x762f
movq %rsi, %rdx
movabsq $-0x100000000, %rdi     # imm = 0xFFFFFFFF00000000
andq %rdi, %rdx
movl -0xc(%r14), %edi
cmpl %esi, %edi
cmovlel %esi, %edi
movslq %edi, %rsi
orq %rdx, %rsi
movq %rsi, -0x8(%rax,%rcx,8)
movq 0x8(%rbx), %rax
leal -0x1(%rax), %ecx
cmpl $-0x1, %ecx
cmovgel %r8d, %ecx
incl %ecx
leal 0x1(%rax), %edx
decq %rax
testl %eax, %eax
js 0x7665
movq 0x18(%rbx), %rsi
movl %eax, %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
shlq $0x4, %rdi
decl %edx
decq %rax
cmpl %ebp, (%rsi,%rdi)
jl 0x7645
jmp 0x7667
movl %ecx, %edx
movslq %edx, %rcx
movq %rcx, 0x8(%rbx)
incl %ebp
testq %rcx, %rcx
jne 0x7582
movl 0x8(%rsp), %eax
movl %eax, %r11d
xorl %r9d, %r9d
movq %r13, %rsi
movl %r12d, %r13d
movl (%rsp), %r12d
xorl %edx, %edx
jmp 0x7bfd
movl %edi, %r11d
xorl %r9d, %r9d
jmp 0x7bfd
movl %edi, %r11d
jmp 0x7bfd
movq 0x30(%rbx), %rax
shlq $0x20, %rdx
movslq -0xc(%r14), %rsi
orq %rdx, %rsi
leaq 0x1(%rcx), %rdx
movq %rdx, 0x20(%rbx)
movq %rsi, (%rax,%rcx,8)
jmp 0x76e8
movq %rsi, %rdx
movabsq $-0x100000000, %rdi     # imm = 0xFFFFFFFF00000000
andq %rdi, %rdx
movl -0xc(%r14), %edi
cmpl %esi, %edi
cmovlel %esi, %edi
movslq %edi, %rsi
orq %rdx, %rsi
movq %rsi, -0x8(%rax,%rcx,8)
movq 0x8(%rbx), %rax
leal -0x1(%rax), %ecx
cmpl $-0x1, %ecx
cmovgel %r8d, %ecx
incl %ecx
leal 0x1(%rax), %edx
decq %rax
testl %eax, %eax
js 0x7724
movq 0x18(%rbx), %rsi
movl %eax, %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
shlq $0x4, %rdi
decl %edx
decq %rax
movq 0x18(%rsp), %r9
cmpl %r9d, (%rsi,%rdi)
jl 0x76fe
jmp 0x7726
movl %ecx, %edx
movslq %edx, %rax
movq %rax, 0x8(%rbx)
movq (%rbx), %r14
movq (%r14), %rsi
movq 0x8(%r14), %rbp
cmpq 0x68(%rsp), %rbp
jae 0x774a
movq 0x10(%rsp), %r9
movl 0x8(%rsp), %r10d
jmp 0x77ba
movq 0x18(%r14), %rax
movq %rsi, %rcx
andq %r15, %rcx
movq %rsi, %rdx
incq %rsi
andq %r15, %rsi
movabsq $-0x400000000000000, %rdi # imm = 0xFC00000000000000
andq %rdi, %rdx
andq 0x10(%r14), %rsi
orq %rdx, %rsi
movq %rsi, (%r14)
decq %rbp
movq %rbp, 0x8(%r14)
movslq (%rax,%rcx,4), %rax
movl 0x180(%rsp,%rax,4), %ecx
decl %ecx
movl %ecx, 0x180(%rsp,%rax,4)
movl 0x8(%rsp), %r10d
subl %ecx, %r10d
movslq %r13d, %rcx
cmpq %rcx, %rbp
jae 0x77b5
decl %r13d
movl 0x80(%rsp,%rax,4), %ecx
decl %ecx
movl %ecx, 0x80(%rsp,%rax,4)
subl %ecx, %r12d
movq 0x10(%rsp), %r9
movq %rsi, %rax
shrq $0x3a, %rax
movl $0x1, %edx
movl %eax, %ecx
shlq %cl, %rdx
cmpq %rdx, %rbp
jne 0x7917
movq %r14, (%rsp)
movl %r10d, 0x8(%rsp)
leal 0x1(%rax), %r14d
movl $0x1, %edx
movl %r14d, %ecx
shlq %cl, %rdx
cmpq %rbp, %rdx
jae 0x7835
movq $-0x1, %r14
incq %r14
movq %rbp, %rdx
movl %r14d, %ecx
shrq %cl, %rdx
cmpq $0x3f, %r14
ja 0x780f
testq %rdx, %rdx
jne 0x77f8
cmpq %r14, %rax
jne 0x7c12
movabsq $0x3ffffffffffffff, %r15 # imm = 0x3FFFFFFFFFFFFFF
movq 0x10(%rsp), %r9
movl 0x8(%rsp), %r10d
movq (%rsp), %r14
jmp 0x7917
movq %rdx, 0x28(%rsp)
movq (%rsp), %r15
movq 0x18(%r15), %rdi
movl $0x4, %esi
movl %r14d, %ecx
shlq %cl, %rsi
callq 0x2200
movq %rax, 0x18(%r15)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0x28(%rsp), %r15
movq %rsi, %rax
movabsq $0x3ffffffffffffff, %rcx # imm = 0x3FFFFFFFFFFFFFF
andq %rcx, %rax
addq %rax, %rdx
cmpq %rbp, %rdx
jbe 0x78ae
movq (%rsp), %rcx
movq 0x18(%rcx), %rcx
movq %rbp, %rdx
subq %rax, %rdx
movq %r15, %rsi
subq %rdx, %rsi
leaq (%rcx,%rsi,4), %rdi
leaq (%rcx,%rax,4), %rsi
shlq $0x2, %rdx
callq 0x2220
movq (%rsp), %rdi
subq %rbp, %r15
addq (%rdi), %r15
movq %r15, %rsi
jmp 0x78d2
subq %r15, %rdx
movq (%rsp), %rdi
jbe 0x78d2
movq %rdi, %rbp
movq 0x18(%rdi), %rdi
leaq (%rdi,%r15,4), %rsi
shlq $0x2, %rdx
callq 0x2220
movq %rbp, %rdi
movq (%rbp), %rsi
movq %r14, %rax
shlq $0x3a, %rax
movabsq $0x3ffffffffffffff, %r15 # imm = 0x3FFFFFFFFFFFFFF
andq %r15, %rsi
orq %rax, %rsi
movq $-0x1, %rax
movl %r14d, %ecx
shlq %cl, %rax
movq %rsi, (%rdi)
notq %rax
movq %rax, 0x10(%rdi)
movq 0x8(%rdi), %rbp
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq 0x10(%rsp), %r9
movl 0x8(%rsp), %r10d
movq %rdi, %r14
movq 0x10(%r14), %rax
movq 0x18(%r14), %rcx
leaq 0x1(%rbp), %rdx
movq %rdx, 0x8(%r14)
andq %r15, %rsi
addq %rbp, %rsi
andq %rax, %rsi
movl %r9d, (%rcx,%rsi,4)
incl %r13d
leal (,%r9,4), %edx
movl 0x180(%rsp,%rdx), %r11d
leal 0x1(%r11), %esi
movl %esi, 0x180(%rsp,%rdx)
movl 0x80(%rsp,%rdx), %esi
leal 0x1(%rsi), %edi
movl %edi, 0x80(%rsp,%rdx)
addl %esi, %r12d
leal 0x2(,%rsi,2), %edx
leal (%rdx,%rdx,4), %edx
cmpl 0x44(%rsp), %edx
jle 0x79b0
movq (%r14), %rdx
andq %r15, %rdx
movslq %r13d, %rsi
addq %rdx, %rbp
subq %rsi, %rbp
incq %rbp
movq %rbp, %rdx
andq %rax, %rdx
movslq (%rcx,%rdx,4), %rdx
movl 0x80(%rsp,%rdx,4), %esi
decl %esi
movl %esi, 0x80(%rsp,%rdx,4)
subl %esi, %r12d
incq %rbp
decl %r13d
cmpl %r9d, %edx
jne 0x7988
addl %r10d, %r11d
leal (%r11,%r11), %eax
leal (%rax,%rax,4), %eax
movl %r13d, %ecx
imull 0x38(%rsp), %ecx
cmpl %ecx, %eax
jle 0x7bf4
movq %r11, 0x60(%rsp)
movl %r12d, (%rsp)
movq (%rbx), %r14
movl $0x100, %edx            # imm = 0x100
leaq 0x280(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x2190
movq %r14, 0x8(%rsp)
movq 0x8(%r14), %rax
movl %r13d, 0x40(%rsp)
movl %r13d, %ecx
notl %ecx
addl %eax, %ecx
js 0x7bd0
movq 0x18(%rsp), %rdx
addl $0x2, %edx
movq %rdx, 0x28(%rsp)
movl %ecx, %r14d
xorl %ecx, %ecx
movl (%rsp), %edx
movl %edx, %r13d
xorl %r12d, %r12d
movq 0x8(%rsp), %rsi
movq 0x18(%rsi), %rdx
movq (%rsi), %rdi
andq %r15, %rdi
addq %r14, %rdi
andq 0x10(%rsi), %rdi
movslq (%rdx,%rdi,4), %rdx
movl 0x280(%rsp,%rdx,4), %edi
leal 0x1(%rdi), %r8d
movl %r8d, 0x280(%rsp,%rdx,4)
addl %edi, %r13d
movl %r14d, %ebp
notl %ebp
addl %eax, %ebp
leal (,%r13,2), %edx
leal (%rdx,%rdx,4), %edx
movl %ebp, %edi
imull 0x38(%rsp), %edi
cmpl %edi, %edx
jle 0x7bb6
movq 0x8(%rbx), %rdx
testq %rdx, %rdx
je 0x7ad9
movq 0x18(%rbx), %rdi
movq 0x18(%rsp), %rsi
leal (%rsi,%r14), %r8d
addq $0xc, %rdi
xorl %r15d, %r15d
cmpl %r8d, -0xc(%rdi)
jl 0x7adc
movl -0x4(%rdi), %r9d
testl %ecx, %ecx
je 0x7ac2
movl %r9d, %r11d
imull %r12d, %r11d
movl (%rdi), %esi
movl %esi, %r10d
imull %ecx, %r10d
cmpl %r10d, %r11d
jg 0x7abd
movl %r12d, %esi
movl %ecx, %r9d
movl %esi, %r12d
jmp 0x7ac5
movl (%rdi), %r12d
movl %r9d, %ecx
incq %r15
addq $0x10, %rdi
cmpq %r15, %rdx
jne 0x7a94
movq %rdx, %r15
jmp 0x7adc
xorl %r15d, %r15d
testl %ecx, %ecx
je 0x7af4
movl %r12d, %esi
imull %r13d, %esi
movl %ecx, %edi
imull %ebp, %edi
cmpl %edi, %esi
jl 0x7bb6
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rsi
cmpq %rax, %rdx
setne %cl
leaq 0x1(%rdx), %rdi
cmpq %rdi, %rax
setae %al
orb %cl, %al
jne 0x7b62
movq %rdx, %rax
shrq %rax
orq %rdx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x10, %rax
orq %rcx, %rax
incq %rax
movq %rax, 0x10(%rbx)
shlq $0x4, %rax
movq %rsi, %rdi
movq %rax, %rsi
callq 0x2200
movq %rax, %rsi
movq %rax, 0x18(%rbx)
movq 0x8(%rbx), %rdx
subq %r15, %rdx
shlq $0x4, %r15
leaq (%rsi,%r15), %rdi
addq $0x10, %rdi
addq %r15, %rsi
shlq $0x4, %rdx
callq 0x2220
incq 0x8(%rbx)
movq 0x18(%rsp), %rax
addl %r14d, %eax
movq 0x18(%rbx), %rcx
movl %eax, (%rcx,%r15)
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x28(%rsp), %rdx
addl %eax, %edx
movl %edx, 0x4(%rcx,%r15)
movl %r13d, 0x8(%rcx,%r15)
movl %ebp, 0xc(%rcx,%r15)
movl %ebp, %r12d
movl %r13d, %ecx
leaq -0x1(%r14), %rdx
testl %r14d, %r14d
movq %rdx, %r14
movabsq $0x3ffffffffffffff, %r15 # imm = 0x3FFFFFFFFFFFFFF
jg 0x7a26
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq 0x48(%rsp), %rsi
movl 0x40(%rsp), %r13d
movl (%rsp), %r12d
movl 0x24(%rsp), %edx
movq 0x10(%rsp), %r9
movq 0x60(%rsp), %r11
jmp 0x7bfd
movq 0x48(%rsp), %rsi
movl 0x24(%rsp), %edx
incq %rsi
movl %edx, %eax
movl %r11d, %edi
cmpq 0x78(%rsp), %rsi
jne 0x7469
jmp 0x7c35
movl $0x1, %r15d
movl %r14d, %ecx
shlq %cl, %r15
cmpq %rax, %r14
jbe 0x7c2d
movq %r15, 0x28(%rsp)
jmp 0x783a
movq %rbp, %rdx
jmp 0x7862
movl 0x20(%rbx), %eax
movq 0x58(%rsp), %rcx
movl %eax, (%rcx)
movq 0x30(%rbx), %rax
addq $0x388, %rsp            # imm = 0x388
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq