// File: chhylp123[P]hifiasm/inter.cpp
// Function: get_spec_ovlp_occ(eg_srt_t*, int, int, int, int, int*, int*, kvec_t_u64_warp*)
int32_t get_spec_ovlp_occ(eg_srt_t *a, int32_t a_n, int32_t st, int32_t vv, int32_t c_thres, int32_t *s, int32_t *e, kvec_t_u64_warp *res)
{
	int32_t i, dst = a[st].d, occ = 1, pp;
	(*s) = (*e) = st; res->a.n = 0;
	for (i = st + 1; i < a_n; i++) {
		if(a[i].d - dst <= vv) {
			(*e) = i; 
			if(a[i].id == a[st].id) continue;
			occ++; kv_push(uint64_t, res->a, (((uint64_t)(a[i].id))<<32)|i);
		} else {
			break;
		}
	}

	for (i = st - 1; i >= 0; i--) {
		if(dst - a[i].d <= vv) {
			(*s) = i; 
			if(a[i].id == a[st].id) continue;
			occ++; kv_push(uint64_t, res->a, (((uint64_t)(a[i].id))<<32)|i);
		} else {
			break;
		}
	}	
	if(occ >= c_thres) {
		radix_sort_gfa64(res->a.a, res->a.a + res->a.n);
		for (i = 0, pp = -1, occ = 0; i < (int32_t)res->a.n; i++) {
			if((int32_t)(res->a.a[i]>>32) != pp) {
				pp = (res->a.a[i]>>32);
				res->a.a[occ] = res->a.a[i];
				occ++;
			}
		}
		res->a.n = occ;
		if(occ >= c_thres) return occ;
		return 0;
	}
	else {
		return 0;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x30(%rbp)
movl $0x1, -0x34(%rbp)
movl -0x18(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq 0x18(%rbp), %rax
movq $0x0, (%rax)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x2f51a3
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
subl -0x30(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x2f5191
movl -0x2c(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movq -0x10(%rbp), %rcx
movslq -0x18(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x14(%rcx), %eax
jne 0x2f50e2
jmp 0x2f5195
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq 0x18(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x2f5153
movq 0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x2f5118
movq 0x18(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x40(%rbp)
jmp 0x2f5123
movl $0x2, %eax
movq %rax, -0x40(%rbp)
jmp 0x2f5123
movq -0x40(%rbp), %rcx
movq 0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x18(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x18(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl %eax, %edx
shlq $0x20, %rdx
movslq -0x2c(%rbp), %rax
orq %rax, %rdx
movq 0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movq %rdx, (%rax,%rcx,8)
jmp 0x2f5193
jmp 0x2f51a3
jmp 0x2f5195
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2f5084
movl -0x18(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jl 0x2f52c9
movl -0x30(%rbp), %eax
movq -0x10(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
subl 0x10(%rcx), %eax
cmpl -0x1c(%rbp), %eax
jg 0x2f52b7
movl -0x2c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movq -0x10(%rbp), %rcx
movslq -0x18(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x14(%rcx), %eax
jne 0x2f5208
jmp 0x2f52bb
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq 0x18(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x2f5279
movq 0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x2f523e
movq 0x18(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x48(%rbp)
jmp 0x2f5249
movl $0x2, %eax
movq %rax, -0x48(%rbp)
jmp 0x2f5249
movq -0x48(%rbp), %rcx
movq 0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x18(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x18(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl %eax, %edx
shlq $0x20, %rdx
movslq -0x2c(%rbp), %rax
orq %rax, %rdx
movq 0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movq %rdx, (%rax,%rcx,8)
jmp 0x2f52b9
jmp 0x2f52c9
jmp 0x2f52bb
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2f51ac
movl -0x34(%rbp), %eax
cmpl -0x20(%rbp), %eax
jl 0x2f53a5
movq 0x18(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x18(%rbp), %rax
movq 0x10(%rax), %rsi
movq 0x18(%rbp), %rax
movq (%rax), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x27a9b0
movl $0x0, -0x2c(%rbp)
movl $0xffffffff, -0x38(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x34(%rbp)
movl -0x2c(%rbp), %eax
movq 0x18(%rbp), %rcx
movq (%rcx), %rcx
cmpl %ecx, %eax
jge 0x2f5381
movq 0x18(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
cmpl -0x38(%rbp), %eax
je 0x2f5374
movq 0x18(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movl %eax, -0x38(%rbp)
movq 0x18(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq 0x18(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2f5376
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2f530d
movslq -0x34(%rbp), %rcx
movq 0x18(%rbp), %rax
movq %rcx, (%rax)
movl -0x34(%rbp), %eax
cmpl -0x20(%rbp), %eax
jl 0x2f539c
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2f53ac
movl $0x0, -0x4(%rbp)
jmp 0x2f53ac
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)