// File: /workspace/github_c_makefile_star2_O1/lh3[P]miniprot/nasw-sse.c
// Function: ns_backtrack
static void ns_backtrack(void *km, int32_t vs, const __m128i *tb, int32_t nl, int32_t al, uint32_t **cigar_, int32_t *n_cigar, int32_t *m_cigar)
{
	int32_t i = nl - 1, j = al - 1, last = 0, slen = (al + vs - 1) / vs;
	uint32_t *cigar = *cigar_, tmp;
	assert(vs == 4 || vs == 8);
	while (i >= 2 && j >= 0) {
		const __m128i *tbi = &tb[i * slen];
		int32_t x = *((int16_t*)&tbi[j%slen] + j/slen);
		int32_t state, ext;
		if (vs == 4) x = *((int32_t*)&tbi[j%slen] + j/slen);
		if (x>>9&1) x = 1|x>>4<<4;
		state = last == 0? x&0xf : last;
		ext = state >= 1 && state <= 5? x>>(state+3)&1 : 0;
		if (state == 0) {
			cigar = ns_push_cigar(km, n_cigar, m_cigar, cigar, NS_CIGAR_M, 1), i -= 3, --j;
		} else if (state == 1) {
			cigar = ns_push_cigar(km, n_cigar, m_cigar, cigar, NS_CIGAR_I, 1), --j;
		} else if (state == 2) {
			cigar = ns_push_cigar(km, n_cigar, m_cigar, cigar, NS_CIGAR_D, 1), i -= 3;
		} else if (state == 3) {
			cigar = ns_push_cigar(km, n_cigar, m_cigar, cigar, NS_CIGAR_N, 1), --i;
		} else if (state == 4) {
			cigar = ns_push_cigar(km, n_cigar, m_cigar, cigar, NS_CIGAR_U, 1), --i;
			if (!ext) --j;
		} else if (state == 5) {
			cigar = ns_push_cigar(km, n_cigar, m_cigar, cigar, NS_CIGAR_V, 1), --i;
			if (!ext) --j;
		} else if (state == 6) {
			cigar = ns_push_cigar(km, n_cigar, m_cigar, cigar, NS_CIGAR_F, 1), --i;
		} else if (state == 7) {
			cigar = ns_push_cigar(km, n_cigar, m_cigar, cigar, NS_CIGAR_F, 2), i -= 2;
		} else if (state == 8) {
			cigar = ns_push_cigar(km, n_cigar, m_cigar, cigar, NS_CIGAR_G, 1), --i, --j;
		} else if (state == 9) {
			cigar = ns_push_cigar(km, n_cigar, m_cigar, cigar, NS_CIGAR_G, 2), i -= 2, --j;
		}
		last = state >= 1 && state <= 5 && ext? state : 0;
	}
	if (j > 0) cigar = ns_push_cigar(km, n_cigar, m_cigar, cigar, NS_CIGAR_I, j);
	if (i >= 0) {
		int32_t l = (i+1) / 3 * 3, t = (i+1) % 3;
		if (l > 0) cigar = ns_push_cigar(km, n_cigar, m_cigar, cigar, NS_CIGAR_D, l);
		if (t != 0) cigar = ns_push_cigar(km, n_cigar, m_cigar, cigar, NS_CIGAR_F, t);
	}
	for (i = 0; i < (*n_cigar)>>1; ++i) // reverse CIGAR
		tmp = cigar[i], cigar[i] = cigar[(*n_cigar) - 1 - i], cigar[(*n_cigar) - 1 - i] = tmp;
	//fprintf(stderr, "%d\t", nl); for (i = 0; i < (*n_cigar); ++i) fprintf(stderr, "%d%c", cigar[i]>>4, NS_CIGAR_STR[cigar[i]&0xf]); fputc('\n', stderr);
	ns_fix_tiny_UV(*n_cigar, cigar);
	*cigar_ = cigar;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %r14d
movq %rdx, 0x18(%rsp)
movq %rdi, 0x8(%rsp)
leal (%r8,%rsi), %eax
decl %eax
cltd
idivl %esi
movl %eax, %ebx
movq %rsi, 0x10(%rsp)
cmpl $0x8, %esi
je 0xa0db
cmpl $0x4, 0x10(%rsp)
jne 0xa791
movq 0x68(%rsp), %r11
movq 0x60(%rsp), %r10
movq %r9, 0x20(%rsp)
movq (%r9), %rsi
leal -0x1(%r8), %r12d
decl %r14d
cmpl $0x2, %r14d
setl %al
testl %r8d, %r8d
setle %cl
orb %al, %cl
jne 0xa5d1
xorl %ecx, %ecx
movq 0x18(%rsp), %r8
movq 0x10(%rsp), %r9
movl %r12d, %eax
cltd
idivl %ebx
movl %r14d, %edi
imull %ebx, %edi
movslq %edi, %rdi
shlq $0x4, %rdi
shlq $0x4, %rdx
addq %r8, %rdx
addq %rdi, %rdx
cltq
cmpl $0x4, %r9d
jne 0xa13f
movl (%rdx,%rax,4), %eax
jmp 0xa143
movswl (%rdx,%rax,2), %eax
movl %eax, %edx
andl $-0x10, %edx
incl %edx
btl $0x9, %eax
cmovael %eax, %edx
movl %edx, %r13d
andl $0xf, %r13d
testl %ecx, %ecx
cmovnel %ecx, %r13d
leal -0x1(%r13), %ebp
xorl %r15d, %r15d
cmpl $0x5, %ebp
setb %r15b
leal 0x3(%r13), %ecx
shrl %cl, %edx
andl %edx, %r15d
cmpl $0x9, %r13d
ja 0xa5ad
leaq 0x9a9a(%rip), %rcx      # 0x13c20
movslq (%rcx,%r13,4), %rax
addq %rcx, %rax
jmpq *%rax
movslq (%r10), %rax
testq %rax, %rax
je 0xa1a4
movl -0x4(%rsi,%rax,4), %ecx
testb $0xf, %cl
je 0xa59f
movl (%r11), %ecx
cmpl %ecx, %eax
jne 0xa1df
movl %ecx, %eax
sarl %eax
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r11)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x81a4
movq 0x10(%rsp), %r9
movq 0x18(%rsp), %r8
movq 0x68(%rsp), %r11
movq 0x60(%rsp), %r10
movq %rax, %rsi
movslq (%r10), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%r10)
movl $0x10, (%rsi,%rax,4)
jmp 0xa5a6
movslq (%r10), %rax
testq %rax, %rax
je 0xa20e
movl -0x4(%rsi,%rax,4), %ecx
movl %ecx, %edx
andl $0xf, %edx
cmpl $0xc, %edx
je 0xa3a4
movl (%r11), %ecx
cmpl %ecx, %eax
jne 0xa249
movl %ecx, %eax
sarl %eax
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r11)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x81a4
movq 0x10(%rsp), %r9
movq 0x18(%rsp), %r8
movq 0x68(%rsp), %r11
movq 0x60(%rsp), %r10
movq %rax, %rsi
movslq (%r10), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%r10)
movl $0x1c, (%rsi,%rax,4)
jmp 0xa594
movl (%r11), %eax
cmpl %eax, (%r10)
jne 0xa29a
movl %eax, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r11)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x81a4
movq 0x10(%rsp), %r9
movq 0x18(%rsp), %r8
movq 0x68(%rsp), %r11
movq 0x60(%rsp), %r10
movq %rax, %rsi
movslq (%r10), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%r10)
movl $0x2b, (%rsi,%rax,4)
addl $-0x2, %r14d
jmp 0xa5aa
movslq (%r10), %rax
testq %rax, %rax
je 0xa455
movl -0x4(%rsi,%rax,4), %ecx
movl %ecx, %edx
andl $0xf, %edx
cmpl $0x2, %edx
jne 0xa455
addl $0x10, %ecx
movl %ecx, -0x4(%rsi,%rax,4)
jmp 0xa4a0
movslq (%r10), %rax
testq %rax, %rax
je 0xa4a9
movl -0x4(%rsi,%rax,4), %ecx
movl %ecx, %edx
andl $0xf, %edx
cmpl $0x3, %edx
jne 0xa4a9
addl $0x10, %ecx
movl %ecx, -0x4(%rsi,%rax,4)
jmp 0xa4f4
movl (%r11), %eax
cmpl %eax, (%r10)
jne 0xa343
movl %eax, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r11)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x81a4
movq 0x10(%rsp), %r9
movq 0x18(%rsp), %r8
movq 0x68(%rsp), %r11
movq 0x60(%rsp), %r10
movq %rax, %rsi
movslq (%r10), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%r10)
movl $0x2a, (%rsi,%rax,4)
addl $-0x2, %r14d
jmp 0xa5ad
movslq (%r10), %rax
testq %rax, %rax
je 0xa4fc
movl -0x4(%rsi,%rax,4), %ecx
movl %ecx, %edx
andl $0xf, %edx
cmpl $0x1, %edx
jne 0xa4fc
addl $0x10, %ecx
movl %ecx, -0x4(%rsi,%rax,4)
jmp 0xa5aa
movslq (%r10), %rax
testq %rax, %rax
je 0xa549
movl -0x4(%rsi,%rax,4), %ecx
movl %ecx, %edx
andl $0xf, %edx
cmpl $0xd, %edx
jne 0xa549
addl $0x10, %ecx
movl %ecx, -0x4(%rsi,%rax,4)
jmp 0xa594
movl (%r11), %eax
cmpl %eax, (%r10)
jne 0xa3ec
movl %eax, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r11)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x81a4
movq 0x10(%rsp), %r9
movq 0x18(%rsp), %r8
movq 0x68(%rsp), %r11
movq 0x60(%rsp), %r10
movq %rax, %rsi
movslq (%r10), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%r10)
movl $0x1a, (%rsi,%rax,4)
jmp 0xa4f4
movl (%r11), %eax
cmpl %eax, (%r10)
jne 0xa43d
movl %eax, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r11)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x81a4
movq 0x10(%rsp), %r9
movq 0x18(%rsp), %r8
movq 0x68(%rsp), %r11
movq 0x60(%rsp), %r10
movq %rax, %rsi
movslq (%r10), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%r10)
movl $0x1b, (%rsi,%rax,4)
decl %r14d
jmp 0xa5aa
movl (%r11), %ecx
cmpl %ecx, %eax
jne 0xa490
movl %ecx, %eax
sarl %eax
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r11)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x81a4
movq 0x10(%rsp), %r9
movq 0x18(%rsp), %r8
movq 0x68(%rsp), %r11
movq 0x60(%rsp), %r10
movq %rax, %rsi
movslq (%r10), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%r10)
movl $0x12, (%rsi,%rax,4)
addl $-0x3, %r14d
jmp 0xa5ad
movl (%r11), %ecx
cmpl %ecx, %eax
jne 0xa4e4
movl %ecx, %eax
sarl %eax
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r11)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x81a4
movq 0x10(%rsp), %r9
movq 0x18(%rsp), %r8
movq 0x68(%rsp), %r11
movq 0x60(%rsp), %r10
movq %rax, %rsi
movslq (%r10), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%r10)
movl $0x13, (%rsi,%rax,4)
decl %r14d
jmp 0xa5ad
movl (%r11), %ecx
cmpl %ecx, %eax
jne 0xa537
movl %ecx, %eax
sarl %eax
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r11)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x81a4
movq 0x10(%rsp), %r9
movq 0x18(%rsp), %r8
movq 0x68(%rsp), %r11
movq 0x60(%rsp), %r10
movq %rax, %rsi
movslq (%r10), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%r10)
movl $0x11, (%rsi,%rax,4)
jmp 0xa5aa
movl (%r11), %ecx
cmpl %ecx, %eax
jne 0xa584
movl %ecx, %eax
sarl %eax
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r11)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x81a4
movq 0x10(%rsp), %r9
movq 0x18(%rsp), %r8
movq 0x68(%rsp), %r11
movq 0x60(%rsp), %r10
movq %rax, %rsi
movslq (%r10), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%r10)
movl $0x1d, (%rsi,%rax,4)
decl %r14d
addl %r15d, %r12d
decl %r12d
jmp 0xa5ad
addl $0x10, %ecx
movl %ecx, -0x4(%rsi,%rax,4)
addl $-0x3, %r14d
decl %r12d
testl %r15d, %r15d
cmovel %r15d, %r13d
cmpl $0x5, %ebp
movl %r13d, %ecx
movl $0x0, %eax
cmovael %eax, %ecx
cmpl $0x2, %r14d
jl 0xa5d1
testl %r12d, %r12d
jns 0xa115
testl %r12d, %r12d
jle 0xa63e
movslq (%r10), %rax
testq %rax, %rax
je 0xa5f9
movl -0x4(%rsi,%rax,4), %ecx
movl %ecx, %edx
andl $0xf, %edx
cmpl $0x1, %edx
jne 0xa5f9
shll $0x4, %r12d
addl %r12d, %ecx
movl %ecx, -0x4(%rsi,%rax,4)
jmp 0xa63e
movl (%r11), %ecx
cmpl %ecx, %eax
jne 0xa62a
movl %ecx, %eax
sarl %eax
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r11)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x81a4
movq 0x68(%rsp), %r11
movq 0x60(%rsp), %r10
movq %rax, %rsi
shll $0x4, %r12d
incl %r12d
movslq (%r10), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%r10)
movl %r12d, (%rsi,%rax,4)
testl %r14d, %r14d
movq 0x20(%rsp), %r15
js 0xa711
incl %r14d
movl $0xaaaaaaab, %eax       # imm = 0xAAAAAAAB
imulq %r14, %rax
shrq $0x21, %rax
leal (%rax,%rax,2), %ebx
subl %ebx, %r14d
testl %ebx, %ebx
jle 0xa6ca
movslq (%r10), %rax
testq %rax, %rax
je 0xa687
movl -0x4(%rsi,%rax,4), %ecx
movl %ecx, %edx
andl $0xf, %edx
cmpl $0x2, %edx
jne 0xa687
shll $0x4, %ebx
addl %ebx, %ecx
movl %ecx, -0x4(%rsi,%rax,4)
jmp 0xa6ca
movl (%r11), %ecx
cmpl %ecx, %eax
jne 0xa6b8
movl %ecx, %eax
sarl %eax
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r11)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x81a4
movq 0x68(%rsp), %r11
movq 0x60(%rsp), %r10
movq %rax, %rsi
shll $0x4, %ebx
orl $0x2, %ebx
movslq (%r10), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%r10)
movl %ebx, (%rsi,%rax,4)
testl %r14d, %r14d
je 0xa711
movl (%r11), %eax
cmpl %eax, (%r10)
jne 0xa6fc
movl %eax, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r11)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x81a4
movq 0x60(%rsp), %r10
movq %rax, %rsi
shll $0x4, %r14d
orl $0xa, %r14d
movslq (%r10), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%r10)
movl %r14d, (%rsi,%rax,4)
movl (%r10), %eax
cmpl $0x2, %eax
jl 0xa74b
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %edx, %edx
movl (%rsi,%rdx,4), %edi
addl %ecx, %eax
cltq
movl (%rsi,%rax,4), %eax
movl %eax, (%rsi,%rdx,4)
movl (%r10), %eax
addl %ecx, %eax
cltq
movl %edi, (%rsi,%rax,4)
incq %rdx
movl (%r10), %eax
movl %eax, %edi
sarl %edi
movslq %edi, %rdi
decl %ecx
cmpq %rdi, %rdx
jl 0xa720
testl %eax, %eax
jle 0xa77f
movl %eax, %eax
xorl %ecx, %ecx
movl (%rsi,%rcx,4), %edx
movl %edx, %edi
andl $0xe, %edi
cmpl $0xc, %edi
setne %dil
cmpl $0x30, %edx
setae %r8b
orb %dil, %r8b
jne 0xa777
andl $0x30, %edx
orl $0xb, %edx
movl %edx, (%rsi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0xa753
movq %rsi, (%r15)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x953c(%rip), %rdi      # 0x13cd4
leaq 0x94b0(%rip), %rsi      # 0x13c4f
leaq 0x9541(%rip), %rcx      # 0x13ce7
movl $0x2c, %edx
callq 0x2150