// File: /workspace/github_c_makefile_star2_O0/xiane[P]libvphevcodec/vdi.cpp
// Function: vdi_get_instance_pool(unsigned int)
vpu_instance_pool_t *vdi_get_instance_pool(u32 core_idx) {
    vdi_info_t *vdi;
    vpu_buffer_t vdb;

    if (core_idx >= MAX_NUM_VPU_CORE)
        return NULL;

    vdi = &s_vdi_info[core_idx];
    if (!vdi || vdi->vpu_fd < 0 || vdi->opened == 0)
        return NULL;

    memset(&vdb, 0x00, sizeof(vpu_buffer_t));
    memset(&vdi->instance_pool, 0x00, sizeof(vpu_buffer_t));
    if (!vdi->pvip) {
        vdb.size = sizeof(vpu_instance_pool_t);
        vdb.cached = 0;
        if (ioctl(vdi->vpu_fd, VDI_IOCTL_GET_INSTANCE_POOL, &vdb) < 0) {
            VLOG(ERR, "[VDI] fail to allocate get instance pool physical space=0x%x", vdb.size);
            return NULL;
        }

        vdb.virt_addr = (ulong) mmap(NULL, vdb.size, PROT_READ | PROT_WRITE, MAP_SHARED, vdi->vpu_fd, 0);
        if ((void *) vdb.virt_addr == MAP_FAILED) {
            VLOG(ERR, "[VDI] fail to map instance pool phyaddr=0x%lx, size = 0x%x", vdb.phys_addr, vdb.size);
            return NULL;
        }
        vdi->instance_pool = vdb;
        vdi->pvip = (vpu_instance_pool_t *) (vdb.virt_addr + (core_idx * sizeof(vpu_instance_pool_t)));
        VLOG(DEBUG, "[VDI] instance pool physaddr=0x%lx, virtaddr=0x%lx, base=0x%lx, size=0x%x",
                                                          vdb.phys_addr, vdb.virt_addr, vdb.base, vdb.size);
    }
    return (vpu_instance_pool_t *) vdi->pvip;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0xc(%rbp)
cmpl $0x1, -0xc(%rbp)
jb 0x979e
movq $0x0, -0x8(%rbp)
jmp 0x9922
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0x29a66(%rip), %rax     # 0x33210
imulq $0x2888, %rcx, %rcx     # imm = 0x2888
addq %rcx, %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x97d6
movq -0x18(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jl 0x97d6
movq -0x18(%rbp), %rax
movzbl 0x8(%rax), %eax
cmpl $0x0, %eax
jne 0x97e3
movq $0x0, -0x8(%rbp)
jmp 0x9922
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x20f0
movq -0x18(%rbp), %rdi
addq $0x40, %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x20f0
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x9916
movl $0x20028, -0x38(%rbp)   # imm = 0x20028
movl $0x0, -0x34(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %edi
movl $0x40205605, %esi       # imm = 0x40205605
leaq -0x38(%rbp), %rdx
movb $0x0, %al
callq 0x2230
cmpl $0x0, %eax
jge 0x986e
jmp 0x9842
movl -0x38(%rbp), %esi
leaq 0x26ccc(%rip), %rdi     # 0x30518
movb $0x0, %al
callq 0x2050
leaq 0x26a0c(%rip), %rdi     # 0x30266
movb $0x0, %al
callq 0x2050
movq $0x0, -0x8(%rbp)
jmp 0x9922
movl -0x38(%rbp), %eax
movl %eax, %esi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %r8d
xorl %eax, %eax
movl %eax, %r9d
movl $0x3, %edx
movl $0x1, %ecx
movq %r9, %rdi
callq 0x2320
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq $-0x1, %rcx
cmpq %rcx, %rax
jne 0x98d5
jmp 0x98a8
movq -0x30(%rbp), %rsi
movl -0x38(%rbp), %edx
leaq 0x26c9f(%rip), %rdi     # 0x30555
movb $0x0, %al
callq 0x2050
leaq 0x269a2(%rip), %rdi     # 0x30266
movb $0x0, %al
callq 0x2050
movq $0x0, -0x8(%rbp)
jmp 0x9922
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, 0x40(%rax)
movq -0x30(%rbp), %rcx
movq %rcx, 0x48(%rax)
movq -0x28(%rbp), %rcx
movq %rcx, 0x50(%rax)
movq -0x20(%rbp), %rcx
movq %rcx, 0x58(%rax)
movq -0x20(%rbp), %rcx
movl -0xc(%rbp), %eax
imulq $0x20028, %rax, %rax    # imm = 0x20028
addq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x9914
jmp 0x9916
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)