// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: update_ug_ou(ma_ug_t*, asg_t*)
void update_ug_ou(ma_ug_t *ug, asg_t *sg)
{
    uint32_t k, i, uv, uw, rv, rw, nv; asg_arc_t *ue, *av;
    for (k = 0; k < ug->g->n_arc; k++) {
        ue = &(ug->g->arc[k]); ue->ou = 0;
        uv = ue->ul>>32; uw = ue->v;
        if(uv&1) rv = ug->u.a[uv>>1].start^1;
        else rv = ug->u.a[uv>>1].end^1;

        if(uw&1) rw = ug->u.a[uw>>1].end;
        else rw = ug->u.a[uw>>1].start;

        av = asg_arc_a(sg, rv);
        nv = asg_arc_n(sg, rv);
        for (i = 0; i < nv; i++) {
            if(av[i].v == rw) break;
        }
        assert(i < nv);
        ue->ou = av[i].ou;
    }

    // asg_arc_t *e; uint32_t v, w;
    // for (k = 0; k < sg->n_arc; k++) {
    //     e = &(sg->arc[k]);
    //     v = e->v^1; w = (e->ul>>32)^1;
    //     av = asg_arc_a(sg, v); nv = asg_arc_n(sg, v);
    //     for (i = 0; i < nv; i++) {
    //         if(av[i].v == w) break;
    //     }
    //     if(i >= nv || av[i].ou != e->ou) fprintf(stderr, "[M::%s::asymmetry]\n", __func__);
    // }

    // for (k = 0; k < ug->g->n_arc; k++) {
    //     e = &(ug->g->arc[k]);
    //     v = e->v^1; w = (e->ul>>32)^1;
    //     av = asg_arc_a(ug->g, v); nv = asg_arc_n(ug->g, v);
    //     for (i = 0; i < nv; i++) {
    //         if(av[i].v == w) break;
    //     }
    //     if(i >= nv || av[i].ou != e->ou) fprintf(stderr, "[M::%s::asymmetry]\n", __func__);
    // }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl 0x4(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jae 0xe58fd
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movw 0x10(%rax), %cx
andw $0xc000, %cx            # imm = 0xC000
orw $0x0, %cx
movw %cx, 0x10(%rax)
movq -0x38(%rbp), %rax
movq (%rax), %rax
shrq $0x20, %rax
movl %eax, -0x1c(%rbp)
movq -0x38(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xe57c6
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
xorl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xe57e5
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
xorl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x20(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xe580e
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x20(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x28(%rbp)
jmp 0xe582a
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x20(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x24(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x24(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0xe5896
movq -0x40(%rbp), %rax
movl -0x18(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpl -0x28(%rbp), %eax
jne 0xe5889
jmp 0xe5896
jmp 0xe588b
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xe5869
movl -0x18(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0xe58a0
jmp 0xe58bf
leaq 0x2a1423(%rip), %rdi    # 0x386cca
leaq 0x2a100f(%rip), %rsi    # 0x3868bd
movl $0x2207, %edx           # imm = 0x2207
leaq 0x2a1417(%rip), %rcx    # 0x386cd1
callq 0x2130
movq -0x40(%rbp), %rax
movl -0x18(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movw 0x10(%rax), %dx
andw $0x3fff, %dx            # imm = 0x3FFF
movq -0x38(%rbp), %rax
movw 0x10(%rax), %cx
andw $0x3fff, %dx            # imm = 0x3FFF
andw $0xc000, %cx            # imm = 0xC000
orw %dx, %cx
movw %cx, 0x10(%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xe5737
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)