// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/hic.cpp
// Function: identify_best_interval_debug(block_phase_type*, G_partition*, bubble_type*, ma_utg_t*, hc_links*, long long, long long, long long*, long long*)
void identify_best_interval_debug(block_phase_type* i_buf, G_partition* g_p, bubble_type* bub, 
ma_utg_t *u, hc_links* link, long long f_bid, long long f_uid, long long* l_bid, long long* l_uid)
{
    long long c_bid, c_uid, min_bid, min_uid;
    double w = 0, min_w = 1;
    uint32_t gid;
    block_phase_type b;
    b.bid = f_bid; b.uid = f_uid;
    memset(i_buf->vis.a, 0, g_p->n);
    min_w = 1;  min_bid = min_uid = -1;
    (*l_bid) = (*l_uid) = -1;

    while (1)
    {
        gid = next_hap_label_id(&b, g_p, bub, u, 1, &c_bid, &c_uid);
        if(gid == (uint32_t)-1) break;
        if(i_buf->vis.a[gid] == 1) continue;
        w += get_new_weight(g_p, i_buf->vis.a, link, gid);
        if(f_bid == 689 && f_uid == 1)
        {
            fprintf(stderr, "gid: %u, w: %f\n", gid, w);
        }
        
        if(min_w > w)
        {
            min_w = w;
            min_bid = c_bid;
            min_uid = c_uid;
        }
        i_buf->vis.a[gid] = 1;
    }

    if(min_w < 0 && min_bid != -1 && min_uid != -1)
    {
        (*l_bid) = min_bid; (*l_uid) = min_uid;
        i_buf->weight = min_w;
        b.bid = min_bid; b.uid = min_uid;


        gid = next_hap_label_id(&b, g_p, bub, u, 1, &c_bid, &c_uid);
        fprintf(stderr, "-min_w: %f, f_bid: %lld, f_uid: %lld, min_bid: %lld, min_uid: %lld, gid: %u\n", 
                                                        min_w, f_bid, f_uid, min_bid, min_uid, gid);
        
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %r9, %rbx
movq %r8, 0x58(%rsp)
movq %rcx, 0x38(%rsp)
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %r14
movq 0xe0(%rsp), %rbp
movq 0xd0(%rsp), %r15
leaq 0x60(%rsp), %rax
movq %r9, 0x20(%rax)
movq %r15, 0x28(%rax)
movq 0x10(%rdi), %rdi
movq (%rsi), %rdx
xorl %esi, %esi
callq 0x20e0
orq $-0x1, (%rbp)
movq 0xd8(%rsp), %rax
orq $-0x1, (%rax)
movq %rbx, 0x50(%rsp)
xorq $0x2b1, %rbx            # imm = 0x2B1
movq %r15, %rcx
xorq $0x1, %rcx
orq %rbx, %rcx
sete 0x17(%rsp)
movsd 0xd4cee(%rip), %xmm0    # 0x1e32a0
movsd %xmm0, 0x18(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
pushq $-0x1
popq %rax
movq %rax, 0x30(%rsp)
movq %rax, 0x28(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, (%rsp)
leaq 0x60(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
movq 0x38(%rsp), %rcx
pushq $0x1
popq %r8
leaq 0x48(%rsp), %r9
callq 0x10dfb2
cmpl $-0x1, %eax
je 0x10e69e
movl %eax, %ebx
movq 0x10(%r14), %rbp
movl %eax, %r15d
cmpb $0x1, (%rbp,%r15)
je 0x10e5cf
movq %r13, %rdi
movq %rbp, %rsi
movq 0x58(%rsp), %rdx
movl %ebx, %ecx
callq 0x10e15b
movsd 0x20(%rsp), %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, %xmm0
cmpb $0x0, 0x17(%rsp)
movsd %xmm1, 0x20(%rsp)
jne 0x10e672
movsd 0x18(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x10e65d
movq 0x48(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x28(%rsp)
minsd %xmm1, %xmm0
movb $0x1, (%rbp,%r15)
movsd %xmm0, 0x18(%rsp)
jmp 0x10e5cf
movq 0x144967(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
leaq 0xdf8ee(%rip), %rsi     # 0x1edf71
movl %ebx, %edx
movsd 0x20(%rsp), %xmm0
movb $0x1, %al
callq 0x22b0
movsd 0x20(%rsp), %xmm0
movq 0x10(%r14), %rbp
jmp 0x10e63d
xorpd %xmm0, %xmm0
movsd 0x18(%rsp), %xmm1
ucomisd %xmm1, %xmm0
seta %al
movq 0x30(%rsp), %rbx
cmpq $-0x1, %rbx
setne %cl
movq 0x28(%rsp), %r15
cmpq $-0x1, %r15
setne %dl
andb %cl, %dl
andb %al, %dl
cmpb $0x1, %dl
je 0x10e6e2
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xd8(%rsp), %rax
movq %rbx, (%rax)
movq 0xe0(%rsp), %rax
movq %r15, (%rax)
movsd %xmm1, 0x18(%r14)
leaq 0x60(%rsp), %rdi
movq %rbx, 0x20(%rdi)
movq %r15, 0x28(%rdi)
leaq 0x40(%rsp), %rax
movq %rax, (%rsp)
pushq $0x1
popq %r8
leaq 0x48(%rsp), %r9
movq %r13, %rsi
movq %r12, %rdx
movq 0x38(%rsp), %rcx
movsd %xmm1, 0x18(%rsp)
callq 0x10dfb2
movq 0x1448a6(%rip), %rcx    # 0x252fe0
movq (%rcx), %rdi
movl %eax, (%rsp)
leaq 0xdf83a(%rip), %rsi     # 0x1edf81
movsd 0x18(%rsp), %xmm0
movq 0x50(%rsp), %rdx
movq 0xd0(%rsp), %rcx
movq %rbx, %r8
movq %r15, %r9
movb $0x1, %al
callq 0x22b0
jmp 0x10e6d0