// File: /workspace/github_c_makefile_star2_O3/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
movq %r9, 0x20(%rsp)
movl %ecx, %r14d
movq %rdx, %r11
movq %rdi, 0x8(%rsp)
leal (%r8,%rsi), %eax
decl %eax
cltd
idivl %esi
movl %eax, %ebx
movq %rsi, 0x10(%rsp)
cmpl $0x8, %esi
je 0xa43d
cmpl $0x4, 0x10(%rsp)
jne 0xaafb
movq 0x68(%rsp), %r10
movq 0x60(%rsp), %r9
leal -0x1(%r8), %r12d
movq 0x20(%rsp), %rax
movq (%rax), %rsi
decl %r14d
cmpl $0x2, %r14d
setl %al
testl %r8d, %r8d
setle %cl
orb %al, %cl
jne 0xa939
xorl %ecx, %ecx
movq %r11, 0x18(%rsp)
movq 0x10(%rsp), %r8
movl %r12d, %eax
cltd
idivl %ebx
movl %r14d, %edi
imull %ebx, %edi
movslq %edi, %rdi
shlq $0x4, %rdi
shlq $0x4, %rdx
addq %r11, %rdx
addq %rdi, %rdx
cltq
cmpl $0x4, %r8d
jne 0xa4a1
movl (%rdx,%rax,4), %eax
jmp 0xa4a5
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
leal 0x3(%r13), %eax
movzbl %al, %eax
xorl %r15d, %r15d
btl %eax, %edx
setb %r15b
cmpl $0x9, %r13d
ja 0xa915
leaq 0xa78a(%rip), %rcx      # 0x14c70
movslq (%rcx,%r13,4), %rax
addq %rcx, %rax
jmpq *%rax
movslq (%r9), %rax
testq %rax, %rax
je 0xa504
movl -0x4(%rsi,%rax,4), %ecx
testb $0xf, %cl
je 0xa907
cmpl (%r10), %eax
jne 0xa540
movl %eax, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r10)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x85ad
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r11
movq 0x68(%rsp), %r10
movq 0x60(%rsp), %r9
movq %rax, %rsi
movl (%r9), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%r9)
cltq
movl $0x10, (%rsi,%rax,4)
jmp 0xa90e
movslq (%r9), %rax
testq %rax, %rax
je 0xa56e
movl -0x4(%rsi,%rax,4), %ecx
movl %ecx, %edx
andl $0xf, %edx
cmpl $0xc, %edx
je 0xa708
cmpl (%r10), %eax
jne 0xa5aa
movl %eax, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r10)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x85ad
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r11
movq 0x68(%rsp), %r10
movq 0x60(%rsp), %r9
movq %rax, %rsi
movl (%r9), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%r9)
cltq
movl $0x1c, (%rsi,%rax,4)
jmp 0xa8fc
movl (%r9), %eax
cmpl (%r10), %eax
jne 0xa5fd
movl %eax, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r10)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x85ad
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r11
movq 0x68(%rsp), %r10
movq 0x60(%rsp), %r9
movq %rax, %rsi
movl (%r9), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%r9)
cltq
movl $0x2b, (%rsi,%rax,4)
addl $-0x2, %r14d
jmp 0xa912
movslq (%r9), %rax
testq %rax, %rax
je 0xa7bd
movl -0x4(%rsi,%rax,4), %ecx
movl %ecx, %edx
andl $0xf, %edx
cmpl $0x2, %edx
jne 0xa7bd
addl $0x10, %ecx
movl %ecx, -0x4(%rsi,%rax,4)
jmp 0xa808
movslq (%r9), %rax
testq %rax, %rax
je 0xa811
movl -0x4(%rsi,%rax,4), %ecx
movl %ecx, %edx
andl $0xf, %edx
cmpl $0x3, %edx
jne 0xa811
addl $0x10, %ecx
movl %ecx, -0x4(%rsi,%rax,4)
jmp 0xa85c
movl (%r9), %eax
cmpl (%r10), %eax
jne 0xa6a8
movl %eax, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r10)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x85ad
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r11
movq 0x68(%rsp), %r10
movq 0x60(%rsp), %r9
movq %rax, %rsi
movl (%r9), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%r9)
cltq
movl $0x2a, (%rsi,%rax,4)
addl $-0x2, %r14d
jmp 0xa915
movslq (%r9), %rax
testq %rax, %rax
je 0xa864
movl -0x4(%rsi,%rax,4), %ecx
movl %ecx, %edx
andl $0xf, %edx
cmpl $0x1, %edx
jne 0xa864
addl $0x10, %ecx
movl %ecx, -0x4(%rsi,%rax,4)
jmp 0xa912
movslq (%r9), %rax
testq %rax, %rax
je 0xa8b1
movl -0x4(%rsi,%rax,4), %ecx
movl %ecx, %edx
andl $0xf, %edx
cmpl $0xd, %edx
jne 0xa8b1
addl $0x10, %ecx
movl %ecx, -0x4(%rsi,%rax,4)
jmp 0xa8fc
movl (%r9), %eax
cmpl (%r10), %eax
jne 0xa753
movl %eax, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r10)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x85ad
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r11
movq 0x68(%rsp), %r10
movq 0x60(%rsp), %r9
movq %rax, %rsi
movl (%r9), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%r9)
cltq
movl $0x1a, (%rsi,%rax,4)
jmp 0xa85c
movl (%r9), %eax
cmpl (%r10), %eax
jne 0xa7a6
movl %eax, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r10)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x85ad
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r11
movq 0x68(%rsp), %r10
movq 0x60(%rsp), %r9
movq %rax, %rsi
movl (%r9), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%r9)
cltq
movl $0x1b, (%rsi,%rax,4)
decl %r14d
jmp 0xa912
cmpl (%r10), %eax
jne 0xa7f9
movl %eax, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r10)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x85ad
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r11
movq 0x68(%rsp), %r10
movq 0x60(%rsp), %r9
movq %rax, %rsi
movl (%r9), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%r9)
cltq
movl $0x12, (%rsi,%rax,4)
addl $-0x3, %r14d
jmp 0xa915
cmpl (%r10), %eax
jne 0xa84d
movl %eax, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r10)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x85ad
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r11
movq 0x68(%rsp), %r10
movq 0x60(%rsp), %r9
movq %rax, %rsi
movl (%r9), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%r9)
cltq
movl $0x13, (%rsi,%rax,4)
decl %r14d
jmp 0xa915
cmpl (%r10), %eax
jne 0xa8a0
movl %eax, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r10)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x85ad
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r11
movq 0x68(%rsp), %r10
movq 0x60(%rsp), %r9
movq %rax, %rsi
movl (%r9), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%r9)
cltq
movl $0x11, (%rsi,%rax,4)
jmp 0xa912
cmpl (%r10), %eax
jne 0xa8ed
movl %eax, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r10)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x85ad
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r11
movq 0x68(%rsp), %r10
movq 0x60(%rsp), %r9
movq %rax, %rsi
movl (%r9), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%r9)
cltq
movl $0x1d, (%rsi,%rax,4)
decl %r14d
addl %r15d, %r12d
decl %r12d
jmp 0xa915
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 0xa939
testl %r12d, %r12d
jns 0xa477
testl %r12d, %r12d
jle 0xa9a6
movslq (%r9), %rax
testq %rax, %rax
je 0xa961
movl -0x4(%rsi,%rax,4), %ecx
movl %ecx, %edx
andl $0xf, %edx
cmpl $0x1, %edx
jne 0xa961
shll $0x4, %r12d
addl %r12d, %ecx
movl %ecx, -0x4(%rsi,%rax,4)
jmp 0xa9a6
cmpl (%r10), %eax
jne 0xa993
movl %eax, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r10)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x85ad
movq 0x68(%rsp), %r10
movq 0x60(%rsp), %r9
movq %rax, %rsi
movl (%r9), %eax
shll $0x4, %r12d
incl %r12d
leal 0x1(%rax), %ecx
movl %ecx, (%r9)
cltq
movl %r12d, (%rsi,%rax,4)
testl %r14d, %r14d
js 0xaa76
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 0xaa2d
movslq (%r9), %rax
testq %rax, %rax
je 0xa9ea
movl -0x4(%rsi,%rax,4), %ecx
movl %ecx, %edx
andl $0xf, %edx
cmpl $0x2, %edx
jne 0xa9ea
shll $0x4, %ebx
addl %ebx, %ecx
movl %ecx, -0x4(%rsi,%rax,4)
jmp 0xaa2d
cmpl (%r10), %eax
jne 0xaa1c
movl %eax, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r10)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x85ad
movq 0x68(%rsp), %r10
movq 0x60(%rsp), %r9
movq %rax, %rsi
movl (%r9), %eax
shll $0x4, %ebx
orl $0x2, %ebx
leal 0x1(%rax), %ecx
movl %ecx, (%r9)
cltq
movl %ebx, (%rsi,%rax,4)
testl %r14d, %r14d
je 0xaa76
movl (%r9), %eax
cmpl (%r10), %eax
jne 0xaa62
movl %eax, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x8, %eax
movl %eax, (%r10)
movslq %eax, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x85ad
movq 0x60(%rsp), %r9
movq %rax, %rsi
movl (%r9), %eax
shll $0x4, %r14d
orl $0xa, %r14d
leal 0x1(%rax), %ecx
movl %ecx, (%r9)
cltq
movl %r14d, (%rsi,%rax,4)
movl (%r9), %eax
cmpl $0x2, %eax
jl 0xaab0
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 (%r9), %eax
addl %ecx, %eax
cltq
movl %edi, (%rsi,%rax,4)
incq %rdx
movl (%r9), %eax
movl %eax, %edi
sarl %edi
movslq %edi, %rdi
decl %ecx
cmpq %rdi, %rdx
jl 0xaa85
testl %eax, %eax
jle 0xaae4
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 0xaadc
andl $0x30, %edx
orl $0xb, %edx
movl %edx, (%rsi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0xaab8
movq 0x20(%rsp), %rax
movq %rsi, (%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa222(%rip), %rdi      # 0x14d24
leaq 0xa196(%rip), %rsi      # 0x14c9f
leaq 0xa227(%rip), %rcx      # 0x14d37
movl $0x2c, %edx
callq 0x2150