// File: chhylp123[P]hifiasm/gfa_ut.cpp
// Function: usg_real_tip(usg_t*, unsigned int, double)
uint32_t usg_real_tip(usg_t *g, uint32_t v0, double rate)
{
    usg_arc_t *av, *aw; uint32_t nv, nw, i, k, ov, ow;
    av = usg_arc_a(g, v0); 
    nv = usg_arc_n(g, v0);
    for (i = 0; i < nv; i++) {
        if(av[i].del) continue;
        aw = usg_arc_a(g, (av[i].v^1)); 
        nw = usg_arc_n(g, (av[i].v^1)); 
        for (k = ov = ow = 0; k < nw; k++) {
            if(aw[k].del) continue;
            if((aw[k].v>>1) == (v0>>1)) {
                if(aw[k].ol > ov) ov = aw[k].ol;
            } else {
                if(aw[k].ol > ow) ow = aw[k].ol;
            }
        }
        if(ow == 0 || ov >= ow) return 0;
        if(ov > (ow*rate)) return 0;
    }
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movsd %xmm0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x14(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movl -0x14(%rbp), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x14(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movl -0x14(%rbp), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, -0x34(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jae 0x34e163
movq -0x28(%rbp), %rax
movl -0x3c(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x34df9f
jmp 0x34e155
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movl -0x3c(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
xorl $0x1, %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movq -0x28(%rbp), %rcx
movl -0x3c(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
xorl $0x1, %ecx
andl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movl -0x3c(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
xorl $0x1, %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movq -0x28(%rbp), %rcx
movl -0x3c(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
xorl $0x1, %ecx
andl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, -0x38(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x38(%rbp), %eax
jae 0x34e118
movq -0x30(%rbp), %rax
movl -0x40(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x34e080
jmp 0x34e10a
movq -0x30(%rbp), %rax
movl -0x40(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
shrl %eax
movl -0x14(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jne 0x34e0d2
movq -0x30(%rbp), %rax
movl -0x40(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpl -0x44(%rbp), %eax
jbe 0x34e0d0
movq -0x30(%rbp), %rax
movl -0x40(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x44(%rbp)
jmp 0x34e108
movq -0x30(%rbp), %rax
movl -0x40(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpl -0x48(%rbp), %eax
jbe 0x34e106
movq -0x30(%rbp), %rax
movl -0x40(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x48(%rbp)
jmp 0x34e108
jmp 0x34e10a
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x34e056
cmpl $0x0, -0x48(%rbp)
je 0x34e126
movl -0x44(%rbp), %eax
cmpl -0x48(%rbp), %eax
jb 0x34e12f
movl $0x0, -0x4(%rbp)
jmp 0x34e16a
movl -0x44(%rbp), %eax
cvtsi2sd %rax, %xmm0
movl -0x48(%rbp), %eax
cvtsi2sd %rax, %xmm1
mulsd -0x20(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x34e153
movl $0x0, -0x4(%rbp)
jmp 0x34e16a
jmp 0x34e155
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x34df75
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nop