// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/hic.cpp
// Function: drop_g_edges_by_utg(bubble_type*, asg_t*, ma_ug_t*, kvec_t_u32_warp*, unsigned int, unsigned int)
void drop_g_edges_by_utg(bubble_type* bub, asg_t *bsg, ma_ug_t *bub_ug, kvec_t_u32_warp* res_btg, 
uint32_t b_utg_beg, uint32_t b_utg_sink)
{
    uint32_t i, k, v, root, nv;
    asg_arc_t *av = NULL;
    if(b_utg_beg != (uint32_t)-1)
    {
        root = b_utg_beg;
        v = get_utg_end_from_btg(bub, bub_ug, root);
        nv = asg_arc_n(bsg, v);
        av = asg_arc_a(bsg, v);
        for (i = 0; i < nv; i++)
        {
            if(av[i].del) continue;
            av[i].del = 1;
            asg_arc_del(bsg, (av[i].v)^1, (av[i].ul>>32)^1, 1);
        }
    }
    
    if(b_utg_sink != (uint32_t)-1)
    {
        root = b_utg_sink;
        v = get_utg_end_from_btg(bub, bub_ug, root);
        nv = asg_arc_n(bsg, v);
        av = asg_arc_a(bsg, v);
        for (i = 0; i < nv; i++)
        {
            if(av[i].del) continue;
            av[i].del = 1;
            asg_arc_del(bsg, (av[i].v)^1, (av[i].ul>>32)^1, 1);
        }
    }
    

    if(res_btg == NULL) return;

    for (k = 0; k < res_btg->a.n; k++)
    {
        root = res_btg->a.a[k];
        v = get_utg_end_from_btg(bub, bub_ug, root);
        nv = asg_arc_n(bsg, v);
        av = asg_arc_a(bsg, v);
        for (i = 0; i < nv; i++)
        {
            if(av[i].del) continue;
            av[i].del = 1;
            asg_arc_del(bsg, (av[i].v)^1, (av[i].ul>>32)^1, 1);
        }


        root = res_btg->a.a[k]^1;
        v = get_utg_end_from_btg(bub, bub_ug, root);
        nv = asg_arc_n(bsg, v);
        av = asg_arc_a(bsg, v);
        for (i = 0; i < nv; i++)
        {
            if(av[i].del) continue;
            av[i].del = 1;
            asg_arc_del(bsg, (av[i].v)^1, (av[i].ul>>32)^1, 1);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
cmpl $-0x1, %r8d
je 0x147ed0
movq 0x10(%rdx), %rax
movl %r8d, %edi
shrl %edi
leaq (%rdi,%rdi,4), %r10
movq 0x18(%rax,%r10,8), %rdi
testb $0x1, %r8b
jne 0x147e21
leaq (%rax,%r10,8), %rax
movl 0x10(%rax), %eax
decl %eax
movl 0x4(%rdi,%rax,8), %eax
jmp 0x147e28
movl 0x4(%rdi), %eax
xorq $0x1, %rax
movq 0x28(%rsi), %rdi
movq (%rdi,%rax,8), %rdi
testl %edi, %edi
je 0x147ed0
movq %rdi, %rax
shrq $0x20, %rax
leaq (%rax,%rax,2), %rax
shlq $0x3, %rax
addq 0x8(%rsi), %rax
movl %edi, %edi
xorl %r8d, %r8d
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
leaq (%r8,%r8,2), %r11
movl 0xc(%rax,%r11,8), %ebx
testl %ebx, %ebx
js 0x147ec8
leaq (%rax,%r11,8), %r11
orl $0x80000000, %ebx       # imm = 0x80000000
movl %ebx, 0xc(%r11)
movl 0x8(%r11), %ebx
xorq $0x1, %rbx
movq 0x28(%rsi), %r14
movq (%r14,%rbx,8), %r14
movq %r14, %rbx
andq %r10, %rbx
je 0x147ec8
movl 0x4(%r11), %r11d
movq 0x8(%rsi), %r15
shrq $0x20, %r14
shlq $0x3, %rbx
leaq (%rbx,%rbx,2), %rbx
leaq (%r14,%r14,2), %r14
leaq (%r15,%r14,8), %r14
addq $0xc, %r14
xorl %r15d, %r15d
movl -0x4(%r14,%r15), %ebp
xorl %r11d, %ebp
cmpl $0x1, %ebp
jne 0x147ebf
orb $-0x80, 0x3(%r14,%r15)
addq $0x18, %r15
cmpq %r15, %rbx
jne 0x147eac
incq %r8
cmpq %rdi, %r8
jne 0x147e56
cmpl $-0x1, %r9d
je 0x147fb2
movq 0x10(%rdx), %rax
movl %r9d, %edi
shrl %edi
leaq (%rdi,%rdi,4), %r8
movq 0x18(%rax,%r8,8), %rdi
testb $0x1, %r9b
jne 0x147f01
leaq (%rax,%r8,8), %rax
movl 0x10(%rax), %eax
decl %eax
movl 0x4(%rdi,%rax,8), %eax
jmp 0x147f08
movl 0x4(%rdi), %eax
xorq $0x1, %rax
movq 0x28(%rsi), %rdi
movq (%rdi,%rax,8), %rdi
testl %edi, %edi
je 0x147fb2
movq %rdi, %rax
shrq $0x20, %rax
leaq (%rax,%rax,2), %rax
shlq $0x3, %rax
addq 0x8(%rsi), %rax
movl %edi, %edi
xorl %r8d, %r8d
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
leaq (%r8,%r8,2), %r10
movl 0xc(%rax,%r10,8), %r11d
testl %r11d, %r11d
js 0x147faa
leaq (%rax,%r10,8), %r10
orl $0x80000000, %r11d      # imm = 0x80000000
movl %r11d, 0xc(%r10)
movl 0x8(%r10), %r11d
xorq $0x1, %r11
movq 0x28(%rsi), %rbx
movq (%rbx,%r11,8), %rbx
movq %rbx, %r11
andq %r9, %r11
je 0x147faa
movl 0x4(%r10), %r10d
movq 0x8(%rsi), %r14
shrq $0x20, %rbx
shlq $0x3, %r11
leaq (%r11,%r11,2), %r11
leaq (%rbx,%rbx,2), %rbx
leaq (%r14,%rbx,8), %rbx
addq $0xc, %rbx
xorl %r14d, %r14d
movl -0x4(%rbx,%r14), %ebp
xorl %r10d, %ebp
cmpl $0x1, %ebp
jne 0x147fa1
orb $-0x80, 0x3(%rbx,%r14)
addq $0x18, %r14
cmpq %r14, %r11
jne 0x147f8e
incq %r8
cmpq %rdi, %r8
jne 0x147f36
testq %rcx, %rcx
je 0x148195
cmpq $0x0, (%rcx)
je 0x148195
xorl %eax, %eax
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq 0x10(%rcx), %r8
movl (%r8,%rax,4), %r11d
movq 0x10(%rdx), %r8
movl %r11d, %r9d
shrl %r9d
leaq (%r9,%r9,4), %r10
movq 0x18(%r8,%r10,8), %r9
testb $0x1, %r11b
jne 0x147fff
leaq (%r8,%r10,8), %r8
movl 0x10(%r8), %r8d
decl %r8d
movl 0x4(%r9,%r8,8), %r8d
jmp 0x148007
movl 0x4(%r9), %r8d
xorq $0x1, %r8
movq 0x28(%rsi), %r9
movq (%r9,%r8,8), %r9
testl %r9d, %r9d
je 0x1480ab
movq %r9, %r8
shrq $0x20, %r8
leaq (%r8,%r8,2), %r8
shlq $0x3, %r8
addq 0x8(%rsi), %r8
movl %r9d, %r9d
xorl %r10d, %r10d
leaq (%r10,%r10,2), %r11
movl 0xc(%r8,%r11,8), %ebx
testl %ebx, %ebx
js 0x1480a3
leaq (%r8,%r11,8), %r11
orl $0x80000000, %ebx       # imm = 0x80000000
movl %ebx, 0xc(%r11)
movl 0x8(%r11), %ebx
xorq $0x1, %rbx
movq 0x28(%rsi), %r14
movq (%r14,%rbx,8), %r14
movq %r14, %rbx
andq %rdi, %rbx
je 0x1480a3
movl 0x4(%r11), %r11d
movq 0x8(%rsi), %r15
shrq $0x20, %r14
shlq $0x3, %rbx
leaq (%rbx,%rbx,2), %rbx
leaq (%r14,%r14,2), %r14
leaq (%r15,%r14,8), %r14
addq $0xc, %r14
xorl %r15d, %r15d
movl -0x4(%r14,%r15), %ebp
xorl %r11d, %ebp
cmpl $0x1, %ebp
jne 0x14809a
orb $-0x80, 0x3(%r14,%r15)
addq $0x18, %r15
cmpq %r15, %rbx
jne 0x148087
incq %r10
cmpq %r9, %r10
jne 0x148031
movq 0x10(%rcx), %r8
movl (%r8,%rax,4), %r11d
movq 0x10(%rdx), %r9
movl %r11d, %r8d
shrl %r8d
leaq (%r8,%r8,4), %r10
movq 0x18(%r9,%r10,8), %r8
testb $0x1, %r11b
jne 0x1480d6
movl 0x4(%r8), %r8d
xorq $0x1, %r8
jmp 0x1480e6
leaq (%r9,%r10,8), %r9
movl 0x10(%r9), %r9d
decl %r9d
movl 0x4(%r8,%r9,8), %r8d
movq 0x28(%rsi), %r9
movq (%r9,%r8,8), %r9
testl %r9d, %r9d
je 0x14818a
movq %r9, %r8
shrq $0x20, %r8
leaq (%r8,%r8,2), %r8
shlq $0x3, %r8
addq 0x8(%rsi), %r8
movl %r9d, %r9d
xorl %r10d, %r10d
leaq (%r10,%r10,2), %r11
movl 0xc(%r8,%r11,8), %ebx
testl %ebx, %ebx
js 0x148182
leaq (%r8,%r11,8), %r11
orl $0x80000000, %ebx       # imm = 0x80000000
movl %ebx, 0xc(%r11)
movl 0x8(%r11), %ebx
xorq $0x1, %rbx
movq 0x28(%rsi), %r14
movq (%r14,%rbx,8), %r14
movq %r14, %rbx
andq %rdi, %rbx
je 0x148182
movl 0x4(%r11), %r11d
movq 0x8(%rsi), %r15
shrq $0x20, %r14
shlq $0x3, %rbx
leaq (%rbx,%rbx,2), %rbx
leaq (%r14,%r14,2), %r14
leaq (%r15,%r14,8), %r14
addq $0xc, %r14
xorl %r15d, %r15d
movl -0x4(%r14,%r15), %ebp
xorl %r11d, %ebp
cmpl $0x1, %ebp
jne 0x148179
orb $-0x80, 0x3(%r14,%r15)
addq $0x18, %r15
cmpq %r15, %rbx
jne 0x148166
incq %r10
cmpq %r9, %r10
jne 0x148110
incl %eax
cmpq %rax, (%rcx)
ja 0x147fcc
popq %rbx
popq %r14
popq %r15
popq %rbp
retq