// File: /workspace/github_c_makefile_star2_O0/xiane[P]libvphevcodec/vdi.cpp
// Function: vdi_clear_memory(unsigned int, unsigned int, unsigned int)
s32 vdi_clear_memory(u32 core_idx, u32 addr, u32 len) {
    vdi_info_t *vdi;
    vpu_buffer_t vdb;
    ulong offset;
    s32 i;
    u8 *zero;
    if (core_idx >= MAX_NUM_VPU_CORE)
        return -1;

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

    memset(&vdb, 0x00, sizeof(vpu_buffer_t));

    for (i = 0; i < MAX_VPU_BUFFER_POOL; i++) {
        if (vdi->vpu_buffer_pool[i].inuse == 1) {
            vdb = vdi->vpu_buffer_pool[i].vdb;
            if (addr >= vdb.phys_addr && addr < (vdb.phys_addr + vdb.size))
                break;
        }
    }
    if (!vdb.size) {
        VLOG(ERR, "address 0x%08x is not mapped address!!!", addr);
        return -1;
    }

    zero = (u8 *) malloc(len);
    if (!zero)
        return -1;

    memset((void *) zero, 0x00, len);
    offset = addr - (ulong) vdb.phys_addr;
    memcpy((void *) ((ulong) vdb.virt_addr + offset), zero, len);
    free(zero);
    return len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
cmpl $0x1, -0x8(%rbp)
jb 0xa713
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa883
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x28af1(%rip), %rax     # 0x33210
imulq $0x2888, %rcx, %rcx     # imm = 0x2888
addq %rcx, %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0xa74b
movq -0x18(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jl 0xa74b
movq -0x18(%rbp), %rax
movzbl 0x8(%rax), %eax
cmpl $0x0, %eax
jne 0xa757
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa883
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x20f0
movl $0x0, -0x44(%rbp)
cmpl $0x100, -0x44(%rbp)     # imm = 0x100
jge 0xa7f5
movq -0x18(%rbp), %rax
addq $0x80, %rax
movslq -0x44(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
cmpl $0x1, 0x20(%rax)
jne 0xa7e5
movq -0x18(%rbp), %rax
addq $0x80, %rax
movslq -0x44(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x38(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x30(%rbp)
movq 0x10(%rax), %rcx
movq %rcx, -0x28(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
movl -0xc(%rbp), %eax
cmpq -0x30(%rbp), %rax
jb 0xa7e3
movl -0xc(%rbp), %eax
movq -0x30(%rbp), %rcx
movl -0x38(%rbp), %edx
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0xa7e3
jmp 0xa7f5
jmp 0xa7e5
jmp 0xa7e7
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xa76e
cmpl $0x0, -0x38(%rbp)
jne 0xa825
jmp 0xa7fd
movl -0xc(%rbp), %esi
leaq 0x25de2(%rip), %rdi     # 0x305e9
movb $0x0, %al
callq 0x2050
leaq 0x25a51(%rip), %rdi     # 0x30266
movb $0x0, %al
callq 0x2050
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa883
movl -0x10(%rbp), %eax
movl %eax, %edi
callq 0x2220
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0xa843
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa883
movq -0x50(%rbp), %rdi
movl -0x10(%rbp), %eax
movl %eax, %edx
xorl %esi, %esi
callq 0x20f0
movl -0xc(%rbp), %eax
subq -0x30(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rdi
addq -0x40(%rbp), %rdi
movq -0x50(%rbp), %rsi
movl -0x10(%rbp), %eax
movl %eax, %edx
callq 0x2150
movq -0x50(%rbp), %rdi
callq 0x2200
movl -0x10(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)