LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_prepare_data(WdtDevice*, BoardInfo*, int)
int wh_w8755_dev_set_basic_op(WDT_DEV *pdev)
{
	if (!pdev)
		return 0;

	g_func_dev_basic.p_wh_get_feature = wh_w8755_dev_get_feature;
	g_func_dev_basic.p_wh_set_feature = wh_w8755_dev_set_feature;
	g_func_dev_basic.p_wh_read_report = wh_w8755_dev_read_report;

	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x3d39
movq %rsi, %r14
movq %rdi, %rbx
leaq -0x34c(%rip), %rax      # 0x3989
movq %rax, 0xd6b4(%rip)      # 0x11390
leaq -0x36b(%rip), %rax      # 0x3978
movq %rax, 0xd69e(%rip)      # 0x11388
leaq 0x70(%rsi), %r15
movq %r15, %rsi
callq 0x34b9
testl %eax, %eax
je 0x3d4b
movq 0x20(%r15), %rax
movq %rax, 0x218(%rbx)
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups %xmm1, 0x208(%rbx)
movups %xmm0, 0x1f8(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3a97
movl $0x1, %ebp
testl %eax, %eax
jne 0x3d6d
leaq 0x79d1(%rip), %rdi      # 0xb708
jmp 0x3d40
leaq 0x799d(%rip), %rdi      # 0xb6dd
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x2506
jmp 0x3d6d
leaq 0x799a(%rip), %rdi      # 0xb6ec
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x2506
movq %rbx, %rdi
movl $0x5, %esi
movl $0x1, %edx
callq 0x2d6b
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_get_feature_devinfo(ReportFeatureDevInfo*, unsigned char*)
int wh_w8760_get_feature_devinfo(W8760_REPORT_FEATURE_DEVINFO* report_feature_devinfo, BYTE* buf)
{
	if (!report_feature_devinfo || !buf)
		return 0;

	report_feature_devinfo->firmware_id = get_unaligned_le32(&buf[1]);	
	report_feature_devinfo->hardware_id = get_unaligned_le32(&buf[5]);
	report_feature_devinfo->serial_no = get_unaligned_le32(&buf[9]);
	report_feature_devinfo->n_touches_usb = buf[13];
	report_feature_devinfo->n_bytes_touch = buf[14];
	memcpy(report_feature_devinfo->platform_id, &buf[16], 8);
	memcpy(report_feature_devinfo->rom_signature, &buf[24], 8);

	report_feature_devinfo->protocol_version = buf[32];	
	report_feature_devinfo->firmware_rev_ext = buf[33];	
	report_feature_devinfo->parameter_section_size = get_unaligned_le16(&buf[34]);	
	report_feature_devinfo->parameter_mapid = get_unaligned_le16(&buf[36]);	
	memcpy(report_feature_devinfo->program_name_fourcc, &buf[38], 4);	
	memcpy(report_feature_devinfo->trackingid_or_old_part_num, &buf[42], 8);	
	
	return 1;
}

// Assembly:
testq %rdi, %rdi
sete %cl
testq %rsi, %rsi
sete %dl
xorl %eax, %eax
orb %cl, %dl
jne 0x3e20
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x1(%rsi), %rdi
callq 0x702b
movl %eax, (%rbx)
leaq 0x5(%r14), %rdi
callq 0x702b
movl %eax, 0x4(%rbx)
leaq 0x9(%r14), %rdi
callq 0x702b
movl %eax, 0x8(%rbx)
movb 0xd(%r14), %al
movb %al, 0xc(%rbx)
movb 0xe(%r14), %al
movb %al, 0xd(%rbx)
movq 0x10(%r14), %rax
movq %rax, 0xf(%rbx)
movq 0x18(%r14), %rax
movq %rax, 0x17(%rbx)
movb 0x20(%r14), %al
movb %al, 0x1f(%rbx)
movb 0x21(%r14), %al
movb %al, 0x20(%rbx)
leaq 0x22(%r14), %rdi
callq 0x7027
movw %ax, 0x21(%rbx)
leaq 0x24(%r14), %rdi
callq 0x7027
movw %ax, 0x23(%rbx)
movl 0x26(%r14), %eax
movl %eax, 0x25(%rbx)
movq 0x2a(%r14), %rax
movq %rax, 0x29(%rbx)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_set_feature(WdtDevice*, unsigned char*, unsigned int)
int wh_w8760_dev_set_feature(WDT_DEV* pdev, BYTE* buf, UINT32 buf_size)
{
	if (!pdev)
		return 0;

	if (buf[0] == W8760_COMMAND9 || buf[0] == W8760_PIPE9)
		buf_size = 10;
	else if (buf[0] == W8760_COMMAND63 || buf[0] == W8760_PIPE63 || 
		buf[0] == W8760_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 0x3e78
movzbl (%rsi), %eax
leal -0x6(%rax), %ecx
cmpb $0x9, %cl
jae 0x3e63
movzbl %cl, %ecx
movl $0x1a3, %edx            # imm = 0x1A3
btl %ecx, %edx
jae 0x3e63
cmpl $0x2, (%rdi)
jne 0x3e78
leaq 0x7a4d(%rip), %rax      # 0xb8a8
movl (%rax,%rcx,4), %edx
jmp 0x9a74
pushq %rax
leaq 0x7a61(%rip), %rdi      # 0xb8cc
movl %eax, %esi
xorl %eax, %eax
callq 0x2506
addq $0x8, %rsp
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_get_feature(WdtDevice*, unsigned char*, unsigned int)
int wh_w8760_dev_get_feature(WDT_DEV* pdev, BYTE* buf, UINT32 buf_size)
{
	if (!pdev)
		return 0;

	if (buf[0] == W8760_COMMAND9 || buf[0] == W8760_PIPE9)
		buf_size = 10;
	else if (buf[0] == W8760_COMMAND63 || buf[0] == W8760_PIPE63 || 
		buf[0] == W8760_BLOCK63 || buf[0] == VND_REQ_DEV_INFO)
		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 0x3ecc
movzbl (%rsi), %eax
cmpl $0xe, %eax
ja 0x3ea1
movl $0x4880, %ecx           # imm = 0x4880
btl %eax, %ecx
jb 0x3ea8
movl $0xa, %edx
movl $0x2040, %ecx           # imm = 0x2040
btl %eax, %ecx
jb 0x3ead
cmpl $0xf2, %eax
jne 0x3eb7
movl $0x40, %edx
cmpl $0x2, (%rdi)
jne 0x3ecc
jmp 0x95fc
pushq %rax
leaq 0x7a0d(%rip), %rdi      # 0xb8cc
movl %eax, %esi
xorl %eax, %eax
callq 0x2506
addq $0x8, %rsp
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_command_read(WdtDevice*, unsigned char*, int, unsigned char*, int, int)
int wh_w8760_dev_command_read(WDT_DEV *pdev, BYTE* cmd, int cmd_size, BYTE* data, int start, int size)
{
	BYTE buf[64];
	if (wh_w8760_dev_command_write(pdev, cmd, 0, cmd_size) > 0) {
		if (size > 9)
			buf[0] = W8760_COMMAND63;
		else 
			buf[0] = W8760_COMMAND9;

		if (wh_w8760_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 %r12
pushq %rbx
subq $0x40, %rsp
movl %r9d, %ebx
movl %r8d, %ebp
movq %rcx, %r14
movq %rdi, %r12
callq 0x3e32
xorl %r15d, %r15d
testl %eax, %eax
jle 0x3f3c
cmpl $0xa, %ebx
setge %al
orb $0x6, %al
movq %rsp, %rsi
movb %al, (%rsi)
movq %r12, %rdi
callq 0x3e7b
testl %eax, %eax
jle 0x3f3c
movslq %ebp, %rax
addq %rax, %r14
leaq 0x1(%rsp), %rsi
movslq %ebx, %rdx
movq %r14, %rdi
callq 0x2150
movl $0x1, %r15d
movl %r15d, %eax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_write_items(WdtDevice*, int, unsigned char*, int, int, int)
int wh_w8760_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];

	cmd[0] = W8760_COMMAND9;
	cmd[1] = cmd_id;
	cmd[2] = item_count;
	memcpy(&cmd[3], &buffer[start], size);

	return wh_w8760_dev_command_write(pdev, cmd, 0, size + 3);
}

// Assembly:
pushq %rbx
subq $0x40, %rsp
movq %rdi, %rbx
imull %r9d, %r8d
leaq 0x3(%rsp), %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 0x3e32
addq $0x40, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_write_array(WdtDevice*, int, unsigned char*, int, int, int)
int wh_w8760_dev_write_array(WDT_DEV *pdev, int cmd_id, BYTE* buffer, int start, int item_size, int item_count)
{
	int max_write_batch = (W8760_USB_MAX_PAYLOAD_SIZE - 2) / item_size;
	int i = start;

	while (item_count >= max_write_batch) {
		if (wh_w8760_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_w8760_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 $0x68, %rsp
movl %r9d, %r15d
movl %ecx, %r12d
movq %rdx, %rcx
movl %esi, %r13d
movq %rdi, 0x10(%rsp)
movl $0x3d, %eax
xorl %edx, %edx
idivl %r8d
cmpl %r9d, %eax
movq %rcx, 0x18(%rsp)
movl %r8d, 0xc(%rsp)
jg 0x403b
movl %eax, %r14d
imull %r8d, %eax
movslq %eax, %rbp
movslq %r12d, %rbx
addq %rcx, %rbx
movb $0x6, 0x20(%rsp)
movb %r13b, 0x21(%rsp)
movb %r14b, 0x22(%rsp)
leaq 0x23(%rsp), %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x2150
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x3e32
testl %eax, %eax
jle 0x4084
subl %r14d, %r15d
addq %rbp, %rbx
addl %ebp, %r12d
cmpl %r14d, %r15d
jge 0x3ffb
testl %r15d, %r15d
jle 0x407d
movl 0xc(%rsp), %ecx
imull %r15d, %ecx
leaq 0x23(%rsp), %rdi
movb $0x6, -0x3(%rdi)
movb %r13b, -0x2(%rdi)
movb %r15b, -0x1(%rdi)
movslq %r12d, %rax
movq 0x18(%rsp), %rsi
addq %rax, %rsi
movslq %ecx, %rdx
callq 0x2150
leaq 0x20(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0x3e32
jmp 0x4086
movl $0x1, %eax
jmp 0x4086
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_wait_cmd_end(WdtDevice*, int, int)
int wh_w8760_dev_wait_cmd_end(WDT_DEV* pdev, int timeout_ms, int invt_ms)
{
	int polling_timeout_ms = 5000;
	int polling_intv_ms = 5;
	int status;
	BYTE	status_buf[4];

	if (timeout_ms)
		polling_timeout_ms = timeout_ms;
	if (invt_ms)
		polling_intv_ms = invt_ms;	
	
	do
	{
		if (wh_w8760_dev_get_device_status(pdev, &status_buf[0], 0, 1) <= 0)
			return 0;
		
		status = status_buf[0];
		if ((status & W8760_COMMAND_BUSY) == 0) {			
			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", __func__, polling_timeout_ms * polling_intv_ms);	
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
testl %esi, %esi
movl $0x1388, %r15d          # imm = 0x1388
cmovnel %esi, %r15d
testl %edx, %edx
movl $0x5, %r14d
cmovnel %edx, %r14d
movl %r14d, %ebp
imull %r15d, %ebp
movl %r14d, %r12d
imull %r14d, %r12d
xorl %r13d, %r13d
movl $0x100c906, 0x4(%rsp)   # imm = 0x100C906
movq %rbx, %rdi
leaq 0x4(%rsp), %rsi
movq %rsp, %rcx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x3ee3
testl %eax, %eax
je 0x412c
testb $0x1, (%rsp)
je 0x4126
movl %r14d, %edi
callq 0x259c
subl %r14d, %r15d
subl %r12d, %ebp
testl %r15d, %r15d
jg 0x40cc
leaq 0x77de(%rip), %rdi      # 0xb8ef
leaq 0x77f2(%rip), %rsi      # 0xb90a
xorl %r13d, %r13d
movl %ebp, %edx
xorl %eax, %eax
callq 0x2506
jmp 0x412c
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_O1/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_run_program_from_background(WdtDevice*, unsigned int)
int wh_w8760_dev_run_program_from_background(WDT_DEV* pdev, UINT32 program_address)
{
	BYTE cmd[2 + 4 + 4];
	cmd[0] = W8760_COMMAND63;
	cmd[1] = W8760_RUN_PROGRAM_FORM_BACKGROUND;
	put_unaligned_le32(program_address, &cmd[2]);
	put_unaligned_le32(0, &cmd[6]);
	return wh_w8760_dev_command_write(pdev, cmd, 0, sizeof(cmd));	
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movl %esi, %eax
movq %rdi, %rbx
leaq 0x8(%rsp), %rsi
movw $0xe507, -0x2(%rsi)     # imm = 0xE507
movl %eax, %edi
callq 0x7032
leaq 0xc(%rsp), %rsi
xorl %edi, %edi
callq 0x7032
leaq 0x6(%rsp), %rsi
movq %rbx, %rdi
callq 0x3e32
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_get_hid_descriptor_register(WdtDevice*, unsigned short*)
int wh_w8760_dev_get_hid_descriptor_register(WDT_DEV* pdev, UINT16* pvalue)
{
	BYTE cmd[] = { W8760_COMMAND9, W8760_GET_HID_DESCRIPTOR_REGISTER };
	BYTE buf[4];

	*pvalue = 0x20;
	if (wh_w8760_dev_command_read(pdev, cmd, sizeof(cmd), buf, 0, 2) <= 0)
		return 0;

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

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rsi, %rbx
leaq 0x2(%rsp), %rsi
movw $0xcf06, (%rsi)         # imm = 0xCF06
movw $0x20, (%rbx)
leaq 0x4(%rsp), %rcx
xorl %ebp, %ebp
xorl %r8d, %r8d
movl $0x2, %r9d
callq 0x3ee3
testl %eax, %eax
je 0x41f2
leaq 0x4(%rsp), %rdi
callq 0x7027
movw %ax, (%rbx)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_get_device_mode(WdtDevice*)
int wh_w8760_dev_get_device_mode(WDT_DEV* pdev)
{
	BYTE status[4];
	if (!pdev)
		return 0;

	if (wh_w8760_dev_get_device_status(pdev, status, 4, 1))
		return status[0];

	return 0;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
testq %rdi, %rdi
je 0x4267
leaq 0xc(%rsp), %rsi
movl $0x104c906, (%rsi)      # imm = 0x104C906
leaq 0x8(%rsp), %rcx
xorl %ebx, %ebx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x3ee3
testl %eax, %eax
je 0x4269
movzbl 0x8(%rsp), %ebx
jmp 0x4269
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_set_n_check_device_mode(WdtDevice*, unsigned char, int, int)
int wh_w8760_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, just return */
	if (pdev->board_info.dev_type & FW_WDT8760_2_ISP)
		return 1;

	if (timeout_ms)
		polling_timeout_ms = timeout_ms;
	if (intv_ms)
		polling_intv_ms = intv_ms;

	do {
		wh_w8760_dev_set_device_mode(pdev, mode);

		if (wh_w8760_dev_get_device_mode(pdev) == mode)
			return 1;

		wh_sleep(polling_intv_ms);
		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 $0x50, 0x189(%rdi)
jne 0x42e1
movq %rdi, %r14
testl %edx, %edx
movl $0x64, %r12d
cmovnel %edx, %r12d
testl %ecx, %ecx
movl $0x5, %ebp
cmovnel %ecx, %ebp
movzbl %sil, %r13d
leaq 0x5(%rsp), %r15
movw $0xca06, 0x5(%rsp)      # imm = 0xCA06
movb %r13b, 0x7(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x3e32
movq %r14, %rdi
callq 0x4232
cmpl %r13d, %eax
je 0x42e1
movl %ebp, %edi
callq 0x259c
subl %ebp, %r12d
testl %r12d, %r12d
jg 0x42ac
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_O1/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_set_address(WdtDevice*, unsigned char, unsigned int)
int wh_w8760_dev_set_address(WDT_DEV* pdev, BYTE type, UINT32 address)
{
	BYTE cmd[8];

	memset(&cmd, 0, sizeof(cmd));

	if (!(type == W8760_SET_MEMORY_ADDRESS || type == W8760_SET_FLASH_ADDRESS))
		return 0;
	
	cmd[0] = W8760_COMMAND9;
	cmd[1] = type;
	put_unaligned_le32(address, &cmd[2]);
	if (type != W8760_SET_MEMORY_ADDRESS)
		cmd[5] = 0;

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

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %esi, %ebp
movq $0x0, (%rsp)
movl %ebp, %ecx
andb $-0x11, %cl
xorl %eax, %eax
cmpb $-0x40, %cl
jne 0x4338
movq %rdi, %rbx
leaq 0x2(%rsp), %rsi
movb $0x6, -0x2(%rsi)
movb %bpl, -0x1(%rsi)
movl %edx, %edi
callq 0x7032
cmpb $-0x40, %bpl
je 0x432d
movb $0x0, 0x5(%rsp)
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x3e32
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_identify_platform(WdtDevice*, BoardInfo*)
int wh_w8760_dev_identify_platform(WDT_DEV* pdev, BOARD_INFO* pboardInfo)
{
	if (!pdev || !pboardInfo)
		return 0;

	if (memcmp(W8760_RomSignatureVerB, pdev->board_info.dev_info.w8760_feature_devinfo.rom_signature, 8) == 0) {
		pboardInfo->dev_type = FW_WDT8760;
		if (pdev->pparam->argus & OPTION_INFO)		
			printf("WDT8760_VerB\n");
		return 1;
	}

	if (memcmp(W8762_RomSignatureVerA, pdev->board_info.dev_info.w8760_feature_devinfo.rom_signature, 8) == 0) {
		pboardInfo->dev_type = FW_WDT8762;
		if (pdev->pparam->argus & OPTION_INFO)		
			printf("WDT8762_VerA\n");
		return 1;
	}

	if (memcmp(W8762_RomSignatureVerC, pdev->board_info.dev_info.w8760_feature_devinfo.rom_signature, 8) == 0) {
		pboardInfo->dev_type = FW_WDT8762;
		if (pdev->pparam->argus & OPTION_INFO)		
			printf("WDT8762_VerC\n");
		return 1;
	}
	
	return 0;
}

// Assembly:
testq %rdi, %rdi
sete %cl
testq %rsi, %rsi
sete %dl
xorl %eax, %eax
orb %cl, %dl
jne 0x4434
movq 0xcf45(%rip), %rcx      # 0x11350
cmpq 0x20f(%rdi), %rcx
je 0x4435
movq 0xcf3d(%rip), %rcx      # 0x11358
cmpq 0x20f(%rdi), %rcx
je 0x4455
movq 0xcf35(%rip), %rcx      # 0x11360
cmpq 0x20f(%rdi), %rcx
je 0x4475
retq
movl $0x800, (%rsi)          # imm = 0x800
movq 0x280(%rdi), %rcx
movl $0x1, %eax
testb $0x8, (%rcx)
je 0x4434
leaq 0x7630(%rip), %rdi      # 0xba83
jmp 0x4493
movl $0x2000, (%rsi)         # imm = 0x2000
movq 0x280(%rdi), %rcx
movl $0x1, %eax
testb $0x8, (%rcx)
je 0x4434
leaq 0x7603(%rip), %rdi      # 0xba76
jmp 0x4493
movl $0x2000, (%rsi)         # imm = 0x2000
movq 0x280(%rdi), %rcx
movl $0x1, %eax
testb $0x8, (%rcx)
je 0x4434
leaq 0x75d6(%rip), %rdi      # 0xba69
pushq %rax
callq 0x2270
movl $0x1, %eax
addq $0x8, %rsp
retq
// File: /workspace/github_cpp_makefile_star2_O1/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_erase_flash(WdtDevice*, unsigned int, unsigned int)
int wh_w8760_dev_erase_flash(WDT_DEV* pdev, UINT32 address, UINT32 size)
{
	BYTE cmd[4];

	cmd[0] = W8760_COMMAND9;
	cmd[1] = (BYTE) W8760_ERASE_FLASH;
	cmd[2] = (BYTE) (address >> 12);
	cmd[3] = (BYTE)(((address & 0x0FFF) + size + 4095) >> 12);

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

	return 0;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq 0xc(%rsp), %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 0x3e32
testl %eax, %eax
jle 0x44e8
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4095
jmp 0x44ea
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_batch_write_flash(WdtDevice*, unsigned char*, int, int)
int wh_w8760_dev_batch_write_flash(WDT_DEV* pdev, BYTE* buf, int start, int size)
{
	if (size > W8760_USB_MAX_PAYLOAD_SIZE - 2) {
		wh_printf("%s: payload data overrun\n", __func__);
		return 0;
	}

	BYTE cmd[W8760_USB_MAX_PAYLOAD_SIZE+1];

	cmd[0] = W8760_COMMAND63;
	cmd[1] = (BYTE) W8760_WRITE_FLASH;
	cmd[2] = (BYTE) size;
	memcpy(&cmd[3], &buf[start], size);

	if (wh_w8760_dev_command_write(pdev, cmd, 0, size + 3) > 0)
		return wh_w8760_dev_wait_cmd_end(pdev, 0, 0);
			
	return 0;
}

// Assembly:
pushq %rbx
subq $0x40, %rsp
cmpl $0x3e, %ecx
jl 0x4513
leaq 0x7423(%rip), %rdi      # 0xb924
leaq 0x7436(%rip), %rsi      # 0xb93e
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2506
jmp 0x4553
movq %rdi, %rbx
leaq 0x3(%rsp), %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 0x3e32
testl %eax, %eax
jle 0x4551
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4095
movl %eax, %ebx
jmp 0x4553
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x40, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_write_flash(WdtDevice*, int, unsigned char*, int, int)
int wh_w8760_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 = W8760_USB_MAX_PAYLOAD_SIZE - 2;
	int cur_addr = 0xFFFFFFFF;
	
	while (byte_count >= max_payload_size) {
		if (!check_is_all_ff(&buf[offset], max_payload_size)) {
			if (cur_addr != addr) {
				if (!wh_w8760_dev_set_flash_address(pdev, addr))
					return 0;
			}

			if (wh_w8760_dev_batch_write_flash(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_w8760_dev_set_flash_address(pdev, addr))
			return 0;
	}

	if (byte_count > 0) 
		return wh_w8760_dev_batch_write_flash(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, %r13d
movl %ecx, %ebx
movl %esi, %r12d
movq %rdi, 0x8(%rsp)
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpl $0x3d, %r8d
movq %rdx, 0x10(%rsp)
jl 0x462c
movslq %ebx, %rbp
addq %rdx, %rbp
movq %rbp, %rdi
movl $0x3d, %esi
callq 0x7035
testl %eax, %eax
je 0x45b5
leaq 0x73b4(%rip), %rdi      # 0xb95d
movl %r12d, %esi
xorl %eax, %eax
callq 0x2506
jmp 0x460e
cmpl %r15d, %r12d
je 0x45ef
movq $0x0, (%rsp)
movw $0xd006, (%rsp)         # imm = 0xD006
movl %r12d, %edi
leaq 0x2(%rsp), %rsi
callq 0x7032
movb $0x0, 0x5(%rsp)
movq 0x8(%rsp), %rdi
movq %rsp, %rsi
callq 0x3e32
testl %eax, %eax
je 0x4684
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl %ebx, %edx
movl $0x3d, %ecx
callq 0x44f0
testl %eax, %eax
je 0x4684
leal 0x3d(%r12), %r15d
leal -0x3d(%r13), %r14d
addl $0x3d, %r12d
addq $0x3d, %rbp
addl $0x3d, %ebx
cmpl $0x79, %r13d
movl %r14d, %r13d
jg 0x4591
jmp 0x462f
movl %r13d, %r14d
cmpl %r12d, %r15d
je 0x4669
leaq 0x2(%rsp), %r13
movq $0x0, -0x2(%r13)
movw $0xd006, -0x2(%r13)     # imm = 0xD006
movl %r12d, %edi
movq %r13, %rsi
callq 0x7032
movb $0x0, 0x3(%r13)
movq %rsp, %rsi
movq 0x8(%rsp), %rdi
callq 0x3e32
testl %eax, %eax
je 0x4684
testl %r14d, %r14d
jle 0x4688
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl %ebx, %edx
movl %r14d, %ecx
callq 0x44f0
jmp 0x468d
xorl %eax, %eax
jmp 0x468d
movl $0x1, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x46fc
movl $0x100, %r12d           # imm = 0x100
subl %eax, %r12d
movl %r12d, %eax
subl %r15d, %eax
movl %r15d, %r8d
cmovll %r12d, %r8d
negl %eax
xorl %ecx, %ecx
cmpl %r12d, %r15d
movl %eax, %r15d
cmovlel %ecx, %r15d
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x455b
testl %eax, %eax
cmovel %eax, %r12d
je 0x4774
addq %r12, %rbx
addl %r12d, %ebp
testl %r15d, %r15d
je 0x476c
movl $0x100, %r12d           # imm = 0x100
xorl %r13d, %r13d
testl $0xfff, %ebp            # imm = 0xFFF
jne 0x4722
leaq 0x6da0(%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 0x455b
testl %eax, %eax
je 0x4777
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 0x470a
movl $0x1, %r13d
jmp 0x4777
movl %eax, %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_O1/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 0x702e
xorl $0xffff, %ebx           # imm = 0xFFFF
movl %ebx, %edi
movq %r15, %rsi
callq 0x702e
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x3e32
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x7032
leaq 0x10(%rsp), %rsi
movl %r15d, %edi
callq 0x7032
leaq 0x13(%rsp), %rsi
movzwl %bp, %edi
callq 0x702e
leaq 0xb(%rsp), %rsi
movq %r14, %rdi
callq 0x3e32
xorl %ebp, %ebp
testl %eax, %eax
jle 0x4886
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4095
testl %eax, %eax
je 0x4886
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 0x3ee3
testl %eax, %eax
je 0x4886
leaq 0x7(%rsp), %rdi
callq 0x7027
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_O1/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 0xa(%rsp), %rsi
movq $0x0, -0x2(%rsi)
movw $0x0, 0x6(%rsi)
movw $0xdf06, -0x2(%rsi)     # imm = 0xDF06
movl %eax, %edi
callq 0x7032
leaq 0xe(%rsp), %rsi
movl %ebx, %edi
callq 0x7032
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x3e32
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x44a3
movl %eax, %r14d
testl %eax, %eax
jne 0x4aa3
leaq 0x6f45(%rip), %rdi      # 0xb9d6
leaq 0x6f56(%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_O1/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 0x4b20
movq %rsi, %r14
movq %rdi, %r15
leaq 0x2(%rsp), %r13
movq $0x0, -0x2(%r13)
movw $0xd006, -0x2(%r13)     # imm = 0xD006
movl %ebp, %edi
movq %r13, %rsi
callq 0x7032
movb $0x0, 0x3(%r13)
movq %rsp, %rsi
movq %r15, %rdi
callq 0x3e32
testl %eax, %eax
je 0x4b20
movq %r15, %rdi
movl %ebp, %esi
movq %r14, %rdx
movl %ebx, %ecx
callq 0x469c
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_O1/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 0x4271
testl %eax, %eax
je 0x4bcf
leaq 0x6c86(%rip), %rdi      # 0xb7e8
callq 0x2270
movq 0x18(%r14), %rsi
movl 0x4(%r14), %ecx
xorl %ebp, %ebp
xorl %edi, %edi
xorl %edx, %edx
callq 0x8966
movl %eax, %r15d
movl (%r14), %edx
movl 0x4(%r14), %ecx
leaq 0x4(%rsp), %rsi
movq %rbx, %rdi
xorl %r8d, %r8d
callq 0x47dd
testl %eax, %eax
je 0x4bcf
movzwl %r15w, %esi
movl 0x4(%rsp), %edx
movl $0x1, %ebp
cmpl %esi, %edx
je 0x4bb9
leaq 0x6dcf(%rip), %rdi      # 0xb97f
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x2506
movq %rbx, %rdi
movl $0x1, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x4271
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_O1/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 0x4c18
leaq 0x4(%rsp), %rsi
xorl %r8d, %r8d
callq 0x3ee3
popq %rcx
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x4c91
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 0x3ee3
testl %eax, %eax
je 0x4c91
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_O1/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 0x4d3b
movq %rsi, %r14
movq %rdi, %r15
callq 0x43f2
testl %eax, %eax
je 0x4d2b
movl $0x1, %ebx
testb $0x50, 0x1(%r14)
jne 0x4d3b
leaq 0x4(%rsp), %rsi
movq %r15, %rdi
callq 0x4c3b
testl %eax, %eax
je 0x4d3b
movzbl 0x6(%rsp), %eax
movw %ax, 0x24(%r14)
movzbl 0x8(%rsp), %eax
movw %ax, 0x28(%r14)
movzbl 0x9(%rsp), %eax
movw %ax, 0x2a(%r14)
movzbl 0x5(%rsp), %eax
movw %ax, 0x26(%r14)
movzbl 0xa(%rsp), %eax
movw %ax, 0x2c(%r14)
movzbl 0xb(%rsp), %eax
movw %ax, 0x2e(%r14)
movl $0x0, 0x20(%r14)
jmp 0x4d3b
leaq 0x6c86(%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_O1/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 0x6933(%rip), %rdi      # 0xba23
xorl %eax, %eax
callq 0x2506
leaq 0xa(%rsp), %rsi
movq $0x0, -0x2(%rsi)
movw $0xc006, -0x2(%rsi)     # imm = 0xC006
movl $0xa022750a, %edi       # imm = 0xA022750A
callq 0x7032
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x3e32
movq %rbx, %rdi
xorl %esi, %esi
callq 0x433f
movq %rbx, %rdi
movl $0x61000, %esi          # imm = 0x61000
callq 0x4177
leaq 0x68fd(%rip), %rdi      # 0xba3c
xorl %eax, %eax
callq 0x2506
movl $0x1, %eax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x68f4(%rip), %rdi      # 0xba50
xorl %eax, %eax
callq 0x2506
movq %rbx, %rdi
movl $0x61000, %esi          # imm = 0x61000
callq 0x4177
leaq 0x68c5(%rip), %rdi      # 0xba3c
xorl %eax, %eax
callq 0x2506
movl $0x1, %eax
popq %rbx
retq
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O1/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 0x51db
movzbl (%rsi), %eax
cmpl $0x6, %eax
je 0x51b7
cmpl $0xb, %eax
je 0x51b0
cmpl $0x7, %eax
jne 0x51c6
movl $0x40, %edx
jmp 0x51bc
movl $0xa, %edx
cmpl $0x2, (%rdi)
jne 0x51db
jmp 0x9a74
pushq %rax
leaq 0x66fe(%rip), %rdi      # 0xb8cc
movl %eax, %esi
xorl %eax, %eax
callq 0x2506
addq $0x8, %rsp
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x5220
movzbl (%rsi), %eax
cmpl $0x6, %eax
je 0x51fc
cmpl $0xb, %eax
je 0x51f5
cmpl $0x7, %eax
jne 0x520b
movl $0x40, %edx
jmp 0x5201
movl $0xa, %edx
cmpl $0x2, (%rdi)
jne 0x5220
jmp 0x95fc
pushq %rax
leaq 0x66b9(%rip), %rdi      # 0xb8cc
movl %eax, %esi
xorl %eax, %eax
callq 0x2506
addq $0x8, %rsp
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x52dc
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x1(%rsi), %rdi
callq 0x702b
movl %eax, (%rbx)
leaq 0x5(%r14), %rdi
callq 0x702b
movl %eax, 0x4(%rbx)
leaq 0x9(%r14), %rdi
callq 0x702b
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_O1/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 0x5304
movq 0xc07d(%rip), %rcx      # 0x11368
cmpq 0x218(%rdi), %rcx
je 0x5305
movq 0xc075(%rip), %rcx      # 0x11370
cmpq 0x218(%rdi), %rcx
je 0x531f
retq
movq 0x280(%rdi), %rcx
movl $0x1, %eax
testb $0x8, (%rcx)
je 0x5304
leaq 0x6a95(%rip), %rdi      # 0xbdb2
jmp 0x5337
movq 0x280(%rdi), %rcx
movl $0x1, %eax
testb $0x8, (%rcx)
je 0x5304
leaq 0x6a6e(%rip), %rdi      # 0xbda5
pushq %rax
callq 0x2270
movl $0x1, %eax
addq $0x8, %rsp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x53b8
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 0x53f0
testl %eax, %eax
je 0x53b8
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_O1/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, %ebx
movl %r8d, %ebp
movq %rcx, %r14
movq %rdi, %r15
callq 0x5199
testl %eax, %eax
je 0x5457
xorps %xmm0, %xmm0
movq %rsp, %rsi
movaps %xmm0, (%rsi)
movaps %xmm0, 0x30(%rsi)
movaps %xmm0, 0x20(%rsi)
movaps %xmm0, 0x10(%rsi)
cmpl $0xa, %ebx
setge %al
orb $0x6, %al
movb %al, (%rsi)
movq %r15, %rdi
callq 0x51de
testl %eax, %eax
jle 0x5469
movslq %ebp, %rax
addq %rax, %r14
leaq 0x1(%rsp), %rsi
movslq %ebx, %rdx
movq %r14, %rdi
callq 0x2150
movl $0x1, %ebx
jmp 0x546b
leaq 0x66e6(%rip), %rdi      # 0xbb44
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2506
jmp 0x546b
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x5535
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 0x53f0
testl %eax, %eax
je 0x557b
addl %r14d, %ebp
subl %ebx, %r15d
cmpl %ebx, %r15d
jge 0x54f3
testl %r15d, %r15d
jle 0x5575
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 0x53f0
movl %eax, %r12d
jmp 0x557b
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_O1/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 $0x20, %rsp
movl $0x0, 0xc(%rsp)
testq %rdi, %rdi
je 0x55ef
leaq 0x10(%rsp), %rsi
movq $0x0, (%rsi)
movw $0x0, 0x8(%rsi)
movl $0x108c906, (%rsi)      # imm = 0x108C906
leaq 0xc(%rsp), %rcx
xorl %ebx, %ebx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x53f0
testl %eax, %eax
je 0x55f1
movzbl 0xc(%rsp), %ebx
jmp 0x55f1
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x8(%rsp), %rsi
movq $0x0, (%rsi)
movw $0x0, 0x8(%rsi)
movw $0xc906, (%rsi)         # imm = 0xC906
movb %dl, 0x2(%rsi)
movb %r9b, 0x3(%rsi)
xorl %r8d, %r8d
callq 0x53f0
addq $0x18, %rsp
retq