// File: /workspace/github_c_makefile_star2_O0/ToniWestbrook[P]paladin/bwamem.c
// Function: mem_align1_core
mem_alnreg_v mem_align1_core(const mem_opt_t *opt, const bwt_t *bwt, const bntseq_t *bns, const uint8_t *pac, int l_seq, char *seq, void *buf)
{
	int i;
	mem_chain_v chn;
	mem_alnreg_v regs;

	for (i = 0; i < l_seq; ++i) {
		// Hash IUPAC value
		seq[i] = seq[i] < VALUE_DEFINED - 1 ? seq[i] : aa_encode_hash[(int)seq[i]];
	}

	chn = mem_chain(opt, bwt, bns, l_seq, (uint8_t*)seq, buf);
	chn.n = mem_chain_flt(opt, chn.n, chn.a);
	mem_flt_chained_seeds(opt, bns, pac, l_seq, (uint8_t*)seq, chn.n, chn.a);
	if (bwa_verbose >= 4) mem_print_chain(bns, &chn);

	kv_init(regs);
	for (i = 0; i < chn.n; ++i) {
		mem_chain_t *p = &chn.a[i];
		if (bwa_verbose >= 4) err_printf("* ---> Processing chain(%d) <---\n", i);
		mem_chain2aln(opt, bns, pac, l_seq, (uint8_t*)seq, p, &regs);
		free(chn.a[i].seeds);
	}
	free(chn.a);
	regs.n = mem_sort_dedup_patch(opt, bns, pac, (uint8_t*)seq, regs.n, regs.a);
	if (opt->flag & MEM_F_SELF_OVLP)
		regs.n = mem_test_and_remove_exact(opt, regs.n, regs.a, l_seq);
	if (bwa_verbose >= 4) {
		err_printf("* %ld chains remain after removing duplicated chains\n", regs.n);
		for (i = 0; i < regs.n; ++i) {
			mem_alnreg_t *p = &regs.a[i];
			printf("** %d, [%d,%d) <=> [%ld,%ld)\n", p->score, p->qb, p->qe, (long)p->rb, (long)p->re);
		}
	}
	for (i = 0; i < regs.n; ++i) {
		mem_alnreg_t *p = &regs.a[i];
		if (p->rid >= 0 && bns->anns[p->rid].is_alt)
			p->is_alt = 1;
	}

	// Mark as filtered by default
	regs.active = 0;

	return regs;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x80(%rbp)
movq %rdi, -0x78(%rbp)
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rsi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x2bf01
movq 0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x15, %eax
jge 0x2bec3
movq 0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x84(%rbp)
jmp 0x2bee3
movq 0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movslq %eax, %rcx
leaq 0x14d57(%rip), %rax     # 0x40c30
movzbl (%rax,%rcx), %eax
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %eax
movb %al, %dl
movq 0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x2be96
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
movl -0x24(%rbp), %r8d
movq 0x10(%rbp), %r9
movq 0x18(%rbp), %rax
leaq -0x58(%rbp), %rdi
movq %rax, (%rsp)
callq 0x1cec0
movq -0x58(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %esi
movq -0x30(%rbp), %rdx
callq 0x1f620
cltq
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
movq 0x10(%rbp), %r8
movq -0x40(%rbp), %rax
movl %eax, %r9d
movq -0x30(%rbp), %rax
movq %rax, (%rsp)
callq 0x27b80
leaq 0x14eab(%rip), %rax     # 0x40e30
cmpl $0x4, (%rax)
jl 0x2bf97
movq -0x18(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1cc90
movq -0x80(%rbp), %rax
movq $0x0, 0x8(%rax)
movq $0x0, (%rax)
movq $0x0, 0x18(%rax)
movl $0x0, -0x28(%rbp)
movslq -0x28(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0x2c03d
movq -0x30(%rbp), %rax
movslq -0x28(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
leaq 0x14e53(%rip), %rax     # 0x40e30
cmpl $0x4, (%rax)
jl 0x2bff3
movl -0x28(%rbp), %esi
leaq 0xedd1(%rip), %rdi      # 0x3adbd
movb $0x0, %al
callq 0x12e40
movq -0x80(%rbp), %rax
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
movq 0x10(%rbp), %r8
movq -0x60(%rbp), %r9
movq %rax, (%rsp)
callq 0x27d70
movq -0x30(%rbp), %rax
movslq -0x28(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rdi
callq 0x3380
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x2bfb9
movq -0x30(%rbp), %rdi
callq 0x3380
movq -0x80(%rbp), %rax
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq 0x10(%rbp), %rcx
movq (%rax), %r8
movq 0x18(%rax), %r9
callq 0x26870
movl %eax, %ecx
movq -0x80(%rbp), %rax
movslq %ecx, %rcx
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movl 0x48(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x2c0a6
movq -0x80(%rbp), %rax
movq -0x8(%rbp), %rdi
movq (%rax), %rcx
movl %ecx, %esi
movq 0x18(%rax), %rdx
movl -0x24(%rbp), %ecx
callq 0x26f30
movl %eax, %ecx
movq -0x80(%rbp), %rax
movslq %ecx, %rcx
movq %rcx, (%rax)
leaq 0x14d83(%rip), %rax     # 0x40e30
cmpl $0x4, (%rax)
jl 0x2c131
movq -0x80(%rbp), %rax
movq (%rax), %rsi
leaq 0xed1f(%rip), %rdi      # 0x3addf
movb $0x0, %al
callq 0x12e40
movl $0x0, -0x28(%rbp)
movq -0x80(%rbp), %rcx
movslq -0x28(%rbp), %rax
cmpq (%rcx), %rax
jae 0x2c12f
movq -0x80(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x28(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movl 0x1c(%rax), %esi
movq -0x68(%rbp), %rax
movl 0x10(%rax), %edx
movq -0x68(%rbp), %rax
movl 0x14(%rax), %ecx
movq -0x68(%rbp), %rax
movq (%rax), %r8
movq -0x68(%rbp), %rax
movq 0x8(%rax), %r9
leaq 0xecf8(%rip), %rdi      # 0x3ae15
movb $0x0, %al
callq 0x3060
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x2c0ce
jmp 0x2c131
movl $0x0, -0x28(%rbp)
movq -0x80(%rbp), %rcx
movslq -0x28(%rbp), %rax
cmpq (%rcx), %rax
jae 0x2c1a6
movq -0x80(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x28(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jl 0x2c199
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x70(%rbp), %rcx
movslq 0x18(%rcx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x14(%rax)
je 0x2c199
movq -0x70(%rbp), %rax
movl 0x48(%rax), %ecx
andl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
orl $0x40000000, %ecx       # imm = 0x40000000
movl %ecx, 0x48(%rax)
jmp 0x2c19b
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x2c138
movq -0x78(%rbp), %rax
movq -0x80(%rbp), %rcx
movl $0x0, 0x10(%rcx)
addq $0x90, %rsp
popq %rbp
retq
nop