// File: /workspace/github_c_makefile_star2_O2/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 $0x3a8, %rsp            # imm = 0x3A8
movq %r9, %r14
movq %r8, 0x70(%rsp)
movl %ecx, %r12d
movl %edx, %ebx
movl %esi, %r15d
andq $0x0, 0x20(%r9)
movq %rdi, 0x50(%rsp)
andq $0x0, 0x8(%r9)
movq (%r9), %rax
andq $0x0, 0x8(%rax)
movabsq $-0x400000000000000, %rcx # imm = 0xFC00000000000000
andq %rcx, (%rax)
leaq 0xa0(%rsp), %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x2130
leaq 0x1a0(%rsp), %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x2130
testl %r15d, %r15d
jns 0x6c64
movq 0x50(%rsp), %rdi
callq 0x20d0
movq %rax, %r15
leaq 0x20(%r14), %rcx
movq %r14, %rdx
addq $0x8, %r14
movq %r12, 0x58(%rsp)
leal -0x2(%r12), %eax
cltq
movq %rax, 0x80(%rsp)
movq %rbx, 0x68(%rsp)
leal (%rbx,%rbx), %eax
movl %eax, 0x4c(%rsp)
movslq %r15d, %rax
movq %rax, 0x98(%rsp)
movq %rcx, %r15
pushq $0x1
popq %rbx
xorl %esi, %esi
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %r12d, %r12d
xorl %eax, %eax
xorl %edi, %edi
movq %rdx, 0x20(%rsp)
movq %rcx, 0x40(%rsp)
cmpq 0x98(%rsp), %rsi
jg 0x72a3
movq %rbp, 0x10(%rsp)
jge 0x6dda
movq 0x50(%rsp), %rcx
movzbl (%rcx,%rsi), %ecx
movq %rsi, 0x38(%rsp)
leaq 0x44ba(%rip), %rdx      # 0xb1a0
movzbl (%rdx,%rcx), %ecx
movq 0x38(%rsp), %rsi
cmpl $0x3, %ecx
ja 0x6dda
leal 0x1(%rax), %edx
andl $0xf, %edi
leal (%rcx,%rdi,4), %edi
cmpl $0x2, %eax
jl 0x6e2f
movl %r13d, 0xc(%rsp)
movq %rdi, 0x30(%rsp)
movl %edx, 0x2c(%rsp)
movl %edx, %ecx
subl 0x58(%rsp), %ecx
testl %ecx, %ecx
movl $0x0, %edx
cmovlel %edx, %ecx
movl %esi, %edx
subl %eax, %edx
addl %ecx, %edx
movq %r15, %rdi
movq %r14, %rsi
movq %rdx, 0x60(%rsp)
callq 0x72c8
movq 0x20(%rsp), %rax
movq (%rax), %r10
movq (%r10), %rsi
movq 0x8(%r10), %r13
cmpq 0x80(%rsp), %r13
jb 0x6e34
movq 0x18(%r10), %rax
movq %rsi, %rcx
movabsq $0x3ffffffffffffff, %rdi # imm = 0x3FFFFFFFFFFFFFF
andq %rdi, %rcx
movq %rsi, %rdx
incq %rsi
andq %rdi, %rsi
movabsq $-0x400000000000000, %rdi # imm = 0xFC00000000000000
andq %rdi, %rdx
andq 0x10(%r10), %rsi
orq %rdx, %rsi
movq %rsi, (%r10)
decq %r13
movq %r13, 0x8(%r10)
movslq (%rax,%rcx,4), %rax
movl 0x1a0(%rsp,%rax,4), %ecx
decl %ecx
movl %ecx, 0x1a0(%rsp,%rax,4)
subl %ecx, 0xc(%rsp)
movslq %r12d, %rcx
cmpq %rcx, %r13
jae 0x6e34
decl %r12d
movl %r12d, 0x1c(%rsp)
movl 0xa0(%rsp,%rax,4), %ecx
decl %ecx
movl %ecx, 0xa0(%rsp,%rax,4)
movq 0x10(%rsp), %rbp
subl %ecx, %ebp
movl %ebp, %r11d
jmp 0x6e41
movl %r12d, %ebp
movl %eax, %ecx
subl 0x58(%rsp), %ecx
pushq $-0x1
popq %rdx
cmovsl %edx, %ecx
movq %rsi, %r12
movl %esi, %edx
subl %eax, %edx
addl %ecx, %edx
addl $0x2, %edx
cmpq $0x0, (%r14)
je 0x6e0d
leal 0x1(%rdx), %ebx
movq %r15, %rdi
movq %r14, %rsi
callq 0x72c8
movl %ebx, %edx
jmp 0x6df5
xorl %edx, %edx
movl %r13d, %r9d
xorl %edi, %edi
pushq $0x1
popq %rbx
movq %r12, %rsi
movl %ebp, %r12d
movq 0x10(%rsp), %rbp
incq %rsi
movl %r9d, %r13d
movl %edx, %eax
jmp 0x6cb8
movl %r13d, %r9d
jmp 0x6e1d
movl %r12d, 0x1c(%rsp)
movq 0x10(%rsp), %rax
movl %eax, %r11d
movq %rsi, %rax
shrq $0x3a, %rax
movq %rbx, %rdx
movl %eax, %ecx
shlq %cl, %rdx
cmpq %rdx, %r13
movq 0x68(%rsp), %rbp
jne 0x6e96
leal 0x1(%rax), %r15d
movl %r15d, %ecx
shlq %cl, %rbx
cmpq %r13, %rbx
movl %r11d, 0x10(%rsp)
jae 0x6eb4
pushq $-0x1
popq %r15
incq %r15
movq %r13, %rdx
movl %r15d, %ecx
shrq %cl, %rdx
cmpq $0x3f, %r15
ja 0x6e89
testq %rdx, %rdx
jne 0x6e72
cmpq %r15, %rax
pushq $0x1
popq %rbx
jne 0x6ea5
movq 0x40(%rsp), %r15
movabsq $0x3ffffffffffffff, %rdi # imm = 0x3FFFFFFFFFFFFFF
jmp 0x6f93
movl %r15d, %ecx
shlq %cl, %rbx
cmpq %rax, %r15
jbe 0x729b
movq 0x18(%r10), %rdi
pushq $0x4
popq %rsi
movl %r15d, %ecx
shlq %cl, %rsi
movq %r10, %r12
callq 0x2200
movq %r12, %r10
movq %rax, 0x18(%r12)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movl 0x10(%rsp), %r11d
movq %rsi, %rax
movabsq $0x3ffffffffffffff, %rdi # imm = 0x3FFFFFFFFFFFFFF
andq %rdi, %rax
addq %rax, %rdx
cmpq %r13, %rdx
jbe 0x6f39
movq 0x18(%r10), %rcx
movq %r13, %rdx
subq %rax, %rdx
movq %rbx, %rsi
subq %rdx, %rsi
leaq (%rcx,%rsi,4), %rdi
leaq (%rcx,%rax,4), %rsi
shlq $0x2, %rdx
movq %r10, %r12
callq 0x2220
movl 0x10(%rsp), %r11d
movq %r12, %r10
movabsq $0x3ffffffffffffff, %rdi # imm = 0x3FFFFFFFFFFFFFF
subq %r13, %rbx
addq (%r12), %rbx
movq %rbx, %rsi
jmp 0x6f67
subq %rbx, %rdx
jbe 0x6f67
movq 0x18(%r10), %rdi
leaq (%rdi,%rbx,4), %rsi
shlq $0x2, %rdx
movq %r10, %rbx
callq 0x2220
movl 0x10(%rsp), %r11d
movq %rbx, %r10
movabsq $0x3ffffffffffffff, %rdi # imm = 0x3FFFFFFFFFFFFFF
movq (%rbx), %rsi
movq %r15, %rax
shlq $0x3a, %rax
andq %rdi, %rsi
orq %rax, %rsi
pushq $-0x1
popq %rax
movl %r15d, %ecx
shlq %cl, %rax
movq %rsi, (%r10)
notq %rax
movq %rax, 0x10(%r10)
movq 0x8(%r10), %r13
movq 0x40(%rsp), %r15
pushq $0x1
popq %rbx
movq 0x10(%r10), %rax
movq 0x18(%r10), %rcx
leaq 0x1(%r13), %rdx
movq %rdx, 0x8(%r10)
andq %rdi, %rsi
addq %r13, %rsi
andq %rax, %rsi
movq 0x30(%rsp), %rdx
movl %edx, (%rcx,%rsi,4)
movl 0x1c(%rsp), %r12d
incl %r12d
leal (,%rdx,4), %edx
movl 0x1a0(%rsp,%rdx), %r9d
leal 0x1(%r9), %esi
movl %esi, 0x1a0(%rsp,%rdx)
movl 0xa0(%rsp,%rdx), %r8d
leal 0x1(%r8), %esi
movl %esi, 0xa0(%rsp,%rdx)
addl %r11d, %r8d
imull $0xa, %esi, %edx
cmpl 0x4c(%rsp), %edx
jle 0x7035
movq (%r10), %rdx
andq %rdi, %rdx
movslq %r12d, %rsi
addq %rdx, %r13
subq %rsi, %r13
incq %r13
movq 0x30(%rsp), %rdi
movq %r13, %rdx
andq %rax, %rdx
movslq (%rcx,%rdx,4), %rdx
movl 0xa0(%rsp,%rdx,4), %esi
decl %esi
movl %esi, 0xa0(%rsp,%rdx,4)
subl %esi, %r8d
incq %r13
decl %r12d
cmpl %edi, %edx
jne 0x700c
jmp 0x703a
movq 0x30(%rsp), %rdi
movq %r8, 0x10(%rsp)
addl 0xc(%rsp), %r9d
imull $0xa, %r9d, %eax
movl %r12d, %ecx
imull %ebp, %ecx
cmpl %ecx, %eax
jle 0x7268
movq %r9, 0x78(%rsp)
movq 0x20(%rsp), %rax
movq (%rax), %r13
movl $0x100, %edx            # imm = 0x100
leaq 0x2a0(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x2190
movq 0x8(%r13), %rax
movl %r12d, 0x1c(%rsp)
notl %r12d
addl %eax, %r12d
movq 0x60(%rsp), %rcx
addl $0x2, %ecx
movq %rcx, 0x88(%rsp)
xorl %ecx, %ecx
xorl %esi, %esi
movq 0x10(%rsp), %rdx
movl %edx, 0xc(%rsp)
movq %r13, 0x90(%rsp)
testl %r12d, %r12d
js 0x7276
movq 0x18(%r13), %rdx
movq (%r13), %rdi
movabsq $0x3ffffffffffffff, %r8 # imm = 0x3FFFFFFFFFFFFFF
andq %r8, %rdi
movl %r12d, %r8d
addq %rdi, %r8
andq 0x10(%r13), %r8
movslq (%rdx,%r8,4), %rdx
movl 0x2a0(%rsp,%rdx,4), %edi
leal 0x1(%rdi), %r8d
movl %r8d, 0x2a0(%rsp,%rdx,4)
movl 0xc(%rsp), %edx
addl %edi, %edx
movl %r12d, %ebx
notl %ebx
addl %eax, %ebx
movl %edx, 0xc(%rsp)
imull $0xa, %edx, %edx
movl %ebx, %edi
imull %ebp, %edi
cmpl %edi, %edx
jle 0x7256
movq (%r14), %rdx
movq 0x60(%rsp), %rdi
leal (%r12,%rdi), %ebp
pushq $0xc
popq %rdi
xorl %r15d, %r15d
cmpq %r15, %rdx
je 0x7173
movq 0x20(%rsp), %r8
movq 0x18(%r8), %r9
cmpl %ebp, -0xc(%r9,%rdi)
jl 0x7176
movl -0x4(%r9,%rdi), %r8d
testl %esi, %esi
je 0x7160
movl %r8d, %r10d
imull %ecx, %r10d
movl (%r9,%rdi), %r9d
movl %r9d, %r11d
imull %esi, %r11d
cmpl %r11d, %r10d
jg 0x7164
movl %ecx, %r9d
movl %esi, %r8d
jmp 0x7164
movl (%r9,%rdi), %r9d
incq %r15
addq $0x10, %rdi
movl %r9d, %ecx
movl %r8d, %esi
jmp 0x7123
movq %rdx, %r15
testl %esi, %esi
je 0x7191
movl %ecx, %edi
imull 0xc(%rsp), %edi
movl %esi, %r8d
imull %ebx, %r8d
cmpl %r8d, %edi
jl 0x7256
movq 0x20(%rsp), %r13
movq 0x10(%r13), %rax
movq 0x18(%r13), %rsi
cmpq %rax, %rdx
setne %cl
leaq 0x1(%rdx), %rdi
cmpq %rdi, %rax
setae %al
orb %cl, %al
jne 0x7204
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(%r13)
shlq $0x4, %rax
movq %rsi, %rdi
movq %rax, %rsi
callq 0x2200
movq %rax, %rsi
movq %rax, 0x18(%r13)
movq 0x8(%r13), %rdx
subq %r15, %rdx
shlq $0x4, %r15
leaq (%rsi,%r15), %rdi
addq $0x10, %rdi
addq %r15, %rsi
shlq $0x4, %rdx
callq 0x2220
incq 0x8(%r13)
movq 0x18(%r13), %rcx
movl %ebp, (%rcx,%r15)
movq 0x90(%rsp), %r13
movq 0x8(%r13), %rax
movq 0x88(%rsp), %rdx
addl %eax, %edx
movl %edx, 0x4(%rcx,%r15)
movl 0xc(%rsp), %esi
movl %esi, 0x8(%rcx,%r15)
movl %ebx, 0xc(%rcx,%r15)
movl %ebx, %ecx
decl %r12d
movq 0x68(%rsp), %rbp
movq 0x40(%rsp), %r15
jmp 0x70b1
movq 0x38(%rsp), %rsi
movl 0x2c(%rsp), %edx
jmp 0x6e1d
pushq $0x1
popq %rbx
movq 0x38(%rsp), %rsi
movl 0x1c(%rsp), %r12d
movq 0x30(%rsp), %rdi
movl 0x2c(%rsp), %edx
movq 0x10(%rsp), %rbp
movq 0x78(%rsp), %r9
jmp 0x6e22
movq %r13, %rdx
jmp 0x6edf
movq 0x20(%rsp), %rdx
movl 0x20(%rdx), %eax
movq 0x70(%rsp), %rcx
movl %eax, (%rcx)
movq 0x30(%rdx), %rax
addq $0x3a8, %rsp            # imm = 0x3A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq