// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/hic.cpp
// Function: flip_unitig_debug(G_partition*, hc_links*, bubble_type*, unsigned int)
void flip_unitig_debug(G_partition* g_p, hc_links* link, bubble_type* bub, uint32_t id)
{
    if(g_p->a[id].h[0] > 0 && g_p->a[id].status[0] != 1 && g_p->a[id].status[0] != -1) return;
    if(g_p->a[id].h[1] > 0 && g_p->a[id].status[1] != 1 && g_p->a[id].status[1] != -1) return;
    uint32_t k, j, m, *h0, h0_n, *h1, h1_n, uID, *h = NULL, h_n;
    int status;
    double weight;
    get_phased_block(g_p, NULL, id, NULL, NULL, &h0, &h0_n, &h1, &h1_n, NULL, NULL);
    // fprintf(stderr, "h0_n: %u, h1_n: %u\n", h0_n, h1_n);
    if(h0_n > 0)
    {

        status = g_p->a[id].status[0];
        // fprintf(stderr, "+status: %d\n", status);
        h = h0; h_n = h0_n;
        for (j = 0; j < h_n; j++)
        {
            // fprintf(stderr, "+j: %u, h_n: %u\n", j, h_n);
            for (k = 0; k < link->a.a[h[j]].e.n; k++)
            {
                // fprintf(stderr, "+k: %u, e_n: %u\n", k, (uint32_t)link->a.a[h[j]].e.n);
                if(link->a.a[h[j]].e.a[k].del) continue;
                for (m = 0; m < h_n; m++)
                {
                    if(h[m] == link->a.a[h[j]].e.a[k].uID) break;
                }
                // fprintf(stderr, "+m: %u, h_n: %u\n", m, h_n);
                if(m < h_n) continue;

                uID = link->a.a[h[j]].e.a[k].uID;

                weight = link->a.a[h[j]].e.a[k].weight;

                if(g_p->index[uID] == (uint32_t)-1) continue;

                if(id == 19675)
                {
                    fprintf(stderr, "+uID+: %u, e-weight: %f, g_p->index[uID]>>1: %u, status[0]: %d, pre_uID_weight: %f\n", 
                                             uID, weight, g_p->index[uID]>>1, status, g_p->a[g_p->index[uID]>>1].weight[g_p->index[uID]&1]);
                }
                

                g_p->a[g_p->index[uID]>>1].weight[g_p->index[uID]&1] -= (2*status*weight);

                if(id == 19675)
                {
                    fprintf(stderr, "+uID+: %u, new_uID_weight: %f\n", uID, 
                                     g_p->a[g_p->index[uID]>>1].weight[g_p->index[uID]&1]);
                }   
                
            }
        }
        g_p->a[id].status[0] *= -1;
    }

    // fprintf(stderr, "hehehe\n");
    if(h1_n > 0)
    {
        status = g_p->a[id].status[1];
        // fprintf(stderr, "-status: %d\n", status);
        h = h1; h_n = h1_n;
        for (j = 0; j < h_n; j++)
        {
            // fprintf(stderr, "-j: %u, h_n: %u\n", j, h_n);
            for (k = 0; k < link->a.a[h[j]].e.n; k++)
            {
                // fprintf(stderr, "-k: %u, e_n: %u\n", k, (uint32_t)link->a.a[h[j]].e.n);
                if(link->a.a[h[j]].e.a[k].del) continue;
                for (m = 0; m < h_n; m++)
                {
                    if(h[m] == link->a.a[h[j]].e.a[k].uID) break;
                }
                // fprintf(stderr, "-m: %u, h_n: %u\n", m, h_n);
                if(m < h_n) continue;

                uID = link->a.a[h[j]].e.a[k].uID;
                // fprintf(stderr, "-uID: %u\n", uID);

                weight = link->a.a[h[j]].e.a[k].weight;

                if(g_p->index[uID] == (uint32_t)-1) continue;

                if(id == 19675)
                {
                    fprintf(stderr, "-uID-: %u, e-weight: %f, g_p->index[uID]>>1: %u, status[1]: %d, pre_uID_weight: %f\n", 
                                             uID, weight, g_p->index[uID]>>1, status, g_p->a[g_p->index[uID]>>1].weight[g_p->index[uID]&1]);
                }

                g_p->a[g_p->index[uID]>>1].weight[g_p->index[uID]&1] -= (2*status*weight);

                if(id == 19675)
                {
                    fprintf(stderr, "-uID-: %u, new_uID_weight: %f\n", uID, 
                                     g_p->a[g_p->index[uID]>>1].weight[g_p->index[uID]&1]);
                }   
            }
        }
        g_p->a[id].status[1] *= -1;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %ecx, %r8d
movq %rdi, %r9
movq 0x10(%rdi), %rax
movl %ecx, %ecx
leaq (%rcx,%rcx,8), %rdi
leaq (%rax,%rdi,8), %rcx
movl 0x18(%rcx), %ebp
testq %rbp, %rbp
je 0x15553f
movl 0x24(%rcx), %edx
cmpl $0x1, %edx
je 0x15553f
cmpl $-0x1, %edx
jne 0x15590d
cmpl $0x0, 0x1c(%rcx)
je 0x155556
movl 0x28(%rcx), %edx
cmpl $0x1, %edx
je 0x155556
cmpl $-0x1, %edx
jne 0x15590d
movl 0x18(%rax,%rdi,8), %r14d
movl 0x1c(%rax,%rdi,8), %r12d
shlq $0x2, %rbp
addq 0x10(%rcx), %rbp
testq %r12, %r12
cmoveq %r12, %rbp
movq %r14, %rbx
testq %r14, %r14
je 0x15557c
movq 0x10(%rax,%rdi,8), %rbx
movl %r8d, 0xc(%rsp)
movq %r9, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdi, 0x48(%rsp)
je 0x155751
movl 0x24(%rax,%rdi,8), %eax
movq %rax, 0x50(%rsp)
addl %eax, %eax
cvtsi2sd %eax, %xmm1
xorpd 0xd9a13(%rip), %xmm1    # 0x22efc0
xorl %r11d, %r11d
movapd %xmm1, 0x30(%rsp)
movq 0x10(%rsi), %rax
movl (%rbx,%r11,4), %ecx
leaq (%rcx,%rcx,2), %rdx
shlq $0x4, %rdx
cmpq $0x0, (%rax,%rdx)
je 0x155738
addq %rax, %rdx
xorl %r15d, %r15d
movq 0x10(%rdx), %rdi
leaq (%r15,%r15,4), %rdx
cmpb $0x0, 0x18(%rdi,%rdx,8)
js 0x15566e
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
movq 0x10(%rax,%rcx), %rdi
movl 0x8(%rdi,%rdx,8), %r10d
xorl %edi, %edi
cmpl %r10d, (%rbx,%rdi,4)
je 0x15566e
incq %rdi
cmpq %rdi, %r14
jne 0x1555fe
movq 0x10(%rax,%rcx), %rcx
movl 0x8(%rcx,%rdx,8), %r13d
movq 0x18(%r9), %rax
movl (%rax,%r13,4), %eax
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
cmpq %rdi, %rax
je 0x15566e
movsd (%rcx,%rdx,8), %xmm0
cmpl $0x4cdb, %r8d           # imm = 0x4CDB
je 0x155694
movq 0x18(%r9), %rax
movl (%rax,%r13,4), %eax
movl %eax, %ecx
shrl %ecx
andl $0x1, %eax
leaq (%rcx,%rcx,8), %rcx
shlq $0x3, %rcx
addq 0x10(%r9), %rcx
mulsd %xmm1, %xmm0
addsd 0x30(%rcx,%rax,8), %xmm0
movsd %xmm0, 0x30(%rcx,%rax,8)
cmpl $0x4cdb, %r8d           # imm = 0x4CDB
je 0x1556fd
incl %r15d
movq 0x10(%rsi), %rax
movl (%rbx,%r11,4), %ecx
leaq (%rcx,%rcx,2), %rdi
shlq $0x4, %rdi
leaq (%rax,%rdi), %rdx
cmpq %r15, (%rax,%rdi)
ja 0x1555d7
jmp 0x155738
movq 0x134945(%rip), %rcx    # 0x289fe0
movq (%rcx), %rdi
movl %eax, %ecx
shrl %ecx
andl $0x1, %eax
leaq (%rcx,%rcx,8), %rdx
shlq $0x3, %rdx
addq 0x10(%r9), %rdx
movsd 0x30(%rdx,%rax,8), %xmm1
leaq 0xda981(%rip), %rsi     # 0x23003f
movl %r13d, %edx
movq 0x50(%rsp), %r8
movb $0x2, %al
movq %r11, 0x28(%rsp)
movsd %xmm0, 0x20(%rsp)
callq 0x22b0
movsd 0x20(%rsp), %xmm0
movq 0x28(%rsp), %r11
movapd 0x30(%rsp), %xmm1
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %r9
movl 0xc(%rsp), %r8d
jmp 0x155636
movq 0x1348dc(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
leaq 0xda985(%rip), %rsi     # 0x230093
movl %r13d, %edx
movb $0x1, %al
movq %r11, %r13
callq 0x22b0
movq %r13, %r11
movapd 0x30(%rsp), %xmm1
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %r9
movl 0xc(%rsp), %r8d
jmp 0x15566e
incq %r11
cmpq %r14, %r11
jne 0x1555b6
movq 0x10(%r9), %rax
movq 0x48(%rsp), %rdi
negl 0x24(%rax,%rdi,8)
testq %r12, %r12
je 0x15590d
movq 0x10(%r9), %rax
movl 0x28(%rax,%rdi,8), %eax
movq %rax, 0x20(%rsp)
addl %eax, %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
xorpd 0xd9848(%rip), %xmm1    # 0x22efc0
xorl %ebx, %ebx
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movapd %xmm1, 0x30(%rsp)
movq 0x10(%rsi), %rax
movl (%rbp,%rbx,4), %ecx
leaq (%rcx,%rcx,2), %rdx
shlq $0x4, %rdx
cmpq $0x0, (%rax,%rdx)
je 0x1558f4
addq %rax, %rdx
xorl %r15d, %r15d
movq 0x10(%rdx), %rdi
leaq (%r15,%r15,4), %rdx
cmpb $0x0, 0x18(%rdi,%rdx,8)
js 0x15583a
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
movq 0x10(%rax,%rcx), %rdi
movl 0x8(%rdi,%rdx,8), %r10d
xorl %edi, %edi
cmpl %r10d, (%rbp,%rdi,4)
je 0x15583a
incq %rdi
cmpq %rdi, %r12
jne 0x1557ce
movq 0x10(%rax,%rcx), %rcx
movl 0x8(%rcx,%rdx,8), %r13d
movq 0x18(%r9), %rax
movl (%rax,%r13,4), %eax
cmpq %r14, %rax
je 0x15583a
movsd (%rcx,%rdx,8), %xmm0
cmpl $0x4cdb, %r8d           # imm = 0x4CDB
je 0x155860
movq 0x18(%r9), %rax
movl (%rax,%r13,4), %eax
movl %eax, %ecx
shrl %ecx
andl $0x1, %eax
leaq (%rcx,%rcx,8), %rcx
shlq $0x3, %rcx
addq 0x10(%r9), %rcx
mulsd %xmm1, %xmm0
addsd 0x30(%rcx,%rax,8), %xmm0
movsd %xmm0, 0x30(%rcx,%rax,8)
cmpl $0x4cdb, %r8d           # imm = 0x4CDB
je 0x1558bf
incl %r15d
movq 0x10(%rsi), %rax
movl (%rbp,%rbx,4), %ecx
leaq (%rcx,%rcx,2), %rdi
shlq $0x4, %rdi
leaq (%rax,%rdi), %rdx
cmpq %r15, (%rax,%rdi)
ja 0x1557a7
jmp 0x1558f4
movq 0x134779(%rip), %rcx    # 0x289fe0
movq (%rcx), %rdi
movl %eax, %ecx
shrl %ecx
andl $0x1, %eax
leaq (%rcx,%rcx,8), %rdx
shlq $0x3, %rdx
addq 0x10(%r9), %rdx
movsd 0x30(%rdx,%rax,8), %xmm1
leaq 0xda828(%rip), %rsi     # 0x2300b2
movl %r13d, %edx
movq 0x20(%rsp), %r8
movb $0x2, %al
movsd %xmm0, 0x28(%rsp)
callq 0x22b0
movsd 0x28(%rsp), %xmm0
movapd 0x30(%rsp), %xmm1
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %r9
movl 0xc(%rsp), %r8d
jmp 0x155802
movq 0x13471a(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
leaq 0xda836(%rip), %rsi     # 0x230106
movl %r13d, %edx
movb $0x1, %al
callq 0x22b0
movapd 0x30(%rsp), %xmm1
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %r9
movl 0xc(%rsp), %r8d
jmp 0x15583a
incq %rbx
cmpq %r12, %rbx
jne 0x155786
movq 0x10(%r9), %rax
movq 0x48(%rsp), %rcx
negl 0x28(%rax,%rcx,8)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq