LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_write_flash_page(WdtDevice*, int, unsigned char*, int)
int wh_w8760_dev_write_flash_page(WDT_DEV* pdev, int addr, BYTE* buf, int size)
{
	int retval = 0;
	unsigned int	write_base;
	unsigned int	write_size;

	write_base = W8760_FLASH_PAGE_SIZE;

	if (addr & 0xFF) {
		unsigned int 	size_partial;
		size_partial = write_base - (addr & 0xFF);
		
		if (size > (int) size_partial) {				
			write_size = size_partial;				
			size = size - size_partial;				
		} else {											
			write_size = size;								
			size = 0;										
		}													
		retval = wh_w8760_dev_write_flash(pdev, addr, (BYTE*) buf, 0, write_size);	
		if (!retval)										
			return retval;									
		buf = buf + size_partial;				
		addr = addr + size_partial;	
	}

	while (size)
	{
		if ((addr & 0xfff) == 0)
			printf("base addr: 0x%x\n", addr);
		if (size > (int) write_base) {				
			write_size = write_base;				
			size = size - write_base;				
		} else {											
			write_size = size;								
			size = 0;										
		}													
		retval = wh_w8760_dev_write_flash(pdev, addr, (BYTE*) buf, 0, write_size);	
		if (!retval)										
			return retval;									
		buf = buf + write_base;				
		addr = addr + write_base;			
	}

	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r15d
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
movl %esi, %eax
andl $0xff, %eax
je 0x46fe
movl $0x100, %r12d           # imm = 0x100
subl %eax, %r12d
movl %r12d, %eax
subl %r15d, %eax
movl %r15d, %r8d
cmovll %r12d, %r8d
negl %eax
xorl %r13d, %r13d
cmpl %r12d, %r15d
movl %eax, %r15d
cmovlel %r13d, %r15d
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x456e
testl %eax, %eax
je 0x4774
addq %r12, %rbx
addl %r12d, %ebp
testl %r15d, %r15d
je 0x476e
movl $0x100, %r12d           # imm = 0x100
xorl %r13d, %r13d
testl $0xfff, %ebp            # imm = 0xFFF
jne 0x4724
leaq 0x6d9e(%rip), %rdi      # 0xb4b9
movl %ebp, %esi
xorl %eax, %eax
callq 0x2050
cmpl %r12d, %r15d
movl $0x100, %r8d            # imm = 0x100
cmovll %r15d, %r8d
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x456e
testl %eax, %eax
je 0x4774
cmpl $0x101, %r15d           # imm = 0x101
leal -0x100(%r15), %eax
movl $0x0, %ecx
cmovll %ecx, %eax
addq $0x100, %rbx            # imm = 0x100
addl $0x100, %ebp            # imm = 0x100
movl %eax, %r15d
testl %eax, %eax
jne 0x470c
movl $0x1, %r13d
movl %r13d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_protect_flash(WdtDevice*, unsigned short)
int wh_w8760_dev_protect_flash(WDT_DEV* pdev, UINT16 protect_mask)
{
	UINT16 mask = protect_mask;
	
	BYTE cmd[] = { W8760_COMMAND9, (BYTE) W8760_PROTECT_FLASH, 0, 0, 0, 0 };
	put_unaligned_le16(mask, &cmd[2]);
	put_unaligned_le16((UINT16)~mask, &cmd[4]);

	return wh_w8760_dev_command_write(pdev, cmd, 0, sizeof(cmd));
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %esi, %ebx
movq %rdi, %r14
leaq 0xc(%rsp), %r15
movw $0x0, (%r15)
movl $0xd406, -0x4(%r15)     # imm = 0xD406
leaq 0xa(%rsp), %rsi
movl %ebx, %edi
callq 0x6f6e
xorl $0xffff, %ebx           # imm = 0xFFFF
movl %ebx, %edi
movq %r15, %rsi
callq 0x6f6e
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x3e56
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_checksum_flash(WdtDevice*, unsigned int*, unsigned int, int, unsigned int)
int wh_w8760_dev_checksum_flash(WDT_DEV* pdev, UINT32* pchksum, UINT32 flash_address,
	int size, UINT32 init_sum)
{
	BYTE cmd[10];
	BYTE buf[4];		

	*pchksum = 0;

	cmd[0] = W8760_COMMAND9;
	cmd[1] = (BYTE) W8760_CALCULATE_FLASH_CHECKSUM;
	put_unaligned_le32(flash_address, &cmd[2]);
	put_unaligned_le32(size, &cmd[5]);	
	put_unaligned_le16(init_sum, &cmd[8]);	

	if (wh_w8760_dev_command_write(pdev, cmd, 0, sizeof(cmd)) <= 0) 
		return 0;
	
	if (wh_w8760_dev_wait_cmd_end(pdev, 0, 0) <= 0)
		return 0;

	if (wh_w8760_dev_read_buf_response (pdev, buf, 2) <= 0)
		return 0;

	*pchksum = get_unaligned_le16(buf);
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %r8d, %ebp
movl %ecx, %r15d
movq %rsi, %rbx
movq %rdi, %r14
movl $0x0, (%rsi)
leaq 0xd(%rsp), %rsi
movw $0xd506, -0x2(%rsi)     # imm = 0xD506
movl %edx, %edi
callq 0x6f72
leaq 0x10(%rsp), %rsi
movl %r15d, %edi
callq 0x6f72
leaq 0x13(%rsp), %rsi
movzwl %bp, %edi
callq 0x6f6e
leaq 0xb(%rsp), %rsi
movq %r14, %rdi
callq 0x3e56
xorl %ebp, %ebp
testl %eax, %eax
jle 0x4883
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x40b9
testl %eax, %eax
je 0x4883
leaq 0x15(%rsp), %rsi
movw $0xc706, (%rsi)         # imm = 0xC706
movb $0x2, 0x2(%rsi)
leaq 0x7(%rsp), %rcx
xorl %ebp, %ebp
movq %r14, %rdi
xorl %r8d, %r8d
movl $0x2, %r9d
callq 0x3f07
testl %eax, %eax
je 0x4883
leaq 0x7(%rsp), %rdi
callq 0x6f67
movzwl %ax, %eax
movl %eax, (%rbx)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_write_register(WdtDevice*, unsigned int, unsigned int)
int wh_w8760_dev_write_register(WDT_DEV* pdev, UINT32 address, UINT32 reg_value)
{
        BYTE cmd[10] = {0};

        cmd[0] = W8760_COMMAND9;
        cmd[1] = (BYTE) W8760_WRITE_REGISTER;
        put_unaligned_le32(address, &cmd[2]);
        put_unaligned_le32(reg_value, &cmd[6]);

        return wh_w8760_dev_command_write(pdev, cmd, 0, sizeof(cmd));
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebx
movl %esi, %eax
movq %rdi, %r14
leaq 0x10(%rsp), %rsi
movq $0x0, (%rsi)
movw $0xdf06, -0x2(%rsi)     # imm = 0xDF06
movl %eax, %edi
callq 0x6f72
leaq 0x14(%rsp), %rsi
movl %ebx, %edi
callq 0x6f72
leaq 0xe(%rsp), %rsi
movq %r14, %rdi
callq 0x3e56
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_flash_erase(WdtDevice*, unsigned int, int)
int wh_w8760_dev_flash_erase(WDT_DEV* pdev, UINT32 address, int size)
{
	int ret = wh_w8760_dev_erase_flash(pdev, address, size);

	if (ret <= 0)
		wh_printf("%s: addr: %x, size: %x\n", __func__, address, size);
	
	return ret;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebx
movl %esi, %ebp
callq 0x44b6
movl %eax, %r14d
testl %eax, %eax
jne 0x4a99
leaq 0x6f4f(%rip), %rdi      # 0xb9d6
leaq 0x6f60(%rip), %rsi      # 0xb9ee
movl %ebp, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x2506
movl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_flash_write_data(WdtDevice*, unsigned char*, unsigned int, int)
int wh_w8760_dev_flash_write_data(WDT_DEV* pdev, BYTE* data, UINT32 address, int length)
{
	if (!pdev || !data)
		return 0;

	if ((address & 0x3) != 0)	
		return 0;

	if (!wh_w8760_dev_set_flash_address(pdev, address))
		return 0;

	return wh_w8760_dev_write_flash_page(pdev, address, data, length);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebx
movl %edx, %ebp
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
testb $0x3, %bpl
setne %al
xorl %r12d, %r12d
orb %cl, %al
jne 0x4b0f
movq %rsi, %r14
movq %rdi, %r15
leaq 0x2(%rsp), %r13
movq $0xd006, -0x2(%r13)     # imm = 0xD006
movl %ebp, %edi
movq %r13, %rsi
callq 0x6f72
movb $0x0, 0x3(%r13)
movq %rsp, %rsi
movq %r15, %rdi
callq 0x3e56
testl %eax, %eax
je 0x4b0f
movq %r15, %rdi
movl %ebp, %esi
movq %r14, %rdx
movl %ebx, %ecx
callq 0x46a1
movl %eax, %r12d
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_verify_chunk_by_read_checksum(WdtDevice*, ChunkInfoEx*)
int wh_w8760_dev_verify_chunk_by_read_checksum(WDT_DEV* pdev, CHUNK_INFO_EX* pChunk)
{
	int retval = 0, result = 1;
	UINT32	bin_checksum;
	UINT32	read_checksum;
	
	retval = wh_w8760_dev_set_n_check_device_mode(pdev, W8760_MODE_COMMAND, 0, 0);
	if (!retval)
		return retval;
		
	printf("Calculating checksum...\n");
	
	bin_checksum = misr_for_bytes(0, pChunk->pData, 0, pChunk->chuckInfo.length);

	retval = wh_w8760_dev_flash_get_checksum(pdev, &read_checksum, pChunk->chuckInfo.targetStartAddr, pChunk->chuckInfo.length);
	if (!retval)
		return retval;

	if (bin_checksum != read_checksum) {
		wh_printf("Checksum mismatch!!! Original=0x%x, Flash checksum=0x%x\n", bin_checksum, read_checksum);
		result = 0;
	}
	
	retval = wh_w8760_dev_set_n_check_device_mode(pdev, W8760_MODE_SENSING, 0, 0);
	if (!retval)
		return retval;
		
	return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
xorl %ebp, %ebp
movl $0x90, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x4295
testl %eax, %eax
je 0x4bbe
leaq 0x6c97(%rip), %rdi      # 0xb7e8
callq 0x2270
movq 0x18(%r14), %rsi
movl 0x4(%r14), %ecx
xorl %ebp, %ebp
xorl %edi, %edi
xorl %edx, %edx
callq 0x88e6
movl %eax, %r15d
movl (%r14), %edx
movl 0x4(%r14), %ecx
leaq 0x4(%rsp), %rsi
movq %rbx, %rdi
xorl %r8d, %r8d
callq 0x47da
testl %eax, %eax
je 0x4bbe
movzwl %r15w, %esi
movl 0x4(%rsp), %edx
movl $0x1, %ebp
cmpl %esi, %edx
je 0x4ba8
leaq 0x6de0(%rip), %rdi      # 0xb97f
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x2506
movq %rbx, %rdi
movl $0x1, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x4295
testl %eax, %eax
cmovel %eax, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_get_device_data(WdtDevice*, unsigned char, int, unsigned char*, int)
int wh_w8760_dev_get_device_data(WDT_DEV* pdev, BYTE type, int offset, BYTE *buf, int size)
{
	BYTE cmd[] = { (BYTE) W8760_COMMAND9, type, (BYTE) offset, (BYTE) size };

	if (type != W8760_GET_DEVICE_INFO && type != W8760_GET_DEVICE_STATUS)
		return 0;

	return wh_w8760_dev_command_read(pdev, cmd, sizeof(cmd), buf, 0,  size);
}

// Assembly:
pushq %rax
movl %r8d, %r9d
movb $0x6, 0x4(%rsp)
movb %sil, 0x5(%rsp)
movb %dl, 0x6(%rsp)
movb %r9b, 0x7(%rsp)
addb $0x36, %sil
xorl %eax, %eax
cmpb $-0x2, %sil
jb 0x4c07
leaq 0x4(%rsp), %rsi
xorl %r8d, %r8d
callq 0x3f07
popq %rcx
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_get_context(WdtDevice*, PctData*)
int wh_w8760_dev_get_context(WDT_DEV* pdev, W8760_PCT_DATA* pPct)
{
	BYTE  buf[64];

	if (!pdev || !pPct)	
		return 0;
	
	if (wh_w8760_dev_read_parameter_page(pdev, buf, 1) <= 0)
		return 0;

	memcpy(pPct, &buf[0], sizeof(W8760_PCT_DATA));

	return 1;
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x58, %rsp
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
xorl %ebp, %ebp
orb %al, %cl
jne 0x4c80
movq %rsi, %rbx
leaq 0xd(%rsp), %rsi
movw $0xb406, (%rsi)         # imm = 0xB406
movb $0x1, 0x2(%rsi)
leaq 0x10(%rsp), %rcx
xorl %ebp, %ebp
xorl %r8d, %r8d
movl $0x3f, %r9d
callq 0x3f07
testl %eax, %eax
je 0x4c80
movl 0x18(%rsp), %eax
movl %eax, 0x8(%rbx)
movq 0x10(%rsp), %rax
movq %rax, (%rbx)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_prepare_data(WdtDevice*, BoardInfo*)
int wh_w8760_prepare_data(WDT_DEV* pdev, BOARD_INFO* p_out_board_info)
{
	if (!pdev || !p_out_board_info)
		return 0;

	W8760_PCT_DATA	pct_data;

	/* initialize the basic function for handling the following operations */
	wh_w8760_dev_set_basic_op(pdev);

	if (!wh_w8760_dev_identify_platform(pdev, p_out_board_info))  {
		wh_printf("Can't get platform identify!\n");
		return 0;
	}
	
	if (p_out_board_info->dev_type & FW_WDT8760_2_ISP)
		return 1;

	if (wh_w8760_dev_get_context(pdev, &pct_data)) {
		/* set the default values */
		p_out_board_info->sys_param.Phy_Frmbuf_W= pct_data.n_cs;
		p_out_board_info->sys_param.Phy_X0= pct_data.x1;
		p_out_board_info->sys_param.Phy_X1= pct_data.xn;

		p_out_board_info->sys_param.Phy_Frmbuf_H= pct_data.n_cd;
		p_out_board_info->sys_param.Phy_Y0= pct_data.y1;
		p_out_board_info->sys_param.Phy_Y1= pct_data.yn;
		
		p_out_board_info->sys_param.xmls_id1 = 0;
		p_out_board_info->sys_param.xmls_id2 = 0;

		return 1;
	}

	return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
xorl %ebx, %ebx
orb %al, %cl
jne 0x4d12
movq %rsi, %r14
movq %rdi, %r15
callq 0x4405
testl %eax, %eax
je 0x4d02
movl $0x1, %ebx
testb $0x50, 0x1(%r14)
jne 0x4d12
leaq 0x4(%rsp), %rsi
movq %r15, %rdi
callq 0x4c2a
testl %eax, %eax
je 0x4d12
movzbl 0x6(%rsp), %eax
movw %ax, 0x24(%r14)
movzbl 0x5(%rsp), %eax
movw %ax, 0x26(%r14)
movd 0x8(%rsp), %xmm0
pxor %xmm1, %xmm1
punpcklbw %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3],xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
movq %xmm0, 0x28(%r14)
movl $0x0, 0x20(%r14)
jmp 0x4d12
leaq 0x6caf(%rip), %rdi      # 0xb9b8
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2506
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8762_isp_rerun_recovery(WdtDevice*)
int wh_w8762_isp_rerun_recovery(WDT_DEV *pdev)
{
        wh_printf("It is maybe WDT8762 ISP\n");
        wh_w8760_dev_set_men_address(pdev, 0xA022750A);
        wh_w8760_dev_write_men_halfword(pdev, 0);
        wh_w8760_dev_run_program_from_background(pdev, 0x061000);
        wh_printf("Rerun Recovery fw \n");
        return 1;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq 0x694b(%rip), %rdi      # 0xba23
xorl %eax, %eax
callq 0x2506
leaq 0xa(%rsp), %rsi
movq $0xc006, -0x2(%rsi)     # imm = 0xC006
movl $0xa022750a, %edi       # imm = 0xA022750A
callq 0x6f72
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x3e56
movq %rbx, %rdi
xorl %esi, %esi
callq 0x435f
movq %rbx, %rdi
movl $0x61000, %esi          # imm = 0x61000
callq 0x419b
leaq 0x691b(%rip), %rdi      # 0xba3c
xorl %eax, %eax
callq 0x2506
movl $0x1, %eax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_isp_rerun_recovery(WdtDevice*)
int wh_w8760_isp_rerun_recovery(WDT_DEV *pdev)
{
        wh_printf("It is maybe WDT8760 ISP\n");
        wh_w8760_dev_run_program_from_background(pdev, 0x061000);
        wh_printf("Rerun Recovery fw \n");
        return 1;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
leaq 0x6912(%rip), %rdi      # 0xba50
xorl %eax, %eax
callq 0x2506
movq %rbx, %rdi
movl $0x61000, %esi          # imm = 0x61000
callq 0x419b
leaq 0x68e3(%rip), %rdi      # 0xba3c
xorl %eax, %eax
callq 0x2506
movl $0x1, %eax
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_set_feature(WdtDevice*, unsigned char*, unsigned int)
int wh_w8790_dev_set_feature(WDT_DEV* pdev, BYTE* buf, UINT32 buf_size)
{
	if (!pdev)
		return 0;

	if (buf[0] == W8790_COMMAND9)
		buf_size = 10;
	else if (buf[0] == W8790_COMMAND63 || buf[0] == W8790_BLOCK63)
		buf_size = 64;
	else {
		wh_printf("Feature id is not supported! (%d)\n", buf[0]);
		return 0;
	}
	if (pdev->intf_index == INTERFACE_I2C)
		return wh_i2c_set_feature(pdev, buf, buf_size);


	return 0;
}

// Assembly:
testq %rdi, %rdi
je 0x51bb
movzbl (%rsi), %eax
cmpl $0x6, %eax
je 0x5197
cmpl $0xb, %eax
je 0x5190
cmpl $0x7, %eax
jne 0x51a6
movl $0x40, %edx
jmp 0x519c
movl $0xa, %edx
cmpl $0x2, (%rdi)
jne 0x51bb
jmp 0x9a12
pushq %rax
leaq 0x671e(%rip), %rdi      # 0xb8cc
movl %eax, %esi
xorl %eax, %eax
callq 0x2506
addq $0x8, %rsp
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_get_feature(WdtDevice*, unsigned char*, unsigned int)
int wh_w8790_dev_get_feature(WDT_DEV* pdev, BYTE* buf, UINT32 buf_size)
{
	if (!pdev)
		return 0;

	if (buf[0] == W8790_COMMAND9)
		buf_size = 10;
	else if (buf[0] == W8790_COMMAND63 || buf[0] == W8790_BLOCK63)
		buf_size = 64;
	else {
		wh_printf("Feature id is not supported! (%d)\n", buf[0]);
		return 0;
	}
	if (pdev->intf_index == INTERFACE_I2C)
		return wh_i2c_get_feature(pdev, buf, buf_size);




	return 0;
}

// Assembly:
testq %rdi, %rdi
je 0x5200
movzbl (%rsi), %eax
cmpl $0x6, %eax
je 0x51dc
cmpl $0xb, %eax
je 0x51d5
cmpl $0x7, %eax
jne 0x51eb
movl $0x40, %edx
jmp 0x51e1
movl $0xa, %edx
cmpl $0x2, (%rdi)
jne 0x5200
jmp 0x958c
pushq %rax
leaq 0x66d9(%rip), %rdi      # 0xb8cc
movl %eax, %esi
xorl %eax, %eax
callq 0x2506
addq $0x8, %rsp
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_parse_device_info(DevInfo_8790_t*, unsigned char*)
int wh_w8790_parse_device_info(W8790_DEV_INFO* report_feature_devinfo, BYTE* buf)
{
	if (!report_feature_devinfo || !buf)
		return 0;

	report_feature_devinfo->firmware_version = get_unaligned_le32(&buf[1]);
	report_feature_devinfo->hardware_version = get_unaligned_le32(&buf[5]);
	report_feature_devinfo->serial_number = get_unaligned_le32(&buf[9]);
	report_feature_devinfo->max_touches = buf[13];
	report_feature_devinfo->firmware_revision_ext = buf[14];
	report_feature_devinfo->partition = buf[15];
	report_feature_devinfo->partition_format_revision = buf[16];


	memcpy(report_feature_devinfo->part_number, &buf[17], 16);
	memcpy(report_feature_devinfo->rom_signature, &buf[33], 8);
	memcpy(report_feature_devinfo->program_name_fourcc, &buf[41], 4);
	memcpy(report_feature_devinfo->tracking_id, &buf[45], 8);

	return 1;
}

// Assembly:
testq %rdi, %rdi
sete %cl
testq %rsi, %rsi
sete %dl
xorl %eax, %eax
orb %cl, %dl
jne 0x52bc
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x1(%rsi), %rdi
callq 0x6f6b
movl %eax, (%rbx)
leaq 0x5(%r14), %rdi
callq 0x6f6b
movl %eax, 0x4(%rbx)
leaq 0x9(%r14), %rdi
callq 0x6f6b
movl %eax, 0x8(%rbx)
movb 0xd(%r14), %al
movb %al, 0xc(%rbx)
movb 0xe(%r14), %al
movb %al, 0xd(%rbx)
movb 0xf(%r14), %al
movb %al, 0xe(%rbx)
movb 0x10(%r14), %al
movb %al, 0xf(%rbx)
movups 0x11(%r14), %xmm0
movups %xmm0, 0x10(%rbx)
movq 0x21(%r14), %rax
movq %rax, 0x20(%rbx)
movl 0x29(%r14), %eax
movl %eax, 0x28(%rbx)
movq 0x2d(%r14), %rax
movq %rax, 0x2c(%rbx)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_identify_platform(WdtDevice*)
int wh_w8790_dev_identify_platform(WDT_DEV* pdev)
{
	// identify chip by reading its ROM.
	if (!pdev )
		return 0;

	if (memcmp(W8790_RomSignatureVerA, pdev->board_info.dev_info.w8790_feature_devinfo.rom_signature, 8) == 0) {
		if (pdev->pparam->argus & OPTION_INFO)		
			printf("WDT8790_VerA\n");

		return 1;
	}
	if (memcmp(W8790_RomSignatureVerB, pdev->board_info.dev_info.w8790_feature_devinfo.rom_signature, 8) == 0) {
                if (pdev->pparam->argus & OPTION_INFO)	
			printf("WDT8790_VerB\n");
		return 1;
	}


	return 0;
}

// Assembly:
xorl %eax, %eax
testq %rdi, %rdi
je 0x52e4
movq 0xc09d(%rip), %rcx      # 0x11368
cmpq 0x218(%rdi), %rcx
je 0x52e5
movq 0xc095(%rip), %rcx      # 0x11370
cmpq 0x218(%rdi), %rcx
je 0x52ff
retq
movq 0x280(%rdi), %rcx
movl $0x1, %eax
testb $0x8, (%rcx)
je 0x52e4
leaq 0x6ab5(%rip), %rdi      # 0xbdb2
jmp 0x5317
movq 0x280(%rdi), %rcx
movl $0x1, %eax
testb $0x8, (%rcx)
je 0x52e4
leaq 0x6a8e(%rip), %rdi      # 0xbda5
pushq %rax
callq 0x2270
movl $0x1, %eax
addq $0x8, %rsp
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_get_context(WdtDevice*, ParameterCoordinatePage_8790_t*)
int wh_w8790_dev_get_context(WDT_DEV* pdev, W8790_PCT* pPct)
{
	BYTE  buf[64] = { 0 };

	if (!pdev || !pPct)
		return 0;

	if (wh_w8790_dev_read_parameter_page(pdev, buf, 1) <= 0)
		return 0;

	memcpy(pPct, &buf[0], sizeof(W8790_PCT));

	return 1;
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x58, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, (%rsp)
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
xorl %ebp, %ebp
orb %al, %cl
jne 0x5398
movq %rsi, %rbx
leaq 0x4e(%rsp), %rsi
movw $0xb406, (%rsi)         # imm = 0xB406
movb $0x1, 0x2(%rsi)
xorl %ebp, %ebp
movl %ebp, 0x3(%rsi)
movl %ebp, 0x6(%rsi)
movq %rsp, %rcx
xorl %r8d, %r8d
movl $0x3f, %r9d
callq 0x53d0
testl %eax, %eax
je 0x5398
movzwl 0x8(%rsp), %eax
movw %ax, 0x8(%rbx)
movq (%rsp), %rax
movq %rax, (%rbx)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_command_read(WdtDevice*, unsigned char*, int, unsigned char*, int, int)
int wh_w8790_dev_command_read(WDT_DEV* pdev, BYTE* cmd, int cmd_size, BYTE* data, int start, int size)
{
	if (wh_w8790_dev_command_write(pdev, cmd, 0, cmd_size) > 0) {

		BYTE	buf[64] = { 0 };
		if (size > 9)
			buf[0] = W8790_COMMAND63;
		else
			buf[0] = W8790_COMMAND9;

		if (wh_w8790_dev_get_feature(pdev, buf, size) > 0) {
			memcpy(&data[start], &buf[1], size);
			return 1;
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x48, %rsp
movl %r9d, %ebp
movl %r8d, %r14d
movq %rcx, %rbx
movq %rdi, %r15
callq 0x5179
testl %eax, %eax
je 0x5437
xorps %xmm0, %xmm0
movq %rsp, %rsi
movaps %xmm0, (%rsi)
movaps %xmm0, 0x30(%rsi)
movaps %xmm0, 0x20(%rsi)
movaps %xmm0, 0x10(%rsi)
cmpl $0xa, %ebp
setge %al
orb $0x6, %al
movb %al, (%rsi)
movq %r15, %rdi
callq 0x51be
testl %eax, %eax
jle 0x5449
movslq %r14d, %rax
addq %rax, %rbx
leaq 0x1(%rsp), %rsi
movslq %ebp, %rdx
movq %rbx, %rdi
callq 0x2150
movl $0x1, %ebx
jmp 0x544b
leaq 0x6706(%rip), %rdi      # 0xbb44
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2506
jmp 0x544b
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_read_array(WdtDevice*, int, unsigned char*, int, int, int)
int wh_w8790_dev_read_array(WDT_DEV* pdev, int cmd_id, BYTE* buffer, int start, int item_size, int item_count)
{
	int max_read_batch = W8790_USB_MAX_PAYLOAD_SIZE / item_size;
	int i = start;

	while (item_count >= max_read_batch) {
		if (wh_w8790_dev_read_items(pdev, cmd_id, buffer, i, item_size, max_read_batch) <= 0)
			return 0;
		i += max_read_batch * item_size;
		item_count -= max_read_batch;
	}
	if (item_count > 0)
		return wh_w8790_dev_read_items(pdev, cmd_id, buffer, i, item_size, item_count);
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r9d, %r15d
movl %ecx, %ebp
movq %rdx, 0x20(%rsp)
movl %esi, 0x4(%rsp)
movq %rdi, 0x18(%rsp)
movl $0x3f, %eax
xorl %edx, %edx
idivl %r8d
cmpl %r9d, %eax
movl %r8d, 0x14(%rsp)
jg 0x5515
movl %eax, %ebx
leaq 0xd(%rsp), %r13
movl %eax, %r14d
imull %r8d, %r14d
xorl %r12d, %r12d
movb $0x6, 0xa(%rsp)
movl 0x4(%rsp), %eax
movb %al, 0xb(%rsp)
movb %bl, 0xc(%rsp)
movl %r12d, 0x3(%r13)
movl %r12d, (%r13)
movq 0x18(%rsp), %rdi
leaq 0xa(%rsp), %rsi
movq 0x20(%rsp), %rcx
movl %ebp, %r8d
movl %r14d, %r9d
callq 0x53d0
testl %eax, %eax
je 0x555b
addl %r14d, %ebp
subl %ebx, %r15d
cmpl %ebx, %r15d
jge 0x54d3
testl %r15d, %r15d
jle 0x5555
leaq 0xa(%rsp), %rsi
movb $0x6, (%rsi)
movl 0x4(%rsp), %eax
movb %al, 0x1(%rsi)
movb %r15b, 0x2(%rsi)
xorl %eax, %eax
movl %eax, 0x3(%rsi)
movl %eax, 0x6(%rsi)
movl 0x14(%rsp), %r9d
imull %r15d, %r9d
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rcx
movl %ebp, %r8d
callq 0x53d0
movl %eax, %r12d
jmp 0x555b
movl $0x1, %r12d
movl %r12d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_get_device_mode(WdtDevice*)
int wh_w8790_dev_get_device_mode(WDT_DEV* pdev)
{
	BYTE	status[4] = { 0 };
	if (!pdev)
		return 0;

	if (wh_w8790_dev_get_device_status(pdev, status, 8, 1))
		return status[0];

	return 0;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movl $0x0, (%rsp)
testq %rdi, %rdi
je 0x55c5
leaq 0x4(%rsp), %rsi
movw $0x0, 0x8(%rsi)
movq $0x108c906, (%rsi)      # imm = 0x108C906
movq %rsp, %rcx
xorl %ebx, %ebx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x53d0
testl %eax, %eax
je 0x55c7
movzbl (%rsp), %ebx
jmp 0x55c7
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_get_device_status(WdtDevice*, unsigned char*, int, int)
int wh_w8790_dev_get_device_status(WDT_DEV* pdev, BYTE* buf, int offset, int size)
{
	BYTE cmd[10] = { 0 };
	cmd[0] = (BYTE)W8790_COMMAND9;// , type, (BYTE)offset, (BYTE)size
	cmd[1] = W8790_GET_DEVICE_STATUS;
	cmd[2] = (BYTE)offset;
	cmd[3] = (BYTE)size;

	return wh_w8790_dev_command_read(pdev, cmd, sizeof(cmd), buf, 0, size);

}

// Assembly:
subq $0x18, %rsp
movl %ecx, %r9d
movq %rsi, %rcx
leaq 0xe(%rsp), %rsi
movw $0x0, 0x8(%rsi)
movl $0x0, 0x4(%rsi)
movw $0xc906, (%rsi)         # imm = 0xC906
movb %dl, 0x2(%rsi)
movb %r9b, 0x3(%rsi)
xorl %r8d, %r8d
callq 0x53d0
addq $0x18, %rsp
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_set_flash_address(WdtDevice*, unsigned int)
int wh_w8790_dev_set_flash_address(WDT_DEV* pdev, UINT32 address)
{
	BYTE cmd[10] = { 0 };

	cmd[0] = W8790_COMMAND9;
	cmd[1] = W8790_SET_FLASH_ADDRESS;
	put_unaligned_le32(address, &cmd[2]);

	return wh_w8790_dev_command_write(pdev, cmd, 0, sizeof(cmd));

}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movl %esi, %eax
movq %rdi, %rbx
leaq 0x8(%rsp), %rsi
movq $0x0, (%rsi)
movw $0xd006, -0x2(%rsi)     # imm = 0xD006
movl %eax, %edi
callq 0x6f72
leaq 0x6(%rsp), %rsi
movq %rbx, %rdi
callq 0x5179
movl $0x1, %ebx
testl %eax, %eax
jne 0x564d
leaq 0x6500(%rip), %rdi      # 0xbb44
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2506
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_get_section_addr_map(WdtDevice*, FlashMapAddr_8790_t*)
int wh_w8790_dev_get_section_addr_map(WDT_DEV* pdev, W8790_FLASH_MAP* psec_map)
{
	UINT32 firmware_map_table_addr = 0x000010;
	W8790_FLASH_SECTION_HEADER	sec_header;

	if (!psec_map)
		return 0;

	if (wh_w8790_dev_set_flash_address(pdev, firmware_map_table_addr) <= 0)
		return 0;

	if (wh_w8790_dev_read_flash(pdev, (BYTE*)&sec_header, sizeof(W8790_FLASH_SECTION_HEADER)) <= 0)
		return 0;

	if (wh_w8790_section_header_valid(&sec_header) && sec_header.PayloadSize >= 32 && sec_header.PayloadSize < 1024) {
		if (wh_w8790_dev_set_flash_address(pdev, firmware_map_table_addr + sizeof(W8790_FLASH_SECTION_HEADER)) <= 0)
			return 0;
		size_t padata_buffer = sec_header.PayloadSize + 16;
		BYTE* pdata = (BYTE*)malloc(padata_buffer);
		if (!pdata) {
			printf("pdata malloc fail \n");
			return 0;
		}
		int ret = wh_w8790_dev_read_flash(pdev, (BYTE*)pdata, sec_header.PayloadSize);


		if (ret > 0) {
			psec_map->ParameterMap = get_unaligned_le32(&pdata[0]);
			psec_map->MainLoader = get_unaligned_le32(&pdata[4]);
			psec_map->ParameterPrimary = get_unaligned_le32(&pdata[8]);
			psec_map->ParameterExtended = get_unaligned_le32(&pdata[12]);
			psec_map->ParameterPrivate = get_unaligned_le32(&pdata[16]);

		}
		free(pdata);
		return ret;
	}
	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
xorl %ebx, %ebx
testq %rsi, %rsi
je 0x57c1
movq %rsi, %r14
movq %rdi, %r15
movl $0x10, %esi
callq 0x5604
testl %eax, %eax
je 0x57c1
leaq 0x16(%rsp), %rsi
movw $0xd106, (%rsi)         # imm = 0xD106
movb $0x10, 0x2(%rsi)
xorl %ebx, %ebx
movl %ebx, 0x3(%rsi)
movl %ebx, 0x6(%rsi)
leaq 0x4(%rsp), %rcx
movq %r15, %rdi
xorl %r8d, %r8d
movl $0x10, %r9d
callq 0x53d0
testl %eax, %eax
je 0x57c1
leaq 0x8(%rsp), %r12
xorl %ebx, %ebx
xorl %edi, %edi
movq %r12, %rsi
xorl %edx, %edx
movl $0xc, %ecx
callq 0x88e6
cmpw -0x2(%r12), %ax
jne 0x57c1
movl 0x8(%rsp), %eax
addl $-0x20, %eax
cmpl $0x3df, %eax            # imm = 0x3DF
ja 0x57c1
movq %r15, %rdi
movl $0x20, %esi
callq 0x5604
testl %eax, %eax
je 0x57c1
movl 0x8(%rsp), %r13d
leal 0x10(%r13), %edi
callq 0x21f0
testq %rax, %rax
je 0x57b5
movq %rax, %r12
movq %r15, %rdi
movl $0xd1, %esi
movq %rax, %rdx
xorl %ecx, %ecx
movl $0x1, %r8d
movl %r13d, %r9d
callq 0x548d
movl %eax, %ebx
testl %eax, %eax
je 0x57ab
movq %r12, %rdi
callq 0x6f6b
movl %eax, (%r14)
leaq 0x4(%r12), %rdi
callq 0x6f6b
movl %eax, 0x4(%r14)
leaq 0x8(%r12), %rdi
callq 0x6f6b
movl %eax, 0x8(%r14)
leaq 0xc(%r12), %rdi
callq 0x6f6b
movl %eax, 0xc(%r14)
movq %r12, %rdi
addq $0x10, %rdi
callq 0x6f6b
movl %eax, 0x10(%r14)
movq %r12, %rdi
callq 0x21e0
jmp 0x57c1
leaq 0x6603(%rip), %rdi      # 0xbdbf
callq 0x2270
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_set_n_check_device_mode(WdtDevice*, unsigned char, int, int)
int wh_w8790_dev_set_n_check_device_mode(WDT_DEV* pdev, BYTE mode, int timeout_ms, int intv_ms)
{
	int polling_timeout_ms = 100;
	int polling_intv_ms = 5;

	// if device in isp mode, we don't check mode
	if (pdev->board_info.dev_type & FW_MAYBE_ISP)
		return 1;

	if (timeout_ms)
		polling_timeout_ms = timeout_ms;
	if (intv_ms)
		polling_intv_ms = intv_ms;

	do {
		wh_w8790_dev_set_device_mode(pdev, mode);

		if (wh_w8790_dev_get_device_mode(pdev) == mode)
			return 1;

		usleep(polling_intv_ms*1000);
		polling_timeout_ms -= polling_intv_ms;
	} while (polling_timeout_ms > 0);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl $0x1, %ebx
testb $0x1, 0x188(%rdi)
jne 0x5839
movq %rdi, %r14
testl %edx, %edx
movl $0x64, %r12d
cmovnel %edx, %r12d
testl %ecx, %ecx
movl $0x5, %r13d
cmovnel %ecx, %r13d
imull $0x3e8, %r13d, %ebp     # imm = 0x3E8
movzbl %sil, %r15d
movq %r14, %rdi
movl %r15d, %esi
callq 0x584a
movq %r14, %rdi
callq 0x5585
cmpl %r15d, %eax
je 0x5839
movl %ebp, %edi
callq 0x2230
subl %r13d, %r12d
testl %r12d, %r12d
jg 0x5810
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_set_device_mode(WdtDevice*, unsigned char)
int wh_w8790_dev_set_device_mode(WDT_DEV* pdev, BYTE mode)
{
	BYTE cmd[10] = { 0 };

	cmd[0] = W8790_COMMAND9;
	cmd[1] = W8790_SET_DEVICE_MODE;
	cmd[2] = mode;

	return wh_w8790_dev_command_write(pdev, cmd, 0, 3);
}

// Assembly:
subq $0x18, %rsp
xorl %ecx, %ecx
leaq 0xe(%rsp), %rax
movl %ecx, 0x6(%rax)
movl %ecx, 0x3(%rax)
movw $0xca06, (%rax)         # imm = 0xCA06
movb %sil, 0x2(%rax)
movq %rax, %rsi
callq 0x5179
movl %eax, %ecx
movl $0x1, %eax
testl %ecx, %ecx
jne 0x5887
leaq 0x62c6(%rip), %rdi      # 0xbb44
xorl %eax, %eax
callq 0x2506
xorl %eax, %eax
addq $0x18, %rsp
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_read_parameter_table_info(WdtDevice*, ParameterTableInfo_8790_t*)
int wh_w8790_dev_read_parameter_table_info(WDT_DEV* pdev, W8790_PARAMETER_INFO* p_out_parameter_info)
{
	BYTE cmd[10] = { 0 };

	cmd[0] = W8790_COMMAND9;
	cmd[1] = W8790_READ_PARAMETER_TABLE_INFO;
	BYTE buf[64];
	

	if (wh_w8790_dev_command_read(pdev, cmd, sizeof(cmd), buf, 0, sizeof(W8790_PARAMETER_INFO))) {
		p_out_parameter_info->PMapID = get_unaligned_le16(&buf[0]);
		p_out_parameter_info->PrimarySector = get_unaligned_le16(&buf[2]);
		p_out_parameter_info->PrimarySize = get_unaligned_le16(&buf[4]);
		p_out_parameter_info->ExtendedSector = get_unaligned_le16(&buf[6]);
		p_out_parameter_info->ExtendedSize = get_unaligned_le16(&buf[8]);
		return 1;
	}
	
	
	return 0;

}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x58, %rsp
movq %rsi, %rbx
leaq 0x6(%rsp), %rsi
movq $0x0, 0x2(%rsi)
movw $0xcd06, (%rsi)         # imm = 0xCD06
leaq 0x10(%rsp), %rcx
xorl %ebp, %ebp
xorl %r8d, %r8d
movl $0xa, %r9d
callq 0x53d0
testl %eax, %eax
je 0x590a
leaq 0x10(%rsp), %rdi
callq 0x6f67
movw %ax, (%rbx)
leaq 0x12(%rsp), %rdi
callq 0x6f67
movw %ax, 0x2(%rbx)
leaq 0x14(%rsp), %rdi
callq 0x6f67
movw %ax, 0x4(%rbx)
leaq 0x16(%rsp), %rdi
callq 0x6f67
movw %ax, 0x6(%rbx)
leaq 0x18(%rsp), %rdi
callq 0x6f67
movw %ax, 0x8(%rbx)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_block_fast_write(WdtDevice*, unsigned char*, int, int)
int wh_w8790_dev_block_fast_write(WDT_DEV* pdev, BYTE* data, int start, int size)
{
	int payload_size = W8790_USB_MAX_PAYLOAD_SIZE;
	while (size > payload_size) {
		if (wh_w8790_dev_one_block_fast_write(pdev, data, start, payload_size) <= 0)
			return 0;
		start += payload_size;
		size -= payload_size;
	}
	if (size > 0)
		return wh_w8790_dev_one_block_fast_write(pdev, data, start, size);
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %ecx, %r15d
movl %edx, %ebp
movq %rdi, %rbx
cmpl $0x40, %ecx
movq %rsi, 0x8(%rsp)
jl 0x59e2
leaq 0x11(%rsp), %r13
movslq %ebp, %r14
addq %rsi, %r14
leaq 0x10(%rsp), %r12
movb $0xb, 0x10(%rsp)
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups 0x2f(%r14), %xmm3
movups %xmm3, 0x2f(%r13)
movups %xmm2, 0x20(%r13)
movups %xmm1, 0x10(%r13)
movups %xmm0, (%r13)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5179
testl %eax, %eax
jle 0x5a2d
leal -0x3f(%r15), %eax
addq $0x3f, %r14
addl $0x3f, %ebp
cmpl $0x7e, %r15d
movl %eax, %r15d
jg 0x5991
jmp 0x59e5
movl %r15d, %eax
testl %eax, %eax
jle 0x5a26
xorps %xmm0, %xmm0
leaq 0x11(%rsp), %rdi
movaps %xmm0, -0x1(%rdi)
movaps %xmm0, 0x2f(%rdi)
movaps %xmm0, 0x1f(%rdi)
movaps %xmm0, 0xf(%rdi)
movb $0xb, -0x1(%rdi)
movslq %ebp, %rcx
movq 0x8(%rsp), %rsi
addq %rcx, %rsi
movl %eax, %edx
callq 0x2150
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x5179
jmp 0x5a2f
movl $0x1, %eax
jmp 0x5a2f
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_one_block_fast_read(WdtDevice*, unsigned char*, int, int)
int wh_w8790_dev_one_block_fast_read(WDT_DEV* pdev, BYTE* data, int start, int size)
{
	BYTE cmd[64] = { 0 };
	int read_size = size;

	if (size > W8790_USB_MAX_PAYLOAD_SIZE)
		read_size = W8790_USB_MAX_PAYLOAD_SIZE;

	cmd[0] = W8790_BLOCK63;

	if (wh_w8790_dev_get_feature(pdev, cmd, read_size) > 0) {
		memcpy(&data[start], &cmd[1], read_size);
		return 1;
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x40, %rsp
movl %ecx, %r14d
movl %edx, %ebp
movq %rsi, %rbx
xorps %xmm0, %xmm0
movq %rsp, %rsi
movaps %xmm0, (%rsi)
movaps %xmm0, 0x30(%rsi)
movaps %xmm0, 0x20(%rsi)
movaps %xmm0, 0x10(%rsi)
movb $0xb, (%rsi)
callq 0x51be
testl %eax, %eax
jle 0x5a99
cmpl $0x3f, %r14d
movl $0x3f, %eax
cmovll %r14d, %eax
movslq %ebp, %rcx
addq %rcx, %rbx
leaq 0x1(%rsp), %rsi
movslq %eax, %rdx
movq %rbx, %rdi
callq 0x2150
movl $0x1, %eax
jmp 0x5a9b
xorl %eax, %eax
addq $0x40, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_block_fast_read(WdtDevice*, unsigned char*, int, int)
int wh_w8790_dev_block_fast_read(WDT_DEV* pdev, BYTE* data, int start, int size)
{
	int payload_size = W8790_USB_MAX_PAYLOAD_SIZE;

	while (size > payload_size) {
		if (wh_w8790_dev_one_block_fast_read(pdev, data, start, payload_size) <= 0)
			return 0;
		start += payload_size;
		size -= payload_size;
	}

	if (size > 0)
		return wh_w8790_dev_one_block_fast_read(pdev, data, start, size);

	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %ecx, %r15d
movl %edx, %ebp
movq %rdi, %r14
cmpl $0x40, %ecx
movq %rsi, 0x8(%rsp)
jl 0x5b39
leaq 0x11(%rsp), %r13
movslq %ebp, %rbx
addq %rsi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movb $0xb, 0x10(%rsp)
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
callq 0x51be
testl %eax, %eax
jle 0x5b86
movups (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups 0x20(%r13), %xmm2
movups 0x2f(%r13), %xmm3
movups %xmm3, 0x2f(%rbx)
movups %xmm2, 0x20(%rbx)
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
leal -0x3f(%r15), %r12d
addq $0x3f, %rbx
addl $0x3f, %ebp
cmpl $0x7e, %r15d
movl %r12d, %r15d
jg 0x5acf
jmp 0x5b3c
movl %r15d, %r12d
testl %r12d, %r12d
jle 0x5b7f
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rsi
movaps %xmm0, (%rsi)
movaps %xmm0, 0x30(%rsi)
movaps %xmm0, 0x20(%rsi)
movaps %xmm0, 0x10(%rsi)
movb $0xb, (%rsi)
movq %r14, %rdi
callq 0x51be
testl %eax, %eax
jle 0x5b86
movslq %ebp, %rax
movq 0x8(%rsp), %rdi
addq %rax, %rdi
leaq 0x11(%rsp), %rsi
movl %r12d, %edx
callq 0x2150
movl $0x1, %eax
jmp 0x5b88
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_write_items(WdtDevice*, int, unsigned char*, int, int, int)
int wh_w8790_dev_write_items(WDT_DEV* pdev, int cmd_id, BYTE* buffer, int start, int item_size, int item_count)
{
	int size = item_count * item_size;
	BYTE cmd[64] = { 0 };

	cmd[0] = W8790_COMMAND9;
	cmd[1] = cmd_id;
	cmd[2] = item_count;
	memcpy(&cmd[3], &buffer[start], size);

	return wh_w8790_dev_command_write(pdev, cmd, 0, size + 3);
}

// Assembly:
pushq %rbx
subq $0x40, %rsp
movq %rdi, %rbx
imull %r9d, %r8d
xorps %xmm0, %xmm0
leaq 0x3(%rsp), %rdi
movaps %xmm0, -0x3(%rdi)
movaps %xmm0, 0x2d(%rdi)
movaps %xmm0, 0x1d(%rdi)
movaps %xmm0, 0xd(%rdi)
movb $0x6, -0x3(%rdi)
movb %sil, -0x2(%rdi)
movb %r9b, -0x1(%rdi)
movslq %ecx, %rsi
addq %rdx, %rsi
movslq %r8d, %rdx
callq 0x2150
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x5179
movl $0x1, %ebx
testl %eax, %eax
jne 0x5bf9
leaq 0x5f54(%rip), %rdi      # 0xbb44
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2506
movl %ebx, %eax
addq $0x40, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_write_array(WdtDevice*, int, unsigned char*, int, int, int)
int wh_w8790_dev_write_array(WDT_DEV* pdev, int cmd_id, BYTE* buffer, int start, int item_size, int item_count)
{
	int max_write_batch = (W8790_USB_MAX_PAYLOAD_SIZE - 2) / item_size;
	int i = start;

	while (item_count >= max_write_batch) {
		if (wh_w8790_dev_write_items(pdev, cmd_id, buffer, i, item_size, max_write_batch) <= 0)
			return 0;

		i += max_write_batch * item_size;
		item_count -= max_write_batch;
	}

	if (item_count > 0)
		return wh_w8790_dev_write_items(pdev, cmd_id, buffer, i, item_size, item_count);

	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r9d, %ebx
movl %r8d, %ebp
movl %ecx, %r14d
movq %rdx, 0x10(%rsp)
movl %esi, 0xc(%rsp)
movq %rdi, %r13
movl $0x3d, %eax
xorl %edx, %edx
idivl %r8d
cmpl %r9d, %eax
jg 0x5c66
movl %eax, %r15d
movl %eax, %r12d
imull %ebp, %r12d
movq %r13, %rdi
movl 0xc(%rsp), %esi
movq 0x10(%rsp), %rdx
movl %r14d, %ecx
movl %ebp, %r8d
movl %r15d, %r9d
callq 0x5b97
testl %eax, %eax
je 0x5c99
addl %r12d, %r14d
subl %r15d, %ebx
cmpl %r15d, %ebx
jge 0x5c3d
testl %ebx, %ebx
jle 0x5c92
movq %r13, %rdi
movl 0xc(%rsp), %esi
movq 0x10(%rsp), %rdx
movl %r14d, %ecx
movl %ebp, %r8d
movl %ebx, %r9d
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5b97
movl $0x1, %eax
jmp 0x5c9b
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_wait_cmd_end(WdtDevice*, int, int)
int wh_w8790_dev_wait_cmd_end(WDT_DEV* pdev, int timeout_ms, int invt_ms)
{
	int polling_timeout_ms = 5000;
	int polling_intv_ms = 10;
	int status;
	BYTE	status_buf[4] = { 0 };

	unsigned long 	start_tick = get_current_ms();
	unsigned long 	time_period;

	if (timeout_ms)
		polling_timeout_ms = timeout_ms;
	if (invt_ms)
		polling_intv_ms = invt_ms;

	do
	{
		if (wh_w8790_dev_get_device_status(pdev, &status_buf[0], 0, 1) <= 0)
			return 0;

		status = status_buf[0];
		if ((status & W8790_COMMAND_BUSY) == 0) {
			time_period = (get_current_ms() - start_tick);
			if (time_period)
				wh_printf("leave %s : %lums\n", __FUNCTION__, time_period);

			return 1;
		}

		wh_sleep(polling_intv_ms);
		polling_timeout_ms -= polling_intv_ms;
	} while (polling_timeout_ms > 0);

	wh_printf("%s: timeout occured (%d)!\n", __FUNCTION__, polling_timeout_ms * polling_intv_ms);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, 0x20(%rsp)
leaq 0x8(%rsp), %rax
movl $0x0, (%rax)
callq 0x25ac
movq %rax, 0x18(%rsp)
testl %ebp, %ebp
movl $0x1388, %r15d          # imm = 0x1388
cmovnel %ebp, %r15d
testl %ebx, %ebx
movl $0xa, %r12d
cmovnel %ebx, %r12d
leaq 0x10(%rsp), %rbx
movl %r12d, %ebp
imull %r15d, %ebp
movl %r12d, %r14d
imull %r12d, %r14d
xorl %r13d, %r13d
movw $0x0, 0x4(%rbx)
movl $0x0, (%rbx)
movl $0x100c906, 0xc(%rsp)   # imm = 0x100C906
movq 0x20(%rsp), %rdi
leaq 0xc(%rsp), %rsi
leaq 0x8(%rsp), %rcx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x53d0
testl %eax, %eax
je 0x5d99
testb $0x1, 0x8(%rsp)
je 0x5d6f
movl %r12d, %edi
callq 0x259c
subl %r12d, %r15d
subl %r14d, %ebp
testl %r15d, %r15d
jg 0x5d04
leaq 0x5b95(%rip), %rdi      # 0xb8ef
leaq 0x5e0a(%rip), %rsi      # 0xbb6b
xorl %r13d, %r13d
movl %ebp, %edx
xorl %eax, %eax
callq 0x2506
jmp 0x5d99
callq 0x25ac
movl $0x1, %r13d
subq 0x18(%rsp), %rax
je 0x5d99
leaq 0x5dd1(%rip), %rdi      # 0xbb59
leaq 0x5ddc(%rip), %rsi      # 0xbb6b
movq %rax, %rdx
xorl %eax, %eax
callq 0x2506
movl %r13d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_flash_erase_cmd(WdtDevice*, unsigned int, unsigned int)
int wh_w8790_dev_flash_erase_cmd(WDT_DEV* pdev, UINT32 address, UINT32 size)
{
	BYTE cmd[10] = { 0 };

	cmd[0] = W8790_COMMAND9;
	cmd[1] = (BYTE)W8790_ERASE_FLASH;
	cmd[2] = (BYTE)(address >> 12);
	cmd[3] = (BYTE)(((address & 0x0FFF) + size + 4095) >> 12);

	if (wh_w8790_dev_command_write(pdev, cmd, 0, sizeof(cmd)) > 0)
		return wh_w8790_dev_wait_cmd_end(pdev, 6000, 0);

	return 0;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq 0x6(%rsp), %rax
movw $0x0, 0x8(%rax)
movl $0x0, 0x4(%rax)
movw $0xd206, (%rax)         # imm = 0xD206
movl %esi, %ecx
shrl $0xc, %ecx
movb %cl, 0x2(%rax)
movl $0xfff, %ecx            # imm = 0xFFF
andl %ecx, %esi
addl %ecx, %edx
addl %esi, %edx
shrl $0xc, %edx
movb %dl, 0x3(%rax)
movq %rax, %rsi
callq 0x5179
testl %eax, %eax
je 0x5e6f
movq %rbx, %rdi
movl $0x1770, %esi           # imm = 0x1770
xorl %edx, %edx
callq 0x5caa
movl %eax, %ebx
jmp 0x5e7f
leaq 0x5cce(%rip), %rdi      # 0xbb44
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2506
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_write_flash_cmd(WdtDevice*, unsigned char*, int, int)
int wh_w8790_dev_write_flash_cmd(WDT_DEV* pdev, BYTE* buf, int start, int size)
{
	if (size > W8790_USB_MAX_PAYLOAD_SIZE - 2) {
		wh_printf("%s: payload data overrun\n", __FUNCTION__);
		return 0;
	}

	BYTE cmd[W8790_USB_MAX_PAYLOAD_SIZE + 1] = { 0 };

	cmd[0] = W8790_COMMAND63;
	cmd[1] = (BYTE)W8790_WRITE_FLASH;
	cmd[2] = (BYTE)size;
	memcpy(&cmd[3], &buf[start], size);

	if (wh_w8790_dev_command_write(pdev, cmd, 0, size + 3) > 0)
		return wh_w8790_dev_wait_cmd_end(pdev, 0, 0);
	wh_printf("w8790_write_cmd fail \n)");
	return 0;
}

// Assembly:
pushq %rbx
subq $0x40, %rsp
cmpl $0x3e, %ecx
jl 0x5eaa
leaq 0x5a8c(%rip), %rdi      # 0xb924
leaq 0x5ce6(%rip), %rsi      # 0xbb85
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2506
jmp 0x5f19
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq 0x3(%rsp), %rdi
movaps %xmm0, -0x3(%rdi)
movaps %xmm0, 0x2d(%rdi)
movaps %xmm0, 0x1d(%rdi)
movaps %xmm0, 0xd(%rdi)
movw $0xd307, -0x3(%rdi)     # imm = 0xD307
movb %cl, -0x1(%rdi)
movslq %edx, %rax
addq %rax, %rsi
movslq %ecx, %rdx
callq 0x2150
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x5179
testl %eax, %eax
je 0x5efb
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5caa
movl %eax, %ebx
jmp 0x5f19
leaq 0x5c42(%rip), %rdi      # 0xbb44
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2506
leaq 0x5c90(%rip), %rdi      # 0xbba2
xorl %eax, %eax
callq 0x2506
movl %ebx, %eax
addq $0x40, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O3/chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_write_flash(WdtDevice*, int, unsigned char*, int, int)
int wh_w8790_dev_write_flash(WDT_DEV* pdev, int addr, BYTE* buf, int start, int size)
{
	int byte_count = size;
	int offset = start;
	int max_payload_size = W8790_USB_MAX_PAYLOAD_SIZE - 2;
	int cur_addr = 0xFFFFFFFF;

	while (byte_count >= max_payload_size) {
		if ((addr & 0xfff) == 0)
			printf("base addr: 0x%x\n", addr);
		if (!check_is_all_ff(&buf[offset], max_payload_size)) {
			if (cur_addr != addr) {
				if (!wh_w8790_dev_set_flash_address(pdev, addr))
					return 0;
			}
			if (wh_w8790_dev_write_flash_cmd(pdev, buf, offset, max_payload_size) <= 0)
				return 0;
			cur_addr = addr + max_payload_size;
		}
		else
			wh_printf("Already ff, no need to set: 0x%x\n", addr);
		offset += max_payload_size;
		byte_count -= max_payload_size;
		addr += max_payload_size;
	}

	if (cur_addr != addr) {
		if (!wh_w8790_dev_set_flash_address(pdev, addr))
			return 0;
	}
	if (byte_count > 0) {
		if ((addr & 0xfff) == 0)
			wh_printf("base addr: 0x%x\n", addr);
		return wh_w8790_dev_write_flash_cmd(pdev, buf, offset, byte_count);

	}

	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r8d, %r12d
movl %ecx, %ebx
movl %esi, %ebp
movq %rdi, 0x8(%rsp)
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpl $0x3d, %r8d
movq %rdx, 0x10(%rsp)
jl 0x5fe8
movslq %ebx, %r13
addq %rdx, %r13
testl $0xfff, %ebp            # imm = 0xFFF
jne 0x5f6e
leaq 0x5554(%rip), %rdi      # 0xb4b9
movl %ebp, %esi
xorl %eax, %eax
callq 0x2050
movq %r13, %rdi
movl $0x3d, %esi
callq 0x6f75
testl %eax, %eax
je 0x5f94
leaq 0x59d7(%rip), %rdi      # 0xb95d
movl %ebp, %esi
xorl %eax, %eax
callq 0x2506
addl $0x3d, %ebp
jmp 0x5fcd
cmpl %ebp, %r15d
je 0x5fad
movq 0x8(%rsp), %rdi
movl %ebp, %esi
callq 0x5604
testl %eax, %eax
je 0x603f
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl %ebx, %edx
movl $0x3d, %ecx
callq 0x5e87
testl %eax, %eax
je 0x603f
addl $0x3d, %ebp
movl %ebp, %r15d
leal -0x3d(%r12), %r14d
addq $0x3d, %r13
addl $0x3d, %ebx
cmpl $0x79, %r12d
movl %r14d, %r12d
jg 0x5f56
jmp 0x5feb
movl %r12d, %r14d
cmpl %ebp, %r15d
je 0x6000
movq 0x8(%rsp), %rdi
movl %ebp, %esi
callq 0x5604
testl %eax, %eax
je 0x603f
testl %r14d, %r14d
jle 0x6043
testl $0xfff, %ebp            # imm = 0xFFF
jne 0x601d
leaq 0x54a5(%rip), %rdi      # 0xb4b9
movl %ebp, %esi
xorl %eax, %eax
callq 0x2506
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl %ebx, %edx
movl %r14d, %ecx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5e87
xorl %eax, %eax
jmp 0x6048
movl $0x1, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq