// File: /workspace/github_cpp_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r9d, %r14d
movq %rcx, %rbx
movq %rdx, (%rsp)
movq %rsi, %r15
cmpl $-0x1, %r8d
je 0x10634b
movq (%rsp), %rsi
movl %r8d, %edx
callq 0x10629b
movq 0x8(%r15), %rcx
movq 0x28(%r15), %rdx
movl %eax, %eax
movq (%rdx,%rax,8), %rax
movl %eax, %edx
shrq $0x20, %rax
imulq $0x18, %rdx, %r12
imulq $0x18, %rax, %rax
leaq (%rax,%rcx), %r13
addq $0xc, %r13
xorl %ebp, %ebp
cmpq %rbp, %r12
je 0x10634b
movl (%r13,%rbp), %eax
testl %eax, %eax
js 0x106345
orl $0x80000000, %eax       # imm = 0x80000000
movl %eax, (%r13,%rbp)
movl -0x8(%r13,%rbp), %edx
movl -0x4(%r13,%rbp), %esi
xorl $0x1, %esi
xorl $0x1, %edx
movq %r15, %rdi
callq 0x10433c
addq $0x18, %rbp
jmp 0x106315
cmpl $-0x1, %r14d
je 0x1063b9
movq (%rsp), %rsi
movl %r14d, %edx
callq 0x10629b
movq 0x8(%r15), %rcx
movq 0x28(%r15), %rdx
movl %eax, %eax
movq (%rdx,%rax,8), %rax
movl %eax, %edx
shrq $0x20, %rax
imulq $0x18, %rdx, %r12
imulq $0x18, %rax, %rax
leaq (%rax,%rcx), %r13
addq $0xc, %r13
xorl %ebp, %ebp
cmpq %rbp, %r12
je 0x1063b9
movl (%r13,%rbp), %eax
testl %eax, %eax
js 0x1063b3
orl $0x80000000, %eax       # imm = 0x80000000
movl %eax, (%r13,%rbp)
movl -0x8(%r13,%rbp), %edx
movl -0x4(%r13,%rbp), %esi
xorl $0x1, %esi
xorl $0x1, %edx
movq %r15, %rdi
callq 0x10433c
addq $0x18, %rbp
jmp 0x106383
testq %rbx, %rbx
je 0x1064b8
xorl %r12d, %r12d
movl %r12d, %r12d
cmpq %r12, (%rbx)
jbe 0x1064b8
movq 0x10(%rbx), %rax
movl (%rax,%r12,4), %edx
movq (%rsp), %rsi
callq 0x10629b
movq 0x8(%r15), %rcx
movq 0x28(%r15), %rdx
movl %eax, %eax
movq (%rdx,%rax,8), %rax
movl %eax, %edx
shrq $0x20, %rax
imulq $0x18, %rdx, %r13
imulq $0x18, %rax, %rax
leaq (%rcx,%rax), %rbp
addq $0xc, %rbp
xorl %r14d, %r14d
cmpq %r14, %r13
je 0x10643f
movl (%rbp,%r14), %eax
testl %eax, %eax
js 0x106439
orl $0x80000000, %eax       # imm = 0x80000000
movl %eax, (%rbp,%r14)
movl -0x8(%rbp,%r14), %edx
movl -0x4(%rbp,%r14), %esi
xorl $0x1, %esi
xorl $0x1, %edx
movq %r15, %rdi
callq 0x10433c
addq $0x18, %r14
jmp 0x106409
movq 0x10(%rbx), %rax
movl (%rax,%r12,4), %edx
xorl $0x1, %edx
movq (%rsp), %rsi
callq 0x10629b
movq 0x8(%r15), %rcx
movq 0x28(%r15), %rdx
movl %eax, %eax
movq (%rdx,%rax,8), %rax
movl %eax, %edx
shrq $0x20, %rax
imulq $0x18, %rdx, %r13
imulq $0x18, %rax, %rax
leaq (%rcx,%rax), %rbp
addq $0xc, %rbp
xorl %r14d, %r14d
cmpq %r14, %r13
je 0x1064b0
movl (%rbp,%r14), %eax
testl %eax, %eax
js 0x1064aa
orl $0x80000000, %eax       # imm = 0x80000000
movl %eax, (%rbp,%r14)
movl -0x8(%rbp,%r14), %edx
movl -0x4(%rbp,%r14), %esi
xorl $0x1, %esi
xorl $0x1, %edx
movq %r15, %rdi
callq 0x10433c
addq $0x18, %r14
jmp 0x10647a
incl %r12d
jmp 0x1063c5
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq