// File: chhylp123[P]hifiasm/gfa_ut.cpp
// Function: get_arc_support(ul_resolve_t*, unsigned long, unsigned long)
uint64_t get_arc_support(ul_resolve_t *uidx, uint64_t v, uint64_t w)
{
    uint64_t *hid_a, hid_n; ul_str_idx_t *str_idx = &(uidx->pstr);
    uint64_t z, vz, occ = 0; ul_str_t *str; int64_t s, s_n;
    hid_a = str_idx->occ.a + str_idx->idx.a[v>>1];
    hid_n = str_idx->idx.a[(v>>1)+1] - str_idx->idx.a[v>>1];

    for (z = occ = 0; z < hid_n; z++) {
        str = &(str_idx->str.a[hid_a[z]>>32]); s_n = str->cn;
        if(s_n < 2) continue;
        vz = (uint32_t)(str->a[(uint32_t)hid_a[z]]);
        assert((v>>1) == (vz>>1)); 

        if(v == vz) {
            for(s = ((uint32_t)hid_a[z]) + 1; s < s_n; s++) {
                if(((uint32_t)(str->a[s])) == w) {
                    occ++; break;
                }
            }
        } else {
            for(s = ((int32_t)((uint32_t)hid_a[z]))-1; s >= 0; s--) {
                if(((uint32_t)(str->a[s])) == (w^1)) {
                    occ++; break;
                }
            }
        }
    }
    return occ;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
addq $0x190, %rax            # imm = 0x190
movq %rax, -0x30(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x10(%rbp), %rdx
shrq %rdx
movq (%rcx,%rdx,8), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
shrq %rcx
movq 0x8(%rax,%rcx,8), %rax
movq -0x30(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x10(%rbp), %rdx
shrq %rdx
subq (%rcx,%rdx,8), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x35c10d
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movq %rax, -0x60(%rbp)
cmpq $0x2, -0x60(%rbp)
jge 0x35bfea
jmp 0x35c0fc
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
shrq %rax
movq -0x40(%rbp), %rcx
shrq %rcx
cmpq %rcx, %rax
jne 0x35c01f
jmp 0x35c03e
leaq 0x3cd19(%rip), %rdi     # 0x398d3f
leaq 0x3a18c(%rip), %rsi     # 0x3961b9
movl $0x3303, %edx           # imm = 0x3303
leaq 0x3db28(%rip), %rcx     # 0x399b61
callq 0x2130
movq -0x10(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0x35c09f
movq -0x20(%rbp), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
addl $0x1, %eax
movl %eax, %eax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
jge 0x35c09d
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
cmpq -0x18(%rbp), %rax
jne 0x35c08d
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x35c09d
jmp 0x35c08f
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x35c05d
jmp 0x35c0fa
movq -0x20(%rbp), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
subl $0x1, %eax
cltq
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jl 0x35c0f8
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq -0x18(%rbp), %rcx
xorq $0x1, %rcx
cmpq %rcx, %rax
jne 0x35c0e8
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x35c0f8
jmp 0x35c0ea
movq -0x58(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x35c0b4
jmp 0x35c0fa
jmp 0x35c0fc
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x35bf9b
movq -0x48(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)