// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/tovlp.cpp
// Function: get_min_dec(clean_mul_t*, unsigned int, unsigned int, utg_trans_t*, unsigned int*)
int get_min_dec(clean_mul_t *cl, uint32_t positive_flag, uint32_t negative_flag, utg_trans_t *o, uint32_t *v)
{
    uint32_t i, n_pop;
    clean_t *p = NULL;
    (*v) = (uint32_t)-1;
    for (i = 0; i < cl->n; i++) cl->a[i].is_b = 0, cl->a[i].min_v = (uint32_t)-1;    
    kt_for(cl->n, bub_iden_worker, cl, cl->g->n_seq<<1);///fast check if there are bubbles in graph
    for (i = 0; i < cl->n; i++)
    {
        if(cl->a[i].is_b) ///pop bubble
        {
            ///pop all bubbles
            n_pop = asg_pop_bubble_primary_trio(cl->g, cl->ug, cl->bs_flag, &(cl->a[i].b),
            cl->max_dist, positive_flag, negative_flag, o);
            if(n_pop ==0) fprintf(stderr, "ERROR-n_pop\n");
            break;
        } 
    }
    kt_for(cl->n, unitig_iden_worker, cl, cl->g->n_seq<<1);
    for (i = 0; i < cl->n; i++)
    {
        if(cl->a[i].min_v == (uint32_t)-1) continue;
        // if(b->min_v == (uint32_t)-1 || (b->min_d > d) || (b->min_d == d && b->min_v < eid))
        ///looks like select the minum node, and back
        if(!p || p->min_d > cl->a[i].min_d || 
        (p->min_d == cl->a[i].min_d && cl->g->seq[p->min_v>>1].len > cl->g->seq[cl->a[i].min_v>>1].len) ||
        (p->min_d == cl->a[i].min_d && cl->g->seq[p->min_v>>1].len == cl->g->seq[cl->a[i].min_v>>1].len && p->min_v > cl->a[i].min_v))
        {
            p = &(cl->a[i]);
        }
    }
    if(p) (*v) = p->min_v;
    return p?1:0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %r8, %rbx
movq %rcx, %r12
movl %edx, %r15d
movl %esi, %ebp
movq %rdi, %r14
movl $0xffffffff, (%r8)      # imm = 0xFFFFFFFF
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0x1912dc
movl $0x198, %eax            # imm = 0x198
addq (%r14), %rax
movl $0x1, %ecx
movl $0x0, (%rax)
movl $0xffffffff, -0x18(%rax) # imm = 0xFFFFFFFF
movl %ecx, %edx
addq $0x1a0, %rax            # imm = 0x1A0
incl %ecx
cmpq %rdx, %rdi
ja 0x1912c0
movq 0x30(%r14), %rax
movl 0x14(%rax), %eax
addl %eax, %eax
movslq %eax, %rcx
leaq 0x16d(%rip), %rsi       # 0x19145c
movq %r14, %rdx
callq 0x1047b4
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x191358
movq (%r14), %rcx
movl $0x1, %edx
xorl %esi, %esi
imulq $0x1a0, %rsi, %rsi      # imm = 0x1A0
cmpl $0x0, 0x198(%rcx,%rsi)
jne 0x191326
movl %edx, %esi
incl %edx
cmpq %rsi, %rax
ja 0x19130a
jmp 0x191358
addq %rsi, %rcx
movq 0x30(%r14), %rdi
movq 0x38(%r14), %rsi
movq 0x18(%r14), %r8
movq 0x20(%r14), %rdx
addq $0x118, %rcx            # imm = 0x118
movl %ebp, %r9d
pushq %r12
pushq %r15
callq 0x191012
addq $0x10, %rsp
testl %eax, %eax
je 0x191452
movl 0x8(%r14), %edi
movq 0x30(%r14), %rax
movl 0x14(%rax), %eax
addl %eax, %eax
movslq %eax, %rcx
leaq 0x13c(%rip), %rsi       # 0x1914ab
movq %r14, %rdx
callq 0x1047b4
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x191432
movq (%r14), %rdx
movl $0x1, %esi
xorl %ecx, %ecx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movl 0x180(%rdx), %r9d
cmpq %rdi, %r9
je 0x1913c0
testq %rcx, %rcx
je 0x1913bd
movq 0x190(%rcx), %r10
movq 0x190(%rdx), %r11
cmpq %r11, %r10
jle 0x1913d3
movq %rdx, %rcx
movl %esi, %r9d
addq $0x1a0, %rdx            # imm = 0x1A0
incl %esi
cmpq %r9, %rax
ja 0x191399
jmp 0x191434
jne 0x1913c0
movq 0x30(%r14), %r15
movq 0x20(%r15), %r15
movl 0x180(%rcx), %r12d
shrl %r12d
movl (%r15,%r12,8), %ebp
andl %r8d, %ebp
movl %r9d, %r12d
shrl %r12d
movl (%r15,%r12,8), %r15d
andl %r8d, %r15d
cmpl %r15d, %ebp
ja 0x1913bd
cmpq %r11, %r10
jne 0x1913c0
movl 0x180(%rcx), %r10d
cmpl %r9d, %r10d
jbe 0x1913c0
movq 0x30(%r14), %r11
movq 0x20(%r11), %r11
shrl %r10d
shrl %r9d
movl (%r11,%r9,8), %r9d
xorl (%r11,%r10,8), %r9d
andl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
je 0x1913bd
jmp 0x1913c0
xorl %ecx, %ecx
testq %rcx, %rcx
je 0x191441
movl 0x180(%rcx), %eax
movl %eax, (%rbx)
xorl %eax, %eax
testq %rcx, %rcx
setne %al
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x24607
jmp 0x191358