// File: /workspace/github_c_makefile_star2_O2/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
movq %rcx, 0x10(%rsp)
leaq 0x18(%rcx), %rax
movq $0x0, 0x8(%rsp)
movl %esi, 0x4(%rsp)
subq $0x1, %rdx
jb 0x475f
movq -0x18(%rax), %r10
movq %r10, %rcx
shrq $0x20, %rcx
movl (%rdi,%rcx,8), %r9d
testl %r9d, %r9d
js 0x4756
movl -0xc(%rax), %r14d
movl (%rdi,%r14,8), %r8d
testl %r8d, %r8d
js 0x4756
testb $-0x80, 0x3(%rax)
movl -0x10(%rax), %r11d
jne 0x4681
movl -0x8(%rax), %ebx
movl -0x4(%rax), %r13d
movl %r8d, %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 0x46c3
subl %r11d, %r13d
addl %ecx, %r13d
jmp 0x46c3
movl -0x8(%rax), %ebx
movl -0x4(%rax), %r13d
movl 0x4(%rdi,%r14,8), %r14d
movl %r13d, %r15d
subl %r14d, %r15d
movl $0x0, %esi
cmovbl %esi, %r15d
addl %r10d, %r15d
movl %r8d, %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 0x46c3
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 %r8d, %r12d
cmovlel %r8d, %r12d
cmpl %r14d, %r13d
cmovbl %r13d, %r14d
movl %r11d, %ecx
subl %r15d, %ecx
cmpl %esi, %ecx
jl 0x4756
subl %r8d, %r12d
subl %r8d, %r14d
movl %r14d, %ecx
subl %r12d, %ecx
cmpl %esi, %ecx
jl 0x4756
leaq -0x18(%rax), %rcx
movabsq $-0x100000000, %r8      # imm = 0xFFFFFFFF00000000
andq %r8, %r10
movslq %r15d, %r8
orq %r10, %r8
movq %r8, -0x18(%rax)
movl %r11d, -0x10(%rax)
movl %r12d, -0x8(%rax)
movl %r14d, -0x4(%rax)
movq 0x8(%rsp), %r9
leaq 0x1(%r9), %r8
shlq $0x5, %r9
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movq 0x10(%rsp), %rcx
movups %xmm1, 0x10(%rcx,%r9)
movups %xmm0, (%rcx,%r9)
movq %r8, 0x8(%rsp)
addq $0x20, %rax
jmp 0x45ff
leaq 0x99d2(%rip), %rax      # 0xe138
cmpl $0x3, (%rax)
jge 0x477f
movq 0x8(%rsp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x9872(%rip), %rax      # 0xdff8
movq (%rax), %r14
xorl %eax, %eax
callq 0x1412
leaq 0x4ca9(%rip), %rsi      # 0x9440
leaq 0x4cc9(%rip), %rdx      # 0x9467
movq %r14, %rdi
movq %rax, %rcx
movq 0x8(%rsp), %r8
xorl %eax, %eax
callq 0x1120
jmp 0x476b