// File: /workspace/github_c_makefile_star2_O3/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, %r15
movq 0xd0(%rsp), %rbp
movq 0xc0(%rsp), %r14
leal (%r13,%r13,2), %ecx
cmpl %eax, %ecx
jne 0x80ec
movq %rsi, %r12
cmpl %r13d, 0x60(%rsi)
jge 0x81e6
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, %r12
movaps %xmm0, (%r12)
movaps %xmm0, 0x10(%r12)
movq %r15, %rdi
movq %rbx, %rsi
movl %eax, %edx
movq %r14, %rcx
movl %r13d, %r8d
pushq %r12
pushq %r10
callq 0x8b54
addq $0x10, %rsp
cmpl $0x0, (%r12)
jle 0x81c3
movq 0x8(%rbp), %rax
xorl %ebx, %ebx
movq 0x18(%rsp), %rcx
movl (%rcx,%rbx,4), %r14d
movslq (%rbp), %rcx
testq %rcx, %rcx
je 0x8180
movl %r14d, %edx
andl $0xe, %edx
cmpl $0xa, %edx
je 0x8180
movl -0x4(%rax,%rcx,4), %edx
movl %edx, %esi
xorl %r14d, %esi
andl $0xf, %esi
jne 0x8180
andl $-0x10, %r14d
addl %r14d, %edx
movl %edx, -0x4(%rax,%rcx,4)
jmp 0x81b3
cmpl 0x4(%rbp), %ecx
jne 0x81a6
movl %ecx, %edx
sarl %edx
addl %edx, %ecx
addl $0x8, %ecx
movl %ecx, 0x4(%rbp)
movslq %ecx, %rdx
shlq $0x2, %rdx
movq %r15, %rdi
movq %rax, %rsi
callq 0x85ad
movl (%rbp), %ecx
leal 0x1(%rcx), %edx
movl %edx, (%rbp)
movslq %ecx, %rcx
movl %r14d, (%rax,%rcx,4)
movq %rax, 0x8(%rbp)
incq %rbx
movslq (%rsp), %rcx
cmpq %rcx, %rbx
jl 0x8148
movq 0x18(%rsp), %rsi
movq %r15, %rdi
callq 0x83df
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 0x81fc
movl -0x4(%rax,%rcx,4), %edx
testb $0xf, %dl
je 0x8236
cmpl 0x4(%rbp), %ecx
jne 0x8222
movl %ecx, %edx
sarl %edx
addl %edx, %ecx
addl $0x8, %ecx
movl %ecx, 0x4(%rbp)
movslq %ecx, %rdx
shlq $0x2, %rdx
movq %r15, %rdi
movq %rax, %rsi
callq 0x85ad
movl (%rbp), %ecx
movl %r13d, %edx
shll $0x4, %edx
leal 0x1(%rcx), %esi
movl %esi, (%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x8242
movl %r13d, %esi
shll $0x4, %esi
addl %esi, %edx
movl %edx, -0x4(%rax,%rcx,4)
movq %rax, 0x8(%rbp)
testl %r13d, %r13d
jle 0x82f4
movslq 0x94(%r12), %rcx
decl %r13d
movl $0xaaaaaaab, %edx       # imm = 0xAAAAAAAB
imulq %r13, %rdx
shrq $0x21, %rdx
incl %edx
addq $0x2, %rbx
xorl %esi, %esi
leaq 0x1148a(%rip), %rdi     # 0x19700
leaq 0x11283(%rip), %r8      # 0x19500
leaq 0x58(%r8), %r9
xorl %eax, %eax
movb -0x2(%rbx), %r10b
movb -0x1(%rbx), %r11b
movl %r10d, %ebp
shlb $0x4, %bpl
leal (,%r11,4), %r15d
orb %bpl, %r15b
movb (%rbx), %bpl
orb %bpl, %r15b
movzbl %r15b, %r15d
addq %rdi, %r15
cmpb $0x4, %bpl
cmovaeq %r9, %r15
cmpb $0x4, %r11b
cmovaeq %r9, %r15
cmpb $0x4, %r10b
cmovaeq %r9, %r15
movzbl (%r15), %r10d
imulq %rcx, %r10
movzbl (%r14,%rsi), %r11d
movzbl (%r8,%r11), %r11d
addq %r10, %r11
movsbl 0xa8(%r12,%r11), %r10d
addl %r10d, %eax
incq %rsi
addq $0x3, %rbx
cmpq %rsi, %rdx
jne 0x8283
jmp 0x81d4
xorl %eax, %eax
jmp 0x81d4
nop