// File: /workspace/github_c_makefile_star2_O2/rikuu[P]kermit/miniasm/hit.c
// Function: ma_hit_contained
size_t ma_hit_contained(const ma_opt_t *opt, sdict_t *d, ma_sub_t *sub, size_t n, ma_hit_t *a)
{
	int32_t *map, r;
	size_t i, m, old_n_seq = d->n_seq;
	asg_arc_t t;
	for (i = m = 0; i < n; ++i) {
		ma_hit_t *h = &a[i];
		ma_sub_t *sq = &sub[h->qns>>32], *st = &sub[h->tn];
		r = ma_hit2arc(h, sq->e - sq->s, st->e - st->s, opt->max_hang, opt->int_frac, opt->min_ovlp, &t);
		if (r == MA_HT_QCONT) sq->del = 1;
		else if (r == MA_HT_TCONT) st->del = 1;
	}
	for (i = 0; i < d->n_seq; ++i)
		if (sub[i].del) d->seq[i].del = 1;
	ma_hit_mark_unused(d, n, a);
	map = sd_squeeze(d);
	for (i = 0; i < old_n_seq; ++i)
		if (map[i] >= 0) sub[map[i]] = sub[i];
	for (i = m = 0; i < n; ++i) {
		ma_hit_t *h = &a[i];
		int32_t qn = map[h->qns>>32], tn = map[h->tn];
		if (qn >= 0 && tn >= 0) {
			a[i].qns = (uint64_t)qn<<32 | (uint32_t)a[i].qns;
			a[i].tn = tn;
			a[m++] = a[i];
		}
	}
	free(map);
	if (ma_verbose >= 3)
		fprintf(stderr, "[M::%s::%s] %d sequences and %ld hits remain after containment removal\n", __func__, sys_timestamp(), d->n_seq, m);
	return m;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, %r14
movq %rcx, %r15
movq %rdi, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
movl (%rsi), %eax
movq %rax, 0x10(%rsp)
movq %r8, 0x20(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, 0x8(%rsp)
subq $0x1, %r15
jb 0x4bce
movl 0x4(%r14), %r13d
movl 0xc(%r14), %ebp
movl (%rdx,%r13,8), %ebx
movl 0x4(%rdx,%r13,8), %esi
movl %ebx, %eax
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl %ecx, %eax
subl %eax, %esi
movl (%rdx,%rbp,8), %r12d
movl 0x4(%rdx,%rbp,8), %edx
movl %r12d, %eax
andl %ecx, %eax
subl %eax, %edx
movq 0x30(%rsp), %rax
movss 0x18(%rax), %xmm0
movl 0x10(%rax), %ecx
movl 0x14(%rax), %r8d
movq %r14, %rdi
leaq 0x38(%rsp), %r9
callq 0x49a1
cmpl $-0x2, %eax
je 0x4bb7
cmpl $-0x3, %eax
movq 0x8(%rsp), %rdx
jne 0x4bc8
leaq (%rdx,%rbp,8), %rax
movl %r12d, %ebx
jmp 0x4bc0
movq 0x8(%rsp), %rdx
leaq (%rdx,%r13,8), %rax
orl $0x80000000, %ebx       # imm = 0x80000000
movl %ebx, (%rax)
addq $0x20, %r14
jmp 0x4b50
pushq $0xc
popq %rax
xorl %ecx, %ecx
movq 0x28(%rsp), %rbx
movq 0x20(%rsp), %r14
movq 0x18(%rsp), %r15
movl (%rbx), %esi
cmpq %rsi, %rcx
jae 0x4c03
cmpl $0x0, (%rdx,%rcx,8)
jns 0x4bfa
movq 0x8(%rbx), %rsi
orl $0x80000000, (%rsi,%rax) # imm = 0x80000000
incq %rcx
addq $0x10, %rax
jmp 0x4be2
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x3c17
movq %rbx, %rdi
callq 0x18e4
movq 0x8(%rsp), %rdi
xorl %ecx, %ecx
movq 0x10(%rsp), %r8
cmpq %rcx, %r8
je 0x4c40
movslq (%rax,%rcx,4), %rdx
testq %rdx, %rdx
js 0x4c3b
movq (%rdi,%rcx,8), %rsi
movq %rsi, (%rdi,%rdx,8)
incq %rcx
jmp 0x4c25
xorl %r12d, %r12d
movq %r14, %rcx
subq $0x1, %r15
jb 0x4c9c
movq (%rcx), %rdx
movq %rdx, %rsi
shrq $0x20, %rsi
movslq (%rax,%rsi,4), %rsi
testq %rsi, %rsi
js 0x4c96
movl 0xc(%rcx), %edi
movl (%rax,%rdi,4), %edi
testl %edi, %edi
js 0x4c96
shlq $0x20, %rsi
movl %edx, %edx
orq %rsi, %rdx
movq %rdx, (%rcx)
movl %edi, 0xc(%rcx)
leaq 0x1(%r12), %rdx
shlq $0x5, %r12
movups 0x10(%rcx), %xmm0
movups %xmm0, 0x10(%r14,%r12)
movups (%rcx), %xmm0
movups %xmm0, (%r14,%r12)
movq %rdx, %r12
addq $0x20, %rcx
jmp 0x4c46
movq %rax, %rdi
callq 0x1040
leaq 0x948d(%rip), %rax      # 0xe138
cmpl $0x3, (%rax)
jge 0x4cc2
movq %r12, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x932f(%rip), %rax      # 0xdff8
movq (%rax), %r14
xorl %eax, %eax
callq 0x1412
movl (%rbx), %r8d
leaq 0x47f3(%rip), %rsi      # 0x94d0
leaq 0x4834(%rip), %rdx      # 0x9518
movq %r14, %rdi
movq %rax, %rcx
movq %r12, %r9
xorl %eax, %eax
callq 0x1120
jmp 0x4cb0
nop