// File: /workspace/github_c_makefile_star2_O2/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
movl 0x14(%rbx), %eax
addl 0x10(%rbx), %eax
cmpl %edi, %eax
cmovlel %edi, %eax
movl %eax, 0x4(%rsp)
movq %rcx, %r14
andq $0x0, (%rcx)
movq %rdx, %r15
movl %esi, %ebp
cmpq $0x0, 0x8(%rcx)
je 0x17eca
movq 0x10(%r14), %rax
xorl %edx, %edx
jmp 0x17ef8
movq $0x2, 0x8(%r14)
movq 0x10(%r14), %rdi
leaq 0xb973(%rip), %rdx      # 0x23850
leaq 0xc279(%rip), %r8       # 0x2415d
pushq $0x8
popq %rsi
movl $0x249, %ecx            # imm = 0x249
callq 0x1e0b4
movq %rax, 0x10(%r14)
movq (%r14), %rdx
leaq 0x1(%rdx), %rcx
movq %r14, 0x8(%rsp)
movq %rcx, (%r14)
andl $0x0, (%rax,%rdx,4)
movslq %ebp, %rdx
movq %rdx, 0x10(%rsp)
pushq $0x1
popq %r13
cmpq 0x10(%rsp), %r13
jge 0x1802c
imulq $0x60, %r13, %rdx
leaq (%r15,%rdx), %rdi
xorl %esi, %esi
cmpq %rsi, %rcx
je 0x17fc4
movslq (%rax,%rsi,4), %r8
imulq $0x60, %r8, %r8
movl 0x10(%r15,%r8), %r10d
movl 0x14(%r15,%r8), %r9d
movl 0x10(%rdi), %r14d
movl 0x14(%rdi), %ebp
cmpl %r14d, %r10d
movl %r14d, %r12d
cmovgl %r10d, %r12d
cmpl %ebp, %r9d
movl %ebp, %r11d
cmovll %r9d, %r11d
subl %r12d, %r11d
jle 0x17f88
subl %r14d, %ebp
subl %r10d, %r9d
cmpl %r9d, %ebp
cmovll %ebp, %r9d
cvtsi2ss %r11d, %xmm0
cvtsi2ss %r9d, %xmm1
mulss 0x9c(%rbx), %xmm1
ucomiss %xmm1, %xmm0
jae 0x17f8d
incq %rsi
jmp 0x17f29
addq %r15, %r8
cmpl $0x0, 0x24(%r8)
movl 0x1c(%rdi), %r9d
jne 0x17f9f
movl %r9d, 0x24(%r8)
movl 0x1c(%r8), %r10d
subl %r9d, %r10d
cmpl 0x4(%rsp), %r10d
jg 0x17fc4
cmpl $0x3fffffff, 0x48(%r8)  # imm = 0x3FFFFFFF
ja 0x17fc0
cmpl $0x3fffffff, 0x48(%rdi) # imm = 0x3FFFFFFF
ja 0x17fc4
incl 0x30(%r8)
cmpq %rsi, %rcx
jne 0x1801c
movq 0x8(%rsp), %r14
cmpq 0x8(%r14), %rcx
jne 0x1800c
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r14)
shlq $0x2, %rsi
movq %rax, %rdi
leaq 0xb85c(%rip), %rdx      # 0x23850
movl $0x259, %ecx            # imm = 0x259
leaq 0xc15d(%rip), %r8       # 0x2415d
callq 0x1e0b4
movq %rax, 0x10(%r14)
movq (%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r14)
movl %r13d, (%rax,%rcx,4)
movq %rdx, %rcx
jmp 0x18024
movl (%rax,%rsi,4), %esi
movl %esi, 0x3c(%r15,%rdx)
incq %r13
jmp 0x17f14
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq