// File: /workspace/github_c_makefile_star2_O1/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
movl 0x4(%rdi), %eax
movl 0xc(%rdi), %r8d
addl (%rdi), %eax
addl 0x8(%rdi), %r8d
cmpl %eax, %r8d
cmovlel %eax, %r8d
movq %rcx, %r14
movl 0x14(%rdi), %eax
movq %rdi, 0x10(%rsp)
addl 0x10(%rdi), %eax
movq %rdx, %r15
cmpl %r8d, %eax
cmovlel %r8d, %eax
movl %eax, 0x4(%rsp)
movl %esi, %ebp
movq $0x0, (%rcx)
cmpq $0x0, 0x8(%rcx)
jne 0x1a33f
movq $0x2, 0x8(%r14)
movq 0x10(%r14), %rdi
leaq 0xe4ab(%rip), %rdx      # 0x287d0
leaq 0xedb1(%rip), %r8       # 0x290dd
movl $0x8, %esi
movl $0x249, %ecx            # imm = 0x249
callq 0x22d64
movq %rax, 0x10(%r14)
movq (%r14), %rax
movq 0x10(%r14), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r14)
movl $0x0, (%rcx,%rax,4)
cmpl $0x2, %ebp
jl 0x1a4d8
movl %ebp, %eax
movq %rax, 0x8(%rsp)
movl $0x1, %r13d
movq (%r14), %rax
testq %rax, %rax
je 0x1a453
movq 0x10(%r14), %rdx
leaq (,%r13,2), %rcx
addq %r13, %rcx
shlq $0x5, %rcx
leaq (%r15,%rcx), %rsi
movl 0x10(%r15,%rcx), %ebx
movl 0x14(%r15,%rcx), %r9d
movl %r9d, %r12d
subl %ebx, %r12d
xorl %ecx, %ecx
movslq (%rdx,%rcx,4), %r8
leaq (%r8,%r8,2), %r10
shlq $0x5, %r10
movl 0x10(%r15,%r10), %ebp
movl 0x14(%r15,%r10), %r11d
cmpl %ebx, %ebp
movl %ebx, %edi
cmovgl %ebp, %edi
cmpl %r9d, %r11d
movl %r9d, %r8d
cmovll %r11d, %r8d
subl %edi, %r8d
jle 0x1a43a
subl %ebp, %r11d
cmpl %r11d, %r12d
cmovll %r12d, %r11d
xorps %xmm0, %xmm0
cvtsi2ss %r8d, %xmm0
xorps %xmm1, %xmm1
cvtsi2ss %r11d, %xmm1
movq 0x10(%rsp), %rdi
mulss 0x9c(%rdi), %xmm1
xorl %r11d, %r11d
ucomiss %xmm1, %xmm0
jb 0x1a435
addq %r15, %r10
cmpl $0x0, 0x24(%r10)
jne 0x1a40b
movl 0x1c(%rsi), %edi
movl %edi, 0x24(%r10)
movl 0x1c(%r10), %edi
subl 0x1c(%rsi), %edi
movl $0x7, %r11d
cmpl 0x4(%rsp), %edi
jg 0x1a435
cmpl $0x3fffffff, 0x48(%r10) # imm = 0x3FFFFFFF
ja 0x1a431
cmpl $0x3fffffff, 0x48(%rsi) # imm = 0x3FFFFFFF
ja 0x1a435
incl 0x30(%r10)
ucomiss %xmm1, %xmm0
jae 0x1a43d
xorl %r11d, %r11d
testl %r11d, %r11d
jne 0x1a455
incq %rcx
cmpq %rcx, %rax
jne 0x1a39f
movq %rax, %rcx
jmp 0x1a455
xorl %ecx, %ecx
cmpq %rcx, %rax
jne 0x1a4af
movq 0x8(%r14), %rcx
cmpq %rcx, %rax
jne 0x1a49b
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r14)
movq 0x10(%r14), %rdi
shlq $0x2, %rsi
leaq 0xe34a(%rip), %rdx      # 0x287d0
movl $0x259, %ecx            # imm = 0x259
leaq 0xec4b(%rip), %r8       # 0x290dd
callq 0x22d64
movq %rax, 0x10(%r14)
movq (%r14), %rax
movq 0x10(%r14), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r14)
movl %r13d, (%rcx,%rax,4)
jmp 0x1a4ca
movq 0x10(%r14), %rax
movl (%rax,%rcx,4), %eax
leaq (,%r13,2), %rcx
addq %r13, %rcx
shlq $0x5, %rcx
movl %eax, 0x3c(%r15,%rcx)
incq %r13
cmpq 0x8(%rsp), %r13
jne 0x1a36a
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq