// File: /workspace/github_c_makefile_star2_O3/ToniWestbrook[P]paladin/bwamem.c
// Function: mem_mark_primary_se_core
static void mem_mark_primary_se_core(const mem_opt_t *opt, int n, mem_alnreg_t *a, int_v *z)
{ // similar to the loop in mem_chain_flt()
	int i, k, tmp;
	tmp = opt->a + opt->b;
	tmp = opt->o_del + opt->e_del > tmp? opt->o_del + opt->e_del : tmp;
	tmp = opt->o_ins + opt->e_ins > tmp? opt->o_ins + opt->e_ins : tmp;
	z->n = 0;
	kv_push(int, *z, 0);
	for (i = 1; i < n; ++i) {
		for (k = 0; k < z->n; ++k) {
			int j = z->a[k];
			int b_max = a[j].qb > a[i].qb? a[j].qb : a[i].qb;
			int e_min = a[j].qe < a[i].qe? a[j].qe : a[i].qe;
			if (e_min > b_max) { // have overlap
				int min_l = a[i].qe - a[i].qb < a[j].qe - a[j].qb? a[i].qe - a[i].qb : a[j].qe - a[j].qb;
				if (e_min - b_max >= min_l * opt->mask_level) { // significant overlap
					if (a[j].sub == 0) a[j].sub = a[i].score;
					if (a[j].score - a[i].score <= tmp && (a[j].is_alt || !a[i].is_alt))
						++a[j].sub_n;
					break;
				}
			}
		}
		if (k == z->n) kv_push(int, *z, i);
		else a[i].secondary = z->a[k];
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl 0x4(%rdi), %eax
movl 0xc(%rdi), %edi
addl (%rbx), %eax
addl 0x8(%rbx), %edi
cmpl %eax, %edi
cmovlel %eax, %edi
movq %rcx, %r14
movl 0x14(%rbx), %eax
addl 0x10(%rbx), %eax
movq %rdx, %r15
cmpl %edi, %eax
cmovlel %edi, %eax
movl %eax, 0x4(%rsp)
movl %esi, %ebp
movq $0x0, (%rcx)
cmpq $0x0, 0x8(%rcx)
je 0x1a8af
movq 0x10(%r14), %rax
xorl %edx, %edx
jmp 0x1a8df
movq $0x2, 0x8(%r14)
movq 0x10(%r14), %rdi
leaq 0xdffe(%rip), %rdx      # 0x288c0
leaq 0xe904(%rip), %r8       # 0x291cd
movl $0x8, %esi
movl $0x249, %ecx            # imm = 0x249
callq 0x2324c
movq %rax, 0x10(%r14)
movq (%r14), %rdx
leaq 0x1(%rdx), %rcx
movq %rcx, (%r14)
movl $0x0, (%rax,%rdx,4)
cmpl $0x2, %ebp
jl 0x1aa5a
movl %ebp, %edx
movq %rdx, 0x10(%rsp)
movl $0x1, %r13d
testq %rcx, %rcx
je 0x1a99f
movq %r14, %rsi
leaq (,%r13,2), %rdx
addq %r13, %rdx
shlq $0x5, %rdx
leaq (%r15,%rdx), %rdi
movq %rdi, 0x8(%rsp)
movl 0x10(%r15,%rdx), %r14d
movl 0x14(%r15,%rdx), %r10d
movl %r10d, %ebp
subl %r14d, %ebp
xorl %edx, %edx
movslq (%rax,%rdx,4), %rdi
leaq (%rdi,%rdi,2), %rdi
shlq $0x5, %rdi
movl 0x10(%r15,%rdi), %r12d
movl 0x14(%r15,%rdi), %r11d
cmpl %r14d, %r12d
movl %r14d, %r8d
cmovgl %r12d, %r8d
cmpl %r10d, %r11d
movl %r10d, %r9d
cmovll %r11d, %r9d
subl %r8d, %r9d
jle 0x1a98f
subl %r12d, %r11d
cmpl %r11d, %ebp
cmovll %ebp, %r11d
xorps %xmm0, %xmm0
cvtsi2ss %r9d, %xmm0
xorps %xmm1, %xmm1
cvtsi2ss %r11d, %xmm1
mulss 0x9c(%rbx), %xmm1
ucomiss %xmm1, %xmm0
jae 0x1a9a3
incq %rdx
cmpq %rdx, %rcx
jne 0x1a939
movq %rcx, %rdx
movq %rsi, %r14
jmp 0x1a9e0
xorl %edx, %edx
jmp 0x1a9e0
addq %r15, %rdi
cmpl $0x0, 0x24(%rdi)
movq 0x8(%rsp), %r10
movl 0x1c(%r10), %r8d
jne 0x1a9b9
movl %r8d, 0x24(%rdi)
movl 0x1c(%rdi), %r9d
subl %r8d, %r9d
cmpl 0x4(%rsp), %r9d
movq %rsi, %r14
jg 0x1a9e0
cmpl $0x3fffffff, 0x48(%rdi) # imm = 0x3FFFFFFF
ja 0x1a9dd
cmpl $0x3fffffff, 0x48(%r10) # imm = 0x3FFFFFFF
ja 0x1a9e0
incl 0x30(%rdi)
cmpq %rdx, %rcx
jne 0x1aa35
cmpq 0x8(%r14), %rcx
jne 0x1aa25
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r14)
shlq $0x2, %rsi
movq %rax, %rdi
leaq 0xdeb3(%rip), %rdx      # 0x288c0
movl $0x259, %ecx            # imm = 0x259
leaq 0xe7b4(%rip), %r8       # 0x291cd
callq 0x2324c
movq %rax, 0x10(%r14)
movq (%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r14)
movl %r13d, (%rax,%rcx,4)
movq %rdx, %rcx
jmp 0x1aa4c
movl (%rax,%rdx,4), %edx
leaq (,%r13,2), %rsi
addq %r13, %rsi
shlq $0x5, %rsi
movl %edx, 0x3c(%r15,%rsi)
incq %r13
cmpq 0x10(%rsp), %r13
jne 0x1a903
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq