// File: /workspace/github_cpp_makefile_star2_O3/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
movl %esi, %ebp
movq %rdi, %r14
movl $0xffffffff, (%r8)      # imm = 0xFFFFFFFF
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0x19a088
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 0x19a06c
movq 0x30(%r14), %rax
movl 0x14(%rax), %eax
addl %eax, %eax
movslq %eax, %rcx
leaq 0x158(%rip), %rsi       # 0x19a1f3
movq %r14, %rdx
callq 0x108f2c
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x19a104
movq (%r14), %rcx
movl $0x1, %edx
xorl %esi, %esi
imulq $0x1a0, %rsi, %rsi      # imm = 0x1A0
cmpl $0x0, 0x198(%rcx,%rsi)
jne 0x19a0d2
movl %edx, %esi
incl %edx
cmpq %rsi, %rax
ja 0x19a0b6
jmp 0x19a104
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 0x199dbd
addq $0x10, %rsp
testl %eax, %eax
je 0x19a1e9
movl 0x8(%r14), %edi
movq 0x30(%r14), %rax
movl 0x14(%rax), %eax
addl %eax, %eax
movslq %eax, %rcx
leaq 0x127(%rip), %rsi       # 0x19a242
movq %r14, %rdx
callq 0x108f2c
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x19a1d8
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 0x19a169
testq %rcx, %rcx
je 0x19a166
movq 0x190(%rdx), %r10
cmpq %r10, 0x190(%rcx)
jle 0x19a17c
movq %rdx, %rcx
movl %esi, %r9d
addq $0x1a0, %rdx            # imm = 0x1A0
incl %esi
cmpq %r9, %rax
ja 0x19a145
jmp 0x19a1c4
jne 0x19a169
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 %r8d, %r12d
movl %r9d, %r13d
shrl %r13d
movl (%r15,%r13,8), %ebp
movl %ebp, %r15d
andl %r8d, %r15d
cmpl %r15d, %r12d
ja 0x19a166
cmpl %r9d, %r10d
jbe 0x19a169
xorl %r11d, %ebp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
je 0x19a166
jmp 0x19a169
testq %rcx, %rcx
je 0x19a1d8
movl 0x180(%rcx), %eax
movl %eax, (%rbx)
movl $0x1, %eax
jmp 0x19a1da
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x23811
jmp 0x19a104