// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: process_tangles(ma_ug_t*, unsigned long*, unsigned long, unsigned int, unsigned int, buf_t*, unsigned char*, unsigned int, long long, long long)
inline uint32_t process_tangles(ma_ug_t *ug, uint64_t* nodes, uint64_t nodes_n, uint32_t beg, uint32_t end,
buf_t* bb, uint8_t* visit, uint32_t trio_flag, long long totalNodeLen, long long totalBaseLen)
{
    uint32_t n_reduce = 1, v, w, kv, is_found = 0;
    asg_t* nsg = ug->g;

    while (n_reduce != 0)
    {
        while (n_reduce != 0)
        {
            n_reduce = 0;
            n_reduce += drop_tips_at_tangle(nsg, nodes, nodes_n, beg, end, bb);
            n_reduce += pop_bubble_at_tangle(ug, totalBaseLen, nodes, nodes_n, beg, end, trio_flag, DROP);
        }
        n_reduce = drop_useless_edges(ug, bb, visit, beg, end, nodes, nodes_n, totalNodeLen);
    }
    // if(pop_bubble_at_tangle(ug, 10000000, nodes, nodes_n, beg, end, trio_flag, DROP)!=0)
    // {
    //     fprintf(stderr, "false bubble popping: beg: %u, end: %u\n", beg>>1, end>>1);
    // }

    v = beg;
    is_found = 0;
    while (1)
    {
        if(v == end) is_found = 1;
        if(is_found == 1) break;

        kv = get_real_length(nsg, v, NULL);
        if(kv!=1) break;
        kv = get_real_length(nsg, v, &w);
        if(get_real_length(nsg, w^1, NULL)!=1) break;

        v = w;
        if(v == beg) break;
    }
    return is_found;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movl $0x1, -0x2c(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x168cca
jmp 0x168c34
cmpl $0x0, -0x2c(%rbp)
je 0x168c96
movl $0x0, -0x2c(%rbp)
movq -0x48(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %r8d
movq -0x28(%rbp), %r9
callq 0x1476b0
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
movq 0x28(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
movl 0x18(%rbp), %eax
movl %eax, (%rsp)
movl $0x5, 0x8(%rsp)
callq 0x147900
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x168c34
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq 0x10(%rbp), %rdx
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %r8d
movq -0x10(%rbp), %r9
movq -0x18(%rbp), %r10
movq 0x20(%rbp), %rax
movq %r10, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x148180
movl %eax, -0x2c(%rbp)
jmp 0x168c28
movl -0x1c(%rbp), %eax
movl %eax, -0x30(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x20(%rbp), %eax
jne 0x168ce6
movl $0x1, -0x3c(%rbp)
cmpl $0x1, -0x3c(%rbp)
jne 0x168cee
jmp 0x168d48
movq -0x48(%rbp), %rdi
movl -0x30(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
movl %eax, -0x38(%rbp)
cmpl $0x1, -0x38(%rbp)
je 0x168d09
jmp 0x168d48
movq -0x48(%rbp), %rdi
movl -0x30(%rbp), %esi
leaq -0x34(%rbp), %rdx
callq 0x166b50
movl %eax, -0x38(%rbp)
movq -0x48(%rbp), %rdi
movl -0x34(%rbp), %esi
xorl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
cmpl $0x1, %eax
je 0x168d36
jmp 0x168d48
movl -0x34(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jne 0x168d46
jmp 0x168d48
jmp 0x168cd7
movl -0x3c(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)