// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/hic.cpp
// Function: update_partition_flag_debug(H_partition*, G_partition*, hc_links*, unsigned int)
void update_partition_flag_debug(H_partition* h, G_partition* g_p, hc_links* link, uint32_t id)
{
    uint32_t k, *h0, h0_n, *h1, h1_n, uID, flag = 0;
    int status;
    get_phased_block(g_p, NULL, id, NULL, NULL, &h0, &h0_n, &h1, &h1_n, NULL, NULL);

    status = g_p->a[id].status[0];
    if(status == 1) flag = h->m[0];
    else if(status == -1) flag = h->m[1];
    else if(status == 0) flag = h->m[2];
    else if(status == -2) flag = 0;
    for (k = 0; k < h0_n; k++)
    {
        uID = h0[k];
        if(flag != (h->hap[uID]&7)) fprintf(stderr, "h0, id: %u, uID: %u, pre_flag: %u, cur_flag: %u\n", id, uID, (h->hap[uID]&7), flag);
        h->hap[uID] >>= 3;
        h->hap[uID] <<= 3;
        h->hap[uID] |= flag;
    }

    status = g_p->a[id].status[1];
    if(status == 1) flag = h->m[0];
    else if(status == -1) flag = h->m[1];
    else if(status == 0) flag = h->m[2];
    else if(status == -2) flag = 0;
    for (k = 0; k < h1_n; k++)
    {
        uID = h1[k];
        if(flag != (h->hap[uID]&7)) fprintf(stderr, "h1, id: %u, uID: %u, pre_flag: %u, cur_flag: %u\n", id, uID, (h->hap[uID]&7), flag);
        h->hap[uID] >>= 3;
        h->hap[uID] <<= 3;
        h->hap[uID] |= flag;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, 0x4(%rsp)
movl %ecx, %ecx
movq 0x10(%rsi), %rax
leaq (%rcx,%rcx,8), %r8
movq 0x10(%rax,%r8,8), %r14
movl 0x18(%rax,%r8,8), %r12d
testq %r12, %r12
leaq (%r14,%r12,4), %rdx
movl 0x1c(%rax,%r8,8), %r15d
cmoveq %r12, %r14
testq %r15, %r15
cmoveq %r15, %rdx
movl 0x24(%rax,%r8,8), %ecx
cmpl $-0x1, %ecx
je 0x1540a0
testl %ecx, %ecx
je 0x15409b
xorl %ebp, %ebp
cmpl $0x1, %ecx
jne 0x1540a3
movl 0x18(%rdi), %ebp
jmp 0x1540a3
movl 0x20(%rdi), %ebp
jmp 0x1540a3
movl 0x1c(%rdi), %ebp
testq %r12, %r12
movq %rdi, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
je 0x15412d
movq %r8, 0x18(%rsp)
movq %rsi, 0x20(%rsp)
movq 0x10(%rdi), %rax
xorl %ebx, %ebx
movl (%r14,%rbx,4), %r13d
movl (%rax,%r13,4), %ecx
movl %ecx, %r8d
andl $0x7, %r8d
cmpl %r8d, %ebp
jne 0x1540e9
andl $-0x8, %ecx
orl %ebp, %ecx
movl %ecx, (%rax,%r13,4)
incq %rbx
cmpq %rbx, %r12
jne 0x1540c2
jmp 0x15411f
movq 0x140ef0(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
leaq 0xe7e29(%rip), %rsi     # 0x23bf23
movl 0x4(%rsp), %edx
movl %r13d, %ecx
movl %ebp, %r9d
xorl %eax, %eax
callq 0x22b0
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rdi
movq 0x10(%rdi), %rax
movl (%rax,%r13,4), %ecx
jmp 0x1540d6
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rsp), %r8
movl 0x28(%rax,%r8,8), %eax
addl $0x2, %eax
cmpl $0x3, %eax
ja 0x15415b
leaq 0xe714b(%rip), %rcx     # 0x23b28c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %ebp, %ebp
jmp 0x15415b
movl 0x20(%rdi), %ebp
jmp 0x15415b
movl 0x18(%rdi), %ebp
jmp 0x15415b
movl 0x1c(%rdi), %ebp
testq %r15, %r15
je 0x1541c6
movq 0x10(%rdi), %rax
movq 0x140e75(%rip), %r14    # 0x294fe0
leaq 0xe7de2(%rip), %r13     # 0x23bf54
xorl %ebx, %ebx
movl (%rdx,%rbx,4), %r12d
movl (%rax,%r12,4), %ecx
movl %ecx, %r8d
andl $0x7, %r8d
cmpl %r8d, %ebp
jne 0x15419b
andl $-0x8, %ecx
orl %ebp, %ecx
movl %ecx, (%rax,%r12,4)
incq %rbx
cmpq %rbx, %r15
jne 0x154174
jmp 0x1541c6
movq (%r14), %rdi
movq %r13, %rsi
movl 0x4(%rsp), %edx
movl %r12d, %ecx
movl %ebp, %r9d
xorl %eax, %eax
callq 0x22b0
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rax
movl (%rax,%r12,4), %ecx
jmp 0x154188
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq