// File: /workspace/github_cpp_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %rbx
movq %rcx, %r12
movl %edx, %r15d
orl $-0x1, (%r8)
movl %esi, %ebp
movq %rdi, %r14
movq 0x8(%rdi), %rdi
xorl %eax, %eax
movl %eax, %eax
cmpq %rax, %rdi
jbe 0x152a0c
movq (%r14), %rcx
imulq $0x1a0, %rax, %rdx      # imm = 0x1A0
andl $0x0, 0x198(%rcx,%rdx)
orl $-0x1, 0x180(%rcx,%rdx)
incl %eax
jmp 0x1529e7
movq 0x30(%r14), %rax
movl 0x14(%rax), %eax
addl %eax, %eax
movslq %eax, %rcx
leaq 0x158(%rip), %rsi       # 0x152b77
movq %r14, %rdx
callq 0xc67c0
movq 0x8(%r14), %rax
xorl %edx, %edx
movl %edx, %edx
cmpq %rdx, %rax
jbe 0x152a7c
movq (%r14), %rcx
imulq $0x1a0, %rdx, %rsi      # imm = 0x1A0
incl %edx
cmpl $0x0, 0x198(%rcx,%rsi)
je 0x152a2d
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 0x152774
addq $0x10, %rsp
testl %eax, %eax
je 0x152b56
movl 0x8(%r14), %edi
movq 0x30(%r14), %rax
movl 0x14(%rax), %eax
addl %eax, %eax
movslq %eax, %rcx
leaq 0x133(%rip), %rsi       # 0x152bc6
movq %r14, %rdx
callq 0xc67c0
movq 0x8(%r14), %rax
xorl %edx, %edx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
xorl %ecx, %ecx
movl %edx, %edx
cmpq %rdx, %rax
jbe 0x152b32
movq (%r14), %r8
imulq $0x1a0, %rdx, %r10      # imm = 0x1A0
movl 0x180(%r8,%r10), %r9d
cmpq %rsi, %r9
je 0x152ae6
addq %r10, %r8
testq %rcx, %rcx
je 0x152ae3
movq 0x190(%r8), %r10
cmpq %r10, 0x190(%rcx)
jle 0x152aea
movq %r8, %rcx
incl %edx
jmp 0x152aad
jne 0x152ae6
movq 0x30(%r14), %r10
movq 0x20(%r10), %r15
movl 0x180(%rcx), %r10d
movl %r10d, %r11d
shrl %r11d
movl (%r15,%r11,8), %r11d
movl %r11d, %r12d
andl %edi, %r12d
movl %r9d, %r13d
shrl %r13d
movl (%r15,%r13,8), %ebp
movl %ebp, %r15d
andl %edi, %r15d
cmpl %r15d, %r12d
ja 0x152ae3
cmpl %r9d, %r10d
jbe 0x152ae6
xorl %r11d, %ebp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
je 0x152ae3
jmp 0x152ae6
testq %rcx, %rcx
je 0x152b3f
movl 0x180(%rcx), %eax
movl %eax, (%rbx)
xorl %eax, %eax
testq %rcx, %rcx
setne %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x100483(%rip), %rax    # 0x252fe0
movq (%rax), %rcx
leaq 0x9ecd7(%rip), %rdi     # 0x1f183e
pushq $0xc
popq %rsi
pushq $0x1
popq %rdx
callq 0x2410
jmp 0x152a7c