// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/inter.cpp
// Function: extract_scaf_res_t(uc_block_t*, ul_idx_t const*, scaf_res_t*, unsigned int, kv_ul_ov_t*)
uint64_t extract_scaf_res_t(uc_block_t *in, const ul_idx_t *uref, scaf_res_t *ref_sc, uint32_t avid, kv_ul_ov_t *res)
{
	utg_rid_dt *a; uint64_t i, a_n, nn, nw; uc_block_t *ou; ul_ov_t p; memset(&p, 0, sizeof(p));
	a = get_r_ug_region(uref->r_ug, &a_n, in->hid);
    for (i = nn = 0; i < a_n; i++) {
		if((a[i].u>>1) == avid) continue;
		ou = &(ref_sc->a[a[i].u>>1].bb.a[a[i].off]);
		p.qn = (uint32_t)-1; p.qs = in->qs; p.qe = in->qe;
		p.tn = a[i].u>>1; p.ts = ou->qs; p.te = ou->qe; 
		p.el = 1; p.rev = ((in->rev == ou->rev)?0:1);
		nw = MAX(p.te-p.ts, p.qe-p.qs); nw *= CHAIN_MATCH; 
		p.sec = ((nw>=0x3fffffff)?(0x3fffffff):(nw));
		kv_push(ul_ov_t, *res, p);

		nn++;
    }
	return nn;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, 0x40(%rsp)
movq %rdi, %r10
movq 0x28(%rsi), %r9
movl (%rdi), %edi
movq (%r9), %rsi
movl (%rsi,%rdi,4), %eax
movl 0x4(%rsi,%rdi,4), %esi
cmpl %eax, %esi
jne 0x1d79e2
xorl %r14d, %r14d
jmp 0x1d7b53
subl %eax, %esi
movq 0x18(%r9), %rdi
cmpl $0x1, %esi
adcl $0x0, %esi
shlq $0x2, %rsi
leaq (%rsi,%rsi,2), %rdx
leaq (%rax,%rax,2), %rax
leaq (%rdi,%rax,4), %rbx
addq $0x4, %rbx
xorl %ebp, %ebp
xorl %r14d, %r14d
movq %r8, 0x30(%rsp)
movl %ecx, 0xc(%rsp)
movq %rdx, 0x28(%rsp)
movq %rbx, 0x20(%rsp)
movl -0x4(%rbx,%rbp), %r13d
shrl %r13d
cmpl %ecx, %r13d
je 0x1d7b46
movq 0x40(%rsp), %rax
movq (%rax), %rax
imulq $0x58, %r13, %rsi
movq 0x30(%rax,%rsi), %rax
movl (%rbx,%rbp), %esi
leaq (%rsi,%rsi,8), %rsi
movl 0x4(%r10), %r11d
movl 0x8(%r10), %r12d
movl 0x4(%rax,%rsi,4), %edi
movl 0x8(%rax,%rsi,4), %r9d
movb 0x20(%rax,%rsi,4), %r15b
xorb 0x20(%r10), %r15b
movl %r9d, 0x18(%rsp)
movl %r9d, %eax
movl %edi, 0x1c(%rsp)
subl %edi, %eax
movl %r12d, 0x10(%rsp)
movl %r11d, 0x14(%rsp)
subl %r11d, %r12d
cmpl %r12d, %eax
cmoval %eax, %r12d
movl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
cmpl %eax, %r12d
cmovael %eax, %r12d
movq (%r8), %rax
movq 0x8(%r8), %rdi
cmpq 0x10(%r8), %rdi
jne 0x1d7ae9
leaq (%rdi,%rdi), %r9
testq %rdi, %rdi
movl $0x2, %esi
cmoveq %rsi, %r9
movq %r9, 0x10(%r8)
leaq (%r9,%r9,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %r9, %rsi
movq %rax, %rdi
movq %r14, 0x38(%rsp)
movq %r10, %r14
callq 0x2370
movq 0x28(%rsp), %rdx
movq %r14, %r10
movq 0x38(%rsp), %r14
movq 0x30(%rsp), %r8
movq 0x20(%rsp), %rbx
movl 0xc(%rsp), %ecx
movq %rax, (%r8)
movq 0x8(%r8), %rdi
shrb $0x5, %r15b
movzbl %r15b, %r9d
shll $0x1f, %r9d
orl %r12d, %r9d
orl $0x40000000, %r9d       # imm = 0x40000000
leaq 0x1(%rdi), %rsi
movq %rsi, 0x8(%r8)
leaq (%rdi,%rdi,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rdi, %rsi
movl $0xffffffff, (%rax,%rsi) # imm = 0xFFFFFFFF
movl 0x14(%rsp), %edi
movl %edi, 0x4(%rax,%rsi)
movl 0x10(%rsp), %edi
movl %edi, 0x8(%rax,%rsi)
movl %r13d, 0xc(%rax,%rsi)
movl 0x1c(%rsp), %edi
movl %edi, 0x10(%rax,%rsi)
movl 0x18(%rsp), %edi
movl %edi, 0x14(%rax,%rsi)
movl %r9d, 0x18(%rax,%rsi)
incq %r14
addq $0xc, %rbp
cmpq %rbp, %rdx
jne 0x1d7a1a
movq %r14, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq