// File: 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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl $0x0, -0x44(%rbp)
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %edx
xorl %eax, %eax
movl %eax, %r8d
leaq -0x28(%rbp), %r9
leaq -0x2c(%rbp), %r11
leaq -0x38(%rbp), %r10
leaq -0x3c(%rbp), %rax
movq %r8, %rsi
movq %r8, %rcx
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
callq 0x214690
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movl 0x24(%rax), %eax
movl %eax, -0x48(%rbp)
cmpl $0x1, -0x48(%rbp)
jne 0x1ee551
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x44(%rbp)
jmp 0x1ee588
cmpl $-0x1, -0x48(%rbp)
jne 0x1ee563
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x44(%rbp)
jmp 0x1ee586
cmpl $0x0, -0x48(%rbp)
jne 0x1ee575
movq -0x8(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x44(%rbp)
jmp 0x1ee584
cmpl $-0x2, -0x48(%rbp)
jne 0x1ee582
movl $0x0, -0x44(%rbp)
jmp 0x1ee584
jmp 0x1ee586
jmp 0x1ee588
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0x1ee63f
movq -0x28(%rbp), %rax
movl -0x20(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movl -0x44(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x40(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
andl $0x7, %ecx
cmpl %ecx, %eax
je 0x1ee5f5
movq 0x1d5a19(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movl -0x1c(%rbp), %edx
movl -0x40(%rbp), %ecx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x40(%rbp), %esi
movl (%rax,%rsi,4), %r8d
andl $0x7, %r8d
movl -0x44(%rbp), %r9d
leaq 0x19e596(%rip), %rsi    # 0x38cb84
movb $0x0, %al
callq 0x22a0
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x40(%rbp), %ecx
movl (%rax,%rcx,4), %edx
shrl $0x3, %edx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x40(%rbp), %ecx
movl (%rax,%rcx,4), %edx
shll $0x3, %edx
movl %edx, (%rax,%rcx,4)
movl -0x44(%rbp), %edx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x40(%rbp), %ecx
orl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1ee58f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movl 0x28(%rax), %eax
movl %eax, -0x48(%rbp)
cmpl $0x1, -0x48(%rbp)
jne 0x1ee669
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x44(%rbp)
jmp 0x1ee6a0
cmpl $-0x1, -0x48(%rbp)
jne 0x1ee67b
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x44(%rbp)
jmp 0x1ee69e
cmpl $0x0, -0x48(%rbp)
jne 0x1ee68d
movq -0x8(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x44(%rbp)
jmp 0x1ee69c
cmpl $-0x2, -0x48(%rbp)
jne 0x1ee69a
movl $0x0, -0x44(%rbp)
jmp 0x1ee69c
jmp 0x1ee69e
jmp 0x1ee6a0
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jae 0x1ee757
movq -0x38(%rbp), %rax
movl -0x20(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movl -0x44(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x40(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
andl $0x7, %ecx
cmpl %ecx, %eax
je 0x1ee70d
movq 0x1d5901(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movl -0x1c(%rbp), %edx
movl -0x40(%rbp), %ecx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x40(%rbp), %esi
movl (%rax,%rsi,4), %r8d
andl $0x7, %r8d
movl -0x44(%rbp), %r9d
leaq 0x19e4af(%rip), %rsi    # 0x38cbb5
movb $0x0, %al
callq 0x22a0
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x40(%rbp), %ecx
movl (%rax,%rcx,4), %edx
shrl $0x3, %edx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x40(%rbp), %ecx
movl (%rax,%rcx,4), %edx
shll $0x3, %edx
movl %edx, (%rax,%rcx,4)
movl -0x44(%rbp), %edx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x40(%rbp), %ecx
orl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1ee6a7
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)