// File: chhylp123[P]hifiasm/hic.cpp
// Function: update_partition_flag(H_partition*, G_partition*, hc_links*, unsigned int)
void update_partition_flag(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];
        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];
        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 0x1ee351
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x44(%rbp)
jmp 0x1ee388
cmpl $-0x1, -0x48(%rbp)
jne 0x1ee363
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x44(%rbp)
jmp 0x1ee386
cmpl $0x0, -0x48(%rbp)
jne 0x1ee375
movq -0x8(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x44(%rbp)
jmp 0x1ee384
cmpl $-0x2, -0x48(%rbp)
jne 0x1ee382
movl $0x0, -0x44(%rbp)
jmp 0x1ee384
jmp 0x1ee386
jmp 0x1ee388
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0x1ee3eb
movq -0x28(%rbp), %rax
movl -0x20(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
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 0x1ee38f
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 0x1ee415
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x44(%rbp)
jmp 0x1ee44c
cmpl $-0x1, -0x48(%rbp)
jne 0x1ee427
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x44(%rbp)
jmp 0x1ee44a
cmpl $0x0, -0x48(%rbp)
jne 0x1ee439
movq -0x8(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x44(%rbp)
jmp 0x1ee448
cmpl $-0x2, -0x48(%rbp)
jne 0x1ee446
movl $0x0, -0x44(%rbp)
jmp 0x1ee448
jmp 0x1ee44a
jmp 0x1ee44c
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jae 0x1ee4af
movq -0x38(%rbp), %rax
movl -0x20(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
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 0x1ee453
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)