// File: /workspace/github_c_makefile_star2_O1/lh3[P]miniprot/align.c
// Function: mp_align_seq
static int32_t mp_align_seq(void *km, const mp_mapopt_t *opt, const ns_opt_t *ns_opt0, int32_t nlen, const uint8_t *nseq, int32_t alen, const char *aseq, const uint8_t *ss, mp_cigar_t *cigar)
{
	int32_t i;
	if (nlen == alen * 3 && alen <= opt->kmer2) {
		cigar->c = ns_push_cigar(km, &cigar->n, &cigar->m, cigar->c, NS_CIGAR_M, alen);
		return mp_score_ungapped(alen, nseq, aseq, opt->asize, opt->mat);
	} else {
		ns_opt_t ns_opt = *ns_opt0;
		ns_rst_t rst;
		ns_opt.flag |= NS_F_CIGAR;
		ns_rst_init(&rst);
		ns_global_gs16b(km, (const char*)nseq, nlen, aseq, alen, &ns_opt, ss, &rst);
		//printf("%d\t%d\t%d\t%d\n", nlen, alen, rst.score, rst.n_cigar);
		for (i = 0; i < rst.n_cigar; ++i)
			cigar->c = ns_push_cigar(km, &cigar->n, &cigar->m, cigar->c, rst.cigar[i]&0xf, rst.cigar[i]>>4);
		kfree(km, rst.cigar);
		return rst.score;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %r9d, %r13d
movq %r8, %rbx
movl %ecx, %eax
movq %rdi, %r12
movq 0xd0(%rsp), %rbp
movq 0xc0(%rsp), %r14
leal (%r13,%r13,2), %ecx
cmpl %eax, %ecx
jne 0x7ce0
movq %rsi, %r15
cmpl %r13d, 0x60(%rsi)
jge 0x7dd7
movq 0xc8(%rsp), %r10
leaq 0x28(%rsp), %r9
movl $0xc, %ecx
movq %r9, %rdi
movq %rdx, %rsi
rep  movsq (%rsi), %es:(%rdi)
orb $0x1, (%r9)
xorps %xmm0, %xmm0
movq %rsp, %r15
movaps %xmm0, (%r15)
movaps %xmm0, 0x10(%r15)
movq %r12, %rdi
movq %rbx, %rsi
movl %eax, %edx
movq %r14, %rcx
movl %r13d, %r8d
pushq %r15
pushq %r10
callq 0x8758
addq $0x10, %rsp
cmpl $0x0, (%r15)
jle 0x7db4
xorl %ebx, %ebx
movq 0x8(%rbp), %rax
movq 0x18(%rsp), %rcx
movl (%rcx,%rbx,4), %r14d
movslq (%rbp), %rcx
testq %rcx, %rcx
je 0x7d71
movl %r14d, %edx
andl $0xe, %edx
cmpl $0xa, %edx
je 0x7d71
movl -0x4(%rax,%rcx,4), %edx
movl %edx, %esi
xorl %r14d, %esi
andl $0xf, %esi
jne 0x7d71
andl $-0x10, %r14d
addl %r14d, %edx
movl %edx, -0x4(%rax,%rcx,4)
jmp 0x7da4
movl 0x4(%rbp), %edx
cmpl %edx, %ecx
jne 0x7d96
movl %edx, %ecx
sarl %ecx
addl %edx, %ecx
addl $0x8, %ecx
movl %ecx, 0x4(%rbp)
movslq %ecx, %rdx
shlq $0x2, %rdx
movq %r12, %rdi
movq %rax, %rsi
callq 0x81a4
movslq (%rbp), %rcx
leal 0x1(%rcx), %edx
movl %edx, (%rbp)
movl %r14d, (%rax,%rcx,4)
movq %rax, 0x8(%rbp)
incq %rbx
movslq (%rsp), %rax
cmpq %rax, %rbx
jl 0x7d35
movq 0x18(%rsp), %rsi
movq %r12, %rdi
callq 0x7fd6
movl 0x10(%rsp), %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rbp), %rax
movslq (%rbp), %rcx
testq %rcx, %rcx
je 0x7ded
movl -0x4(%rax,%rcx,4), %edx
testb $0xf, %dl
je 0x7e27
movl 0x4(%rbp), %edx
cmpl %edx, %ecx
jne 0x7e12
movl %edx, %ecx
sarl %ecx
addl %edx, %ecx
addl $0x8, %ecx
movl %ecx, 0x4(%rbp)
movslq %ecx, %rdx
shlq $0x2, %rdx
movq %r12, %rdi
movq %rax, %rsi
callq 0x81a4
movl %r13d, %ecx
shll $0x4, %ecx
movslq (%rbp), %rdx
leal 0x1(%rdx), %esi
movl %esi, (%rbp)
movl %ecx, (%rax,%rdx,4)
jmp 0x7e33
movl %r13d, %esi
shll $0x4, %esi
addl %esi, %edx
movl %edx, -0x4(%rax,%rcx,4)
movq %rax, 0x8(%rbp)
testl %r13d, %r13d
jle 0x7ee5
movslq 0x94(%r15), %rcx
decl %r13d
movl $0xaaaaaaab, %edx       # imm = 0xAAAAAAAB
imulq %r13, %rdx
shrq $0x21, %rdx
incl %edx
addq $0x2, %rbx
xorl %esi, %esi
leaq 0x1089a(%rip), %rdi     # 0x18700
leaq 0x10693(%rip), %r8      # 0x18500
leaq 0x58(%r8), %r9
xorl %eax, %eax
movb -0x2(%rbx), %r10b
movb -0x1(%rbx), %r11b
movl %r10d, %ebp
shlb $0x4, %bpl
leal (,%r11,4), %r12d
orb %bpl, %r12b
movb (%rbx), %bpl
orb %bpl, %r12b
movzbl %r12b, %r12d
addq %rdi, %r12
cmpb $0x4, %bpl
cmovaeq %r9, %r12
cmpb $0x4, %r11b
cmovaeq %r9, %r12
cmpb $0x4, %r10b
cmovaeq %r9, %r12
movzbl (%r12), %r10d
imulq %rcx, %r10
movzbl (%r14,%rsi), %r11d
movzbl (%r8,%r11), %r11d
addq %r10, %r11
movsbl 0xa8(%r15,%r11), %r10d
addl %r10d, %eax
incq %rsi
addq $0x3, %rbx
cmpq %rsi, %rdx
jne 0x7e73
jmp 0x7dc5
xorl %eax, %eax
jmp 0x7dc5