// File: chhylp123[P]hifiasm/inter.cpp
// Function: check_elen_gchain(ul_ov_t*, long, float)
int64_t check_elen_gchain(ul_ov_t *a, int64_t a_n, float trans_thres)
{
	uint32_t sp_e, ep_e, ts, te, tl = 0, el = 0, iel = 0; 
	sp_e = ep_e = ts = te = (uint32_t)-1;
	int64_t k;
	for (k = a_n-1; k >= 0; k--) {
		if(ts == (uint32_t)-1 || a[k].qe <= ts) {
			if(ts != (uint32_t)-1) tl += te - ts;
            ts = a[k].qs; te = a[k].qe;
		} else {
			ts = MIN(ts, a[k].qs);
		}
		if(!(a[k].el)) continue;

		if(sp_e == (uint32_t)-1 || a[k].qe <= sp_e) {
			if(sp_e != (uint32_t)-1) el += ep_e - sp_e;
            sp_e = a[k].qs;
            ep_e = a[k].qe;
		} else {
			sp_e = MIN(sp_e, a[k].qs);
		}
	}
	if(ts != (uint32_t)-1) tl += te - ts;
	if(sp_e != (uint32_t)-1) el += ep_e - sp_e;

	iel = tl - el;
	// fprintf(stderr, "[M::%s] el:%u, iel:%u\n", __func__, el, iel);
	if((iel == 0) || (iel <= (tl*trans_thres))) return 1;
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movss %xmm0, -0x1c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x28(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x20(%rbp) # imm = 0xFFFFFFFF
movq -0x18(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jl 0x299547
cmpl $-0x1, -0x28(%rbp)
je 0x299423
movq -0x10(%rbp), %rax
imulq $0x1c, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpl -0x28(%rbp), %eax
ja 0x29945b
cmpl $-0x1, -0x28(%rbp)
je 0x299435
movl -0x2c(%rbp), %eax
subl -0x28(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
imulq $0x1c, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
imulq $0x1c, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x2c(%rbp)
jmp 0x29948f
movl -0x28(%rbp), %eax
movq -0x10(%rbp), %rcx
imulq $0x1c, -0x40(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
ja 0x299477
movl -0x28(%rbp), %eax
movl %eax, -0x44(%rbp)
jmp 0x299489
movq -0x10(%rbp), %rax
imulq $0x1c, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
imulq $0x1c, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
shrl $0x1e, %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x2994ae
jmp 0x299536
cmpl $-0x1, -0x20(%rbp)
je 0x2994c8
movq -0x10(%rbp), %rax
imulq $0x1c, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpl -0x20(%rbp), %eax
ja 0x299500
cmpl $-0x1, -0x20(%rbp)
je 0x2994da
movl -0x24(%rbp), %eax
subl -0x20(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
imulq $0x1c, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
imulq $0x1c, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x24(%rbp)
jmp 0x299534
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
imulq $0x1c, -0x40(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
ja 0x29951c
movl -0x20(%rbp), %eax
movl %eax, -0x48(%rbp)
jmp 0x29952e
movq -0x10(%rbp), %rax
imulq $0x1c, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x299536
movq -0x40(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x2993fe
cmpl $-0x1, -0x28(%rbp)
je 0x299559
movl -0x2c(%rbp), %eax
subl -0x28(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
cmpl $-0x1, -0x20(%rbp)
je 0x29956b
movl -0x24(%rbp), %eax
subl -0x20(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
subl -0x34(%rbp), %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
je 0x299594
movl -0x38(%rbp), %eax
cvtsi2ss %rax, %xmm1
movl -0x30(%rbp), %eax
cvtsi2ss %rax, %xmm0
mulss -0x1c(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jb 0x29959e
movq $0x1, -0x8(%rbp)
jmp 0x2995a6
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
popq %rbp
retq
nopl (%rax)