// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/inter.cpp
// Function: extract_trans_scaf_res_t(uc_block_t*, ul_idx_t const*, scaf_res_t*, ma_ug_t*, kv_u_trans_t*, unsigned int, unsigned int, kv_ul_ov_t*)
void extract_trans_scaf_res_t(uc_block_t *qin, const ul_idx_t *uref, scaf_res_t *ref_sc, ma_ug_t *gfa, kv_u_trans_t *ta, uint32_t avid, uint32_t is_exact, kv_ul_ov_t *res)
{
	utg_rid_dt *a; uint64_t i, a_n; uc_block_t *rin; 
	u_trans_t *u; uint64_t k, u_n;
	ul_ov_t p; memset(&p, 0, sizeof(p));

	// fprintf(stderr, "\n[M::%s] utg%.6u%c, [%u, %u)\n", __func__, qin->hid+1, "lc"[gfa->u.a[qin->hid].circ], qin->qs, qin->qe);
	u = u_trans_a(*ta, qin->hid); 
	u_n = u_trans_n(*ta, qin->hid);
	for (k = 0; k < u_n; k++) {
		if(is_exact && u[k].f != RC_0 && u[k].f != RC_1) continue;
		// fprintf(stderr, "+[M::%s] utg%.6u%c->utg%.6u%c, q::[%u, %u), %c, t::[%u, %u)\n", __func__, qin->hid+1, "lc"[gfa->u.a[qin->hid].circ], u[k].tn+1, "lc"[gfa->u.a[u[k].tn].circ], u[k].qs, u[k].qe, "+-"[u[k].rev], u[k].ts, u[k].te);
		a = get_r_ug_region(uref->r_ug, &a_n, u[k].tn);
    	for (i = 0; i < a_n; i++) {
			if((a[i].u>>1) == avid) continue;
			rin = &(ref_sc->a[a[i].u>>1].bb.a[a[i].off]);
			if(gen_trans_ovlp_scaf(gfa, &(u[k]), qin, rin, &p)) {
				p.tn = a[i].u>>1; p.qn = u[k].f; p.el = 0; p.sec = u[k].nw;
				kv_push(ul_ov_t, *res, p);

				// fprintf(stderr, "-[M::%s] q::[%u, %u), %c, t::[%u, %u), qin->qs::%u, rin->qs::%u\n", __func__, p.qs, p.qe, "+-"[p.rev], p.ts, p.te, qin->qs, rin->qs);
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r9d, %ebx
movq %rcx, 0x50(%rsp)
movq %rdx, 0x48(%rsp)
movq %rsi, 0x30(%rsp)
movq 0x98(%rsp), %rbp
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movups %xmm0, 0xc(%rax)
movaps %xmm0, (%rax)
movq 0x28(%r8), %rax
movq %rdi, 0x40(%rsp)
movl (%rdi), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, %ecx
movq %rcx, 0x38(%rsp)
shrq $0x20, %rax
imulq $0x30, %rax, %rax
addq 0x10(%r8), %rax
movq %rax, (%rsp)
xorl %eax, %eax
cmpq 0x38(%rsp), %rax
je 0x18b291
movq %rax, 0x8(%rsp)
cmpl $0x0, 0x90(%rsp)
je 0x18b176
imulq $0x30, 0x8(%rsp), %rax
movq (%rsp), %rcx
testb $0x3e, 0x28(%rcx,%rax)
je 0x18b176
movq 0x8(%rsp), %rax
incq %rax
jmp 0x18b141
movq 0x30(%rsp), %rax
movq 0x28(%rax), %rcx
imulq $0x30, 0x8(%rsp), %r12
movq (%rsp), %rax
movl 0x14(%rax,%r12), %eax
movq (%rcx), %rsi
movl (%rsi,%rax,4), %edx
movl 0x4(%rsi,%rax,4), %eax
subl %edx, %eax
jne 0x18b1a1
xorl %r14d, %r14d
jmp 0x18b1a9
imulq $0xc, %rdx, %r14
addq 0x18(%rcx), %r14
addq (%rsp), %r12
imulq $0xc, %rax, %r15
xorl %r13d, %r13d
cmpq %r13, %r15
je 0x18b16c
movl (%r14,%r13), %eax
shrl %eax
cmpl %ebx, %eax
je 0x18b288
movq 0x48(%rsp), %rcx
movq (%rcx), %rdx
imulq $0x58, %rax, %rax
movl 0x4(%r14,%r13), %ecx
imulq $0x24, %rcx, %rcx
addq 0x30(%rdx,%rax), %rcx
movq 0x50(%rsp), %rdi
movq %r12, %rsi
movq 0x40(%rsp), %rdx
leaq 0x10(%rsp), %r8
callq 0x18aff1
testq %rax, %rax
je 0x18b288
movl (%r14,%r13), %eax
shrl %eax
movl %eax, 0x1c(%rsp)
movzbl 0x28(%r12), %eax
andl $0x3f, %eax
movl %eax, 0x10(%rsp)
cvttsd2si 0x20(%r12), %rax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movl 0x28(%rsp), %ecx
movl $0x80000000, %edx       # imm = 0x80000000
andl %edx, %ecx
orl %eax, %ecx
movl %ecx, 0x28(%rsp)
movq (%rbp), %rax
movq 0x8(%rbp), %rcx
cmpq 0x10(%rbp), %rcx
jne 0x18b269
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x10(%rbp)
imulq $0x1c, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, (%rbp)
movq 0x8(%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbp)
imulq $0x1c, %rcx, %rcx
movups 0x1c(%rsp), %xmm0
movups %xmm0, 0xc(%rax,%rcx)
movaps 0x10(%rsp), %xmm0
movups %xmm0, (%rax,%rcx)
addq $0xc, %r13
jmp 0x18b1b4
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq