LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/tudurom[P]disputils/randr.c
// Function: get_providers
int
get_providers(xcb_connection_t * conn, xcb_screen_t * scrn, xcb_randr_provider_t ** ps)
{
	xcb_randr_get_providers_cookie_t pc;
	pc = xcb_randr_get_providers(conn, scrn->root);

	xcb_randr_get_providers_reply_t *pr;
	pr = xcb_randr_get_providers_reply(conn, pc, NULL);
	if (!pr)
		errx(1, "Could not aquire the array of providers.");

	*ps = xcb_randr_get_providers_providers(pr);

	return xcb_randr_get_providers_providers_length(pr);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rdi, %r14
movl (%rsi), %esi
callq 0x11e0
movq %r14, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x1180
testq %rax, %rax
je 0x1607
movq %rax, %r14
movq %rax, %rdi
callq 0x1090
movq %rax, (%rbx)
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x1170
leaq 0xa5f(%rip), %rsi       # 0x206d
movl $0x1, %edi
xorl %eax, %eax
callq 0x10b0
// File: /workspace/github_c_makefile_star2_O1/tudurom[P]disputils/randr.c
// Function: get_outputs
int
get_outputs(xcb_connection_t * conn, xcb_randr_provider_t provider, xcb_randr_output_t ** os)
{
	xcb_randr_get_provider_info_cookie_t pic;
	pic = xcb_randr_get_provider_info(conn, provider, 0);

	xcb_randr_get_provider_info_reply_t *pir;
	pir = xcb_randr_get_provider_info_reply(conn, pic, NULL);
	if (!pir)
		errx(1, "Could not aquire the array of outputs.");

	*os = xcb_randr_get_provider_info_outputs(pir);
	return xcb_randr_get_provider_info_outputs_length(pir);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rdi, %r14
xorl %edx, %edx
callq 0x1040
movq %r14, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x11b0
testq %rax, %rax
je 0x1659
movq %rax, %r14
movq %rax, %rdi
callq 0x1060
movq %rax, (%rbx)
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x1220
leaq 0xa36(%rip), %rsi       # 0x2096
movl $0x1, %edi
xorl %eax, %eax
callq 0x10b0
// File: /workspace/github_c_makefile_star2_O1/tudurom[P]disputils/randr.c
// Function: get_output_info
xcb_randr_get_output_info_reply_t *
get_output_info(xcb_connection_t * conn, xcb_randr_output_t output)
{
	xcb_randr_get_output_info_cookie_t oic;

	oic = xcb_randr_get_output_info(conn, output, 0);
	xcb_randr_get_output_info_reply_t *output_info_reply;

	output_info_reply = xcb_randr_get_output_info_reply(conn, oic, NULL);
	if (!output_info_reply)
		errx(1, "Could not get output info.");

	return output_info_reply;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
xorl %edx, %edx
callq 0x1230
movq %rbx, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x11f0
testq %rax, %rax
je 0x168a
popq %rbx
retq
leaq 0xa2c(%rip), %rsi       # 0x20bd
movl $0x1, %edi
xorl %eax, %eax
callq 0x10b0
// File: /workspace/github_c_makefile_star2_O1/tudurom[P]disputils/randr.c
// Function: get_output_name
uint8_t*
get_output_name(xcb_connection_t * conn, xcb_randr_output_t output)
{
	xcb_randr_get_output_info_reply_t *r;

	r = get_output_info(conn, output);
	uint8_t *name = xcb_randr_get_output_info_name(r);
	int len = xcb_randr_get_output_info_name_length(r);
	uint8_t *ret  =
		malloc(sizeof(uint8_t) * len + 1);
	int i;
	for (i = 0; i < xcb_randr_get_output_info_name_length(r); i++) {
		ret[i] = name[i];
	}
	ret[len] = '\0';
	return ret;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
callq 0x166c
movq %rax, %rbx
movq %rax, %rdi
callq 0x1160
movq %rax, %r14
movq %rbx, %rdi
callq 0x1070
movslq %eax, %r12
leaq 0x1(%r12), %rdi
callq 0x1150
movq %rax, %r15
movq %rbx, %rdi
callq 0x1070
testl %eax, %eax
jle 0x16fa
xorl %r13d, %r13d
movb (%r14,%r13), %al
movb %al, (%r15,%r13)
incq %r13
movq %rbx, %rdi
callq 0x1070
cltq
cmpq %rax, %r13
jl 0x16e0
movb $0x0, (%r15,%r12)
movq %r15, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/tudurom[P]disputils/randr.c
// Function: get_focused_window
xcb_window_t
get_focused_window(xcb_connection_t * conn)
{
	xcb_window_t    win = 0;
	xcb_get_input_focus_cookie_t input_focus_cookie;
	xcb_get_input_focus_reply_t *input_focus_reply;

	input_focus_cookie = xcb_get_input_focus(conn);
	input_focus_reply = xcb_get_input_focus_reply(conn, input_focus_cookie, NULL);
	if (!input_focus_reply)
		errx(1, "Cannot get focused window.");
	win = input_focus_reply->focus;
	free(input_focus_reply);
	return win;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x10e0
movq %rbx, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x10d0
testq %rax, %rax
je 0x1759
movl 0x8(%rax), %ebx
movq %rax, %rdi
callq 0x1030
movl %ebx, %eax
popq %rbx
retq
leaq 0x978(%rip), %rsi       # 0x20d8
movl $0x1, %edi
xorl %eax, %eax
callq 0x10b0
// File: /workspace/github_c_makefile_star2_O1/tudurom[P]disputils/randr.c
// Function: get_window_geometry
xcb_get_geometry_reply_t *
get_window_geometry(xcb_connection_t * conn, xcb_window_t window)
{
	xcb_get_geometry_cookie_t get_geometry_cookie;
	xcb_get_geometry_reply_t *get_geometry_reply;

	get_geometry_cookie = xcb_get_geometry(conn, window);
	get_geometry_reply = xcb_get_geometry_reply(conn, get_geometry_cookie, NULL);

	if (!get_geometry_reply)
		errx(1, "0x%08x: no such window", window);
	return get_geometry_reply;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
callq 0x1130
movq %r14, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x10f0
testq %rax, %rax
je 0x1793
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x959(%rip), %rsi       # 0x20f3
movl $0x1, %edi
movl %ebx, %edx
xorl %eax, %eax
callq 0x10b0
// File: /workspace/github_c_makefile_star2_O1/tudurom[P]disputils/randr.c
// Function: get_primary_output
xcb_randr_get_output_primary_reply_t *
get_primary_output(xcb_connection_t * conn)
{
	xcb_screen_t   *scrn;
	xcb_window_t    root;
	xcb_randr_get_output_primary_cookie_t c;
	xcb_randr_get_output_primary_reply_t *primary_output;

	get_screen(conn, &scrn);
	root = scrn->root;

	c = xcb_randr_get_output_primary(conn, root);
	primary_output = xcb_randr_get_output_primary_reply(conn, c, NULL);

	return primary_output;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq %rsp, %r14
movq %r14, %rsi
callq 0x159a
movq (%r14), %rax
movl (%rax), %esi
movq %rbx, %rdi
callq 0x1210
movq %rbx, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x1080
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/AML_HEVCEncoder.cpp
// Function: dumpCodedPicture(AMVHEVCEncHandle_s*, int, unsigned char const*, unsigned int)
void dumpCodedPicture(AMVHEVCEncHandle *Handle, const int idx, const unsigned char *buffer, const uint32_t nal_length) {
    VLOG(INFO, "-------------- Picture[%d] dump --------------", idx);
    VLOG(INFO, " widthxheight - %dx%d", Handle->src_pics[idx].width, Handle->src_pics[idx].height);
    VLOG(INFO, " nal_type     - %x", Handle->src_pics[idx].type);
    VLOG(INFO, " order, pts   - %d, %ld", Handle->src_pics[idx].order,  Handle->src_pics[idx].pts);
    VLOG(INFO, " nal_length   - %d", nal_length);
    VLOG(INFO, "-------------- NAL + PayLoad Start -----------------");

    int max_stride = nal_length / 4;
    for (int i = 0; i < max_stride; i += 8)
        VLOG(INFO, "[%d] %2x %2x %2x %2x %2x %2x %2x %2x", i,
                buffer[i], buffer[i+1], buffer[i+2], buffer[i+3], buffer[i+4], buffer[i+5], buffer[i+6], buffer[i+7]);

    for(int i=0; i < nal_length%4; i++)
        VLOG(INFO, "[%d] %2x", i, buffer[i]);

    VLOG(INFO, "-------------- PayLoad End -------------------");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebp
movq %rdx, %rbx
movl %esi, %r15d
movq %rdi, %r14
leaq 0x29437(%rip), %rdi     # 0x2b8b0
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
movslq %r15d, %rax
leaq (%rax,%rax,4), %r15
shlq $0x4, %r15
movl 0xe4(%r14,%r15), %esi
movl 0xe8(%r14,%r15), %edx
leaq 0x29433(%rip), %rdi     # 0x2b8df
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
movl 0xb8(%r14,%r15), %esi
leaq 0x29429(%rip), %rdi     # 0x2b8f5
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
movl 0xe0(%r14,%r15), %esi
movq 0xa0(%r14,%r15), %rdx
leaq 0x29414(%rip), %rdi     # 0x2b908
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
leaq 0x29414(%rip), %rdi     # 0x2b920
movl %ebp, %esi
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
leaq 0x2940d(%rip), %rdi     # 0x2b933
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
movl %ebp, 0x4(%rsp)
cmpl $0x4, %ebp
jb 0x25af
movl 0x4(%rsp), %eax
movl %eax, %r12d
shrl $0x2, %r12d
leaq 0x29416(%rip), %r14     # 0x2b968
xorl %r15d, %r15d
movzbl (%rbx,%r15), %edx
movzbl 0x1(%rbx,%r15), %ecx
movzbl 0x2(%rbx,%r15), %r8d
movzbl 0x3(%rbx,%r15), %r9d
movzbl 0x4(%rbx,%r15), %r10d
movzbl 0x5(%rbx,%r15), %r11d
movzbl 0x6(%rbx,%r15), %r13d
movzbl 0x7(%rbx,%r15), %ebp
movq %r14, %rdi
movl %r15d, %esi
xorl %eax, %eax
pushq %rbp
pushq %r13
pushq %r11
pushq %r10
callq 0x2050
addq $0x20, %rsp
movl $0xa, %edi
callq 0x2220
addq $0x8, %r15
cmpq %r12, %r15
jb 0x2555
movl 0x4(%rsp), %eax
andl $0x3, %eax
je 0x25e9
movl %eax, %r12d
leaq 0x293cb(%rip), %r14     # 0x2b98d
xorl %r15d, %r15d
movzbl (%rbx,%r15), %edx
movq %r14, %rdi
movl %r15d, %esi
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
incq %r15
cmpq %r15, %r12
jne 0x25c5
leaq 0x293a6(%rip), %rdi     # 0x2b996
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/AML_HEVCEncoder.cpp
// Function: Wave4BitIssueCommand(unsigned int, unsigned int, unsigned int)
void Wave4BitIssueCommand(Uint32 coreIdx, Uint32 instanceIndex, Uint32 cmd) {

	(void)instanceIndex;

    VpuWriteReg(coreIdx, W4_VPU_BUSY_STATUS, 1);
    VpuWriteReg(coreIdx, W4_RET_SUCCESS, 0);  //for debug
    //VpuWriteReg(coreIdx, W4_CORE_INDEX, 0);
    //VpuWriteReg(coreIdx, W4_INST_INDEX, (instanceIndex & 0xffff) | (codecMode << 16));

    VpuWriteReg(coreIdx, W4_COMMAND, cmd);
    VpuWriteReg(coreIdx, W4_VPU_HOST_INT_REQ, 1);
    return;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %edx, %ebx
movl %edi, %ebp
movl $0x70, %esi
movl $0x1, %edx
callq 0x2150
movl %ebp, %edi
movl $0x110, %esi            # imm = 0x110
xorl %edx, %edx
callq 0x2150
movl %ebp, %edi
movl $0x100, %esi            # imm = 0x100
movl %ebx, %edx
callq 0x2150
movl %ebp, %edi
movl $0x38, %esi
movl $0x1, %edx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x2150
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/AML_HEVCEncoder.cpp
// Function: Wave4VpuReset(AMVHEVCEncHandle_s*, unsigned int, int)
AMVEnc_Status Wave4VpuReset(AMVHEVCEncHandle *Handle, Uint32 coreIdx, int resetMode) {
    u32 val = 0;

    // VPU doesn't send response. Force to set BUSY flag to 0.
    VpuWriteReg(coreIdx, W4_VPU_BUSY_STATUS, 0);

    if (resetMode == SW_RESET_SAFETY) {
        Wave4VpuSleepWake(Handle, coreIdx, 1, NULL, 0, 0);
    }

    switch (resetMode) {
    case SW_RESET_ON_BOOT:
        val = W4_RST_BLOCK_ALL;
        break;
    case SW_RESET_FORCE:
        val = W4_RST_BLOCK_BCLK_ALL | W4_RST_BLOCK_CCLK_ALL;
        break;
    case SW_RESET_SAFETY:
        val = W4_RST_BLOCK_ACLK_ALL | W4_RST_BLOCK_BCLK_ALL | W4_RST_BLOCK_CCLK_ALL;
        break;
    default:
        return AMVENC_NOT_SUPPORTED;
    }

    if (val) {
        VpuWriteReg(coreIdx, W4_VPU_RESET_REQ, val);
        if (vdi_wait_vpu_busy(coreIdx, VPU_BUSY_CHECK_TIMEOUT, W4_VPU_RESET_STATUS) == -1) {
            VpuWriteReg(coreIdx, W4_VPU_RESET_REQ, 0);
            VLOG(INFO, "Wave4VpuReset time out reset");
            reset_error = 1;
            return AMVENC_TIMEOUT;
        }
        VpuWriteReg(coreIdx, W4_VPU_RESET_REQ, 0);
    }

    if (resetMode == SW_RESET_SAFETY || resetMode == SW_RESET_ON_BOOT) {
        Wave4VpuSleepWake(Handle, coreIdx, 0, NULL, 0, val);
    }
    return AMVENC_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebp
movl %esi, %ebx
movq %rdi, %r14
movl %esi, %edi
movl $0x70, %esi
xorl %edx, %edx
callq 0x2150
cmpl $0x2, %ebp
je 0x4781
cmpl $0x1, %ebp
je 0x4779
movl $0xfffffffe, %r12d      # imm = 0xFFFFFFFE
testl %ebp, %ebp
jne 0x4802
movq %r14, %rdi
movl %ebx, %esi
movl $0x1, %edx
xorl %r9d, %r9d
callq 0x21d0
movl $0xffffff, %r15d        # imm = 0xFFFFFF
jmp 0x4787
movl $0xffff, %r15d          # imm = 0xFFFF
jmp 0x4787
movl $0xfffffff, %r15d       # imm = 0xFFFFFFF
movl %ebx, %edi
movl $0x50, %esi
movl %r15d, %edx
callq 0x2150
movl %ebx, %edi
movl $0x1388, %esi           # imm = 0x1388
movl $0x54, %edx
callq 0x2060
movl %eax, %r12d
movl %ebx, %edi
movl $0x50, %esi
xorl %edx, %edx
callq 0x2150
cmpl $-0x1, %r12d
je 0x47dd
movl $0x1, %r12d
testl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
jne 0x4802
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
movl %r15d, %r9d
callq 0x21d0
jmp 0x4802
leaq 0x285bb(%rip), %rdi     # 0x2cd9f
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
movb $0x1, 0x2b9d8(%rip)     # 0x301d4
movl $0xffffffdc, %r12d      # imm = 0xFFFFFFDC
movl %r12d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/AML_HEVCEncoder.cpp
// Function: AML_HEVCEncNAL(AMVHEVCEncHandle_s*, unsigned char*, unsigned int*, int*)
AMVEnc_Status AML_HEVCEncNAL(AMVHEVCEncHandle *Handle, unsigned char *buffer, unsigned int *buf_nal_size, int *nal_type) {
    AMVEnc_Status ret = AMVENC_FAIL;
    int end = 0;
    int reset_count = 0;

    if (reset_error)
        return ret;
retry:
    ret = Wave4VpuEncEncPic(Handle, Handle->src_idx, end, buffer, buf_nal_size, nal_type);

    if (ret != AMVENC_SUCCESS) {
        if (ret == AMVENC_OVERFLOW)
            return ret;
        if (reset_mode == 2) {
            Wave4VpuCreateInstance(Handle, 0);
        }
        Wave4VpuEncSeqInit(Handle, 0);
        if (Handle->mGopIdx == 0)
            Wave4VpuEncSeqSet(Handle);
        Handle->src_count = VpuReadReg(Handle->instance_id, W4_RET_ENC_MIN_SRC_BUF_NUM);
        Wave4VpuEncRegisterFrame(Handle, 0);
        Handle->src_idx = 0;
        reset_count++;
        if (reset_count < 5)
            goto retry;

        //ret = AMVENC_REENCODE_PICTURE;
        //return ret;
    }
    Handle->src_idx++;
    Handle->src_idx = Handle->src_idx % Handle->src_count;
    Handle->enc_counter++;

    return AMVENC_PICTURE_READY;
}

// Assembly:
xorl %eax, %eax
cmpb $0x0, 0x298cb(%rip)     # 0x301d4
jne 0x69ae
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
movl $0x5, %ebp
movl 0x4(%rbx), %esi
movq %rbx, %rdi
xorl %edx, %edx
movq %r12, %rcx
movq %r15, %r8
movq %r14, %r9
callq 0x2380
cmpl $-0x27, %eax
je 0x69a6
cmpl $0x1, %eax
je 0x6991
movq %rbx, %rdi
xorl %esi, %esi
callq 0x21b0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2090
cmpl $0x0, 0x304(%rbx)
jne 0x696d
movq %rbx, %rdi
callq 0x20d0
movl (%rbx), %edi
movl $0x1d8, %esi            # imm = 0x1D8
callq 0x2200
movl %eax, 0x8(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2310
movl $0x0, 0x4(%rbx)
decl %ebp
jne 0x6928
movl 0x4(%rbx), %eax
incl %eax
xorl %edx, %edx
divl 0x8(%rbx)
movl %edx, 0x4(%rbx)
incl 0x2c(%rbx)
movl $0x2, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/libvp_hevc_codec.cpp
// Function: vl_video_encoder_destroy
int vl_video_encoder_destroy(vl_codec_handle_t codec_handle) {
    AMVHEVCEncHandle *handle = (AMVHEVCEncHandle *)codec_handle;
    AML_HEVCRelease(handle);
    if (handle->mSPSPPSData)
        free(handle->mSPSPPSData);
    if (handle->mEncParams)
        destroyEncParams(handle->mEncParams);
    if (handle)
        delete handle;
    return 1;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x2270
movq 0x2f0(%rbx), %rdi
testq %rdi, %rdi
je 0x7088
callq 0x21f0
movq 0x2e0(%rbx), %rdi
testq %rdi, %rdi
je 0x709e
movl $0x60, %esi
callq 0x21c0
testq %rbx, %rbx
je 0x70b0
movl $0x310, %esi            # imm = 0x310
movq %rbx, %rdi
callq 0x21c0
movl $0x1, %eax
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O1/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 %rbx
subq $0x20, %rsp
testl %edi, %edi
je 0x73df
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
retq
movl 0x28dff(%rip), %edi     # 0x301e4
xorl %ebx, %ebx
testl %edi, %edi
js 0x73d6
cmpb $0x0, 0x28df6(%rip)     # 0x301e8
je 0x73d6
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, (%rsp)
movaps %xmm0, 0x28e19(%rip)    # 0x30220
movaps %xmm0, 0x28e22(%rip)    # 0x30230
cmpq $0x0, 0x28dda(%rip)     # 0x301f0
je 0x7421
movq 0x28dd1(%rip), %rbx     # 0x301f0
jmp 0x73d6
movq %rsp, %rbx
movq $0x20028, (%rbx)        # imm = 0x20028
movl $0x40205605, %esi       # imm = 0x40205605
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2230
movl (%rbx), %esi
testl %eax, %eax
js 0x7486
movl 0x28d9d(%rip), %r8d     # 0x301e4
xorl %edi, %edi
movl $0x3, %edx
movl $0x1, %ecx
xorl %r9d, %r9d
callq 0x2320
movq %rax, 0x18(%rsp)
cmpq $-0x1, %rax
je 0x7498
movaps (%rsp), %xmm0
movaps 0x10(%rsp), %xmm1
movaps %xmm1, 0x28dba(%rip)    # 0x30230
movaps %xmm0, 0x28da3(%rip)    # 0x30220
movq %rax, 0x28d6c(%rip)     # 0x301f0
jmp 0x7418
leaq 0x2607b(%rip), %rdi     # 0x2d508
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2050
jmp 0x74b0
movq 0x8(%rsp), %rsi
movl (%rsp), %edx
leaq 0x2609e(%rip), %rdi     # 0x2d545
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
jmp 0x73d6
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/vdi.cpp
// Function: vdi_set_clock_gate(unsigned int, unsigned int)
s32 vdi_set_clock_gate(u32 core_idx, u32 enable) {
    vdi_info_t *vdi;
    s32 ret;

    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;

    vdi->clock_state = enable;
    ret = ioctl(vdi->vpu_fd, VDI_IOCTL_SET_CLOCK_GATE, &enable);
    return ret;
}

// Assembly:
pushq %rax
movl %esi, 0x4(%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %edi, %edi
jne 0x74f7
movl 0x28d11(%rip), %edi     # 0x301e4
testl %edi, %edi
js 0x74f7
cmpb $0x0, 0x28d0a(%rip)     # 0x301e8
je 0x74f7
movl %esi, 0x28d16(%rip)     # 0x301fc
leaq 0x4(%rsp), %rdx
movl $0x40045603, %esi       # imm = 0x40045603
xorl %eax, %eax
callq 0x2230
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/vdi.cpp
// Function: vdi_set_bit_firmware_to_pm(unsigned int, unsigned short const*)
s32 vdi_set_bit_firmware_to_pm(u32 core_idx, const u16 *code) {
    s32 i;
    vpu_bit_firmware_info_t bit_firmware_info;
    vdi_info_t *vdi;

    if (core_idx >= MAX_NUM_VPU_CORE)
        return 0;

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

    bit_firmware_info.size = sizeof(vpu_bit_firmware_info_t);
    bit_firmware_info.core_idx = core_idx;
    bit_firmware_info.reg_base_offset = 0;
    for (i = 0; i < 512; i++)
        bit_firmware_info.bit_code[i] = code[i];

    if (write(vdi->vpu_fd, &bit_firmware_info, bit_firmware_info.size) < 0) {
        VLOG(ERR, "[VDI] fail to vdi_set_bit_firmware core=%d", bit_firmware_info.core_idx);
        return -1;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x418, %rsp            # imm = 0x418
xorl %ebx, %ebx
testl %edi, %edi
je 0x763f
movl %ebx, %eax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %rbp
retq
movl 0x28b9f(%rip), %ebp     # 0x301e4
testl %ebp, %ebp
js 0x7633
cmpb $0x0, 0x28b98(%rip)     # 0x301e8
je 0x7633
leaq 0x18(%rsp), %rdi
movq $0x40c, -0xc(%rdi)      # imm = 0x40C
movl $0x0, -0x4(%rdi)
movl $0x400, %edx            # imm = 0x400
callq 0x2140
leaq 0xc(%rsp), %rsi
movl $0x40c, %edx            # imm = 0x40C
movl %ebp, %edi
callq 0x20c0
testq %rax, %rax
jns 0x7633
leaq 0x25e50(%rip), %rdi     # 0x2d4dd
xorl %esi, %esi
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x7633
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/vdi.cpp
// Function: vdi_get_common_memory(unsigned int, vpu_buffer_t*)
s32 vdi_get_common_memory(u32 core_idx, vpu_buffer_t *vb) {
    vdi_info_t *vdi;

    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;

    memcpy(vb, &vdi->vpu_common_memory, sizeof(vpu_buffer_t));
    return 0;
}

// Assembly:
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %edi, %edi
je 0x76b1
retq
cmpl $0x0, 0x28b2c(%rip)     # 0x301e4
js 0x76b0
cmpb $0x0, 0x28b27(%rip)     # 0x301e8
je 0x76b0
movaps 0x28b86(%rip), %xmm0    # 0x30250
movups %xmm0, 0x10(%rsi)
movaps 0x28b6b(%rip), %xmm0    # 0x30240
movups %xmm0, (%rsi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/vdi.cpp
// Function: vdi_open_instance(unsigned int, unsigned int)
s32 vdi_open_instance(u32 core_idx, u32 inst_idx) {
    vdi_info_t *vdi;
    vpudrv_inst_info_t inst_info;
    u32* pCodecInst;

    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;

    inst_info.core_idx = core_idx;
    inst_info.inst_idx = inst_idx;
    if (ioctl(vdi->vpu_fd, VDI_IOCTL_OPEN_INSTANCE, &inst_info) < 0) {
        VLOG(ERR, "[VDI] fail to deliver open instance num inst_idx=%d", inst_idx);
        return -1;
    }
    vdi->pvip->vpu_instance_num = inst_info.inst_open_count;
    pCodecInst = (u32 *) vdi->pvip->codecInstPool[inst_idx];
    pCodecInst[0] = 1;
    return 0;
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x18, %rsp
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %edi, %edi
je 0x76f3
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
movl 0x28aeb(%rip), %edi     # 0x301e4
testl %edi, %edi
js 0x76ea
cmpb $0x0, 0x28ae4(%rip)     # 0x301e8
je 0x76ea
movl %esi, %ebp
leaq 0xc(%rsp), %rdx
movl $0x0, (%rdx)
movl %esi, 0x4(%rdx)
movl $0x400c5609, %esi       # imm = 0x400C5609
xorl %eax, %eax
callq 0x2230
testl %eax, %eax
js 0x7748
movl 0x14(%rsp), %eax
movq 0x28abf(%rip), %rcx     # 0x301f0
movl %eax, 0x20020(%rcx)
movl %ebp, %eax
shlq $0xf, %rax
movl $0x1, (%rcx,%rax)
xorl %ebx, %ebx
jmp 0x76ea
leaq 0x25e31(%rip), %rdi     # 0x2d580
movl %ebp, %esi
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
jmp 0x76ea
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/vdi.cpp
// Function: vdi_get_instance_num(unsigned int)
s32 vdi_get_instance_num(u32 core_idx) {
    vdi_info_t *vdi;

    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;

    return vdi->pvip->vpu_instance_num;
}

// Assembly:
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %edi, %edi
je 0x77f7
retq
cmpl $0x0, 0x289e6(%rip)     # 0x301e4
js 0x77f6
cmpb $0x0, 0x289e1(%rip)     # 0x301e8
je 0x77f6
movq 0x289e0(%rip), %rax     # 0x301f0
movl 0x20020(%rax), %eax
retq
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/vdi.cpp
// Function: vdi_fio_read_register(unsigned int, unsigned int)
void vdi_write_register(u32 core_idx, u32 addr, u32 data) {
    vdi_info_t *vdi;
    ulong *reg_addr;

    if (core_idx >= MAX_NUM_VPU_CORE)
        return;

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

    reg_addr = (ulong *) (addr + (ulong) vdi->vdb_register.virt_addr);
    *(volatile u32 *) reg_addr = data;
}

// Assembly:
testl %edi, %edi
jne 0x78b2
cmpl $0x0, 0x2894a(%rip)     # 0x301e4
js 0x78b2
cmpb $0x0, 0x28945(%rip)     # 0x301e8
je 0x78b2
movzwl %si, %eax
movq 0x28969(%rip), %rcx     # 0x30218
movl %eax, 0x20(%rcx)
cmpl $0x0, 0x2892b(%rip)     # 0x301e4
sets %al
cmpb $0x0, 0x28925(%rip)     # 0x301e8
sete %cl
orb %al, %cl
movl $0xffffd8ef, %edx       # imm = 0xFFFFD8EF
movq 0x28944(%rip), %rsi     # 0x30218
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
incl %edx
je 0x78ef
testl %edi, %edi
jne 0x78ef
testb %cl, %cl
jne 0x78eb
cmpl $0x0, 0x20(%rsi)
jns 0x78d9
testl %edi, %edi
je 0x78f0
retq
cmpl $0x0, 0x288ed(%rip)     # 0x301e4
js 0x78ef
cmpb $0x0, 0x288e8(%rip)     # 0x301e8
je 0x78ef
movq 0x2890f(%rip), %rax     # 0x30218
movl 0x24(%rax), %eax
retq
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/vdi.cpp
// Function: WriteRegVCE(unsigned int, unsigned int, unsigned int, unsigned int)
void WriteRegVCE(u32 core_idx, u32 vce_core_idx, u32 vce_addr, u32 udata) {
    s32 vcpu_reg_addr;

    vdi_fio_write_register(core_idx, VCORE_DBG_READY(vce_core_idx), 0);

    vcpu_reg_addr = vce_addr >> 2;
    vdi_fio_write_register(core_idx, VCORE_DBG_DATA(vce_core_idx), udata);
    vdi_fio_write_register(core_idx, VCORE_DBG_ADDR(vce_core_idx), (vcpu_reg_addr) & 0x00007FFF);

    if (vdi_fio_read_register(0, VCORE_DBG_READY(vce_core_idx)) < 0)
        VLOG(ERR, "failed to write VCE register: 0x%04x", vce_addr);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %ecx, %ebp
movl %edx, %ebx
movl %esi, %r14d
movl %edi, %r15d
shll $0xc, %r14d
leal 0x8308(%r14), %r12d
movl %r12d, %esi
xorl %edx, %edx
callq 0x2070
shrl $0x2, %ebx
leal 0x8304(%r14), %esi
movl %r15d, %edi
movl %ebp, %edx
callq 0x2070
addl $0x8300, %r14d          # imm = 0x8300
andl $0x7fff, %ebx           # imm = 0x7FFF
movl %r15d, %edi
movl %r14d, %esi
movl %ebx, %edx
callq 0x2070
xorl %edi, %edi
movl %r12d, %esi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2030
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/vdi.cpp
// Function: ReadRegVCE(unsigned int, unsigned int, unsigned int)
u32 ReadRegVCE(u32 core_idx, u32 vce_core_idx, u32 vce_addr) {
    s32 vcpu_reg_addr;
    s32 udata;
    s32 vce_core_base = 0x8000 + 0x1000 * vce_core_idx;

    vdi_fio_write_register(core_idx, VCORE_DBG_READY(vce_core_idx), 0);

    vcpu_reg_addr = vce_addr >> 2;

    vdi_fio_write_register(core_idx, VCORE_DBG_ADDR(vce_core_idx), vcpu_reg_addr + vce_core_base);

    if (vdi_fio_read_register(0, VCORE_DBG_READY(vce_core_idx)) == 1)
        udata = vdi_fio_read_register(0, VCORE_DBG_DATA(vce_core_idx));
    else
        udata = -1;
    return udata;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r14d
movl %esi, %ebx
movl %edi, %ebp
shll $0xc, %ebx
leal 0x8308(%rbx), %r15d
movl %r15d, %esi
xorl %edx, %edx
callq 0x2070
shrl $0x2, %r14d
leal 0x8300(%rbx), %esi
leal (%rbx,%r14), %edx
addl $0x8000, %edx           # imm = 0x8000
movl %ebp, %edi
callq 0x2070
xorl %edi, %edi
movl %r15d, %esi
callq 0x2030
cmpl $0x1, %eax
jne 0x7a23
addl $0x8304, %ebx           # imm = 0x8304
xorl %edi, %edi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2030
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
pushq %rbx
pushq %rax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %edi, %edi
je 0x7a48
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
cmpl $0x0, 0x28795(%rip)     # 0x301e4
js 0x7a3f
cmpb $0x0, 0x28790(%rip)     # 0x301e8
je 0x7a3f
movl %edx, %ebp
movl %esi, %edi
xorl %eax, %eax
movl $0xa0, %edx
leaq 0x28774(%rip), %r9      # 0x301e0
xorl %ecx, %ecx
xorl %r8d, %r8d
cmpl $0x1, (%rdx,%r9)
jne 0x7a97
movl -0x20(%rdx,%r9), %eax
movq -0x18(%rdx,%r9), %r8
movq -0x8(%rdx,%r9), %rcx
cmpq %rdi, %r8
ja 0x7a97
movq %rax, %r10
addq %r8, %r10
cmpq %rdi, %r10
ja 0x7aa4
addq $0x28, %rdx
cmpq $0x28a0, %rdx           # imm = 0x28A0
jne 0x7a71
testl %eax, %eax
je 0x7abb
movl %ebp, %edx
subq %r8, %rdi
addq %rcx, %rdi
xorl %esi, %esi
callq 0x20e0
movl %ebp, %ebx
jmp 0x7a3f
leaq 0x25af2(%rip), %rdi     # 0x2d5b4
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
jmp 0x7a3f
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/vdi.cpp
// Function: vdi_set_sdram(unsigned int, unsigned int, unsigned int, unsigned char)
void vdi_set_sdram(u32 core_idx, u32 addr, u32 len, u8 data) {
    vdi_info_t *vdi;
    u8 *buf;

    if (core_idx >= MAX_NUM_VPU_CORE)
        return;

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

    buf = (u8 *) malloc(len);
    if (!buf)
        return;

    memset(buf, data, len);
    vdi_write_memory(core_idx, addr, buf, len);
    free(buf);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testl %edi, %edi
je 0x7aed
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0x286f0(%rip)     # 0x301e4
js 0x7ae4
cmpb $0x0, 0x286eb(%rip)     # 0x301e8
je 0x7ae4
movl %ecx, %r14d
movl %edx, %ebx
movl %esi, %ebp
movl %edx, %r12d
movq %r12, %rdi
callq 0x2210
testq %rax, %rax
je 0x7ae4
movq %rax, %r15
movzbl %r14b, %esi
movq %rax, %rdi
movq %r12, %rdx
callq 0x20e0
xorl %edi, %edi
movl %ebp, %esi
movq %r15, %rdx
movl %ebx, %ecx
callq 0x2110
movq %r15, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x21f0
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/vdi.cpp
// Function: vdi_write_memory(unsigned int, unsigned int, unsigned char*, unsigned int)
s32 vdi_write_memory(u32 core_idx, u32 addr, u8 *data, u32 len) {
    vdi_info_t *vdi;
    vpu_buffer_t vdb;
    ulong offset;
    s32 i;

    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;
    }
    offset = addr - (ulong) vdb.phys_addr;
    memcpy((void *) ((ulong) vdb.virt_addr + offset), data, len);
    return len;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %edi, %edi
je 0x7b5b
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
cmpl $0x0, 0x28682(%rip)     # 0x301e4
js 0x7b52
cmpb $0x0, 0x2867d(%rip)     # 0x301e8
je 0x7b52
movl %ecx, %ebp
movl %esi, %edi
xorl %eax, %eax
movl $0xa0, %r8d
leaq 0x28660(%rip), %r9      # 0x301e0
xorl %ecx, %ecx
xorl %r10d, %r10d
cmpl $0x1, (%r8,%r9)
jne 0x7bab
movl -0x20(%r8,%r9), %r10d
movq -0x18(%r8,%r9), %rcx
movq -0x8(%r8,%r9), %rax
cmpq %rdi, %rcx
ja 0x7bab
movq %r10, %r11
addq %rcx, %r11
cmpq %rdi, %r11
ja 0x7bb8
addq $0x28, %r8
cmpq $0x28a0, %r8            # imm = 0x28A0
jne 0x7b85
testl %r10d, %r10d
je 0x7bd7
subq %rcx, %rdi
addq %rax, %rdi
movl %ebp, %eax
movq %rdx, %rsi
movq %rax, %rdx
callq 0x2140
movl %ebp, %ebx
jmp 0x7b52
leaq 0x259d6(%rip), %rdi     # 0x2d5b4
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
jmp 0x7b52
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/vdi.cpp
// Function: vdi_read_memory(unsigned int, unsigned int, unsigned char*, unsigned int)
s32 vdi_read_memory(u32 core_idx, u32 addr, u8 *data, u32 len) {
    vdi_info_t *vdi;
    vpu_buffer_t vdb;
    ulong offset;
    s32 i;

    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)
        return -1;

    offset = addr - (ulong) vdb.phys_addr;
    memcpy(data, (void *) ((ulong) vdb.virt_addr + offset), len);
    return len;
}

// Assembly:
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %edi, %edi
je 0x7bfe
retq
cmpl $0x0, 0x285df(%rip)     # 0x301e4
js 0x7bfd
cmpb $0x0, 0x285da(%rip)     # 0x301e8
je 0x7bfd
pushq %rbx
movl %ecx, %ebx
movl %esi, %esi
xorl %ecx, %ecx
movl $0xa0, %r8d
leaq 0x285bc(%rip), %r9      # 0x301e0
xorl %edi, %edi
xorl %r10d, %r10d
cmpl $0x1, (%r8,%r9)
jne 0x7c4f
movl -0x20(%r8,%r9), %r10d
movq -0x18(%r8,%r9), %rdi
movq -0x8(%r8,%r9), %rcx
cmpq %rsi, %rdi
ja 0x7c4f
movq %r10, %r11
addq %rdi, %r11
cmpq %rsi, %r11
ja 0x7c5c
addq $0x28, %r8
cmpq $0x28a0, %r8            # imm = 0x28A0
jne 0x7c29
testl %r10d, %r10d
je 0x7c76
subq %rdi, %rsi
addq %rcx, %rsi
movl %ebx, %eax
movq %rdx, %rdi
movq %rax, %rdx
callq 0x2140
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/vdi.cpp
// Function: vdi_attach_dma_memory(unsigned int, vpu_buffer_t*)
s32 vdi_attach_dma_memory(u32 core_idx, vpu_buffer_t *vb) {
    vdi_info_t *vdi;
    s32 i;
    vpu_buffer_t vdb;

    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));

    vdb.size = vb->size;
    vdb.phys_addr = vb->phys_addr;
    vdb.base = vb->base;
    vdb.virt_addr = vb->virt_addr;
    vdb.cached = vb->cached;

    for (i = 0; i < MAX_VPU_BUFFER_POOL; i++) {
        if (vdi->vpu_buffer_pool[i].vdb.phys_addr == vb->phys_addr) {
            vdi->vpu_buffer_pool[i].vdb = vdb;
            vdi->vpu_buffer_pool[i].inuse = 1;
            break;
        }
    }
    if (i == MAX_VPU_BUFFER_POOL) {
        for (i = 0; i < MAX_VPU_BUFFER_POOL; i++) {
            if (vdi->vpu_buffer_pool[i].inuse == 0) {
                vdi->vpu_buffer_pool[i].vdb = vdb;
                vdi->vpu_buffer_pool_count++;
                vdi->vpu_buffer_pool[i].inuse = 1;
                break;
            }
        }
    }
    VLOG(INFO, "[VDI] vdi_attach_dma_memory, physaddr=0x%lx, virtaddr=0x%lx, size=0x%x, index=%d",
                                                                    vb->phys_addr, vb->virt_addr, vb->size, i);
    return 0;
}

// Assembly:
pushq %rbx
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %edi, %edi
jne 0x7e95
cmpl $0x0, 0x28430(%rip)     # 0x301e4
js 0x7e95
cmpb $0x0, 0x28427(%rip)     # 0x301e8
je 0x7e95
movl (%rsi), %eax
movl 0x4(%rsi), %r9d
movq 0x8(%rsi), %rcx
movq 0x10(%rsi), %rdx
movq 0x18(%rsi), %rdi
leaq 0x28480(%rip), %r10     # 0x30260
xorl %r8d, %r8d
cmpq %rcx, 0x8(%r10)
je 0x7e01
incq %r8
addq $0x28, %r10
cmpq $0x100, %r8             # imm = 0x100
jne 0x7de3
movl $0x100, %r8d            # imm = 0x100
jmp 0x7e1c
movl %eax, (%r10)
movl %r9d, 0x4(%r10)
movq %rcx, 0x8(%r10)
movq %rdx, 0x10(%r10)
movq %rdi, 0x18(%r10)
movl $0x1, 0x20(%r10)
cmpl $0x100, %r8d            # imm = 0x100
jne 0x7e6e
leaq 0x28454(%rip), %r10     # 0x30280
xorl %r8d, %r8d
cmpl $0x0, (%r10)
je 0x7e4d
incq %r8
addq $0x28, %r10
cmpq $0x100, %r8             # imm = 0x100
jne 0x7e2f
movl $0x100, %r8d            # imm = 0x100
jmp 0x7e6e
movl %eax, -0x20(%r10)
movl %r9d, -0x1c(%r10)
movq %rcx, -0x18(%r10)
movq %rdx, -0x10(%r10)
movq %rdi, -0x8(%r10)
incl 0x2abf9(%rip)           # 0x32a60
movl $0x1, (%r10)
movq 0x8(%rsi), %rax
movq 0x18(%rsi), %rdx
movl (%rsi), %ecx
leaq 0x257dc(%rip), %rdi     # 0x2d65b
xorl %ebx, %ebx
movq %rax, %rsi
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/vdi.cpp
// Function: vdi_dettach_dma_memory(unsigned int, vpu_buffer_t*)
s32 vdi_dettach_dma_memory(u32 core_idx, vpu_buffer_t *vb) {
    vdi_info_t *vdi;
    s32 i;

    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;

    if (vb->size == 0)
        return -1;

    for (i = 0; i < MAX_VPU_BUFFER_POOL; i++) {
        if (vdi->vpu_buffer_pool[i].vdb.phys_addr == vb->phys_addr) {
            vdi->vpu_buffer_pool[i].inuse = 0;
            vdi->vpu_buffer_pool_count--;
            break;
        }
    }
    return 0;
}

// Assembly:
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %edi, %edi
je 0x7ea3
retq
cmpl $0x0, 0x2833a(%rip)     # 0x301e4
js 0x7ea2
cmpb $0x0, 0x28335(%rip)     # 0x301e8
je 0x7ea2
cmpl $0x0, (%rsi)
je 0x7ea2
movq 0x8(%rsi), %rcx
movl $0xa0, %eax
leaq 0x28316(%rip), %rdx     # 0x301e0
cmpq %rcx, -0x18(%rax,%rdx)
je 0x7edf
addq $0x28, %rax
cmpq $0x28a0, %rax           # imm = 0x28A0
jne 0x7eca
jmp 0x7eec
movl $0x0, (%rax,%rdx)
decl 0x2ab74(%rip)           # 0x32a60
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/vdi.cpp
// Function: vdi_free_dma_memory(unsigned int, vpu_buffer_t*)
void vdi_free_dma_memory(u32 core_idx, vpu_buffer_t *vb) {
    vdi_info_t *vdi;
    s32 i;
    vpu_buffer_t vdb;

    if (core_idx >= MAX_NUM_VPU_CORE)
        return;

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

    if (vb->size == 0)
        return;

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

    for (i = 0; i < MAX_VPU_BUFFER_POOL; i++) {
        if (vdi->vpu_buffer_pool[i].vdb.phys_addr == vb->phys_addr) {
            vdi->vpu_buffer_pool[i].inuse = 0;
            vdi->vpu_buffer_pool_count--;
            vdb = vdi->vpu_buffer_pool[i].vdb;
            break;
        }
    }

    if (!vdb.size) {
        VLOG(ERR, "[VDI] invalid buffer to free address = 0x%lx", vdb.virt_addr);
        return;
    }

    ioctl(vdi->vpu_fd, VDI_IOCTL_FREE_PHYSICALMEMORY, &vdb);

    if (munmap((void *) vdb.virt_addr, vdb.size) != 0) {
        VLOG(ERR, "[VDI] fail to vdi_free_dma_memory virtial address = 0x%lx", vdb.virt_addr);
    }
    memset(vb, 0, sizeof(vpu_buffer_t));
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x28, %rsp
testl %edi, %edi
je 0x7f02
addq $0x28, %rsp
popq %rbx
popq %r14
retq
movl 0x282dc(%rip), %edi     # 0x301e4
testl %edi, %edi
js 0x7efa
cmpb $0x0, 0x282d5(%rip)     # 0x301e8
je 0x7efa
movq %rsi, %rbx
cmpl $0x0, (%rsi)
je 0x7efa
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, (%rsp)
movq 0x8(%rbx), %rdx
movl $0xa0, %eax
leaq 0x282a7(%rip), %rcx     # 0x301e0
cmpq %rdx, -0x18(%rax,%rcx)
je 0x7f4e
addq $0x28, %rax
cmpq $0x28a0, %rax           # imm = 0x28A0
jne 0x7f39
jmp 0x7f6e
movl $0x0, (%rax,%rcx)
decl 0x2ab05(%rip)           # 0x32a60
movups -0x20(%rax,%rcx), %xmm0
movups -0x10(%rax,%rcx), %xmm1
movaps %xmm0, (%rsp)
movaps %xmm1, 0x10(%rsp)
cmpl $0x0, (%rsp)
je 0x7fc2
movq %rsp, %r14
movl $0x40205601, %esi       # imm = 0x40205601
movq %r14, %rdx
xorl %eax, %eax
callq 0x2230
movq 0x18(%r14), %rdi
movl (%r14), %esi
callq 0x20f0
testl %eax, %eax
je 0x7fb3
movq 0x18(%rsp), %rsi
leaq 0x25737(%rip), %rdi     # 0x2d6d9
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
jmp 0x7efa
movq 0x18(%rsp), %rsi
leaq 0x256de(%rip), %rdi     # 0x2d6ac
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
addq $0x28, %rsp
popq %rbx
popq %r14
jmp 0x2220
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/vdi.cpp
// Function: vdi_wait_bus_busy(unsigned int, unsigned int, unsigned int)
s32 vdi_wait_bus_busy(u32 core_idx, u32 timeoutMs, u32 gdi_busy_flag) {
    ulong elapse, cur;
    struct timeval tv;
    vdi_info_t *vdi;

    vdi = &s_vdi_info[core_idx];
    tv.tv_sec = 0;
    tv.tv_usec = 0;
    gettimeofday(&tv, NULL);
    elapse = tv.tv_sec * 1000 + tv.tv_usec / 1000;

    while (1) {
        if (vdi_fio_read_register(core_idx, gdi_busy_flag) == 0x738)
            break;
        gettimeofday(&tv, NULL);
        cur = tv.tv_sec * 1000 + tv.tv_usec / 1000;
        if ((cur - elapse) > timeoutMs) {
            VLOG(ERR, "[VDI] vdi_wait_bus_busy timeout, timeoutMs: %d, PC=0x%x",
                                                     timeoutMs, vdi_read_register(core_idx, W4_VCPU_CUR_PC));
            return -1;
        }
        usleep(5);
    }
    return 0;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %r14d
movl %esi, %r13d
movl %edi, %ebp
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r15
movaps %xmm0, (%r15)
xorl %r12d, %r12d
movq %r15, %rdi
xorl %esi, %esi
callq 0x22b0
movq (%r15), %rbx
movabsq $-0x20c49ba5e353f7cf, %rax # imm = 0xDF3B645A1CAC0831
imulq 0x8(%r15)
movq %rdx, %r15
movl %ebp, %edi
movl %r14d, %esi
callq 0x2030
cmpl $0x738, %eax            # imm = 0x738
je 0x8127
movq %r15, %rax
shrq $0x3f, %rax
sarq $0x7, %r15
addq %rax, %r15
movl %r13d, 0xc(%rsp)
movl %r13d, %r12d
movabsq $0x20c49ba5e353f7cf, %r13 # imm = 0x20C49BA5E353F7CF
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x22b0
movq 0x10(%rsp), %rcx
subq %rbx, %rcx
movq %r13, %rax
imulq 0x18(%rsp)
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %rdx
addq %rax, %rdx
addq %r15, %rdx
imulq $0x3e8, %rcx, %rax      # imm = 0x3E8
addq %rdx, %rax
cmpq %r12, %rax
ja 0x80e0
movl $0x5, %edi
callq 0x2240
movl %ebp, %edi
movl %r14d, %esi
callq 0x2030
cmpl $0x738, %eax            # imm = 0x738
jne 0x8084
xorl %r12d, %r12d
jmp 0x8127
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
testl %ebp, %ebp
jne 0x810b
cmpl $0x0, 0x280ee(%rip)     # 0x301e4
js 0x810b
cmpb $0x0, 0x280e9(%rip)     # 0x301e8
je 0x810b
movq 0x28110(%rip), %rax     # 0x30218
movl 0x4(%rax), %edx
leaq 0x25601(%rip), %rdi     # 0x2d713
movl 0xc(%rsp), %esi
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
movl %r12d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/vdi.cpp
// Function: vdi_wait_vpu_busy(unsigned int, unsigned int, unsigned int)
s32 vdi_wait_vpu_busy(u32 core_idx, u32 timeoutMs, u32 addr_bit_busy_flag) {
    ulong elapse, cur;
    struct timeval tv;
    s32 i;
    u32 normalReg = 1;
    tv.tv_sec = 0;
    tv.tv_usec = 0;
    gettimeofday(&tv, NULL);
    elapse = tv.tv_sec * 1000 + tv.tv_usec / 1000;

    if (addr_bit_busy_flag & 0x8000)
        normalReg = 0;

    i = 0;
    while (1) {
        if (normalReg == 1) {
            if (vdi_read_register(core_idx, addr_bit_busy_flag) == 0)
                break;
        } else {
            if (vdi_fio_read_register(core_idx, addr_bit_busy_flag) == 0)
                break;
        }
        i++;
        gettimeofday(&tv, NULL);
        cur = tv.tv_sec * 1000 + tv.tv_usec / 1000;
        if ((cur - elapse) > timeoutMs) {
            for (i = 0; i < 20; i++) {
                VLOG(ERR, "[VDI] vdi_wait_vpu_busy timeout, timeoutMs: %d, PC=0x%x",
						timeoutMs, vdi_read_register(core_idx, W4_VCPU_CUR_PC));
            }
            return -1;
        }
        usleep(5);
    }
    VLOG(DEBUG, "[VDI] vdi_wait_vpu_busy i = %d", i);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r14d
movl %esi, %ebx
movl %edi, %ebp
xorps %xmm0, %xmm0
movq %rsp, %r12
movaps %xmm0, (%r12)
movq %r12, %rdi
xorl %esi, %esi
callq 0x22b0
movq (%r12), %r15
movabsq $-0x20c49ba5e353f7cf, %rax # imm = 0xDF3B645A1CAC0831
imulq 0x8(%r12)
movq %rdx, %r12
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %r12
addq %rax, %r12
movl %r14d, %eax
movq %rax, 0x10(%rsp)
movl %ebx, %r13d
testw %r14w, %r14w
js 0x81c5
testl %ebp, %ebp
jne 0x81d7
cmpl $0x0, 0x28041(%rip)     # 0x301e4
js 0x81d7
cmpb $0x0, 0x2803c(%rip)     # 0x301e8
je 0x81d7
movq 0x28063(%rip), %rax     # 0x30218
movq 0x10(%rsp), %rcx
cmpl $0x0, (%rax,%rcx)
jne 0x81d7
jmp 0x827b
movl %ebp, %edi
movl %r14d, %esi
callq 0x2030
testl %eax, %eax
je 0x827b
movq %rsp, %rdi
xorl %esi, %esi
callq 0x22b0
movq (%rsp), %rcx
subq %r15, %rcx
movabsq $0x20c49ba5e353f7cf, %rax # imm = 0x20C49BA5E353F7CF
imulq 0x8(%rsp)
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %rdx
addq %rax, %rdx
addq %r12, %rdx
imulq $0x3e8, %rcx, %rax      # imm = 0x3E8
addq %rdx, %rax
cmpq %r13, %rax
ja 0x8226
movl $0x5, %edi
callq 0x2240
jmp 0x8192
movl $0x14, %r12d
leaq 0x25518(%rip), %r15     # 0x2d74b
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
testl %ebp, %ebp
jne 0x825e
cmpl $0x0, 0x27f9b(%rip)     # 0x301e4
js 0x825e
cmpb $0x0, 0x27f96(%rip)     # 0x301e8
je 0x825e
movq 0x27fbd(%rip), %rax     # 0x30218
movl 0x4(%rax), %edx
movq %r15, %rdi
movl %ebx, %esi
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
decl %r12d
jne 0x8239
jmp 0x827e
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/xiane[P]libvphevcodec/vdi.cpp
// Function: vdi_wait_interrupt(unsigned int, unsigned int)
s32 vdi_wait_interrupt(u32 coreIdx, u32 timeout) {
    s32 intr_reason = 0;
    s32 ret;
    vdi_info_t *vdi;
    vpudrv_intr_info_t intr_info;

    if (coreIdx >= MAX_NUM_VPU_CORE)
        return -1;

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

    intr_info.timeout = timeout;
    intr_info.intr_reason = 0;
    ret = ioctl(vdi->vpu_fd, VDI_IOCTL_WAIT_INTERRUPT, (void*) &intr_info);
    if (ret != 0)
        return -1;

    intr_reason = intr_info.intr_reason;
    return intr_reason;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %edi, %edi
jne 0x82d7
movl 0x27f41(%rip), %edi     # 0x301e4
testl %edi, %edi
js 0x82d7
cmpb $0x0, 0x27f3a(%rip)     # 0x301e8
je 0x82d7
movq %rsp, %r14
movl %esi, (%r14)
movl $0x0, 0x4(%r14)
xorl %ebx, %ebx
movl $0x40085602, %esi       # imm = 0x40085602
movq %r14, %rdx
xorl %eax, %eax
callq 0x2230
negl %eax
sbbl %ebx, %ebx
orl 0x4(%r14), %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq