// File: /workspace/github_c_makefile_star2_O1/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 0x61a2
movq %rcx, 0x10(%rsp)
leaq 0x18(%rcx), %r8
movq $0x0, (%rsp)
movl %esi, 0xc(%rsp)
movq -0x18(%r8), %r10
movq %r10, %r12
shrq $0x20, %r12
movl (%rdi,%r12,8), %r15d
testl %r15d, %r15d
js 0x6193
movl -0xc(%r8), %r14d
movl (%rdi,%r14,8), %eax
testl %eax, %eax
js 0x6193
testb $-0x80, 0x3(%r8)
jne 0x60b7
movl -0x8(%r8), %ebx
movl %eax, %ebp
subl %ebx, %ebp
movl $0x0, %ecx
cmovbl %ecx, %ebp
addl %r10d, %ebp
movl -0x4(%r8), %r9d
movl %r9d, %r11d
subl 0x4(%rdi,%r14,8), %r11d
cmovbl %ecx, %r11d
movl %r15d, %r13d
subl %r10d, %r13d
cmovbl %ecx, %r13d
movl -0x10(%r8), %ecx
addl %ebx, %r13d
movl 0x4(%rdi,%r12,8), %ebx
cmpl %ebx, %ecx
jb 0x60b1
subl %ecx, %r9d
addl %ebx, %r9d
movl 0xc(%rsp), %esi
jmp 0x60f7
movl -0x4(%r8), %r9d
movl %r9d, %ebp
subl 0x4(%rdi,%r14,8), %ebp
movl $0x0, %ebx
cmovbl %ebx, %ebp
addl %r10d, %ebp
movl -0x10(%r8), %r13d
movl -0x8(%r8), %ecx
movl %eax, %r11d
subl %ecx, %r11d
cmovbl %ebx, %r11d
subl 0x4(%rdi,%r12,8), %r13d
cmovbl %ebx, %r13d
addl %ecx, %r13d
movl %r10d, %ecx
subl %r15d, %ecx
ja 0x60f7
addl %ecx, %r9d
movl -0x10(%r8), %ecx
subl %r11d, %ecx
cmpl %r15d, %ebp
cmovlel %r15d, %ebp
subl %r15d, %ebp
movl 0x4(%rdi,%r12,8), %r11d
cmpl %r11d, %ecx
cmovael %r11d, %ecx
subl %r15d, %ecx
cmpl %eax, %r13d
cmovlel %eax, %r13d
movl 0x4(%rdi,%r14,8), %r11d
cmpl %r11d, %r9d
cmovbl %r9d, %r11d
movl %ecx, %r9d
subl %ebp, %r9d
cmpl %esi, %r9d
jl 0x6193
subl %eax, %r13d
subl %eax, %r11d
movl %r11d, %eax
subl %r13d, %eax
cmpl %esi, %eax
jl 0x6193
leaq -0x18(%r8), %rax
movabsq $-0x100000000, %r9      # imm = 0xFFFFFFFF00000000
andq %r9, %r10
movslq %ebp, %r9
orq %r10, %r9
movq %r9, -0x18(%r8)
movl %ecx, -0x10(%r8)
movl %r13d, -0x8(%r8)
movl %r11d, -0x4(%r8)
movq (%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, (%rsp)
addq $0x20, %r8
decq %rdx
jne 0x603f
jmp 0x61aa
movq $0x0, (%rsp)
leaq 0x8f87(%rip), %rax      # 0xf138
cmpl $0x3, (%rax)
jge 0x61c9
movq (%rsp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rsp), %rdi
callq 0x1c97
jmp 0x61b6