// File: chhylp123[P]hifiasm/gfa_ut.cpp
// Function: get_bridges(ul_resolve_t*, unsigned long*, unsigned long, unsigned int*, unsigned int*)
inline void get_bridges(ul_resolve_t *uidx, uint64_t *v_a, uint64_t v_n, uint32_t *w_occ, uint32_t *am_occ)
{
    ul_bg_t *bg = &(uidx->uovl.bg); uint64_t k, w, am, l; uint32_t uv, uw, bv, bw; 
    for (k = w = am = 0, uv = uw = (uint32_t)-1; k < v_n; k++) {
        w += bg->w_n[v_a[k]>>1]; am += bg->a_n[v_a[k]>>1]; uw = v_a[k];
        if(uv != (uint32_t)-1) {
            bv = uidx->uovl.cc.iug_a[uv>>1].a[((uv&1)?(0):(uidx->uovl.cc.iug_a[uv>>1].n-1))].v; if(uv&1) bv ^= 1;
            bw = uidx->uovl.cc.iug_a[uw>>1].a[((uw&1)?(uidx->uovl.cc.iug_a[uw>>1].n-1):(0))].v; if(uw&1) bw ^= 1;
            if((ulg_type(uidx->uovl, (bv>>1))) && (ulg_type(uidx->uovl, (bw>>1)))) {
                l = get_bg_flag(uidx, bv, bw);
                if(l == bg_wrong) w++;
                if(l == bg_ambiguous) am++;
            }
        }
        uv = uw;
    }
    if(w_occ) *w_occ = w;
    if(am_occ) *am_occ = am;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
addq $0x1f0, %rax            # imm = 0x1F0
addq $0x88, %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
movl $0xffffffff, -0x58(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x54(%rbp) # imm = 0xFFFFFFFF
movq -0x38(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x37d288
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq -0x38(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq %rcx
movl (%rax,%rcx,4), %eax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq -0x38(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq %rcx
movl (%rax,%rcx,4), %eax
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, -0x58(%rbp)
cmpl $-0x1, -0x54(%rbp)
je 0x37d271
movq -0x8(%rbp), %rax
movq 0x260(%rax), %rax
movl -0x54(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x68(%rbp)
movl -0x54(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x37d118
xorl %eax, %eax
movq %rax, -0x70(%rbp)
jmp 0x37d13c
movq -0x8(%rbp), %rax
movq 0x260(%rax), %rax
movl -0x54(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
subq $0x1, %rax
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rax
movq -0x70(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x5c(%rbp)
movl -0x54(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x37d164
movl -0x5c(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x8(%rbp), %rax
movq 0x260(%rax), %rax
movl -0x58(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x78(%rbp)
movl -0x58(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x37d1b6
movq -0x8(%rbp), %rax
movq 0x260(%rax), %rax
movl -0x58(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
subq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0x37d1be
xorl %eax, %eax
movq %rax, -0x80(%rbp)
jmp 0x37d1be
movq -0x78(%rbp), %rax
movq -0x80(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x60(%rbp)
movl -0x58(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x37d1e6
movl -0x60(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x60(%rbp)
movl -0x5c(%rbp), %eax
shrl %eax
movl %eax, %eax
movl %eax, %edx
movq -0x8(%rbp), %rax
movq 0x208(%rax), %rsi
movl $0x1, %eax
xorl %ecx, %ecx
cmpq %rsi, %rdx
cmovael %ecx, %eax
cmpl $0x0, %eax
je 0x37d26f
movl -0x60(%rbp), %eax
shrl %eax
movl %eax, %eax
movl %eax, %edx
movq -0x8(%rbp), %rax
movq 0x208(%rax), %rsi
movl $0x1, %eax
xorl %ecx, %ecx
cmpq %rsi, %rdx
cmovael %ecx, %eax
cmpl $0x0, %eax
je 0x37d26f
movq -0x8(%rbp), %rdi
movl -0x5c(%rbp), %esi
movl -0x60(%rbp), %edx
callq 0x37d2c0
movl %eax, %eax
movq %rax, -0x50(%rbp)
cmpq $0x2, -0x50(%rbp)
jne 0x37d25a
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
cmpq $0x3, -0x50(%rbp)
jne 0x37d26d
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x37d26f
jmp 0x37d271
movl -0x58(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x37d079
cmpq $0x0, -0x20(%rbp)
je 0x37d29b
movq -0x40(%rbp), %rax
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, -0x28(%rbp)
je 0x37d2ae
movq -0x48(%rbp), %rax
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)