// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: usg_tip_del(usg_t*, unsigned int, asg64_v*, asg64_v*)
int usg_tip_del(usg_t *g, uint32_t v, asg64_v *z_a, asg64_v *z_b)
{
    uint64_t a_n = z_a->n, b_n = z_b->n, kv, nv, i; 
    int32_t n_ext = 0; usg_arc_t *av;

    av = usg_arc_a(g, v^1); nv = usg_arc_n(g, v^1);
    for (i = kv = 0; i < nv && kv <= 1; i++) {
        if (av[i].del || g->a[av[i].v>>1].del) continue;
        kv++; 
    }
    if(kv > 1) return 0;
    n_ext += g->a[v>>1].occ; g->a[v>>1].del = 1; kv_push(uint64_t, *z_b, v>>1);

    av = usg_arc_a(g, v); nv = usg_arc_n(g, v);
    for (i = 0; i < nv; i++) {
        if (av[i].del || g->a[av[i].v>>1].del) continue;
        kv_push(uint64_t, *z_a, av[i].v);
    }   

    while (z_a->n > a_n) {
        v = z_a->a[--z_a->n]; if(g->a[v>>1].del) continue;

        av = usg_arc_a(g, v^1); nv = usg_arc_n(g, v^1);
        for (i = kv = 0; i < nv && kv < 1; i++) {
            if (av[i].del || g->a[av[i].v>>1].del) continue;
            kv++; 
        }
        if(kv > 0) continue;
        n_ext += g->a[v>>1].occ; g->a[v>>1].del = 1; kv_push(uint64_t, *z_b, v>>1);

        av = usg_arc_a(g, v); nv = usg_arc_n(g, v);
        for (i = 0; i < nv; i++) {
            if (av[i].del || g->a[av[i].v>>1].del) continue;
            kv_push(uint64_t, *z_a, av[i].v);
        }        
    }

    for (i = b_n; i < z_b->n; i++) usg_seq_del(g, z_b->a[i]);
    z_b->n = b_n; z_a->n = a_n;
    return n_ext;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r14
movq %rdx, %rbx
movl %esi, %r12d
movq %rdi, %r15
movq (%rdx), %rax
movq %rax, 0x8(%rsp)
movq (%rcx), %rax
movq %rax, 0x10(%rsp)
movq (%rdi), %rcx
movl %esi, %ebp
shrl %ebp
andl $0x1, %r12d
movl %r12d, %eax
xorl $0x1, %eax
imulq $0x78, %rbp, %r13
leaq (%rcx,%r13), %rdx
leaq (%rax,%rax,2), %rsi
movq 0x10(%rdx,%rsi,8), %rax
testq %rax, %rax
je 0x225dfa
movq 0x20(%rdx,%rsi,8), %rdx
addq $0xc, %rdx
movl $0x1, %edi
xorl %esi, %esi
cmpl $0x0, (%rdx)
js 0x225ddc
movl -0x4(%rdx), %r8d
shrl %r8d
imulq $0x78, %r8, %r8
cmpb $0x1, 0x70(%rcx,%r8)
adcq $0x0, %rsi
cmpq %rax, %rdi
jae 0x225dee
incq %rdi
addq $0x20, %rdx
cmpq $0x2, %rsi
jb 0x225dc2
xorl %eax, %eax
cmpq $0x1, %rsi
ja 0x22609f
movl 0x4(%rcx,%r13), %eax
movb $0x1, 0x70(%rcx,%r13)
movq 0x10(%rsp), %rdx
cmpq 0x8(%r14), %rdx
movl %eax, 0x4(%rsp)
jne 0x225e41
leaq (%rdx,%rdx), %rax
testq %rdx, %rdx
movl $0x2, %esi
cmovneq %rax, %rsi
movq %rsi, 0x8(%r14)
movq 0x10(%r14), %rdi
shlq $0x3, %rsi
callq 0x2370
movq %rax, 0x10(%r14)
movq (%r14), %rdx
movq (%r15), %rcx
jmp 0x225e45
movq 0x10(%r14), %rax
leaq 0x1(%rdx), %rsi
movq %rsi, (%r14)
movq %rbp, (%rax,%rdx,8)
movl %r12d, %eax
addq %r13, %rcx
leaq (%rax,%rax,2), %rax
movq 0x10(%rcx,%rax,8), %r12
testq %r12, %r12
je 0x22605d
movq 0x20(%rcx,%rax,8), %r13
addq $0x8, %r13
movl $0x2, %ebp
cmpl $0x0, 0x4(%r13)
js 0x225ed3
movq (%r15), %rax
movl (%r13), %ecx
movl %ecx, %edx
shrl %edx
imulq $0x78, %rdx, %rdx
cmpb $0x0, 0x70(%rax,%rdx)
jne 0x225ed3
movq (%rbx), %rdx
movq 0x10(%rbx), %rax
cmpq 0x8(%rbx), %rdx
jne 0x225ec6
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
cmoveq %rbp, %rsi
movq %rsi, 0x8(%rbx)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%rbx)
movl (%r13), %ecx
movq (%rbx), %rdx
movl %ecx, %ecx
leaq 0x1(%rdx), %rsi
movq %rsi, (%rbx)
movq %rcx, (%rax,%rdx,8)
addq $0x20, %r13
decq %r12
jne 0x225e76
jmp 0x22605d
movq 0x10(%rbx), %rdx
movq (%r15), %rcx
movq %rax, %rsi
decq %rax
movq %rax, (%rbx)
movq -0x8(%rdx,%rsi,8), %rbp
movl %ebp, %r13d
shrl %r13d
imulq $0x78, %r13, %r12
cmpb $0x0, 0x70(%rcx,%r12)
jne 0x225f6c
andl $0x1, %ebp
movq %rbp, %rsi
xorq $0x1, %rsi
leaq (%rcx,%r12), %rdi
leaq (%rsi,%rsi,2), %r8
movq 0x10(%rdi,%r8,8), %rsi
testq %rsi, %rsi
je 0x225f7c
movq 0x20(%rdi,%r8,8), %rdi
xorl %r8d, %r8d
movq %r8, %r9
shlq $0x5, %r9
cmpl $0x0, 0xc(%rdi,%r9)
js 0x225f5d
addq %rdi, %r9
movl 0x8(%r9), %r9d
shrl %r9d
imulq $0x78, %r9, %r9
movb 0x70(%rcx,%r9), %r9b
testb %r9b, %r9b
je 0x225f67
incq %r8
cmpq %rsi, %r8
jb 0x225f2c
jmp 0x225f67
incq %r8
cmpq %rsi, %r8
jb 0x225f2c
jmp 0x225f7c
testb %r9b, %r9b
jne 0x225f7c
cmpq 0x8(%rsp), %rax
ja 0x225ee8
jmp 0x22606b
movl 0x4(%rsp), %esi
addl 0x4(%rcx,%r12), %esi
movb $0x1, 0x70(%rcx,%r12)
movq (%r14), %rdx
movq 0x10(%r14), %rax
cmpq 0x8(%r14), %rdx
movl %esi, 0x4(%rsp)
jne 0x225fc6
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r14)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%r14)
movq (%r14), %rdx
movq (%r15), %rcx
leaq 0x1(%rdx), %rsi
movq %rsi, (%r14)
movq %r13, (%rax,%rdx,8)
addq %r12, %rcx
leaq (,%rbp,2), %rax
addq %rbp, %rax
movq 0x10(%rcx,%rax,8), %r12
testq %r12, %r12
je 0x22605d
movq 0x20(%rcx,%rax,8), %r13
addq $0x8, %r13
cmpl $0x0, 0x4(%r13)
js 0x226054
movq (%r15), %rax
movl (%r13), %ecx
movl %ecx, %edx
shrl %edx
imulq $0x78, %rdx, %rdx
cmpb $0x0, 0x70(%rax,%rdx)
jne 0x226054
movq (%rbx), %rdx
movq 0x10(%rbx), %rax
cmpq 0x8(%rbx), %rdx
jne 0x226047
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%rbx)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%rbx)
movl (%r13), %ecx
movq (%rbx), %rdx
movl %ecx, %ecx
leaq 0x1(%rdx), %rsi
movq %rsi, (%rbx)
movq %rcx, (%rax,%rdx,8)
addq $0x20, %r13
decq %r12
jne 0x225ff2
movq (%rbx), %rax
cmpq 0x8(%rsp), %rax
ja 0x225ee1
movq 0x10(%rsp), %r13
cmpq (%r14), %r13
jae 0x226090
movq %r13, %r12
movq 0x10(%r14), %rax
movl (%rax,%r12,8), %esi
movq %r15, %rdi
callq 0x21431e
incq %r12
cmpq (%r14), %r12
jb 0x226078
movq %r13, (%r14)
movq 0x8(%rsp), %rax
movq %rax, (%rbx)
movl 0x4(%rsp), %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq