LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/LeoFu9487[P]push_swap/libft/ft_substr.c
// Function: ft_substr
char	*ft_substr(char const *s, size_t start, size_t len)
{
	char	*ans;
	size_t	l;
	size_t	ct;

	if (start >= ft_strlen(s))
	{
		ans = ft_calloc(1, sizeof(char));
		return (ans);
	}
	l = (size_t)ft_min((int)(ft_strlen(s) - start), (int)len);
	if (!s)
		return (NULL);
	ans = ft_calloc(l + 1, sizeof(char));
	if (!ans)
		return (NULL);
	ct = -1;
	while (++ct < l)
		ans[ct] = s[start + ct];
	ans[ct] = '\0';
	return (ans);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
callq 0x26a8
cmpq %r14, %rax
jbe 0x2751
movq %rbx, %rdi
callq 0x26a8
subl %r14d, %eax
movl %eax, %edi
movl %r15d, %esi
callq 0x2484
testq %rbx, %rbx
je 0x2768
movl %eax, %r15d
movslq %eax, %r12
leaq 0x1(%r12), %rdi
movl $0x1, %esi
callq 0x2658
testq %rax, %rax
je 0x2768
testl %r15d, %r15d
je 0x274a
addq %r14, %rbx
xorl %ecx, %ecx
movb (%rbx,%rcx), %dl
movb %dl, (%rax,%rcx)
incq %rcx
cmpq %rcx, %r12
jne 0x273c
movb $0x0, (%rax,%r12)
jmp 0x276a
movl $0x1, %edi
movl $0x1, %esi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2658
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O3/LeoFu9487[P]push_swap/libft/ft_memory.c
// Function: ft_memory
void	*ft_memory(size_t elem_cnt,
size_t elem_size, void *del, t_memory type)
{
	static t_list	*head;
	void			*new_mem;

	if (type == push)
	{
		new_mem = ft_calloc_2(elem_cnt, elem_size);
		if (!new_mem)
			ft_putstr_fd("ERROR_IN_FT_MEMORY_0\n", 1);
		else if (!(ft_lstadd_front(&head, ft_lstnew_2(new_mem))))
			ft_putstr_fd("ERROR_IN_FT_MEMORY_1\n", 1);
		return (new_mem);
	}
	if (type == pop)
		ft_lstdelone_2(&head, ft_lstfind(head, del), free);
	else
		ft_lstclear_2(&head, free);
	return (NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
cmpl $0x1, %ecx
je 0x27d9
testl %ecx, %ecx
jne 0x2825
movq %rsi, %r14
imulq %rdi, %r14
movq %r14, %rdi
callq 0x1070
testq %rax, %rax
je 0x2863
movq %rax, %rbx
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x26cc
movl $0x10, %edi
callq 0x1070
movq %rax, %r14
testq %rax, %rax
je 0x287d
movq %rbx, (%r14)
movq $0x0, 0x8(%r14)
jmp 0x288e
movq 0x2888(%rip), %rdi      # 0x5068
movq %rdx, %rsi
callq 0x28f8
testq %rax, %rax
je 0x28e5
movq %rax, %rbx
movq 0x286d(%rip), %rcx      # 0x5068
cmpq %rax, %rcx
je 0x28b4
testq %rcx, %rcx
je 0x28d4
movq %rcx, %rax
movq 0x8(%rcx), %rcx
cmpq %rbx, %rcx
jne 0x2804
addq $0x8, %rax
movq %rbx, %rcx
jmp 0x28bb
movq 0x283c(%rip), %r14      # 0x5068
movq $0x0, 0x2831(%rip) # 0x5068
testq %r14, %r14
je 0x28e5
xorl %ebx, %ebx
movq (%r14), %rdi
callq 0x1030
movq 0x8(%r14), %r15
movq %r14, %rdi
callq 0x1030
movq %r15, %r14
testq %r15, %r15
jne 0x2842
jmp 0x28e7
leaq 0x880(%rip), %rdi       # 0x30ea
movl $0x1, %esi
callq 0x1dc0
leaq 0x843(%rip), %rdi       # 0x30be
jmp 0x28db
leaq 0x87c(%rip), %rdi       # 0x3100
movl $0x1, %esi
callq 0x1dc0
leaq 0x27d3(%rip), %rdi      # 0x5068
movq %r14, %rsi
callq 0x291c
testl %eax, %eax
jne 0x28e7
leaq 0x82c(%rip), %rdi       # 0x30d4
movl $0x1, %esi
callq 0x1dc0
jmp 0x28e7
leaq 0x27ad(%rip), %rax      # 0x5068
movq 0x8(%rcx), %rcx
movq %rcx, (%rax)
movq (%rbx), %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1030
jmp 0x28e5
leaq 0x83b(%rip), %rdi       # 0x3116
movl $0x1, %esi
callq 0x1dc0
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/LeoFu9487[P]push_swap/libft/ft_lstfind.c
// Function: ft_lstfind
t_list	*ft_lstfind(t_list *head, void *target)
{
	while (head)
	{
		if (head->content == target)
			return (head);
		head = head->next;
	}
	return (NULL);
}

// Assembly:
testq %rdi, %rdi
je 0x2916
pushq %rbp
movq %rsp, %rbp
movq %rdi, %rax
cmpq %rsi, (%rax)
je 0x2914
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x2904
xorl %eax, %eax
popq %rbp
retq
xorl %eax, %eax
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/LeoFu9487[P]push_swap/libft/ft_lstadd_front.c
// Function: ft_lstadd_front
int	ft_lstadd_front(t_list **lst, t_list *new)
{
	if (!new || !lst)
	{
		ft_putstr_fd("ERROR_IN_FT_LSTADD_FRONT\n", 1);
		return (0);
	}
	if (!*lst)
	{
		*lst = new;
		return (1);
	}
	new->next = *lst;
	*lst = new;
	return (1);
}

// Assembly:
testq %rsi, %rsi
setne %al
testq %rdi, %rdi
setne %cl
testb %al, %cl
je 0x2941
movq (%rdi), %rax
testq %rax, %rax
je 0x2938
movq %rax, 0x8(%rsi)
movq %rsi, (%rdi)
movl $0x1, %eax
retq
pushq %rbp
movq %rsp, %rbp
leaq 0x7e3(%rip), %rdi       # 0x312f
movl $0x1, %esi
callq 0x1dc0
xorl %eax, %eax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x15df
movq %rax, %r14
movq %rax, %rdi
callq 0x1090
movq %rax, (%rbx)
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x1170
leaq 0xa87(%rip), %rsi       # 0x206d
movl $0x1, %edi
xorl %eax, %eax
callq 0x10b0
// File: /workspace/github_c_makefile_star2_O3/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 0x1631
movq %rax, %r14
movq %rax, %rdi
callq 0x1060
movq %rax, (%rbx)
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x1220
leaq 0xa5e(%rip), %rsi       # 0x2096
movl $0x1, %edi
xorl %eax, %eax
callq 0x10b0
// File: /workspace/github_c_makefile_star2_O3/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 0x1662
popq %rbx
retq
leaq 0xa54(%rip), %rsi       # 0x20bd
movl $0x1, %edi
xorl %eax, %eax
callq 0x10b0
// File: /workspace/github_c_makefile_star2_O3/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 0x1644
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 0x16d2
xorl %r13d, %r13d
movb (%r14,%r13), %al
movb %al, (%r15,%r13)
incq %r13
movq %rbx, %rdi
callq 0x1070
cltq
cmpq %rax, %r13
jl 0x16b8
movb $0x0, (%r15,%r12)
movq %r15, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x1731
movl 0x8(%rax), %ebx
movq %rax, %rdi
callq 0x1030
movl %ebx, %eax
popq %rbx
retq
leaq 0x9a0(%rip), %rsi       # 0x20d8
movl $0x1, %edi
xorl %eax, %eax
callq 0x10b0
// File: /workspace/github_c_makefile_star2_O3/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 0x176b
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x981(%rip), %rsi       # 0x20f3
movl $0x1, %edi
movl %ebx, %edx
xorl %eax, %eax
callq 0x10b0
// File: /workspace/github_c_makefile_star2_O3/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 0x2944f(%rip), %rdi     # 0x2b8c8
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 0x2944b(%rip), %rdi     # 0x2b8f7
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
movl 0xb8(%r14,%r15), %esi
leaq 0x29441(%rip), %rdi     # 0x2b90d
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
movl 0xe0(%r14,%r15), %esi
movq 0xa0(%r14,%r15), %rdx
leaq 0x2942c(%rip), %rdi     # 0x2b920
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
leaq 0x2942c(%rip), %rdi     # 0x2b938
movl %ebp, %esi
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
leaq 0x29425(%rip), %rdi     # 0x2b94b
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 0x2942e(%rip), %r14     # 0x2b980
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 0x293e3(%rip), %r14     # 0x2b9a5
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 0x293be(%rip), %rdi     # 0x2b9ae
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_O3/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 0x4759
cmpl $0x1, %ebp
je 0x4751
movl $0xfffffffe, %r12d      # imm = 0xFFFFFFFE
testl %ebp, %ebp
jne 0x47da
movq %r14, %rdi
movl %ebx, %esi
movl $0x1, %edx
xorl %r9d, %r9d
callq 0x21d0
movl $0xffffff, %r15d        # imm = 0xFFFFFF
jmp 0x475f
movl $0xffff, %r15d          # imm = 0xFFFF
jmp 0x475f
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 0x47b5
movl $0x1, %r12d
testl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
jne 0x47da
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
movl %r15d, %r9d
callq 0x21d0
jmp 0x47da
leaq 0x285fb(%rip), %rdi     # 0x2cdb7
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
movb $0x1, 0x2ba00(%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_O3/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, 0x29901(%rip)     # 0x301d4
jne 0x698e
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
movl 0x4(%rdi), %ebp
movl $0x5, %r13d
movq %rbx, %rdi
movl %ebp, %esi
xorl %edx, %edx
movq %r12, %rcx
movq %r15, %r8
movq %r14, %r9
callq 0x2380
cmpl $-0x27, %eax
je 0x6980
cmpl $0x1, %eax
je 0x696b
movq %rbx, %rdi
xorl %esi, %esi
callq 0x21b0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2090
cmpl $0x0, 0x304(%rbx)
jne 0x693d
movq %rbx, %rdi
callq 0x20d0
movl (%rbx), %edi
movl $0x1d8, %esi            # imm = 0x1D8
callq 0x2200
movl %eax, 0x8(%rbx)
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2310
movl $0x0, 0x4(%rbx)
decl %r13d
jne 0x68f9
movl $0x1, %eax
jmp 0x6970
movl 0x4(%rbx), %eax
incl %eax
xorl %edx, %edx
divl 0x8(%rbx)
movl %edx, 0x4(%rbx)
incl 0x2c(%rbx)
movl $0x2, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x700f
callq 0x21f0
movq 0x2e0(%rbx), %rdi
testq %rdi, %rdi
je 0x7025
movl $0x60, %esi
callq 0x21c0
testq %rbx, %rbx
je 0x7037
movl $0x310, %esi            # imm = 0x310
movq %rbx, %rdi
callq 0x21c0
movl $0x1, %eax
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O3/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 0x7360
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
retq
movl 0x28e7e(%rip), %edi     # 0x301e4
xorl %ebx, %ebx
testl %edi, %edi
js 0x7357
cmpb $0x0, 0x28e75(%rip)     # 0x301e8
je 0x7357
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsp)
movq $0x0, 0x18(%rsp)
movaps %xmm0, 0x28e93(%rip)    # 0x30220
movaps %xmm0, 0x28e9c(%rip)    # 0x30230
movq 0x28e55(%rip), %rbx     # 0x301f0
testq %rbx, %rbx
jne 0x7357
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 0x740b
movl 0x28e1e(%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 0x741d
movq %rax, %rbx
movups (%rsp), %xmm0
movups 0x10(%rsp), %xmm1
movaps %xmm1, 0x28e38(%rip)    # 0x30230
movaps %xmm0, 0x28e21(%rip)    # 0x30220
movq %rax, 0x28dea(%rip)     # 0x301f0
jmp 0x7357
leaq 0x26106(%rip), %rdi     # 0x2d518
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2050
jmp 0x7435
movq 0x8(%rsp), %rsi
movl (%rsp), %edx
leaq 0x26129(%rip), %rdi     # 0x2d555
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
jmp 0x7357
// File: /workspace/github_c_makefile_star2_O3/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 0x747c
movl 0x28d8c(%rip), %edi     # 0x301e4
testl %edi, %edi
js 0x747c
cmpb $0x0, 0x28d85(%rip)     # 0x301e8
je 0x747c
movl %esi, 0x28d91(%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_O3/xiane[P]libvphevcodec/vdi.cpp
// Function: vdi_release(unsigned int)
s32 vdi_release(u32 core_idx) {
    s32 i;
    vpu_buffer_t vdb;
    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;

    if (vdi->task_num > 1) {
        // means that the opened instance remains
        vdi->task_num--;
        return 0;
    }

    if (vdi->vdb_register.virt_addr)
        munmap((void *) vdi->vdb_register.virt_addr, vdi->vdb_register.size);

    memset(&vdi->vdb_register, 0x00, sizeof(vpu_buffer_t));
    vdb.size = 0;
    // get common memory information to free virtual address
    for (i = 0; i < MAX_VPU_BUFFER_POOL; i++) {
        if (vdi->vpu_common_memory.phys_addr >= vdi->vpu_buffer_pool[i].vdb.phys_addr
           && vdi->vpu_common_memory.phys_addr < (vdi->vpu_buffer_pool[i].vdb.phys_addr + vdi->vpu_buffer_pool[i].vdb.size)) {
            vdi->vpu_buffer_pool[i].inuse = 0;
            vdi->vpu_buffer_pool_count--;
            vdb = vdi->vpu_buffer_pool[i].vdb;
            break;
        }
    }

    if (vdb.size > 0) {
        munmap((void *) vdb.virt_addr, vdb.size);
        memset(&vdi->vpu_common_memory, 0x00, sizeof(vpu_buffer_t));
    }

    if (vdi->instance_pool.virt_addr)
        munmap((void *) vdi->instance_pool.virt_addr, vdi->instance_pool.size);

    vdi->task_num--;

    if (vdi->vpu_fd >= 0) {
        close(vdi->vpu_fd);
        vdi->vpu_fd = -1;
    }
    memset(vdi, 0x00, sizeof(vdi_info_t));
    vdi->vpu_fd = -1;
    return 0;
}

// Assembly:
testl %edi, %edi
je 0x7485
xorl %eax, %eax
retq
cmpl $0x0, 0x28d58(%rip)     # 0x301e4
js 0x7482
cmpb $0x0, 0x28d53(%rip)     # 0x301e8
je 0x7482
movl 0x28d5b(%rip), %eax     # 0x301f8
cmpl $0x2, %eax
jb 0x74ac
decl %eax
movl %eax, 0x28d4e(%rip)     # 0x301f8
jmp 0x7482
pushq %rax
movq 0x28d64(%rip), %rdi     # 0x30218
testq %rdi, %rdi
je 0x74c4
movl 0x28d41(%rip), %esi     # 0x30200
callq 0x20f0
xorps %xmm0, %xmm0
movaps %xmm0, 0x28d42(%rip)    # 0x30210
movaps %xmm0, 0x28d2b(%rip)    # 0x30200
movq 0x28d6c(%rip), %rdx     # 0x30248
xorl %eax, %eax
leaq 0x28cfb(%rip), %rcx     # 0x301e0
movq 0x88(%rax,%rcx), %rsi
cmpq %rsi, %rdx
jb 0x7501
movl 0x80(%rax,%rcx), %edi
addq %rdi, %rsi
cmpq %rsi, %rdx
jb 0x750f
addq $0x28, %rax
cmpq $0x2800, %rax           # imm = 0x2800
jne 0x74e5
jmp 0x754a
movl $0x0, 0xa0(%rax,%rcx)
decl 0x2b540(%rip)           # 0x32a60
movl 0x80(%rax,%rcx), %esi
testq %rsi, %rsi
je 0x754a
movq 0x98(%rax,%rcx), %rdi
callq 0x20f0
xorps %xmm0, %xmm0
movaps %xmm0, 0x28cfd(%rip)    # 0x30240
movaps %xmm0, 0x28d06(%rip)    # 0x30250
movq 0x28ce7(%rip), %rdi     # 0x30238
testq %rdi, %rdi
je 0x7561
movl 0x28cc4(%rip), %esi     # 0x30220
callq 0x20f0
decl 0x28c91(%rip)           # 0x301f8
movl 0x28c77(%rip), %edi     # 0x301e4
testl %edi, %edi
js 0x7576
callq 0x2370
leaq 0x28c63(%rip), %rdi     # 0x301e0
movl $0x2888, %edx           # imm = 0x2888
xorl %esi, %esi
callq 0x20e0
movl $0xffffffff, 0x28c51(%rip) # imm = 0xFFFFFFFF
addq $0x8, %rsp
jmp 0x7482
// File: /workspace/github_c_makefile_star2_O3/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 0x75b7
movl %ebx, %eax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %rbp
retq
movl 0x28c27(%rip), %ebp     # 0x301e4
testl %ebp, %ebp
js 0x75ab
cmpb $0x0, 0x28c20(%rip)     # 0x301e8
je 0x75ab
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 0x75ab
leaq 0x25ee8(%rip), %rdi     # 0x2d4ed
xorl %esi, %esi
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x75ab
// File: /workspace/github_c_makefile_star2_O3/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 0x7629
retq
cmpl $0x0, 0x28bb4(%rip)     # 0x301e4
js 0x7628
cmpb $0x0, 0x28baf(%rip)     # 0x301e8
je 0x7628
movaps 0x28c0e(%rip), %xmm0    # 0x30250
movups %xmm0, 0x10(%rsi)
movaps 0x28bf3(%rip), %xmm0    # 0x30240
movups %xmm0, (%rsi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x766b
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
movl 0x28b73(%rip), %edi     # 0x301e4
testl %edi, %edi
js 0x7662
cmpb $0x0, 0x28b6c(%rip)     # 0x301e8
je 0x7662
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 0x76c0
movl 0x14(%rsp), %eax
movq 0x28b47(%rip), %rcx     # 0x301f0
movl %eax, 0x20020(%rcx)
movl %ebp, %eax
shlq $0xf, %rax
movl $0x1, (%rcx,%rax)
xorl %ebx, %ebx
jmp 0x7662
leaq 0x25ec9(%rip), %rdi     # 0x2d590
movl %ebp, %esi
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
jmp 0x7662
// File: /workspace/github_c_makefile_star2_O3/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 0x776f
retq
cmpl $0x0, 0x28a6e(%rip)     # 0x301e4
js 0x776e
cmpb $0x0, 0x28a69(%rip)     # 0x301e8
je 0x776e
movq 0x28a68(%rip), %rax     # 0x301f0
movl 0x20020(%rax), %eax
retq
// File: /workspace/github_c_makefile_star2_O3/xiane[P]libvphevcodec/vdi.cpp
// Function: vdi_fio_read_register(unsigned int, unsigned int)
u32 vdi_fio_read_register(u32 core_idx, u32 addr) {
    u32 ctrl;
    u32 count = 0;
    u32 data = 0xffffffff;

    ctrl = (addr & 0xffff);
    ctrl |= (0 << 16); /* read operation */
    vdi_write_register(core_idx, W4_VPU_FIO_CTRL_ADDR, ctrl);
    count = FIO_TIMEOUT;
    while (count--) {
        ctrl = vdi_read_register(core_idx, W4_VPU_FIO_CTRL_ADDR);
        if (ctrl & 0x80000000) {
            data = vdi_read_register(core_idx, W4_VPU_FIO_DATA);
            break;
        }
    }
    return data;
}

// Assembly:
movl 0x289d7(%rip), %ecx     # 0x301e4
movb 0x289d5(%rip), %dl      # 0x301e8
testl %edi, %edi
jne 0x7840
testl %ecx, %ecx
sets %al
testb %dl, %dl
sete %r8b
orb %al, %r8b
jne 0x7840
movzwl %si, %eax
movq 0x289e7(%rip), %rcx     # 0x30218
movl %eax, 0x20(%rcx)
movl 0x289aa(%rip), %ecx     # 0x301e4
movb 0x289a8(%rip), %dl      # 0x301e8
movl $0xffffd8f0, %r8d       # imm = 0xFFFFD8F0
movq 0x289cb(%rip), %rsi     # 0x30218
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %r8d, %r8d
je 0x786f
testl %edi, %edi
jne 0x786f
testl %ecx, %ecx
js 0x786f
testb %dl, %dl
je 0x786f
incl %r8d
cmpl $0x0, 0x20(%rsi)
jns 0x7852
movl 0x24(%rsi), %eax
retq
// File: /workspace/github_c_makefile_star2_O3/xiane[P]libvphevcodec/vdi.cpp
// Function: vdi_fio_write_register(unsigned int, 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
je 0x7875
retq
movl 0x28969(%rip), %ecx     # 0x301e4
testl %ecx, %ecx
sets %dil
movb 0x28961(%rip), %al      # 0x301e8
testb %al, %al
sete %r8b
orb %dil, %r8b
jne 0x78a8
movq 0x2897f(%rip), %rax     # 0x30218
movl %edx, 0x24(%rax)
movl 0x28942(%rip), %ecx     # 0x301e4
movb 0x28940(%rip), %al      # 0x301e8
testl %ecx, %ecx
js 0x7874
testb %al, %al
je 0x7874
movzwl %si, %eax
orl $0x10000, %eax          # imm = 0x10000
movq 0x28959(%rip), %rcx     # 0x30218
movl %eax, 0x20(%rcx)
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x79b4
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
cmpl $0x0, 0x28829(%rip)     # 0x301e4
js 0x79ab
cmpb $0x0, 0x28824(%rip)     # 0x301e8
je 0x79ab
movl %edx, %ebp
movl %esi, %edi
xorl %eax, %eax
movl $0xa0, %edx
leaq 0x28808(%rip), %r9      # 0x301e0
xorl %ecx, %ecx
xorl %r8d, %r8d
cmpl $0x1, (%rdx,%r9)
jne 0x7a03
movl -0x20(%rdx,%r9), %eax
movq -0x18(%rdx,%r9), %r8
movq -0x8(%rdx,%r9), %rcx
cmpq %rdi, %r8
ja 0x7a03
movq %rax, %r10
addq %r8, %r10
cmpq %rdi, %r10
ja 0x7a10
addq $0x28, %rdx
cmpq $0x28a0, %rdx           # imm = 0x28A0
jne 0x79dd
testl %eax, %eax
je 0x7a27
movl %ebp, %edx
subq %r8, %rdi
addq %rcx, %rdi
xorl %esi, %esi
callq 0x20e0
movl %ebp, %ebx
jmp 0x79ab
leaq 0x25b96(%rip), %rdi     # 0x2d5c4
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
jmp 0x79ab
// File: /workspace/github_c_makefile_star2_O3/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 0x7a59
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0x28784(%rip)     # 0x301e4
js 0x7a50
cmpb $0x0, 0x2877f(%rip)     # 0x301e8
je 0x7a50
movl %ecx, %r14d
movl %edx, %ebx
movl %esi, %ebp
movl %edx, %r12d
movq %r12, %rdi
callq 0x2210
testq %rax, %rax
je 0x7a50
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_O3/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 0x7ac7
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
cmpl $0x0, 0x28716(%rip)     # 0x301e4
js 0x7abe
cmpb $0x0, 0x28711(%rip)     # 0x301e8
je 0x7abe
movl %ecx, %ebp
movl %esi, %edi
xorl %eax, %eax
movl $0xa0, %ecx
leaq 0x286f5(%rip), %r9      # 0x301e0
xorl %r8d, %r8d
xorl %r10d, %r10d
cmpl $0x1, (%rcx,%r9)
jne 0x7b17
movl -0x20(%rcx,%r9), %r10d
movq -0x18(%rcx,%r9), %r8
movq -0x8(%rcx,%r9), %rax
cmpq %rdi, %r8
ja 0x7b17
movq %r10, %r11
addq %r8, %r11
cmpq %rdi, %r11
ja 0x7b24
addq $0x28, %rcx
cmpq $0x28a0, %rcx           # imm = 0x28A0
jne 0x7af1
testl %r10d, %r10d
je 0x7b43
subq %r8, %rdi
addq %rax, %rdi
movl %ebp, %eax
movq %rdx, %rsi
movq %rax, %rdx
callq 0x2140
movl %ebp, %ebx
jmp 0x7abe
leaq 0x25a7a(%rip), %rdi     # 0x2d5c4
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
jmp 0x7abe
// File: /workspace/github_c_makefile_star2_O3/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 0x7b6a
retq
cmpl $0x0, 0x28673(%rip)     # 0x301e4
js 0x7b69
cmpb $0x0, 0x2866e(%rip)     # 0x301e8
je 0x7b69
pushq %rbx
movl %ecx, %ebx
movl %esi, %esi
xorl %ecx, %ecx
movl $0xa0, %r8d
leaq 0x28650(%rip), %r9      # 0x301e0
xorl %edi, %edi
xorl %r10d, %r10d
cmpl $0x1, (%r8,%r9)
jne 0x7bbb
movl -0x20(%r8,%r9), %r10d
movq -0x18(%r8,%r9), %rdi
movq -0x8(%r8,%r9), %rcx
cmpq %rsi, %rdi
ja 0x7bbb
movq %r10, %r11
addq %rdi, %r11
cmpq %rsi, %r11
ja 0x7bc8
addq $0x28, %r8
cmpq $0x28a0, %r8            # imm = 0x28A0
jne 0x7b95
testl %r10d, %r10d
je 0x7be2
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_O3/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 0x7dfa
cmpl $0x0, 0x284be(%rip)     # 0x301e4
js 0x7dfa
cmpb $0x0, 0x284b5(%rip)     # 0x301e8
je 0x7dfa
movl (%rsi), %edi
movl 0x4(%rsi), %edx
movq 0x8(%rsi), %r9
movq 0x10(%rsi), %rcx
movq 0x18(%rsi), %rax
leaq 0x2850f(%rip), %r10     # 0x30260
xorl %r8d, %r8d
cmpq %r9, 0x8(%r10)
je 0x7d92
incq %r8
addq $0x28, %r10
cmpq $0x100, %r8             # imm = 0x100
jne 0x7d54
leaq 0x2850f(%rip), %r10     # 0x30280
xorl %r8d, %r8d
cmpl $0x0, (%r10)
je 0x7da3
incq %r8
addq $0x28, %r10
cmpq $0x100, %r8             # imm = 0x100
jne 0x7d74
movl $0x100, %r8d            # imm = 0x100
jmp 0x7dd3
movl %edi, (%r10)
movl %edx, 0x4(%r10)
movq %rcx, 0x10(%r10)
movq %rax, 0x18(%r10)
jmp 0x7dbd
movl %edi, -0x20(%r10)
movl %edx, -0x1c(%r10)
movq %r9, -0x18(%r10)
movq %rcx, -0x10(%r10)
movq %rax, -0x8(%r10)
incl 0x2aca3(%rip)           # 0x32a60
leaq (%r8,%r8,4), %rax
leaq 0x28418(%rip), %rcx     # 0x301e0
movl $0x1, 0xa0(%rcx,%rax,8)
movq 0x8(%rsi), %rax
movq 0x18(%rsi), %rdx
movl (%rsi), %ecx
leaq 0x25887(%rip), %rdi     # 0x2d66b
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_O3/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 0x7e08
retq
cmpl $0x0, 0x283d5(%rip)     # 0x301e4
js 0x7e07
cmpb $0x0, 0x283d0(%rip)     # 0x301e8
je 0x7e07
cmpl $0x0, (%rsi)
je 0x7e07
movq 0x8(%rsi), %rcx
movl $0xa0, %eax
leaq 0x283b1(%rip), %rdx     # 0x301e0
cmpq %rcx, -0x18(%rax,%rdx)
je 0x7e44
addq $0x28, %rax
cmpq $0x28a0, %rax           # imm = 0x28A0
jne 0x7e2f
jmp 0x7e51
movl $0x0, (%rax,%rdx)
decl 0x2ac0f(%rip)           # 0x32a60
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x7e67
addq $0x28, %rsp
popq %rbx
popq %r14
retq
movl 0x28377(%rip), %edi     # 0x301e4
testl %edi, %edi
js 0x7e5f
cmpb $0x0, 0x28370(%rip)     # 0x301e8
je 0x7e5f
movq %rsi, %rbx
cmpl $0x0, (%rsi)
je 0x7e5f
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, (%rsp)
movq 0x8(%rbx), %rdx
movl $0xa0, %eax
leaq 0x28342(%rip), %rcx     # 0x301e0
cmpq %rdx, -0x18(%rax,%rcx)
je 0x7eb3
addq $0x28, %rax
cmpq $0x28a0, %rax           # imm = 0x28A0
jne 0x7e9e
jmp 0x7f27
movl $0x0, (%rax,%rcx)
decl 0x2aba0(%rip)           # 0x32a60
movups -0x20(%rax,%rcx), %xmm0
movups -0x10(%rax,%rcx), %xmm1
movaps %xmm0, (%rsp)
movaps %xmm1, 0x10(%rsp)
cmpl $0x0, (%rsp)
je 0x7f27
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 0x7f18
movq 0x18(%rsp), %rsi
leaq 0x257e2(%rip), %rdi     # 0x2d6e9
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
callq 0x2220
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
jmp 0x7e5f
movq 0x18(%rsp), %rsi
leaq 0x25789(%rip), %rdi     # 0x2d6bc
xorl %eax, %eax
callq 0x2050
movl $0xa, %edi
addq $0x28, %rsp
popq %rbx
popq %r14
jmp 0x2220
// File: /workspace/github_c_makefile_star2_O3/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 0x808c
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 0x8045
movl $0x5, %edi
callq 0x2240
movl %ebp, %edi
movl %r14d, %esi
callq 0x2030
cmpl $0x738, %eax            # imm = 0x738
jne 0x7fe9
xorl %r12d, %r12d
jmp 0x808c
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
testl %ebp, %ebp
jne 0x8070
cmpl $0x0, 0x28189(%rip)     # 0x301e4
js 0x8070
cmpb $0x0, 0x28184(%rip)     # 0x301e8
je 0x8070
movq 0x281ab(%rip), %rax     # 0x30218
movl 0x4(%rax), %edx
leaq 0x256ac(%rip), %rdi     # 0x2d723
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