LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_ct.cpp
// Function: wh_printf(char const*, ...)
void wh_printf(const char *fmt, ...)
{
	if (!g_show_extra_info)
		return;
	
	va_list args;
	va_start(args, fmt);
	vprintf(fmt, args);
	va_end(args);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
testb %al, %al
je 0x2515
movaps %xmm0, -0xa0(%rbp)
movaps %xmm1, -0x90(%rbp)
movaps %xmm2, -0x80(%rbp)
movaps %xmm3, -0x70(%rbp)
movaps %xmm4, -0x60(%rbp)
movaps %xmm5, -0x50(%rbp)
movaps %xmm6, -0x40(%rbp)
movaps %xmm7, -0x30(%rbp)
movq %r9, -0xa8(%rbp)
movq %r8, -0xb0(%rbp)
movq %rcx, -0xb8(%rbp)
movq %rdx, -0xc0(%rbp)
movq %rsi, -0xc8(%rbp)
movq %rdi, -0x8(%rbp)
cmpl $0x0, 0x12e31(%rip)     # 0x15374
jne 0x2547
jmp 0x257c
leaq -0x20(%rbp), %rax
leaq -0xd0(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x8, (%rax)
movq -0x8(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x21b0
leaq -0x20(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_ct.cpp
// Function: check_privilege()
int check_privilege()
{
	uid_t uid = getuid();
	uid_t euid = geteuid();

	if (uid == 0 || euid == 0)
		return 1;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
callq 0x20f0
movl %eax, -0x8(%rbp)
callq 0x2120
movl %eax, -0xc(%rbp)
cmpl $0x0, -0x8(%rbp)
je 0x2634
cmpl $0x0, -0xc(%rbp)
jne 0x263d
movl $0x1, -0x4(%rbp)
jmp 0x2644
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_ct.cpp
// Function: check_file(char*)
int check_file(char* filename)
{
	FILE*	p_file = 0;

	p_file = fopen(filename, "r");

	if (p_file) {
		
		/* file existed */
		fclose(p_file);
		return 1;		
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xe557(%rip), %rsi      # 0x10bc6
callq 0x21d0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x2691
movq -0x18(%rbp), %rdi
callq 0x21a0
movl $0x1, -0x4(%rbp)
jmp 0x2698
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_dev_exec_report_type_write(WdtDevice*, unsigned char, unsigned char*, int)
int wh_w8755_dev_exec_report_type_write(WDT_DEV* pdev, BYTE type, BYTE *pbuf, int size)
{
	W8755_WRITE_DATA write_data;

	if (!pdev || !pbuf)
		return 0;

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

	write_data.DD.rpt_id = W8755_RPTID_WRITE_DATA;
	write_data.DD.type = type;
	write_data.DD.size = size;

	memcpy(&write_data.DD.data[0], pbuf, size);

	if (g_func_dev_basic.p_wh_set_feature)
		return g_func_dev_basic.p_wh_set_feature(pdev, write_data.buffer, 4 + write_data.DD.size);		

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x2b17
cmpq $0x0, -0x20(%rbp)
jne 0x2b20
movl $0x0, -0x4(%rbp)
jmp 0x2b84
leaq -0x64(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x2110
movb $0x8, -0x64(%rbp)
movb -0x11(%rbp), %al
movb %al, -0x63(%rbp)
movl -0x24(%rbp), %eax
movw %ax, -0x62(%rbp)
leaq -0x64(%rbp), %rdi
addq $0x4, %rdi
movq -0x20(%rbp), %rsi
movslq -0x24(%rbp), %rdx
callq 0x2150
cmpq $0x0, 0x1281a(%rip)     # 0x15378
je 0x2b7d
movq 0x12811(%rip), %rax     # 0x15378
movq -0x10(%rbp), %rdi
leaq -0x64(%rbp), %rsi
movzwl -0x62(%rbp), %edx
addl $0x4, %edx
callq *%rax
movl %eax, -0x4(%rbp)
jmp 0x2b84
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_dev_exec_set_report_read(WdtDevice*, unsigned char, unsigned char*, int)
int wh_w8755_dev_exec_set_report_read(WDT_DEV* pdev, BYTE type, BYTE *pbuf, int size)
{
	W8755_WRITE_DATA write_data;

	if (!pdev || !pbuf || !g_func_dev_basic.p_wh_set_feature)
		return 0;

	write_data.DD.rpt_id = W8755_RPTID_REQ_READ;	
	write_data.DD.type = type;
	write_data.DD.size = size;
	
	return g_func_dev_basic.p_wh_set_feature(pdev, write_data.buffer, 4);	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x2bc1
cmpq $0x0, -0x20(%rbp)
je 0x2bc1
cmpq $0x0, 0x127b9(%rip)     # 0x15378
jne 0x2bca
movl $0x0, -0x4(%rbp)
jmp 0x2bf4
movb $0x6, -0x64(%rbp)
movb -0x11(%rbp), %al
movb %al, -0x63(%rbp)
movl -0x24(%rbp), %eax
movw %ax, -0x62(%rbp)
movq 0x12796(%rip), %rax     # 0x15378
movq -0x10(%rbp), %rdi
leaq -0x64(%rbp), %rsi
movl $0x4, %edx
callq *%rax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_dev_exec_get_report_read(WdtDevice*, unsigned char, unsigned char*, int)
int wh_w8755_dev_exec_get_report_read(WDT_DEV* pdev, BYTE type, BYTE *pbuf, int size)
{
	W8755_READ_DATA read_data;
	int retval;
	UINT32 read_checksum, calc_checksum;
	
	if (!pdev || !pbuf || !g_func_dev_basic.p_wh_get_feature)
		return 0;

	memset(&read_data.buffer[0], 0xff, 4);
	memset(&read_data.buffer[4], 0, 60);
			
	read_data.DD.rpt_id = W8755_RPTID_READ_DATA;
	read_data.DD.type = type;
	retval = g_func_dev_basic.p_wh_get_feature(pdev, read_data.buffer, 64);
	if (!retval)
		return 0;

	if (read_data.DD.rpt_id != W8755_RPTID_READ_DATA) {
		wh_printf("%s: wrong rpt_id\n", __func__);
		return 0;
	}
		
	read_checksum = read_data.DD.checksum;
	calc_checksum = 0;
	for (int i=0; i<60; i++)
		calc_checksum += read_data.DD.data[i];
		
	if (read_checksum != calc_checksum) {
		wh_printf("%s: wrong chksum\n", __func__);
		return 0;
	}
	
	memcpy(pbuf, read_data.DD.data, size);
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x2c34
cmpq $0x0, -0x20(%rbp)
je 0x2c34
cmpq $0x0, 0x1274e(%rip)     # 0x15380
jne 0x2c40
movl $0x0, -0x4(%rbp)
jmp 0x2d3a
leaq -0x64(%rbp), %rdi
movl $0xff, %esi
movl $0x4, %edx
callq 0x2110
leaq -0x64(%rbp), %rdi
addq $0x4, %rdi
xorl %esi, %esi
movl $0x3c, %edx
callq 0x2110
movb $0x7, -0x64(%rbp)
movb -0x11(%rbp), %al
movb %al, -0x63(%rbp)
movq 0x12708(%rip), %rax     # 0x15380
movq -0x10(%rbp), %rdi
leaq -0x64(%rbp), %rsi
movl $0x40, %edx
callq *%rax
movl %eax, -0x68(%rbp)
cmpl $0x0, -0x68(%rbp)
jne 0x2c9c
movl $0x0, -0x4(%rbp)
jmp 0x2d3a
movzbl -0x64(%rbp), %eax
cmpl $0x7, %eax
je 0x2cc3
leaq 0xc7cc(%rip), %rdi      # 0xf478
leaq 0xc7d7(%rip), %rsi      # 0xf48a
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0x2d3a
movzwl -0x62(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl $0x0, -0x70(%rbp)
movl $0x0, -0x74(%rbp)
cmpl $0x3c, -0x74(%rbp)
jge 0x2cf8
movslq -0x74(%rbp), %rax
movzbl -0x60(%rbp,%rax), %eax
addl -0x70(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x2cd8
movl -0x6c(%rbp), %eax
cmpl -0x70(%rbp), %eax
je 0x2d1e
leaq 0xc7a5(%rip), %rdi      # 0xf4ac
leaq 0xc77c(%rip), %rsi      # 0xf48a
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0x2d3a
movq -0x20(%rbp), %rdi
leaq -0x64(%rbp), %rsi
addq $0x4, %rsi
movslq -0x24(%rbp), %rdx
callq 0x2150
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_dev_exec_report_type_read(WdtDevice*, unsigned char, unsigned char*, int, int)
int wh_w8755_dev_exec_report_type_read(WDT_DEV* pdev, BYTE type, BYTE *pbuf, int size, int offset)
{
	int retval;
	int i_size;

	if (offset & TYPE_READ_OFFSET_SET)
		i_size = offset & 0xFF;
	else
		i_size = size;

	retval = wh_w8755_dev_exec_set_report_read(pdev, type, pbuf, i_size);
	if (!retval)
		return 0;

	return wh_w8755_dev_exec_get_report_read(pdev, type, pbuf, size);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movl -0x28(%rbp), %eax
andl $0x10000, %eax          # imm = 0x10000
cmpl $0x0, %eax
je 0x2d87
movl -0x28(%rbp), %eax
andl $0xff, %eax
movl %eax, -0x30(%rbp)
jmp 0x2d8d
movl -0x24(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movb -0x11(%rbp), %al
movq -0x20(%rbp), %rdx
movl -0x30(%rbp), %ecx
movzbl %al, %esi
callq 0x2b90
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x2db5
movl $0x0, -0x4(%rbp)
jmp 0x2dce
movq -0x10(%rbp), %rdi
movb -0x11(%rbp), %al
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
movzbl %al, %esi
callq 0x2c00
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_dev_get_new_device_info(WdtDevice*, unsigned char*, int, int)
int wh_w8755_dev_get_new_device_info(WDT_DEV* pdev, BYTE *pbuf, int offset, int size)
{
	BYTE buf[64];
	
	if (wh_w8755_dev_exec_report_type_read(pdev, W8755_FW_GET_DEVICE_INFO, buf, 32, TYPE_READ_OFFSET_SET | offset)) {
		memcpy(pbuf, &buf[0], size);
		return 1;
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rdx
movl -0x1c(%rbp), %r8d
orl $0x10000, %r8d          # imm = 0x10000
movl $0x73, %esi
movl $0x20, %ecx
callq 0x2d50
cmpl $0x0, %eax
je 0x2e37
movq -0x18(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movslq -0x20(%rbp), %rdx
callq 0x2150
movl $0x1, -0x4(%rbp)
jmp 0x2e3e
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_dev_flash_write_data(WdtDevice*, unsigned char*, unsigned int, int)
int wh_w8755_dev_flash_write_data(WDT_DEV* pdev, BYTE* pdata, UINT32 start_addr, int size)
{
	int retval = 0;
	unsigned int	write_base;
	unsigned int	write_size;

	write_base = 0x100;

	if (start_addr & 0xFF) {
		unsigned int 	size_partial;
		size_partial = write_base - (start_addr & 0xFF);
		
		WRITE_FLASH_PAGE(size_partial);			
	}

	while (size) {
		if ((start_addr & 0xfff) == 0)
			printf("base addr: 0x%x\n", start_addr);
	
		WRITE_FLASH_PAGE(write_base);			
	}

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x100, -0x28(%rbp)     # imm = 0x100
movl -0x1c(%rbp), %eax
andl $0xff, %eax
cmpl $0x0, %eax
je 0x3056
movl -0x28(%rbp), %eax
movl -0x1c(%rbp), %ecx
andl $0xff, %ecx
subl %ecx, %eax
movl %eax, -0x30(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x30(%rbp), %eax
jle 0x300b
movl -0x30(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x20(%rbp), %eax
subl -0x30(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x3018
movl -0x20(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl -0x2c(%rbp), %ecx
callq 0x2e50
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x303f
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x30ed
movq -0x18(%rbp), %rax
movl -0x30(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movl -0x1c(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x3058
cmpl $0x0, -0x20(%rbp)
je 0x30e6
movl -0x1c(%rbp), %eax
andl $0xfff, %eax            # imm = 0xFFF
cmpl $0x0, %eax
jne 0x3080
movl -0x1c(%rbp), %esi
leaq 0xc45c(%rip), %rdi      # 0xf4d5
movb $0x0, %al
callq 0x2050
movl -0x20(%rbp), %eax
cmpl -0x28(%rbp), %eax
jle 0x3099
movl -0x28(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x20(%rbp), %eax
subl -0x28(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x30a6
movl -0x20(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl -0x2c(%rbp), %ecx
callq 0x2e50
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x30ca
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x30ed
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movl -0x1c(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x3058
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_dev_enable_spi_flash_protection(WdtDevice*, int)
int wh_w8755_dev_enable_spi_flash_protection(WDT_DEV* pdev, int protect)
{
	if (protect) {
		int retval = wh_w8755_dev_send_commands(pdev, WH_CMD_FLASH_PROTECTION_ON, 0);
			
		wh_sleep(20);
		return retval;
	}	
	else
	{
		if (wh_w8755_dev_send_commands(pdev, WH_CMD_FLASH_PROTECTION_OFF, 0)) {
			wh_sleep(20);

			return 1;
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x34ca
movq -0x10(%rbp), %rdi
movl $0x16, %esi
xorl %edx, %edx
callq 0x3100
movl %eax, -0x18(%rbp)
movl $0x14, %edi
callq 0x2590
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x34fb
movq -0x10(%rbp), %rdi
movl $0x17, %esi
xorl %edx, %edx
callq 0x3100
cmpl $0x0, %eax
je 0x34f2
movl $0x14, %edi
callq 0x2590
movl $0x1, -0x4(%rbp)
jmp 0x34fb
jmp 0x34f4
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_dev_read_flash_status_register(WdtDevice*, unsigned int*)
unsigned int wh_w8755_dev_read_flash_status_register(WDT_DEV* pdev, unsigned int *pdata)
{
	BYTE				buf[64];

	*pdata = 0xff;

 	if (!wh_w8755_dev_exec_report_type_read(pdev, W8755_ISP_GET_FLASH_STATUS, buf, DataPayloadSize, 0)) {
		wh_printf("%s: report type read error\n", __func__);
		return 0;
	}

	*pdata = (unsigned int) buf[0];

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl $0xff, (%rax)
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rdx
movl $0x64, %esi
movl $0x3c, %ecx
xorl %r8d, %r8d
callq 0x2d50
cmpl $0x0, %eax
jne 0x36b7
leaq 0xbe71(%rip), %rdi      # 0xf511
leaq 0xbe86(%rip), %rsi      # 0xf52d
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0x36c8
movzbl -0x60(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_dev_write_flash_status_register(WdtDevice*, unsigned int)
unsigned int wh_w8755_dev_write_flash_status_register(WDT_DEV* pdev, unsigned int r)
{
	BYTE				data;
	unsigned int		result;
	int					timeout_count = 0;
	
	data = (BYTE) (r & 0xff);

	if (!wh_w8755_dev_exec_report_type_write(pdev, W8755_ISP_SET_FLASH_STATUS, &data, 1)) {
		wh_printf("%s: report type write error\n", __func__);
		return 0;
	}

	/* timeout should be limit to 1 second */
	result = 0xFF;
	while ((result & 0x01) && (timeout_count < 100) ) {
		wh_w8755_dev_read_flash_status_register(pdev, &result);
		wh_printf("count: %d, (%d)\n", timeout_count, result);
		wh_sleep(10);
		timeout_count ++;
	}

	if (timeout_count >= 100)
		wh_printf("%s: error in timeout !\n", __func__);

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x14(%rbp), %eax
andl $0xff, %eax
movb %al, -0x15(%rbp)
movq -0x10(%rbp), %rdi
movl $0x84, %esi
leaq -0x15(%rbp), %rdx
movl $0x1, %ecx
callq 0x2af0
cmpl $0x0, %eax
jne 0x373e
leaq 0xbe31(%rip), %rdi      # 0xf555
leaq 0xbe47(%rip), %rsi      # 0xf572
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0x37c0
movl $0xff, -0x1c(%rbp)
movl -0x1c(%rbp), %ecx
andl $0x1, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x21(%rbp)
je 0x375f
cmpl $0x64, -0x20(%rbp)
setl %al
movb %al, -0x21(%rbp)
movb -0x21(%rbp), %al
testb $0x1, %al
jne 0x3768
jmp 0x379e
movq -0x10(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x3660
movl -0x20(%rbp), %esi
movl -0x1c(%rbp), %edx
leaq 0xbe19(%rip), %rdi      # 0xf59b
movb $0x0, %al
callq 0x24e0
movl $0xa, %edi
callq 0x2590
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x3745
cmpl $0x64, -0x20(%rbp)
jl 0x37b9
leaq 0xbe01(%rip), %rdi      # 0xf5ac
leaq 0xbdc0(%rip), %rsi      # 0xf572
movb $0x0, %al
callq 0x24e0
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_dev_flash_get_checksum(WdtDevice*, unsigned int*, unsigned int, int)
int wh_w8755_dev_flash_get_checksum(WDT_DEV* pdev, UINT32* pchecksum, UINT32 address, int size)
{
	BYTE			buf[64];
	unsigned int	checksum;
	int				delay;	

	put_unaligned_le32(address, &buf[0]);
	put_unaligned_le32(size, &buf[4]);
	
	if (!wh_w8755_dev_exec_report_type_write(pdev, W8755_ISP_SET_CHECKSUM_CALC, buf, 8)) {
		printf("%s: report type write error!\n", __func__);
		return 0;
	}

	delay = (size + 1023) / 1024;
	delay = wh_w8755_i2c_delay(pdev, delay * 4);
	wh_printf("chksum delay: %d ms\n", delay);

	if (!wh_w8755_dev_exec_report_type_read(pdev, W8755_ISP_GET_CHECKSUM, buf, DataPayloadSize, 0)) {
		wh_printf("%s: report type read chksum error!\n", __func__);
		return 0;
	}

	checksum = get_unaligned_le16(buf);
	*pchecksum = checksum;

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl -0x1c(%rbp), %edi
leaq -0x60(%rbp), %rsi
callq 0x9200
movl -0x20(%rbp), %edi
leaq -0x60(%rbp), %rsi
addq $0x4, %rsi
callq 0x9200
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rdx
movl $0x88, %esi
movl $0x8, %ecx
callq 0x2af0
cmpl $0x0, %eax
jne 0x39df
leaq 0xbc7f(%rip), %rdi      # 0xf644
leaq 0xbc96(%rip), %rsi      # 0xf662
movb $0x0, %al
callq 0x2050
movl $0x0, -0x4(%rbp)
jmp 0x3a74
movl -0x20(%rbp), %eax
addl $0x3ff, %eax            # imm = 0x3FF
movl $0x400, %ecx            # imm = 0x400
cltd
idivl %ecx
movl %eax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
movl -0x68(%rbp), %eax
shll $0x2, %eax
movslq %eax, %rsi
callq 0x3510
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %esi
leaq 0xbc71(%rip), %rdi      # 0xf682
movb $0x0, %al
callq 0x24e0
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rdx
movl $0x65, %esi
movl $0x3c, %ecx
xorl %r8d, %r8d
callq 0x2d50
cmpl $0x0, %eax
jne 0x3a55
leaq 0xbc59(%rip), %rdi      # 0xf697
leaq 0xbc1d(%rip), %rsi      # 0xf662
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0x3a74
leaq -0x60(%rbp), %rdi
callq 0x9140
movzwl %ax, %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_dev_parse_new_dev_info(WdtDevice*, WeidaDeviceInfoNew*)
int wh_w8755_dev_parse_new_dev_info(WDT_DEV* pdev, W8755_DEV_INFO_NEW *pdev_info_new)
{
	BYTE	buffer[32];
	int	retval;

	retval = wh_w8755_dev_get_new_device_info(pdev, buffer, 0, 32);
	if (!retval)
		return 0;
	
	pdev_info_new->protocol_version = get_unaligned_le32(&buffer[0x00]);
	pdev_info_new->firmware_id = get_unaligned_le32(&buffer[0x04]);
	pdev_info_new->status = get_unaligned_le32(&buffer[0x08]);
	pdev_info_new->config_size = get_unaligned_le16(&buffer[0x10]);
	pdev_info_new->parameter_map_sum = get_unaligned_le16(&buffer[0x12]);
	pdev_info_new->firmware_revision = get_unaligned_le16(&buffer[0x14]);
	pdev_info_new->max_points = buffer[0x16];
	pdev_info_new->bytes_per_point = buffer[0x16];
	pdev_info_new->customer_config_id = get_unaligned_le32(&buffer[0x18]);

	pdev_info_new->boot_partition = W8755_BP_DEFAULT;
	if (pdev_info_new->protocol_version >= 0x01010000) {
		if (buffer[0x001E] == 0xB1)
			pdev_info_new->boot_partition = W8755_BP_PRIMARY;
		else if (buffer[0x001E] == 0xB2)
			pdev_info_new->boot_partition = W8755_BP_SECONDARY;
	}	



	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x40(%rbp), %rsi
xorl %edx, %edx
movl $0x20, %ecx
callq 0x2de0
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0x3ab9
movl $0x0, -0x4(%rbp)
jmp 0x3bb7
leaq -0x40(%rbp), %rdi
callq 0x9170
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
leaq -0x40(%rbp), %rdi
addq $0x4, %rdi
callq 0x9170
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4(%rax)
leaq -0x40(%rbp), %rdi
addq $0x8, %rdi
callq 0x9170
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
leaq -0x40(%rbp), %rdi
addq $0x10, %rdi
callq 0x9140
movzwl %ax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xc(%rax)
leaq -0x40(%rbp), %rdi
addq $0x12, %rdi
callq 0x9140
movzwl %ax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x10(%rax)
leaq -0x40(%rbp), %rdi
addq $0x14, %rdi
callq 0x9140
movzwl %ax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x14(%rax)
movzbl -0x2a(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x18(%rax)
movzbl -0x2a(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x1c(%rax)
leaq -0x40(%rbp), %rdi
addq $0x18, %rdi
callq 0x9170
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x24(%rax)
movq -0x18(%rbp), %rax
cmpl $0x1010000, (%rax)      # imm = 0x1010000
jb 0x3bb0
movzbl -0x22(%rbp), %eax
cmpl $0xb1, %eax
jne 0x3b96
movq -0x18(%rbp), %rax
movl $0x1, 0x24(%rax)
jmp 0x3bae
movzbl -0x22(%rbp), %eax
cmpl $0xb2, %eax
jne 0x3bac
movq -0x18(%rbp), %rax
movl $0x2, 0x24(%rax)
jmp 0x3bae
jmp 0x3bb0
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
// File: chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_dev_verify_chunk_by_read_checksum(WdtDevice*, ChunkInfoEx*)
int wh_w8755_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_w8755_dev_send_commands(pdev, WH_CMD_ALGO_STOP, 0);
	if (!retval)
		return retval;
		
	printf("Calculating checksum...\n");
	
	bin_checksum = misr_for_bytes(0, pChunk->pData, 0, pChunk->chuckInfo.length);

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

	if (bin_checksum != read_checksum) {
		printf("Checksum mismatch!!! Original=0x%x, Flash checksum=0x%x", bin_checksum, read_checksum);
		result = 0;
	}
	
	retval = wh_w8755_dev_send_commands(pdev, WH_CMD_ALGO_START, 0);
	if (!retval)
		return retval;
		
	return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x1, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x3100
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x3ef2
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3f93
leaq 0xb851(%rip), %rdi      # 0xf74a
movb $0x0, %al
callq 0x2050
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
xorl %edx, %edx
movl %edx, %edi
callq 0xb780
movzwl %ax, %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %edx
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
leaq -0x28(%rbp), %rsi
callq 0x3970
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x3f49
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3f93
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
je 0x3f6c
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
leaq 0xb805(%rip), %rdi      # 0xf763
movb $0x0, %al
callq 0x2050
movl $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movl $0x3, %esi
xorl %edx, %edx
callq 0x3100
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x3f8d
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3f93
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_dev_program_chunk_verify(WdtDevice*, ChunkInfoEx*, int)
int wh_w8755_dev_program_chunk_verify(WDT_DEV* pdev, CHUNK_INFO_EX* pInputChunk, int option)
{
	int retval = 0;
	int ret = 0;

	CHUNK_INFO_EX	*pChunk = pInputChunk;
	FUNC_PTR_STRUCT_DEV_OPERATION funcs;

	memset(&funcs, 0, sizeof(FUNC_PTR_STRUCT_DEV_OPERATION));	

	retval = wh_w8755_dev_send_commands(pdev, WH_CMD_ALGO_STOP, 0);
	if (!retval)
		return retval;
		
	retval = wh_w8755_dev_send_commands(pdev, WH_CMD_FLASH_UNLOCK, 0);
	if (!retval)
		return retval;

	retval = wh_w8755_dev_flash_erase(pdev, pChunk->chuckInfo.targetStartAddr, pChunk->chuckInfo.length);
	if (!retval)
		goto chunk_exit;
		
	printf("Chunk program begin ...\n");
	retval = wh_w8755_dev_flash_write_data(pdev, pChunk->pData, pChunk->chuckInfo.targetStartAddr, pChunk->chuckInfo.length);
	if (!retval)
		goto chunk_exit;
	printf("Chunk program end...\n");

	if (wh_w8755_dev_verify_chunk(pdev, pInputChunk) <= 0) {
		printf("Checksum failed\n");
		goto chunk_exit;
	}
		
chunk_exit:
	ret = wh_w8755_dev_send_commands(pdev, WH_CMD_FLASH_LOCK, 0);
	if (!ret)
		return ret;
	
	ret = wh_w8755_dev_send_commands(pdev, WH_CMD_ALGO_START, 0);
	if (!ret)
		return ret;
		
	return retval;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x2110
movq -0x10(%rbp), %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x3100
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jne 0x3ffd
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x40f3
movq -0x10(%rbp), %rdi
movl $0x11, %esi
xorl %edx, %edx
callq 0x3100
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jne 0x4021
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x40f3
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movl (%rax), %esi
movq -0x30(%rbp), %rax
movl 0x4(%rax), %edx
callq 0x37d0
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jne 0x4042
jmp 0x40ab
leaq 0xb752(%rip), %rdi      # 0xf79b
movb $0x0, %al
callq 0x2050
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x30(%rbp), %rax
movl (%rax), %edx
movq -0x30(%rbp), %rax
movl 0x4(%rax), %ecx
callq 0x2fb0
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jne 0x4079
jmp 0x40ab
leaq 0xb734(%rip), %rdi      # 0xf7b4
movb $0x0, %al
callq 0x2050
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4100
cmpl $0x0, %eax
jg 0x40a9
leaq 0xb72a(%rip), %rdi      # 0xf7ca
movb $0x0, %al
callq 0x2050
jmp 0x40ab
jmp 0x40ab
movq -0x10(%rbp), %rdi
movl $0x10, %esi
xorl %edx, %edx
callq 0x3100
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x40cc
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x40f3
movq -0x10(%rbp), %rdi
movl $0x3, %esi
xorl %edx, %edx
callq 0x3100
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x40ed
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x40f3
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_dev_program_chunk(WdtDevice*, ChunkInfoEx*, int)
int wh_w8755_dev_program_chunk(WDT_DEV* pdev, CHUNK_INFO_EX* pInputChunk, int option)
{
	if (!pdev)
		return 0;
	
	if (pdev->pparam->argus & OPTION_BLOCK)
		return wh_w8755_dev_program_chunk_verify(pdev, pInputChunk, option);
	else
		return wh_w8755_dev_program_4k_chunk_verify(pdev, pInputChunk, option);

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x4163
movl $0x0, -0x4(%rbp)
jmp 0x41a2
movq -0x10(%rbp), %rax
movq 0x280(%rax), %rax
movl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x418f
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0x3fa0
movl %eax, -0x4(%rbp)
jmp 0x41a2
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0x3bc0
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_dev_set_feature(WdtDevice*, unsigned char*, unsigned int)
int wh_w8755_dev_set_feature(WDT_DEV* pdev, BYTE* buf, UINT32 buf_size)
{
	int ret = 0;
	
	if (!pdev)
		return 0;

	if (pdev->intf_index == INTERFACE_I2C) {
		ret = wh_i2c_set_feature(pdev, buf, buf_size);	
		return ret;
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x41da
movl $0x0, -0x4(%rbp)
jmp 0x4205
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x41fe
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0xd160
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4205
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop
// File: chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_dev_get_feature(WdtDevice*, unsigned char*, unsigned int)
int wh_w8755_dev_get_feature(WDT_DEV* pdev, BYTE* buf, UINT32 buf_size)
{
	int ret = 0;

	if (!pdev)
		return 0;

	if (pdev->intf_index == INTERFACE_I2C) {
		ret = wh_i2c_get_feature(pdev, buf, buf_size);		
		return ret;
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x423a
movl $0x0, -0x4(%rbp)
jmp 0x4265
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x425e
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0xca10
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4265
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop
// File: chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_dev_read_report(WdtDevice*, unsigned char*, unsigned int)
int wh_w8755_dev_read_report(WDT_DEV* pdev, BYTE* buf, UINT32 buf_size)
{
	if (!pdev)
		return 0;

	if (pdev->intf_index == INTERFACE_I2C)
		return wh_i2c_read(pdev, buf, buf_size);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x4293
movl $0x0, -0x4(%rbp)
jmp 0x42b8
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x42b1
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0xd4a0
movl %eax, -0x4(%rbp)
jmp 0x42b8
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_dev_set_basic_op(WdtDevice*)
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
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x42e8
movl $0x0, -0x4(%rbp)
jmp 0x4319
leaq -0xdf(%rip), %rax       # 0x4210
movq %rax, 0x1108a(%rip)     # 0x15380
leaq -0x14d(%rip), %rax      # 0x41b0
movq %rax, 0x11074(%rip)     # 0x15378
leaq -0x9b(%rip), %rax       # 0x4270
movq %rax, 0x1107e(%rip)     # 0x15390
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nop
// File: chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_dev_flash_read_data(WdtDevice*, unsigned char*, unsigned int, int)
int wh_w8755_dev_flash_read_data(WDT_DEV* pdev, BYTE* data, UINT32 address, int length)
{
	int		addr_start, data_len, packet_size;
	BYTE*	 psource_data = 0;
	int		count = 0;
	int		retval = 1;

	if (!pdev || !data)
		return 0;

	// address and length should be align to 4
	if ((address & 0x3) != 0 || (length & 0x3) != 0)
		return 0;

	data_len = length;
	addr_start = address;
	psource_data = data;

	packet_size = W8755_PACKET_SIZE;

	retval = wh_w8755_dev_exec_report_type_write(pdev, W8755_ISP_SET_FLASH_ADDRESS, (BYTE *) &addr_start, 4);
	if (!retval)
		return 0;

	while(data_len)	{
		if (data_len < W8755_PACKET_SIZE)
			packet_size = data_len;

		if (!wh_w8755_dev_exec_report_type_read(pdev, W8755_ISP_GET_FLASH, psource_data, packet_size, 0)) {
			wh_printf("can't get flash: 0x%x\n", addr_start);
			break;
		}

		data_len = data_len - packet_size;
		psource_data = psource_data + packet_size;
		addr_start = addr_start + packet_size;

		wh_sleep(1);
		count++;
	}

	return retval;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movq $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x1, -0x40(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x435a
cmpq $0x0, -0x18(%rbp)
jne 0x4366
movl $0x0, -0x4(%rbp)
jmp 0x444f
movl -0x1c(%rbp), %eax
andl $0x3, %eax
cmpl $0x0, %eax
jne 0x437c
movl -0x20(%rbp), %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x4388
movl $0x0, -0x4(%rbp)
jmp 0x444f
movl -0x20(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x3c, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
movl $0x87, %esi
leaq -0x24(%rbp), %rdx
movl $0x4, %ecx
callq 0x2af0
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
jne 0x43cf
movl $0x0, -0x4(%rbp)
jmp 0x444f
jmp 0x43d1
cmpl $0x0, -0x28(%rbp)
je 0x4449
cmpl $0x3c, -0x28(%rbp)
jge 0x43e3
movl -0x28(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rdx
movl -0x2c(%rbp), %ecx
movl $0x63, %esi
xorl %r8d, %r8d
callq 0x2d50
cmpl $0x0, %eax
jne 0x4413
movl -0x24(%rbp), %esi
leaq 0xb3d1(%rip), %rdi      # 0xf7db
movb $0x0, %al
callq 0x24e0
jmp 0x4449
movl -0x28(%rbp), %eax
subl -0x2c(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0x38(%rbp), %rax
movslq -0x2c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x24(%rbp), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x24(%rbp)
movl $0x1, %edi
callq 0x2590
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x43d1
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8755_funcs.cpp
// Function: wh_w8755_prepare_data(WdtDevice*, BoardInfo*, int)
int wh_w8755_prepare_data(WDT_DEV* pdev, BOARD_INFO* pboard_info, int maybe_isp)
{
	 /* initialize the basic function for handling the following operations */
        if(!wh_w8755_dev_set_basic_op(pdev)) {
		wh_printf("pdev is null \n");
		return 0;
	}

        if (!wh_w8755_dev_parse_new_dev_info(pdev, &pboard_info->dev_info.w8755_dev_info)) {
                wh_printf("Can't get new device info!\n");
		wh_w8755_dev_set_device_mode(pdev, W8755_DM_SENSING);
                return 0;
        }

	memcpy(&pdev->board_info.dev_info.w8755_dev_info, &pboard_info->dev_info.w8755_dev_info, sizeof(W8755_DEV_INFO_NEW));

	if (!wh_w8755_dev_read_flash_map(pdev, pboard_info)) {
                 wh_printf("Can't get address table!\n");
                 return 0;
         }


        return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x42d0
cmpl $0x0, %eax
jne 0x46eb
leaq 0xb11a(%rip), %rdi      # 0xf7f2
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0x4777
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x70, %rsi
callq 0x3a80
cmpl $0x0, %eax
jne 0x4726
leaq 0xb0f9(%rip), %rdi      # 0xf801
movb $0x0, %al
callq 0x24e0
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x3420
movl $0x0, -0x4(%rbp)
jmp 0x4777
movq -0x10(%rbp), %rdi
addq $0x188, %rdi            # imm = 0x188
addq $0x70, %rdi
movq -0x18(%rbp), %rsi
addq $0x70, %rsi
movl $0x28, %edx
callq 0x2150
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4460
cmpl $0x0, %eax
jne 0x4770
leaq 0xb0bd(%rip), %rdi      # 0xf81d
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0x4777
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
// File: 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:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x479e
cmpq $0x0, -0x18(%rbp)
jne 0x47aa
movl $0x0, -0x4(%rbp)
jmp 0x4898
movq -0x18(%rbp), %rdi
addq $0x1, %rdi
callq 0x9170
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rdi
addq $0x5, %rdi
callq 0x9170
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x18(%rbp), %rdi
addq $0x9, %rdi
callq 0x9170
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rax
movb 0xd(%rax), %cl
movq -0x10(%rbp), %rax
movb %cl, 0xc(%rax)
movq -0x18(%rbp), %rax
movb 0xe(%rax), %cl
movq -0x10(%rbp), %rax
movb %cl, 0xd(%rax)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq %rcx, 0xf(%rax)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq %rcx, 0x17(%rax)
movq -0x18(%rbp), %rax
movb 0x20(%rax), %cl
movq -0x10(%rbp), %rax
movb %cl, 0x1f(%rax)
movq -0x18(%rbp), %rax
movb 0x21(%rax), %cl
movq -0x10(%rbp), %rax
movb %cl, 0x20(%rax)
movq -0x18(%rbp), %rdi
addq $0x22, %rdi
callq 0x9140
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x21(%rax)
movq -0x18(%rbp), %rdi
addq $0x24, %rdi
callq 0x9140
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x23(%rax)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movl 0x26(%rcx), %ecx
movl %ecx, 0x25(%rax)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x2a(%rcx), %rcx
movq %rcx, 0x29(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_read_report(WdtDevice*, unsigned char*, unsigned int)
int wh_w8760_dev_read_report(WDT_DEV* pdev, BYTE* buf, UINT32 buf_size)
{
	if (!pdev)
		return 0;
	
	if (pdev->intf_index == INTERFACE_I2C)
		return wh_i2c_read(pdev, buf, buf_size);	
	
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x48d3
movl $0x0, -0x4(%rbp)
jmp 0x48f8
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x48f1
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0xd4a0
movl %eax, -0x4(%rbp)
jmp 0x48f8
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: 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:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x4936
movl $0x0, -0x4(%rbp)
jmp 0x49c9
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x6, %eax
je 0x494e
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xd, %eax
jne 0x4957
movl $0xa, -0x1c(%rbp)
jmp 0x49a4
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x7, %eax
je 0x497b
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xe, %eax
je 0x497b
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xb, %eax
jne 0x4984
movl $0x40, -0x1c(%rbp)
jmp 0x49a2
movq -0x18(%rbp), %rax
movzbl (%rax), %esi
leaq 0xaf3c(%rip), %rdi      # 0xf8ce
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0x49c9
jmp 0x49a4
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x49c2
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0xd160
movl %eax, -0x4(%rbp)
jmp 0x49c9
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: 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:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x4a06
movl $0x0, -0x4(%rbp)
jmp 0x4aa7
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x6, %eax
je 0x4a1e
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xd, %eax
jne 0x4a27
movl $0xa, -0x1c(%rbp)
jmp 0x4a82
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x7, %eax
je 0x4a59
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xe, %eax
je 0x4a59
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xb, %eax
je 0x4a59
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xf2, %eax
jne 0x4a62
movl $0x40, -0x1c(%rbp)
jmp 0x4a80
movq -0x18(%rbp), %rax
movzbl (%rax), %esi
leaq 0xae5e(%rip), %rdi      # 0xf8ce
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0x4aa7
jmp 0x4a82
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x4aa0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0xca10
movl %eax, -0x4(%rbp)
jmp 0x4aa7
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
// File: chenhn123[P]wdt_util_src/wdt_ct/w8760_funcs.cpp
// Function: wh_w8760_dev_set_basic_op(WdtDevice*)
int wh_w8760_dev_set_basic_op(WDT_DEV *pdev)
{
	if (!pdev)
		return 0;

	g_func_dev_basic.p_wh_get_feature = wh_w8760_dev_get_feature;
	g_func_dev_basic.p_wh_set_feature = wh_w8760_dev_set_feature;
	g_func_dev_basic.p_wh_read_report = wh_w8760_dev_read_report;

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x4ac8
movl $0x0, -0x4(%rbp)
jmp 0x4af9
leaq -0xef(%rip), %rax       # 0x49e0
movq %rax, 0x108ca(%rip)     # 0x153a0
leaq -0x1cd(%rip), %rax      # 0x4910
movq %rax, 0x108b4(%rip)     # 0x15398
leaq -0x23b(%rip), %rax      # 0x48b0
movq %rax, 0x108be(%rip)     # 0x153b0
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nop
// File: 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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movl %r9d, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %ecx
xorl %edx, %edx
callq 0x4b00
cmpl $0x0, %eax
jle 0x4bc2
cmpl $0x9, -0x30(%rbp)
jle 0x4b82
movb $0x7, -0x70(%rbp)
jmp 0x4b86
movb $0x6, -0x70(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x70(%rbp), %rsi
movl -0x30(%rbp), %edx
callq 0x49e0
cmpl $0x0, %eax
jle 0x4bc0
movq -0x28(%rbp), %rdi
movslq -0x2c(%rbp), %rax
addq %rax, %rdi
leaq -0x70(%rbp), %rsi
addq $0x1, %rsi
movslq -0x30(%rbp), %rdx
callq 0x2150
movl $0x1, -0x4(%rbp)
jmp 0x4bc9
jmp 0x4bc2
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: 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 %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movl -0x24(%rbp), %eax
imull -0x20(%rbp), %eax
movl %eax, -0x28(%rbp)
movb $0x6, -0x70(%rbp)
movl -0xc(%rbp), %eax
movb %al, -0x6f(%rbp)
movl -0x24(%rbp), %eax
movb %al, -0x6e(%rbp)
leaq -0x70(%rbp), %rdi
addq $0x3, %rdi
movq -0x18(%rbp), %rsi
movslq -0x1c(%rbp), %rax
addq %rax, %rsi
movslq -0x28(%rbp), %rdx
callq 0x2150
movq -0x8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
movl -0x28(%rbp), %ecx
addl $0x3, %ecx
xorl %edx, %edx
callq 0x4b00
addq $0x70, %rsp
popq %rbp
retq
nop
// File: 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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movl $0x3d, %eax
cltd
idivl -0x28(%rbp)
movl %eax, -0x30(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jl 0x4d2b
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
movl -0x34(%rbp), %ecx
movl -0x28(%rbp), %r8d
movl -0x30(%rbp), %r9d
callq 0x4c40
cmpl $0x0, %eax
jg 0x4d11
movl $0x0, -0x4(%rbp)
jmp 0x4d58
movl -0x30(%rbp), %eax
imull -0x28(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %ecx
movl -0x2c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x2c(%rbp)
jmp 0x4ce0
cmpl $0x0, -0x2c(%rbp)
jle 0x4d51
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
movl -0x34(%rbp), %ecx
movl -0x28(%rbp), %r8d
movl -0x2c(%rbp), %r9d
callq 0x4c40
movl %eax, -0x4(%rbp)
jmp 0x4d58
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)