// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xa0, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x20(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x20(%rbp), %eax
addl -0xc(%rbp), %eax
subl $0x1, %eax
cltd
idivl -0xc(%rbp)
movl %eax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
cmpl $0x4, -0xc(%rbp)
je 0x115e9
cmpl $0x8, -0xc(%rbp)
jne 0x115eb
jmp 0x1160a
leaq 0x10342(%rip), %rdi     # 0x21934
leaq 0x102b6(%rip), %rsi     # 0x218af
movl $0x2c, %edx
leaq 0x10342(%rip), %rcx     # 0x21947
callq 0x2180
jmp 0x1160c
xorl %eax, %eax
cmpl $0x2, -0x2c(%rbp)
movb %al, -0x65(%rbp)
jl 0x11621
cmpl $0x0, -0x30(%rbp)
setge %al
movb %al, -0x65(%rbp)
movb -0x65(%rbp), %al
testb $0x1, %al
jne 0x1162d
jmp 0x119e5
movq -0x18(%rbp), %rax
movl -0x2c(%rbp), %ecx
imull -0x38(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x78(%rbp)
movl -0x30(%rbp), %eax
cltd
idivl -0x38(%rbp)
movq -0x78(%rbp), %rax
movslq %edx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movl -0x30(%rbp), %eax
cltd
idivl -0x38(%rbp)
movl %eax, %ecx
movq -0x70(%rbp), %rax
movslq %ecx, %rcx
movswl (%rax,%rcx,2), %eax
movl %eax, -0x54(%rbp)
cmpl $0x4, -0xc(%rbp)
jne 0x116c1
movq -0x50(%rbp), %rax
movq %rax, -0x88(%rbp)
movl -0x30(%rbp), %eax
cltd
idivl -0x38(%rbp)
movq -0x88(%rbp), %rax
movslq %edx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movl -0x30(%rbp), %eax
cltd
idivl -0x38(%rbp)
movl %eax, %ecx
movq -0x80(%rbp), %rax
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
sarl $0x9, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x116de
movl -0x54(%rbp), %eax
sarl $0x4, %eax
shll $0x4, %eax
orl $0x1, %eax
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x116f2
movl -0x54(%rbp), %eax
andl $0xf, %eax
movl %eax, -0x8c(%rbp)
jmp 0x116fb
movl -0x34(%rbp), %eax
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
movl %eax, -0x58(%rbp)
cmpl $0x1, -0x58(%rbp)
jl 0x11726
cmpl $0x5, -0x58(%rbp)
jg 0x11726
movl -0x54(%rbp), %eax
movl -0x58(%rbp), %ecx
addl $0x3, %ecx
sarl %cl, %eax
andl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x11730
xorl %eax, %eax
movl %eax, -0x90(%rbp)
jmp 0x11730
movl -0x90(%rbp), %eax
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x58(%rbp)
jne 0x11778
movq -0x8(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq 0x18(%rbp), %rdx
movq -0x40(%rbp), %rcx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x15370
movq %rax, -0x40(%rbp)
movl -0x2c(%rbp), %eax
subl $0x3, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x119b0
cmpl $0x1, -0x58(%rbp)
jne 0x117ae
movq -0x8(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq 0x18(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl $0x1, %r9d
movl %r9d, %r8d
callq 0x15370
movq %rax, -0x40(%rbp)
movl -0x30(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x119ae
cmpl $0x2, -0x58(%rbp)
jne 0x117e7
movq -0x8(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq 0x18(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl $0x2, %r8d
movl $0x1, %r9d
callq 0x15370
movq %rax, -0x40(%rbp)
movl -0x2c(%rbp), %eax
subl $0x3, %eax
movl %eax, -0x2c(%rbp)
jmp 0x119ac
cmpl $0x3, -0x58(%rbp)
jne 0x11820
movq -0x8(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq 0x18(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl $0x3, %r8d
movl $0x1, %r9d
callq 0x15370
movq %rax, -0x40(%rbp)
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x119aa
cmpl $0x4, -0x58(%rbp)
jne 0x11868
movq -0x8(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq 0x18(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl $0xc, %r8d
movl $0x1, %r9d
callq 0x15370
movq %rax, -0x40(%rbp)
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x5c(%rbp)
jne 0x11863
movl -0x30(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x119a8
cmpl $0x5, -0x58(%rbp)
jne 0x118b0
movq -0x8(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq 0x18(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl $0xd, %r8d
movl $0x1, %r9d
callq 0x15370
movq %rax, -0x40(%rbp)
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x5c(%rbp)
jne 0x118ab
movl -0x30(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x119a6
cmpl $0x6, -0x58(%rbp)
jne 0x118e9
movq -0x8(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq 0x18(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl $0xa, %r8d
movl $0x1, %r9d
callq 0x15370
movq %rax, -0x40(%rbp)
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x119a4
cmpl $0x7, -0x58(%rbp)
jne 0x11922
movq -0x8(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq 0x18(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl $0xa, %r8d
movl $0x2, %r9d
callq 0x15370
movq %rax, -0x40(%rbp)
movl -0x2c(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x2c(%rbp)
jmp 0x119a2
cmpl $0x8, -0x58(%rbp)
jne 0x11961
movq -0x8(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq 0x18(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl $0xb, %r8d
movl $0x1, %r9d
callq 0x15370
movq %rax, -0x40(%rbp)
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x119a0
cmpl $0x9, -0x58(%rbp)
jne 0x1199e
movq -0x8(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq 0x18(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl $0xb, %r8d
movl $0x2, %r9d
callq 0x15370
movq %rax, -0x40(%rbp)
movl -0x2c(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x119a0
jmp 0x119a2
jmp 0x119a4
jmp 0x119a6
jmp 0x119a8
jmp 0x119aa
jmp 0x119ac
jmp 0x119ae
jmp 0x119b0
cmpl $0x1, -0x58(%rbp)
jl 0x119cd
cmpl $0x5, -0x58(%rbp)
jg 0x119cd
cmpl $0x0, -0x5c(%rbp)
je 0x119cd
movl -0x58(%rbp), %eax
movl %eax, -0x94(%rbp)
jmp 0x119d7
xorl %eax, %eax
movl %eax, -0x94(%rbp)
jmp 0x119d7
movl -0x94(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x1160c
cmpl $0x0, -0x30(%rbp)
jle 0x11a0e
movq -0x8(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq 0x18(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl -0x30(%rbp), %r9d
movl $0x1, %r8d
callq 0x15370
movq %rax, -0x40(%rbp)
cmpl $0x0, -0x2c(%rbp)
jl 0x11a8d
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl $0x3, %ecx
cltd
idivl %ecx
imull $0x3, %eax, %eax
movl %eax, -0x60(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl $0x3, %ecx
cltd
idivl %ecx
movl %edx, -0x64(%rbp)
cmpl $0x0, -0x60(%rbp)
jle 0x11a62
movq -0x8(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq 0x18(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl -0x60(%rbp), %r9d
movl $0x2, %r8d
callq 0x15370
movq %rax, -0x40(%rbp)
cmpl $0x0, -0x64(%rbp)
je 0x11a8b
movq -0x8(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq 0x18(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl -0x64(%rbp), %r9d
movl $0xa, %r8d
callq 0x15370
movq %rax, -0x40(%rbp)
jmp 0x11a8d
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq 0x10(%rbp), %rcx
movl (%rcx), %ecx
sarl %ecx
cmpl %ecx, %eax
jge 0x11af6
movq -0x40(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x44(%rbp)
movq -0x40(%rbp), %rax
movq 0x10(%rbp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
subl -0x2c(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq -0x40(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x44(%rbp), %edx
movq -0x40(%rbp), %rax
movq 0x10(%rbp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
subl -0x2c(%rbp), %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x11a94
movq 0x10(%rbp), %rax
movl (%rax), %edi
movq -0x40(%rbp), %rsi
callq 0x15450
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)