// File: chhylp123[P]hifiasm/gfa_ut.cpp
// Function: get_ul_read_weight(all_ul_t*, unsigned int*, uinfo_t*, ul_vec_t*, unsigned int, unsigned int, unsigned int)
uint64_t get_ul_read_weight(all_ul_t *ul, uint32_t *prg, uinfo_t *g_idx, ul_vec_t *p, uint32_t ii, uint32_t v, uint32_t w)
{
    assert((!p->bb.a[ii].base)&&(p->bb.a[ii].hid == (v>>1))&&(p->bb.a[ii].el)&&(p->bb.a[ii].pchain));
    if(p->bb.a[ii].aidx == (uint32_t)-1) return 0; ///not connected
    uc_block_t *li = NULL, *lk = NULL; uint32_t li_v, lk_v;
    li = &(p->bb.a[ii]); li_v = (((uint32_t)(li->hid))<<1)|((uint32_t)(li->rev)); //li_v^=1;
    if(li_v != v) return 0;

    for (lk = &(p->bb.a[li->aidx]), w^=1; lk; ) {
        lk_v = (((uint32_t)(lk->hid))<<1)|((uint32_t)(lk->rev)); //lk_v^=1;
        while (lk_v != (w^1)) {
            if(g_idx[w].p==(uint32_t)-1) break;
            w = g_idx[w].p;
        }

        if(lk_v == (w^1)) {

        }

        lk = ((lk->aidx==(uint32_t)-1)?NULL:&(p->bb.a[lk->aidx]));
        
    }
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movl %r9d, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movb 0x20(%rax), %cl
shrb $0x6, %cl
andb $0x1, %cl
xorl %eax, %eax
cmpb $0x0, %cl
movb %al, -0x49(%rbp)
jne 0x322ddb
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
movl -0x30(%rbp), %edx
shrl %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x49(%rbp)
jne 0x322ddb
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movb 0x20(%rax), %cl
shrb $0x7, %cl
xorl %eax, %eax
cmpb $0x0, %cl
movb %al, -0x49(%rbp)
je 0x322ddb
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movb 0x20(%rax), %al
andb $0x1f, %al
cmpb $0x0, %al
setne %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x322de4
jmp 0x322de6
jmp 0x322e05
leaq 0x73c18(%rip), %rdi     # 0x396a05
leaq 0x733c5(%rip), %rsi     # 0x3961b9
movl $0xd22, %edx            # imm = 0xD22
leaq 0x73c5e(%rip), %rcx     # 0x396a5e
callq 0x2130
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
cmpl $-0x1, 0x1c(%rax)
jne 0x322e2a
movq $0x0, -0x8(%rbp)
jmp 0x322f54
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl (%rax), %eax
shll %eax
movq -0x38(%rbp), %rcx
movb 0x20(%rcx), %cl
shrb $0x5, %cl
andb $0x1, %cl
movzbl %cl, %ecx
orl %ecx, %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x30(%rbp), %eax
je 0x322e82
movq $0x0, -0x8(%rbp)
jmp 0x322f54
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x38(%rbp), %rcx
movl 0x1c(%rcx), %ecx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movl 0x10(%rbp), %eax
xorl $0x1, %eax
movl %eax, 0x10(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x322f4c
movq -0x40(%rbp), %rax
movl (%rax), %eax
shll %eax
movq -0x40(%rbp), %rcx
movb 0x20(%rcx), %cl
shrb $0x5, %cl
andb $0x1, %cl
movzbl %cl, %ecx
orl %ecx, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl 0x10(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
je 0x322f04
movq -0x20(%rbp), %rax
movl 0x10(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $-0x1, (%rax)
jne 0x322eef
jmp 0x322f04
movq -0x20(%rbp), %rax
movl 0x10(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, 0x10(%rbp)
jmp 0x322ecd
movl -0x48(%rbp), %eax
movl 0x10(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0x322f13
jmp 0x322f13
movq -0x40(%rbp), %rax
cmpl $-0x1, 0x1c(%rax)
jne 0x322f25
xorl %eax, %eax
movq %rax, -0x58(%rbp)
jmp 0x322f3f
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x40(%rbp), %rcx
movl 0x1c(%rcx), %ecx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x322ea5
movq $0x1, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nop