// File: /workspace/github_c_makefile_star2_O3/rikuu[P]kermit/miniasm/hit.c
// Function: ma_hit_cut
size_t ma_hit_cut(const ma_sub_t *reg, int min_span, size_t n, ma_hit_t *a)
{
	size_t i, m;
	for (i = m = 0; i < n; ++i) {
		ma_hit_t *p = &a[i];
		const ma_sub_t *rq = &reg[p->qns>>32], *rt = &reg[p->tn];
		int qs, qe, ts, te;
		if (rq->del || rt->del) continue;
		if (p->rev) {
			qs = p->te < rt->e? (uint32_t)p->qns : (uint32_t)p->qns + (p->te - rt->e);
			qe = p->ts > rt->s? p->qe : p->qe - (rt->s - p->ts);
			ts = p->qe < rq->e? p->ts : p->ts + (p->qe - rq->e);
			te = (uint32_t)p->qns > rq->s? p->te : p->te - (rq->s - (uint32_t)p->qns);
		} else {
			qs = p->ts > rt->s? (uint32_t)p->qns : (uint32_t)p->qns + (rt->s - p->ts);
			qe = p->te < rt->e? p->qe : p->qe - (p->te - rt->e);
			ts = (uint32_t)p->qns > rq->s? p->ts : p->ts + (rq->s - (uint32_t)p->qns);
			te = p->qe < rq->e? p->te : p->te - (p->qe - rq->e);
		}
		qs = (qs > rq->s? qs : rq->s) - rq->s;
		qe = (qe < rq->e? qe : rq->e) - rq->s;
		ts = (ts > rt->s? ts : rt->s) - rt->s;
		te = (te < rt->e? te : rt->e) - rt->s;
		if (qe - qs >= min_span && te - ts >= min_span) {
			p->qns = p->qns>>32<<32 | qs, p->qe = qe, p->ts = ts, p->te = te;
			a[m++] = *p;
		}
	}
	if (ma_verbose >= 3)
		fprintf(stderr, "[M::%s::%s] %ld hits remain after cut\n", __func__, sys_timestamp(), m);
	return m;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdx, %rdx
je 0x5ef8
movq %rcx, 0x10(%rsp)
leaq 0x18(%rcx), %r8
movq $0x0, 0x8(%rsp)
movl %esi, 0x4(%rsp)
movq -0x18(%r8), %r10
movq %r10, %rcx
shrq $0x20, %rcx
movl (%rdi,%rcx,8), %r9d
testl %r9d, %r9d
js 0x5ee9
movl -0xc(%r8), %r14d
movl (%rdi,%r14,8), %eax
testl %eax, %eax
js 0x5ee9
testb $-0x80, 0x3(%r8)
movl -0x10(%r8), %r11d
jne 0x5e14
movl -0x8(%r8), %ebx
movl -0x4(%r8), %r13d
movl %eax, %r15d
subl %ebx, %r15d
movl $0x0, %esi
cmovbl %esi, %r15d
addl %r10d, %r15d
movl 0x4(%rdi,%r14,8), %r14d
movl %r13d, %ebp
subl %r14d, %ebp
cmovbl %esi, %ebp
movl %r9d, %r12d
subl %r10d, %r12d
cmovbl %esi, %r12d
addl %ebx, %r12d
movl 0x4(%rdi,%rcx,8), %ecx
cmpl %ecx, %r11d
jb 0x5e56
subl %r11d, %r13d
addl %ecx, %r13d
jmp 0x5e56
movl -0x8(%r8), %ebx
movl -0x4(%r8), %r13d
movl 0x4(%rdi,%r14,8), %r14d
movl %r13d, %r15d
subl %r14d, %r15d
movl $0x0, %esi
cmovbl %esi, %r15d
addl %r10d, %r15d
movl %eax, %ebp
subl %ebx, %ebp
cmovbl %esi, %ebp
movl 0x4(%rdi,%rcx,8), %ecx
movl %r11d, %r12d
subl %ecx, %r12d
cmovbl %esi, %r12d
addl %ebx, %r12d
movl %r10d, %ebx
subl %r9d, %ebx
ja 0x5e56
addl %ebx, %r13d
movl 0x4(%rsp), %esi
subl %ebp, %r11d
cmpl %r9d, %r15d
cmovlel %r9d, %r15d
subl %r9d, %r15d
cmpl %ecx, %r11d
cmovael %ecx, %r11d
subl %r9d, %r11d
cmpl %eax, %r12d
cmovlel %eax, %r12d
cmpl %r14d, %r13d
cmovbl %r13d, %r14d
movl %r11d, %ecx
subl %r15d, %ecx
cmpl %esi, %ecx
jl 0x5ee9
subl %eax, %r12d
subl %eax, %r14d
movl %r14d, %eax
subl %r12d, %eax
cmpl %esi, %eax
jl 0x5ee9
leaq -0x18(%r8), %rax
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
andq %rcx, %r10
movslq %r15d, %rcx
orq %r10, %rcx
movq %rcx, -0x18(%r8)
movl %r11d, -0x10(%r8)
movl %r12d, -0x8(%r8)
movl %r14d, -0x4(%r8)
movq 0x8(%rsp), %r9
leaq 0x1(%r9), %rcx
shlq $0x5, %r9
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movq 0x10(%rsp), %rax
movups %xmm1, 0x10(%rax,%r9)
movups %xmm0, (%rax,%r9)
movq %rcx, 0x8(%rsp)
addq $0x20, %r8
decq %rdx
jne 0x5d9b
jmp 0x5f01
movq $0x0, 0x8(%rsp)
leaq 0x8230(%rip), %rax      # 0xe138
cmpl $0x3, (%rax)
jge 0x5f21
movq 0x8(%rsp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rdi
callq 0x1cb2
jmp 0x5f0d