// File: /workspace/github_c_makefile_star2_O0/ToniWestbrook[P]paladin/bwamem.c
// Function: mem_mark_primary_se
int mem_mark_primary_se(const mem_opt_t *opt, int n, mem_alnreg_t *a, int64_t id)
{
	int i, n_pri;
	int_v z = {0,0,0};
	if (n == 0) return 0;
	for (i = n_pri = 0; i < n; ++i) {
		a[i].sub = a[i].alt_sc = 0, a[i].secondary = a[i].secondary_all = -1, a[i].hash = hash_64(id+i);
		if (!a[i].is_alt) ++n_pri;
	}
	ks_introsort(mem_ars_hash, n, a);
	mem_mark_primary_se_core(opt, n, a, &z);
	for (i = 0; i < n; ++i) {
		mem_alnreg_t *p = &a[i];
		p->secondary_all = i; // keep the rank in the first round
		if (!p->is_alt && p->secondary >= 0 && a[p->secondary].is_alt)
			p->alt_sc = a[p->secondary].score;
	}
	if (n_pri >= 0 && n_pri < n) {
		kv_resize(int, z, n);
		if (n_pri > 0) ks_introsort(mem_ars_hash2, n, a);
		for (i = 0; i < n; ++i) z.a[a[i].secondary_all] = i;
		for (i = 0; i < n; ++i) {
			if (a[i].secondary >= 0) {
				a[i].secondary_all = z.a[a[i].secondary];
				if (a[i].is_alt) a[i].secondary = INT_MAX;
			} else a[i].secondary_all = -1;
		}
		if (n_pri > 0) { // mark primary for hits to the primary assembly only
			for (i = 0; i < n_pri; ++i) a[i].sub = 0, a[i].secondary = -1;
			mem_mark_primary_se_core(opt, n_pri, a, &z);
		}
	} else {
		for (i = 0; i < n; ++i)
			a[i].secondary_all = a[i].secondary;
	}
	free(z.a);
	return n_pri;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x3130
cmpl $0x0, -0x14(%rbp)
jne 0x26fe9
movl $0x0, -0x4(%rbp)
jmp 0x27356
movl $0x0, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x270b4
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x28(%rax)
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x24(%rax)
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, 0x40(%rax) # imm = 0xFFFFFFFF
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, 0x3c(%rax) # imm = 0xFFFFFFFF
movq -0x28(%rbp), %rdi
movslq -0x2c(%rbp), %rax
addq %rax, %rdi
callq 0x27360
movq %rax, %rcx
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x58(%rax)
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movl 0x48(%rax), %eax
sarl $0x1e, %eax
cmpl $0x0, %eax
jne 0x270a4
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x270a6
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x26ff7
movslq -0x14(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x23890
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
leaq -0x48(%rbp), %rcx
callq 0x27400
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x27169
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movl -0x2c(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x40(%rax)
movq -0x50(%rbp), %rax
movl 0x48(%rax), %eax
sarl $0x1e, %eax
cmpl $0x0, %eax
jne 0x27159
movq -0x50(%rbp), %rax
cmpl $0x0, 0x3c(%rax)
jl 0x27159
movq -0x20(%rbp), %rax
movq -0x50(%rbp), %rcx
movslq 0x3c(%rcx), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movl 0x48(%rax), %eax
sarl $0x1e, %eax
cmpl $0x0, %eax
je 0x27159
movq -0x20(%rbp), %rax
movq -0x50(%rbp), %rcx
movslq 0x3c(%rcx), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movl 0x1c(%rax), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x28(%rax)
jmp 0x2715b
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x270dc
cmpl $0x0, -0x30(%rbp)
jl 0x27307
movl -0x30(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x27307
movslq -0x14(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
shlq $0x2, %rsi
leaq 0x1351e(%rip), %rdx     # 0x3a6b8
movl $0x270, %ecx            # imm = 0x270
leaq 0x1381e(%rip), %r8      # 0x3a9c4
callq 0x31d40
movq %rax, -0x38(%rbp)
cmpl $0x0, -0x30(%rbp)
jle 0x271c2
movslq -0x14(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x253e0
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x271f9
movl -0x2c(%rbp), %edx
movq -0x38(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq -0x2c(%rbp), %rsi
imulq $0x60, %rsi, %rsi
addq %rsi, %rcx
movslq 0x40(%rcx), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x271c9
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x272a5
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x3c(%rax)
jl 0x2727f
movq -0x38(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rcx
movslq 0x3c(%rcx), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x40(%rax)
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movl 0x48(%rax), %eax
sarl $0x1e, %eax
cmpl $0x0, %eax
je 0x2727d
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movl $0x7fffffff, 0x3c(%rax) # imm = 0x7FFFFFFF
jmp 0x27295
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, 0x40(%rax) # imm = 0xFFFFFFFF
jmp 0x27297
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x27200
cmpl $0x0, -0x30(%rbp)
jle 0x27305
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x272f1
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x24(%rax)
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, 0x3c(%rax) # imm = 0xFFFFFFFF
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x272b2
movq -0x10(%rbp), %rdi
movl -0x30(%rbp), %esi
movq -0x20(%rbp), %rdx
leaq -0x48(%rbp), %rcx
callq 0x27400
jmp 0x27347
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x27345
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movl 0x3c(%rax), %ecx
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x40(%rax)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2730e
jmp 0x27347
movq -0x38(%rbp), %rdi
callq 0x3380
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop