// File: /workspace/github_c_makefile_star2_O0/lh3[P]miniprot/nasw-sse.c
// Function: ns_prep_seq_left
static uint8_t *ns_prep_seq_left(void *km, const char *ns, int32_t nl, const char *as, int32_t al, const ns_opt_t *opt, const uint8_t *ss, uint8_t **aas_, int8_t **donor_, int8_t **acceptor_)
{
	int32_t i, j;
	uint8_t *nas, *aas, tmp;
	int8_t *donor, *acceptor;
	nas = Kmalloc(km, uint8_t, nl + al + (nl + 1) * 2); // nas and aas are allocated together
	*aas_ = aas = nas + nl;
	*donor_ = donor = (int8_t*)aas + al, *acceptor_ = acceptor = donor + nl + 1;
	for (j = 0; j < al; ++j) // generate aas[]. NB: this is reversed
		aas[al - 1 - j] = opt->aa20[(uint8_t)as[j]];
	for (i = 0; i < nl; ++i) // nt4 encoding of ns[] for computing donor[] and acceptor[]. NB: this is reversed
		nas[nl - 1 - i] = opt->nt4[(uint8_t)ns[i]];
	for (i = 0; i < nl + 1; ++i)
		donor[i] = acceptor[i] = opt->sp[3];
	for (i = 0; i < nl - 3; ++i) { // generate donor[] (actually acceptor as the string is reversed)
		int32_t t = 3, penY = 0;
		if (nas[i+1] == 2 && nas[i+2] == 0) { // GA. (the reverse of .AG)
			t = i + 3 < nl && (nas[i+3] == 1 || nas[i+3] == 3)? -1 : 0;
			for (j = i + 5; j < nl && j < i + 8; ++j)
				if (nas[j] != 1 && nas[j] != 3) penY += opt->sp[5];
		} else if (nas[i+1] == 1 && nas[i+2] == 0) t = 2; // CA.
		donor[i] = t < 0? 0 : opt->sp[t];
		if (t == -1 || t == 0) donor[i] += penY;
	}
	for (i = 1; i < nl; ++i) { // generate acceptor[] (actually donor)
		int32_t t = 3;
		if (nas[i-1] == 3 && nas[i] == 2) // .TG (the reverse of GT.)
			t = i >= 2 && (nas[i-2] == 0 || nas[i-2] == 2)? (i+1 < nl && nas[i+1] == 2? -1 : 4) : 0;
		else if (nas[i-1] == 1 && nas[i] == 2 && i+1 < nl && nas[i+1] == 1) t = 1; // .CG
		else if (nas[i-1] == 3 && nas[i] == 0) t = 2; // .TA
		acceptor[i] = t < 0? 0 : opt->sp[t];
	}
	if (ss) {
		int32_t max_spsc = (opt->io + 1) / 2 - 1;
		for (i = 0; i < nl; ++i) {
			int32_t spsc = (int8_t)(ss[i]>>1) - (int8_t)NS_SPSC_OFFSET;
			if (spsc > max_spsc) spsc = max_spsc;
			if (ss[i] == 0xff) {
				donor[nl - i - 1] -= opt->sp_null_bonus;
				acceptor[nl - i - 1] -= opt->sp_null_bonus;
			} else if (ss[i]&1) {
				donor[nl - i - 1] -= spsc;
			} else {
				acceptor[nl - i - 1] -= spsc;
			}
		}
	}
	ns_prep_nas(ns, nl, opt, nas);
	for (i = 0; i < nl>>1; ++i) // reverse
		tmp = nas[i], nas[i] = nas[nl - 1 - i], nas[nl - 1 - i] = tmp;
	memmove(nas + 2, nas, nl - 2);
	nas[0] = nas[1] = opt->aa20['X'];
	return nas;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %eax
addl -0x24(%rbp), %eax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
shll %ecx
addl %ecx, %eax
movslq %eax, %rsi
shlq $0x0, %rsi
callq 0xaeb0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rcx
movslq -0x14(%rbp), %rax
addq %rax, %rcx
movq %rcx, -0x48(%rbp)
movq 0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rcx
movslq -0x24(%rbp), %rax
addq %rax, %rcx
movq %rcx, -0x58(%rbp)
movq 0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x58(%rbp), %rcx
movslq -0x14(%rbp), %rax
addq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x60(%rbp)
movq 0x28(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x10810
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x20(%rbp), %rcx
movslq -0x38(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
movb (%rax,%rcx), %dl
movq -0x48(%rbp), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
subl -0x38(%rbp), %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x107d3
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x10854
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rcx
movslq -0x34(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
movb (%rax,%rcx), %dl
movq -0x40(%rbp), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
subl -0x34(%rbp), %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x10817
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x10892
movq -0x30(%rbp), %rax
movl 0x2c(%rax), %eax
movb %al, %dl
movq -0x60(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x58(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1085b
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl -0x14(%rbp), %ecx
subl $0x3, %ecx
cmpl %ecx, %eax
jge 0x10a49
movl $0x3, -0x64(%rbp)
movl $0x0, -0x68(%rbp)
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jne 0x109b8
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x109b8
movl -0x34(%rbp), %ecx
addl $0x3, %ecx
xorl %eax, %eax
cmpl -0x14(%rbp), %ecx
movb %al, -0x75(%rbp)
jge 0x10937
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %ecx
movb $0x1, %al
cmpl $0x1, %ecx
movb %al, -0x76(%rbp)
je 0x10931
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x3, %eax
sete %al
movb %al, -0x76(%rbp)
movb -0x76(%rbp), %al
movb %al, -0x75(%rbp)
movb -0x75(%rbp), %dl
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x64(%rbp)
movl -0x34(%rbp), %eax
addl $0x5, %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %ecx
xorl %eax, %eax
cmpl -0x14(%rbp), %ecx
movb %al, -0x77(%rbp)
jge 0x10971
movl -0x38(%rbp), %eax
movl -0x34(%rbp), %ecx
addl $0x8, %ecx
cmpl %ecx, %eax
setl %al
movb %al, -0x77(%rbp)
movb -0x77(%rbp), %al
testb $0x1, %al
jne 0x1097a
jmp 0x109b6
movq -0x40(%rbp), %rax
movslq -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x1, %eax
je 0x109a9
movq -0x40(%rbp), %rax
movslq -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x3, %eax
je 0x109a9
movq -0x30(%rbp), %rax
movl 0x34(%rax), %eax
addl -0x68(%rbp), %eax
movl %eax, -0x68(%rbp)
jmp 0x109ab
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x10953
jmp 0x109ed
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x1, %eax
jne 0x109eb
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x109eb
movl $0x2, -0x64(%rbp)
jmp 0x109ed
cmpl $0x0, -0x64(%rbp)
jge 0x109fa
xorl %eax, %eax
movl %eax, -0x7c(%rbp)
jmp 0x10a09
movq -0x30(%rbp), %rax
movslq -0x64(%rbp), %rcx
movl 0x20(%rax,%rcx,4), %eax
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movb %al, %dl
movq -0x58(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb %dl, (%rax,%rcx)
cmpl $-0x1, -0x64(%rbp)
je 0x10a25
cmpl $0x0, -0x64(%rbp)
jne 0x10a39
movl -0x68(%rbp), %esi
movq -0x58(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %edx
addl %esi, %edx
movb %dl, (%rax,%rcx)
jmp 0x10a3b
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x10899
movl $0x1, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x10be7
movl $0x3, -0x6c(%rbp)
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x3, %eax
jne 0x10b21
movq -0x40(%rbp), %rax
movslq -0x34(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jne 0x10b21
cmpl $0x2, -0x34(%rbp)
jl 0x10b09
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x10ac4
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jne 0x10b09
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
xorl %eax, %eax
cmpl -0x14(%rbp), %ecx
movb %al, -0x7d(%rbp)
jge 0x10aee
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x2, %eax
sete %al
movb %al, -0x7d(%rbp)
movb -0x7d(%rbp), %dl
movl $0x4, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x84(%rbp)
jmp 0x10b13
xorl %eax, %eax
movl %eax, -0x84(%rbp)
jmp 0x10b13
movl -0x84(%rbp), %eax
movl %eax, -0x6c(%rbp)
jmp 0x10ba4
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x1, %eax
jne 0x10b72
movq -0x40(%rbp), %rax
movslq -0x34(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jne 0x10b72
movl -0x34(%rbp), %eax
addl $0x1, %eax
cmpl -0x14(%rbp), %eax
jge 0x10b72
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x1, %eax
jne 0x10b72
movl $0x1, -0x6c(%rbp)
jmp 0x10ba2
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x3, %eax
jne 0x10ba0
movq -0x40(%rbp), %rax
movslq -0x34(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x10ba0
movl $0x2, -0x6c(%rbp)
jmp 0x10ba2
jmp 0x10ba4
cmpl $0x0, -0x6c(%rbp)
jge 0x10bb4
xorl %eax, %eax
movl %eax, -0x88(%rbp)
jmp 0x10bc6
movq -0x30(%rbp), %rax
movslq -0x6c(%rbp), %rcx
movl 0x20(%rax,%rcx,4), %eax
movl %eax, -0x88(%rbp)
movl -0x88(%rbp), %eax
movb %al, %dl
movq -0x60(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x10a50
cmpq $0x0, 0x10(%rbp)
je 0x10cf9
movq -0x30(%rbp), %rax
movl 0xc(%rax), %eax
addl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
subl $0x1, %eax
movl %eax, -0x70(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x10cf7
movq 0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movzbl (%rax,%rcx), %eax
sarl %eax
movsbl %al, %eax
subl $0x40, %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x70(%rbp), %eax
jle 0x10c42
movl -0x70(%rbp), %eax
movl %eax, -0x74(%rbp)
movq 0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xff, %eax
jne 0x10c97
movq -0x30(%rbp), %rax
movl 0x38(%rax), %esi
movq -0x58(%rbp), %rax
movl -0x14(%rbp), %ecx
subl -0x34(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %edx
subl %esi, %edx
movb %dl, (%rax,%rcx)
movq -0x30(%rbp), %rax
movl 0x38(%rax), %esi
movq -0x60(%rbp), %rax
movl -0x14(%rbp), %ecx
subl -0x34(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %edx
subl %esi, %edx
movb %dl, (%rax,%rcx)
jmp 0x10ce7
movq 0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movzbl (%rax,%rcx), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x10cc9
movl -0x74(%rbp), %esi
movq -0x58(%rbp), %rax
movl -0x14(%rbp), %ecx
subl -0x34(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %edx
subl %esi, %edx
movb %dl, (%rax,%rcx)
jmp 0x10ce5
movl -0x74(%rbp), %esi
movq -0x60(%rbp), %rax
movl -0x14(%rbp), %ecx
subl -0x34(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %edx
subl %esi, %edx
movb %dl, (%rax,%rcx)
jmp 0x10ce7
jmp 0x10ce9
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x10c11
jmp 0x10cf9
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x30(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0x152a0
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl -0x14(%rbp), %ecx
sarl %ecx
cmpl %ecx, %eax
jge 0x10d6d
movq -0x40(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x49(%rbp)
movq -0x40(%rbp), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
subl -0x34(%rbp), %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %dl
movq -0x40(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb %dl, (%rax,%rcx)
movb -0x49(%rbp), %dl
movq -0x40(%rbp), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
subl -0x34(%rbp), %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x10d14
movq -0x40(%rbp), %rdi
addq $0x2, %rdi
movq -0x40(%rbp), %rsi
movl -0x14(%rbp), %eax
subl $0x2, %eax
movslq %eax, %rdx
callq 0x2280
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rax
movb 0x58(%rax), %cl
movq -0x40(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x40(%rbp), %rax
movb %cl, (%rax)
movq -0x40(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)