// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]oatk/graph.c
// Function: asmg_bub_backtrack
static int asmg_bub_backtrack(asmg_t *g, uint64_t v0, uint64_t max_del, int protect_super_bubble, asmg_tbuf_t *b)
{
    uint64_t i, v, w;
    asmg_arc_t *a;

    assert(b->S.n == 0);
    if (max_del > 0) {
        uint64_t n_kept = 0;
        v = b->v_sink;
        do { ++n_kept, v = b->a[v].p; } while (v != v0);
        if (b->b.n > n_kept + max_del) return 0;
    }
    if (protect_super_bubble) {
        uint64_t n_kept, b_kept, c_kept, b_tot, c_tot;
        n_kept = b_kept = c_kept = 0;
        v = b->v_sink;
        do { ++n_kept, b_kept += g->vtx[v>>1].len, c_kept += g->vtx[v>>1].len * g->vtx[v>>1].cov, v = b->a[v].p; } while (v != v0);
        b_tot = c_tot = 0;
        for (i = 0; i < b->b.n; ++i) b_tot += g->vtx[b->b.a[i]>>1].len, c_tot += g->vtx[b->b.a[i]>>1].len * g->vtx[b->b.a[i]>>1].cov;
        // check length for super bubble protection: b_delt / n_delt * 2 > b_source + b_sink
        uint64_t le, re, le_wt, re_wt; // left and right extension 
        u64_v_t a = {0, 0, 0};
        le = re = le_wt = re_wt = 0;
        asmg_uext(g, v0^1,      g->n_vtx*2+1, 0, &le, &a, 0);
        le_wt = asmg_cwt_len(g, a.a, a.n);
        asmg_uext(g, b->v_sink, g->n_vtx*2+1, 0, &re, &a, 0);
        re_wt = asmg_cwt_len(g, a.a, a.n);
        free(a.a);
        //if ((b_tot - b_kept) * 2 > (g->vtx[v0>>1].len + g->vtx[b->v_sink>>1].len) * (b->b.n - n_kept)) return 0;
        // if ((b_tot - b_kept) * 2 > (le + re) * (b->b.n - n_kept)) return 0;
        if ((c_tot - c_kept) * (le + re) * 2 > (le_wt + re_wt) * (b_tot - b_kept)) return 0;
        // check coverage for super bubbble protection: c_delt / b_delt * 2 > c_kept / b_kept
        if ((c_tot - c_kept) * b_kept * 2 > c_kept * (b_tot - b_kept)) return 0;
    }
    for (i = 0; i < b->b.n; ++i)
        g->vtx[b->b.a[i]>>1].del = 1;
    for (i = 0; i < b->e.n; ++i) {
        a = &g->arc[b->e.a[i]];
        a->del = 1;
        asmg_arc_del(g, a->w^1, a->v^1, 1);
    }
    v = b->v_sink;
    do {
        w = b->a[v].p; // w->v
        g->vtx[v>>1].del = 0;
        asmg_arc_del(g, w, v, 0);
        asmg_arc_del(g, v^1, w^1, 0);
        v = w;
    } while (v != v0);
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x254bb
jmp 0x254da
leaq 0x9847(%rip), %rdi      # 0x2ed09
leaq 0x9718(%rip), %rsi      # 0x2ebe1
movl $0x313, %edx            # imm = 0x313
leaq 0x9840(%rip), %rcx      # 0x2ed15
callq 0x21e0
cmpq $0x0, -0x20(%rbp)
jbe 0x25547
movq $0x0, -0x58(%rbp)
movq -0x30(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0x40(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x18(%rbp), %rax
jne 0x254f5
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x58(%rbp), %rcx
addq -0x20(%rbp), %rcx
cmpq %rcx, %rax
jbe 0x25545
movl $0x0, -0x4(%rbp)
jmp 0x259bb
jmp 0x25547
cmpl $0x0, -0x24(%rbp)
je 0x25853
movq $0x0, -0x70(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x30(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x40(%rbp), %rcx
shrq %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
addq -0x68(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x40(%rbp), %rcx
shrq %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x40(%rbp), %rdx
shrq %rdx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
movl 0x20(%rcx), %ecx
andl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
movl %ecx, %ecx
imulq %rcx, %rax
addq -0x70(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0x40(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x18(%rbp), %rax
jne 0x25575
movq $0x0, -0x80(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jae 0x256d9
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x30(%rcx), %rcx
movq -0x38(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
addq -0x78(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x30(%rcx), %rcx
movq -0x38(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x30(%rbp), %rdx
movq 0x30(%rdx), %rdx
movq -0x38(%rbp), %rsi
movq (%rdx,%rsi,8), %rdx
shrq %rdx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
movl 0x20(%rcx), %ecx
andl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
movl %ecx, %ecx
imulq %rcx, %rax
addq -0x80(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x25629
leaq -0xb8(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x21f0
movq $0x0, -0xa0(%rbp)
movq $0x0, -0x98(%rbp)
movq $0x0, -0x90(%rbp)
movq $0x0, -0x88(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
xorq $0x1, %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rax
shlq %rax
addq $0x1, %rax
movl %eax, %edx
xorl %eax, %eax
movl %eax, %ecx
leaq -0x88(%rbp), %r8
leaq -0xb8(%rbp), %r9
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0x20d70
movq -0x10(%rbp), %rdi
movq -0xa8(%rbp), %rsi
movq -0xb8(%rbp), %rdx
callq 0x21730
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x68(%rax), %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rax
shlq %rax
addq $0x1, %rax
movl %eax, %edx
xorl %eax, %eax
movl %eax, %ecx
leaq -0x90(%rbp), %r8
leaq -0xb8(%rbp), %r9
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0x20d70
movq -0x10(%rbp), %rdi
movq -0xa8(%rbp), %rsi
movq -0xb8(%rbp), %rdx
callq 0x21730
movq %rax, -0xa0(%rbp)
movq -0xa8(%rbp), %rdi
callq 0x2060
movq -0x80(%rbp), %rax
subq -0x70(%rbp), %rax
movq -0x88(%rbp), %rcx
addq -0x90(%rbp), %rcx
imulq %rcx, %rax
shlq %rax
movq -0x98(%rbp), %rcx
addq -0xa0(%rbp), %rcx
movq -0x78(%rbp), %rdx
subq -0x68(%rbp), %rdx
imulq %rdx, %rcx
cmpq %rcx, %rax
jbe 0x25820
movl $0x0, -0x4(%rbp)
jmp 0x259bb
movq -0x80(%rbp), %rax
subq -0x70(%rbp), %rax
imulq -0x68(%rbp), %rax
shlq %rax
movq -0x70(%rbp), %rcx
movq -0x78(%rbp), %rdx
subq -0x68(%rbp), %rdx
imulq %rdx, %rcx
cmpq %rcx, %rax
jbe 0x25851
movl $0x0, -0x4(%rbp)
jmp 0x259bb
jmp 0x25853
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jae 0x258ab
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x30(%rcx), %rcx
movq -0x38(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %ecx
andl $0xbfffffff, %ecx       # imm = 0xBFFFFFFF
orl $0x40000000, %ecx       # imm = 0x40000000
movl %ecx, 0x20(%rax)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x2585b
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0x2592a
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x48(%rcx), %rcx
movq -0x38(%rbp), %rdx
imulq $0x30, (%rcx,%rdx,8), %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl 0x20(%rax), %ecx
andl $0xbfffffff, %ecx       # imm = 0xBFFFFFFF
orl $0x40000000, %ecx       # imm = 0x40000000
movl %ecx, 0x20(%rax)
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rsi
xorq $0x1, %rsi
movq -0x50(%rbp), %rax
movq (%rax), %rdx
xorq $0x1, %rdx
movl $0x1, %ecx
callq 0x21ce0
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x258b3
movq -0x30(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0x40(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x40(%rbp), %rcx
shrq %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %ecx
andl $0xbfffffff, %ecx       # imm = 0xBFFFFFFF
orl $0x0, %ecx
movl %ecx, 0x20(%rax)
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
xorl %ecx, %ecx
callq 0x21ce0
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
xorq $0x1, %rsi
movq -0x48(%rbp), %rdx
xorq $0x1, %rdx
xorl %ecx, %ecx
callq 0x21ce0
movq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x18(%rbp), %rax
jne 0x25936
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopw (%rax,%rax)