// File: chhylp123[P]hifiasm/hic.cpp
// Function: get_phased_block(G_partition*, bubble_type*, unsigned long, unsigned int*, unsigned int*, unsigned int**, unsigned int*, unsigned int**, unsigned int*, unsigned int*, unsigned int*)
inline void get_phased_block(G_partition* x, bubble_type* bub, uint64_t id, 
uint32_t* beg, uint32_t* sink, uint32_t** h0, uint32_t* h0_n, uint32_t** h1, uint32_t* h1_n,
uint32_t* phased, uint32_t* bub_id)
{
    if(bub && beg && sink && bub_id)
    {
        (*bub_id) = (*beg) = (*sink) = (uint32_t)-1;
        if(x->a[id].a.n > 0)
        {
            (*bub_id) = bub->index[x->a[id].a.a[0]];
            if(IF_BUB(x->a[id].a.a[0], *bub))
            {
                (*beg) = bub->list.a[bub->num.a[(*bub_id)]];
                (*sink) = bub->list.a[bub->num.a[(*bub_id)] + 1];
            }
        }
    }
    
    (*h0) = x->a[id].a.a; 
    (*h0_n) = x->a[id].h[0];

    (*h1) = x->a[id].a.a + x->a[id].h[0];
    (*h1_n) = x->a[id].h[1];
    if(phased) (*phased) = x->a[id].full_bub;
    if((*h0_n) == 0) (*h0) = NULL;
    if((*h1_n) == 0) (*h1) = NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x2147cb
cmpq $0x0, -0x20(%rbp)
je 0x2147cb
cmpq $0x0, -0x28(%rbp)
je 0x2147cb
cmpq $0x0, 0x30(%rbp)
je 0x2147cb
movq -0x28(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq -0x20(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x30(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x48, -0x18(%rbp), %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
jbe 0x2147c9
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
imulq $0x48, -0x18(%rbp), %rdx
addq %rdx, %rcx
movq 0x10(%rcx), %rcx
movl (%rcx), %ecx
movl (%rax,%rcx,4), %ecx
movq 0x30(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
imulq $0x48, -0x18(%rbp), %rdx
addq %rdx, %rcx
movq 0x10(%rcx), %rcx
movl (%rcx), %ecx
movl (%rax,%rcx,4), %eax
movq -0x10(%rbp), %rcx
movq 0x80(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jae 0x2147c7
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x40(%rcx), %rcx
movq 0x30(%rbp), %rdx
movl (%rdx), %edx
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x40(%rcx), %rcx
movq 0x30(%rbp), %rdx
movl (%rdx), %edx
movl (%rcx,%rdx,4), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
jmp 0x2147c9
jmp 0x2147cb
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x48, -0x18(%rbp), %rcx
addq %rcx, %rax
movq 0x10(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x48, -0x18(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
movq 0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x48, -0x18(%rbp), %rcx
addq %rcx, %rax
movq 0x10(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x48, -0x18(%rbp), %rdx
addq %rdx, %rax
movl 0x18(%rax), %eax
shlq $0x2, %rax
addq %rax, %rcx
movq 0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x48, -0x18(%rbp), %rcx
addq %rcx, %rax
movl 0x1c(%rax), %ecx
movq 0x20(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, 0x28(%rbp)
je 0x21486e
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x48, -0x18(%rbp), %rcx
addq %rcx, %rax
movzbl 0x20(%rax), %ecx
movq 0x28(%rbp), %rax
movl %ecx, (%rax)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x214882
movq -0x30(%rbp), %rax
movq $0x0, (%rax)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x214896
movq 0x18(%rbp), %rax
movq $0x0, (%rax)
popq %rbp
retq
nopl (%rax,%rax)