// File: chhylp123[P]hifiasm/gfa_ut.cpp
// Function: get_eul_weight(bubble_type*, unsigned int, unsigned int, uinfo_t*, ubuf_t*, all_ul_t*, asg_t*)
uint64_t get_eul_weight(bubble_type* bub, uint32_t v, uint32_t w, uinfo_t *g_idx, ubuf_t *b, all_ul_t *ul, asg_t *g)
{
    uint64_t *a, to = 0; int64_t a_n, l, k;
    a = ul->ridx.occ.a + ul->ridx.idx.a[v>>1];
	a_n = ul->ridx.idx.a[(v>>1)+1] - ul->ridx.idx.a[v>>1]; 
    b->dp.pat.n = b->dp.pat_cor.n = b->dp.ref.n = 0;
    for (l = 0, k = 1; k <= a_n; k++) {
        if((k == a_n) || ((a[k]>>32) != (a[l]>>32))) {
            // if((v == 106 && w == 103) || (v == 24 && w == 23)) {
            //     fprintf(stderr, "+[M::%s::] l->%ld, k->%ld, a_n->%ld\n", __func__, l, k, a_n);
            // }
            to += ul_dp(bub, ul, b, a + l, k - l, g, v, w, 1);
            // if((v == 106 && w == 103) || (v == 24 && w == 23)) { 
            //     fprintf(stderr, "-[M::%s::] l->%ld, k->%ld, a_n->%ld\n", __func__, l, k, a_n);
            // }
            to += ul_dp(bub, ul, b, a + l, k - l, g, v, w, 0);
            // if((v == 106 && w == 103) || (v == 24 && w == 23)) {
            //     fprintf(stderr, "*[M::%s::] l->%ld, k->%ld, a_n->%ld\n", __func__, l, k, a_n);
            // }
            l = k;
        }
    }

    return to;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x28(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0xc(%rbp), %edx
shrl %edx
movl %edx, %edx
movl (%rcx,%rdx,4), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movl -0xc(%rbp), %ecx
shrl %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movq -0x28(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0xc(%rbp), %edx
shrl %edx
movl %edx, %edx
subl (%rcx,%rdx,4), %eax
movl %eax, %eax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rax
movq $0x0, 0x90(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0xc0(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0xa8(%rax)
movq $0x0, -0x48(%rbp)
movq $0x1, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x40(%rbp), %rax
jg 0x325c1e
movq -0x50(%rbp), %rax
cmpq -0x40(%rbp), %rax
je 0x325b6a
movq -0x30(%rbp), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq -0x30(%rbp), %rcx
movq -0x48(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
cmpq %rcx, %rax
je 0x325c0b
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x48(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x50(%rbp), %r8
subq -0x48(%rbp), %r8
movq 0x10(%rbp), %r9
movl -0xc(%rbp), %r10d
movl -0x10(%rbp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movl $0x1, 0x10(%rsp)
callq 0x325710
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x48(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x50(%rbp), %r8
subq -0x48(%rbp), %r8
movq 0x10(%rbp), %r9
movl -0xc(%rbp), %r10d
movl -0x10(%rbp), %eax
xorl %r11d, %r11d
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x325710
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x325c0d
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x325b29
movq -0x38(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)