LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: 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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl $0x1388, -0x1c(%rbp)    # imm = 0x1388
movl $0x5, -0x20(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x4d9c
movl -0x14(%rbp), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x18(%rbp)
je 0x4da8
movl -0x18(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x4daa
movq -0x10(%rbp), %rdi
leaq -0x28(%rbp), %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x4e30
cmpl $0x0, %eax
jg 0x4dcc
movl $0x0, -0x4(%rbp)
jmp 0x4e23
movzbl -0x28(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x4de7
movl $0x1, -0x4(%rbp)
jmp 0x4e23
movl -0x20(%rbp), %edi
callq 0x2590
movl -0x20(%rbp), %ecx
movl -0x1c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jg 0x4daa
movl -0x1c(%rbp), %edx
imull -0x20(%rbp), %edx
leaq 0xaae3(%rip), %rdi      # 0xf8f1
leaq 0xaaf7(%rip), %rsi      # 0xf90c
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: 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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movb $0x7, -0x16(%rbp)
movb $-0x1b, -0x15(%rbp)
movl -0xc(%rbp), %edi
leaq -0x16(%rbp), %rsi
addq $0x2, %rsi
callq 0x9200
leaq -0x16(%rbp), %rsi
addq $0x6, %rsi
xorl %edi, %edi
callq 0x9200
movq -0x8(%rbp), %rdi
leaq -0x16(%rbp), %rsi
xorl %edx, %edx
movl $0xa, %ecx
callq 0x4b00
addq $0x20, %rsp
popq %rbp
retq
// File: 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
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movw 0xa9af(%rip), %ax       # 0xf8c6
movw %ax, -0x1a(%rbp)
movq -0x18(%rbp), %rax
movw $0x20, (%rax)
movq -0x10(%rbp), %rdi
leaq -0x1a(%rbp), %rsi
leaq -0x1e(%rbp), %rcx
movl $0x2, %r9d
xorl %r8d, %r8d
movl %r9d, %edx
callq 0x4b40
cmpl $0x0, %eax
jg 0x4f4f
movl $0x0, -0x4(%rbp)
jmp 0x4f69
leaq -0x1e(%rbp), %rdi
callq 0x9140
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, (%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_set_device_mode(WdtDevice*, unsigned char)
int wh_w8760_dev_set_device_mode(WDT_DEV* pdev, BYTE mode)
{
	BYTE cmd[3];

	cmd[0] = W8760_COMMAND9;
	cmd[1] = W8760_SET_DEVICE_MODE;
	cmd[2] = mode;
	
	return wh_w8760_dev_command_write(pdev, cmd, 0, 3);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movb $0x6, -0xc(%rbp)
movb $-0x36, -0xb(%rbp)
movb -0x9(%rbp), %al
movb %al, -0xa(%rbp)
movq -0x8(%rbp), %rdi
leaq -0xc(%rbp), %rsi
xorl %edx, %edx
movl $0x3, %ecx
callq 0x4b00
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: 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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x501c
movl $0x0, -0x4(%rbp)
jmp 0x5048
movq -0x10(%rbp), %rdi
leaq -0x14(%rbp), %rsi
movl $0x4, %edx
movl $0x1, %ecx
callq 0x4e30
cmpl $0x0, %eax
je 0x5041
movzbl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5048
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_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
movq %rsp, %rbp
subq $0x30, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl $0x64, -0x20(%rbp)
movl $0x5, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl 0x188(%rax), %eax
andl $0x5000, %eax           # imm = 0x5000
cmpl $0x0, %eax
je 0x50a3
movl $0x1, -0x4(%rbp)
jmp 0x5104
cmpl $0x0, -0x18(%rbp)
je 0x50af
movl -0x18(%rbp), %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x50bb
movl -0x1c(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x50bd
movq -0x10(%rbp), %rdi
movzbl -0x11(%rbp), %esi
callq 0x4fc0
movq -0x10(%rbp), %rdi
callq 0x5000
movzbl -0x11(%rbp), %ecx
cmpl %ecx, %eax
jne 0x50e4
movl $0x1, -0x4(%rbp)
jmp 0x5104
movl -0x24(%rbp), %edi
callq 0x2590
movl -0x24(%rbp), %ecx
movl -0x20(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jg 0x50bd
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: 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
movq %rsp, %rbp
subq $0x20, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movl %edx, -0x18(%rbp)
leaq -0x20(%rbp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x2110
movzbl -0x11(%rbp), %eax
cmpl $0xc0, %eax
je 0x5154
movzbl -0x11(%rbp), %eax
cmpl $0xd0, %eax
je 0x5154
movl $0x0, -0x4(%rbp)
jmp 0x5194
movb $0x6, -0x20(%rbp)
movb -0x11(%rbp), %al
movb %al, -0x1f(%rbp)
movl -0x18(%rbp), %edi
leaq -0x20(%rbp), %rsi
addq $0x2, %rsi
callq 0x9200
movzbl -0x11(%rbp), %eax
cmpl $0xc0, %eax
je 0x517d
movb $0x0, -0x1b(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x20(%rbp), %rsi
xorl %edx, %edx
movl $0x6, %ecx
callq 0x4b00
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: 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:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x526e
cmpq $0x0, -0x18(%rbp)
jne 0x527a
movl $0x0, -0x4(%rbp)
jmp 0x53a4
movq -0x10(%rbp), %rax
addq $0x188, %rax            # imm = 0x188
addq $0x70, %rax
addq $0x17, %rax
movq (%rax), %rcx
movq 0x100aa(%rip), %rax     # 0x15340
subq %rcx, %rax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x52dd
movq -0x18(%rbp), %rax
movl $0x800, (%rax)          # imm = 0x800
movq -0x10(%rbp), %rax
movq 0x280(%rax), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x52d1
leaq 0xa65c(%rip), %rdi      # 0xf926
movb $0x0, %al
callq 0x2050
movl $0x1, -0x4(%rbp)
jmp 0x53a4
movq -0x10(%rbp), %rax
addq $0x188, %rax            # imm = 0x188
addq $0x70, %rax
addq $0x17, %rax
movq (%rax), %rcx
movq 0x1004f(%rip), %rax     # 0x15348
subq %rcx, %rax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x533d
movq -0x18(%rbp), %rax
movl $0x2000, (%rax)         # imm = 0x2000
movq -0x10(%rbp), %rax
movq 0x280(%rax), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x5334
leaq 0xa607(%rip), %rdi      # 0xf934
movb $0x0, %al
callq 0x2050
movl $0x1, -0x4(%rbp)
jmp 0x53a4
movq -0x10(%rbp), %rax
addq $0x188, %rax            # imm = 0x188
addq $0x70, %rax
addq $0x17, %rax
movq (%rax), %rcx
movq 0xfff7(%rip), %rax      # 0x15350
subq %rcx, %rax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x539d
movq -0x18(%rbp), %rax
movl $0x2000, (%rax)         # imm = 0x2000
movq -0x10(%rbp), %rax
movq 0x280(%rax), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x5394
leaq 0xa5b5(%rip), %rdi      # 0xf942
movb $0x0, %al
callq 0x2050
movl $0x1, -0x4(%rbp)
jmp 0x53a4
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: 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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movb $0x6, -0x1c(%rbp)
movb $-0x2e, -0x1b(%rbp)
movl -0x14(%rbp), %eax
shrl $0xc, %eax
movb %al, -0x1a(%rbp)
movl -0x14(%rbp), %eax
andl $0xfff, %eax            # imm = 0xFFF
addl -0x18(%rbp), %eax
addl $0xfff, %eax            # imm = 0xFFF
shrl $0xc, %eax
movb %al, -0x19(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
xorl %edx, %edx
movl $0x4, %ecx
callq 0x4b00
cmpl $0x0, %eax
jle 0x5414
movq -0x10(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x4d70
movl %eax, -0x4(%rbp)
jmp 0x541b
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_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 %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
cmpl $0x3d, -0x20(%rbp)
jle 0x546a
leaq 0xa4fd(%rip), %rdi      # 0xf950
leaq 0xa510(%rip), %rsi      # 0xf96a
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0x54c7
movb $0x7, -0x60(%rbp)
movb $-0x2d, -0x5f(%rbp)
movl -0x20(%rbp), %eax
movb %al, -0x5e(%rbp)
leaq -0x60(%rbp), %rdi
addq $0x3, %rdi
movq -0x18(%rbp), %rsi
movslq -0x1c(%rbp), %rax
addq %rax, %rsi
movslq -0x20(%rbp), %rdx
callq 0x2150
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl -0x20(%rbp), %ecx
addl $0x3, %ecx
xorl %edx, %edx
callq 0x4b00
cmpl $0x0, %eax
jle 0x54c0
movq -0x10(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x4d70
movl %eax, -0x4(%rbp)
jmp 0x54c7
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
// File: 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
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 -0x28(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x30(%rbp)
movl $0x3d, -0x34(%rbp)
movl $0xffffffff, -0x38(%rbp) # imm = 0xFFFFFFFF
movl -0x2c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jl 0x55b1
movq -0x20(%rbp), %rdi
movslq -0x30(%rbp), %rax
addq %rax, %rdi
movl -0x34(%rbp), %esi
callq 0x9240
cmpl $0x0, %eax
jne 0x557e
movl -0x38(%rbp), %eax
cmpl -0x14(%rbp), %eax
je 0x554f
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x5220
cmpl $0x0, %eax
jne 0x554d
movl $0x0, -0x4(%rbp)
jmp 0x55fa
jmp 0x554f
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x30(%rbp), %edx
movl -0x34(%rbp), %ecx
callq 0x5430
cmpl $0x0, %eax
jg 0x5573
movl $0x0, -0x4(%rbp)
jmp 0x55fa
movl -0x14(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x558f
movl -0x14(%rbp), %esi
leaq 0xa401(%rip), %rdi      # 0xf989
movb $0x0, %al
callq 0x24e0
movl -0x34(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x34(%rbp), %ecx
movl -0x2c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x2c(%rbp)
movl -0x34(%rbp), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0x5504
movl -0x38(%rbp), %eax
cmpl -0x14(%rbp), %eax
je 0x55d5
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x5220
cmpl $0x0, %eax
jne 0x55d3
movl $0x0, -0x4(%rbp)
jmp 0x55fa
jmp 0x55d5
cmpl $0x0, -0x2c(%rbp)
jle 0x55f3
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x30(%rbp), %edx
movl -0x2c(%rbp), %ecx
callq 0x5430
movl %eax, -0x4(%rbp)
jmp 0x55fa
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: 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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movw %si, %ax
movq %rdi, -0x8(%rbp)
movw %ax, -0xa(%rbp)
movw -0xa(%rbp), %ax
movw %ax, -0xc(%rbp)
movl 0xa147(%rip), %eax      # 0xf8c8
movl %eax, -0x12(%rbp)
movw 0xa141(%rip), %ax       # 0xf8cc
movw %ax, -0xe(%rbp)
movw -0xc(%rbp), %ax
leaq -0x12(%rbp), %rsi
addq $0x2, %rsi
movzwl %ax, %edi
callq 0x91b0
movzwl -0xc(%rbp), %eax
xorl $-0x1, %eax
leaq -0x12(%rbp), %rsi
addq $0x4, %rsi
movzwl %ax, %edi
callq 0x91b0
movq -0x8(%rbp), %rdi
leaq -0x12(%rbp), %rsi
xorl %edx, %edx
movl $0x6, %ecx
callq 0x4b00
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_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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movb $0x6, -0x2e(%rbp)
movb $-0x2b, -0x2d(%rbp)
movl -0x1c(%rbp), %edi
leaq -0x2e(%rbp), %rsi
addq $0x2, %rsi
callq 0x9200
movl -0x20(%rbp), %edi
leaq -0x2e(%rbp), %rsi
addq $0x5, %rsi
callq 0x9200
movl -0x24(%rbp), %eax
leaq -0x2e(%rbp), %rsi
addq $0x8, %rsi
movzwl %ax, %edi
callq 0x91b0
movq -0x10(%rbp), %rdi
leaq -0x2e(%rbp), %rsi
xorl %edx, %edx
movl $0xa, %ecx
callq 0x4b00
cmpl $0x0, %eax
jg 0x5861
movl $0x0, -0x4(%rbp)
jmp 0x58b5
movq -0x10(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x4d70
cmpl $0x0, %eax
jg 0x587c
movl $0x0, -0x4(%rbp)
jmp 0x58b5
movq -0x10(%rbp), %rdi
leaq -0x32(%rbp), %rsi
movl $0x2, %edx
callq 0x4f80
cmpl $0x0, %eax
jg 0x589c
movl $0x0, -0x4(%rbp)
jmp 0x58b5
leaq -0x32(%rbp), %rdi
callq 0x9140
movzwl %ax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop
// File: 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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
leaq -0x1a(%rbp), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x2110
movb $0x6, -0x1a(%rbp)
movb $-0x21, -0x19(%rbp)
movl -0xc(%rbp), %edi
leaq -0x1a(%rbp), %rsi
addq $0x2, %rsi
callq 0x9200
movl -0x10(%rbp), %edi
leaq -0x1a(%rbp), %rsi
addq $0x6, %rsi
callq 0x9200
movq -0x8(%rbp), %rdi
leaq -0x1a(%rbp), %rsi
xorl %edx, %edx
movl $0xa, %ecx
callq 0x4b00
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_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
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
callq 0x53b0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jg 0x5ba5
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
leaq 0x9e6b(%rip), %rdi      # 0xfa02
leaq 0x9e7c(%rip), %rsi      # 0xfa1a
movb $0x0, %al
callq 0x24e0
movl -0x14(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop
// File: 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
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x5bd4
cmpq $0x0, -0x18(%rbp)
jne 0x5bdd
movl $0x0, -0x4(%rbp)
jmp 0x5c21
movl -0x1c(%rbp), %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x5bf1
movl $0x0, -0x4(%rbp)
jmp 0x5c21
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x5220
cmpl $0x0, %eax
jne 0x5c0b
movl $0x0, -0x4(%rbp)
jmp 0x5c21
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x18(%rbp), %rdx
movl -0x20(%rbp), %ecx
callq 0x5610
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: 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
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 $0x90, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x5060
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x5cb4
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5d57
leaq 0x9a8f(%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 0x5c30
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x5d0b
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5d57
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
je 0x5d2e
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
leaq 0x9c8b(%rip), %rdi      # 0xf9ab
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x5060
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x5d51
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5d57
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
// File: 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 %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movb $0x6, -0x28(%rbp)
movb -0x11(%rbp), %al
movb %al, -0x27(%rbp)
movl -0x18(%rbp), %eax
movb %al, -0x26(%rbp)
movl -0x24(%rbp), %eax
movb %al, -0x25(%rbp)
movzbl -0x11(%rbp), %eax
cmpl $0xc8, %eax
je 0x5df2
movzbl -0x11(%rbp), %eax
cmpl $0xc9, %eax
je 0x5df2
movl $0x0, -0x4(%rbp)
jmp 0x5e12
movq -0x10(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rcx
movl -0x24(%rbp), %r9d
movl $0x4, %edx
xorl %r8d, %r8d
callq 0x4b40
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: 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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x5e8e
cmpq $0x0, -0x18(%rbp)
jne 0x5e97
movl $0x0, -0x4(%rbp)
jmp 0x5ecf
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl $0x1, %edx
callq 0x5e20
cmpl $0x0, %eax
jg 0x5eb7
movl $0x0, -0x4(%rbp)
jmp 0x5ecf
movq -0x18(%rbp), %rax
movq -0x60(%rbp), %rcx
movq %rcx, (%rax)
movl -0x58(%rbp), %ecx
movl %ecx, 0x8(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: 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 %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x5efe
cmpq $0x0, -0x18(%rbp)
jne 0x5f0a
movl $0x0, -0x4(%rbp)
jmp 0x5feb
movq -0x10(%rbp), %rdi
callq 0x4ab0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5250
cmpl $0x0, %eax
jne 0x5f3f
leaq 0x9ab8(%rip), %rdi      # 0xf9e4
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0x5feb
movq -0x18(%rbp), %rax
movl (%rax), %eax
andl $0x5000, %eax           # imm = 0x5000
cmpl $0x0, %eax
je 0x5f5b
movl $0x1, -0x4(%rbp)
jmp 0x5feb
movq -0x10(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x5e70
cmpl $0x0, %eax
je 0x5fe4
movzbl -0x22(%rbp), %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x24(%rax)
movzbl -0x20(%rbp), %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x28(%rax)
movzbl -0x1f(%rbp), %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x2a(%rax)
movzbl -0x23(%rbp), %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x26(%rax)
movzbl -0x1e(%rbp), %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x2c(%rax)
movzbl -0x1d(%rbp), %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x2e(%rax)
movq -0x18(%rbp), %rax
movw $0x0, 0x20(%rax)
movq -0x18(%rbp), %rax
movw $0x0, 0x22(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x5feb
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/w8760_funcs.cpp
// Function: wh_w8760_dev_program_chunk(WdtDevice*, ChunkInfoEx*, int)
int wh_w8760_dev_program_chunk(WDT_DEV* pdev, CHUNK_INFO_EX* pInputChunk, int option)
{
	if (!pdev)
		return 0;
	
	if (pdev->pparam->argus & OPTION_BLOCK)
		return wh_w8760_dev_program_chunk_verify(pdev, pInputChunk, option);
	else
		return wh_w8760_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 0x6523
movl $0x0, -0x4(%rbp)
jmp 0x6562
movq -0x10(%rbp), %rax
movq 0x280(%rax), %rax
movl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x654f
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0x6320
movl %eax, -0x4(%rbp)
jmp 0x6562
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0x6000
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/w8760_funcs.cpp
// Function: wh_w8760_get_rom_signature(int, unsigned char*)
int wh_w8760_get_rom_signature(int type, BYTE* buf)
{
	if(type == 0)
	{
		memcpy(buf, W8760_RomSignatureVerB, sizeof(W8760_RomSignatureVerB));
		return 1;
	}
	else if(type == 1)
	{
		memcpy(buf, W8762_RomSignatureVerA, sizeof(W8762_RomSignatureVerA));
		return 1;
	}
	else if(type == 2)
	{
		memcpy(buf, W8762_RomSignatureVerC, sizeof(W8762_RomSignatureVerC));
		return 1;
	}
	else
	{
		return 0;
	}


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x0, -0x8(%rbp)
jne 0x6598
movq -0x10(%rbp), %rax
movq 0xedb4(%rip), %rcx      # 0x15340
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x65d9
cmpl $0x1, -0x8(%rbp)
jne 0x65b5
movq -0x10(%rbp), %rax
movq 0xed9f(%rip), %rcx      # 0x15348
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x65d9
cmpl $0x2, -0x8(%rbp)
jne 0x65d2
movq -0x10(%rbp), %rax
movq 0xed8a(%rip), %rcx      # 0x15350
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x65d9
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nop
// File: 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 %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
leaq 0x94a1(%rip), %rdi      # 0xfa94
movb $0x0, %al
callq 0x24e0
movq -0x8(%rbp), %rdi
movl $0xa022750a, %esi       # imm = 0xA022750A
callq 0x51f0
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x51a0
movq -0x8(%rbp), %rdi
movl $0x61000, %esi          # imm = 0x61000
callq 0x4eb0
leaq 0x9485(%rip), %rdi      # 0xfaad
movb $0x0, %al
callq 0x24e0
movl $0x1, %eax
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: 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 %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
leaq 0x946e(%rip), %rdi      # 0xfac1
movb $0x0, %al
callq 0x24e0
movq -0x8(%rbp), %rdi
movl $0x61000, %esi          # imm = 0x61000
callq 0x4eb0
leaq 0x943e(%rip), %rdi      # 0xfaad
movb $0x0, %al
callq 0x24e0
movl $0x1, %eax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_read_report(WdtDevice*, unsigned char*, unsigned int)
int wh_w8790_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 0x66b3
movl $0x0, -0x4(%rbp)
jmp 0x66d8
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x66d1
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0xd4a0
movl %eax, -0x4(%rbp)
jmp 0x66d8
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/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:
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 0x6713
movl $0x0, -0x4(%rbp)
jmp 0x678e
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x6, %eax
jne 0x6728
movl $0xa, -0x1c(%rbp)
jmp 0x6769
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x7, %eax
je 0x6740
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xb, %eax
jne 0x6749
movl $0x40, -0x1c(%rbp)
jmp 0x6767
movq -0x18(%rbp), %rax
movzbl (%rax), %esi
leaq 0x9177(%rip), %rdi      # 0xf8ce
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0x678e
jmp 0x6769
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x6787
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0xd160
movl %eax, -0x4(%rbp)
jmp 0x678e
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: 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:
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 0x67c3
movl $0x0, -0x4(%rbp)
jmp 0x683e
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x6, %eax
jne 0x67d8
movl $0xa, -0x1c(%rbp)
jmp 0x6819
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x7, %eax
je 0x67f0
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xb, %eax
jne 0x67f9
movl $0x40, -0x1c(%rbp)
jmp 0x6817
movq -0x18(%rbp), %rax
movzbl (%rax), %esi
leaq 0x90c7(%rip), %rdi      # 0xf8ce
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0x683e
jmp 0x6819
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x6837
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0xca10
movl %eax, -0x4(%rbp)
jmp 0x683e
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_set_basic_op(WdtDevice*)
int wh_w8790_dev_set_basic_op(WDT_DEV* pdev)
{
	if (!pdev)
		return 0;

	g_func_dev_basic.p_wh_get_feature = wh_w8790_dev_get_feature;
	g_func_dev_basic.p_wh_set_feature = wh_w8790_dev_set_feature;
	g_func_dev_basic.p_wh_read_report = wh_w8790_dev_read_report;

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x6868
movl $0x0, -0x4(%rbp)
jmp 0x6899
leaq -0xcf(%rip), %rax       # 0x67a0
movq %rax, 0xeb4a(%rip)      # 0x153c0
leaq -0x18d(%rip), %rax      # 0x66f0
movq %rax, 0xeb34(%rip)      # 0x153b8
leaq -0x1fb(%rip), %rax      # 0x6690
movq %rax, 0xeb3e(%rip)      # 0x153d0
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nop
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_command_write(WdtDevice*, unsigned char*, int, int)
int wh_w8790_dev_command_write(WDT_DEV* pdev, BYTE* data, int start, int size)
{
	if(wh_w8790_dev_set_feature(pdev, &data[start], size))
		return 1;
	else
	{
		wh_printf("command_write_fail!\n");
		return 0;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movslq -0x1c(%rbp), %rax
addq %rax, %rsi
movl -0x20(%rbp), %edx
callq 0x66f0
cmpl $0x0, %eax
je 0x68db
movl $0x1, -0x4(%rbp)
jmp 0x68f0
leaq 0x926a(%rip), %rdi      # 0xfb4c
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: 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:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x691e
cmpq $0x0, -0x18(%rbp)
jne 0x692a
movl $0x0, -0x4(%rbp)
jmp 0x69f0
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 -0x18(%rbp), %rax
movb 0xf(%rax), %cl
movq -0x10(%rbp), %rax
movb %cl, 0xe(%rax)
movq -0x18(%rbp), %rax
movb 0x10(%rax), %cl
movq -0x10(%rbp), %rax
movb %cl, 0xf(%rax)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x11(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0x19(%rcx), %rcx
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x21(%rcx), %rcx
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movl 0x29(%rcx), %ecx
movl %ecx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x2d(%rcx), %rcx
movq %rcx, 0x2c(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: 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:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x6a1f
movl $0x0, -0x4(%rbp)
jmp 0x6ad2
movq -0x10(%rbp), %rax
addq $0x188, %rax            # imm = 0x188
addq $0x70, %rax
addq $0x20, %rax
movq (%rax), %rcx
movq 0xe91d(%rip), %rax      # 0x15358
subq %rcx, %rax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x6a75
movq -0x10(%rbp), %rax
movq 0x280(%rax), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x6a6c
leaq 0x90fc(%rip), %rdi      # 0xfb61
movb $0x0, %al
callq 0x2050
movl $0x1, -0x4(%rbp)
jmp 0x6ad2
movq -0x10(%rbp), %rax
addq $0x188, %rax            # imm = 0x188
addq $0x70, %rax
addq $0x20, %rax
movq (%rax), %rcx
movq 0xe8cf(%rip), %rax      # 0x15360
subq %rcx, %rax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x6acb
movq -0x10(%rbp), %rax
movq 0x280(%rax), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x6ac2
leaq 0x90b4(%rip), %rdi      # 0xfb6f
movb $0x0, %al
callq 0x2050
movl $0x1, -0x4(%rbp)
jmp 0x6ad2
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: 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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x2110
cmpq $0x0, -0x10(%rbp)
je 0x6b0e
cmpq $0x0, -0x18(%rbp)
jne 0x6b17
movl $0x0, -0x4(%rbp)
jmp 0x6b51
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl $0x1, %edx
callq 0x6b60
cmpl $0x0, %eax
jg 0x6b37
movl $0x0, -0x4(%rbp)
jmp 0x6b51
movq -0x18(%rbp), %rax
movq -0x60(%rbp), %rcx
movq %rcx, (%rax)
movw -0x58(%rbp), %cx
movw %cx, 0x8(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: 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
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 0x68a0
cmpl $0x0, %eax
jle 0x6c72
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x2110
cmpl $0x9, -0x30(%rbp)
jle 0x6c32
movb $0x7, -0x70(%rbp)
jmp 0x6c36
movb $0x6, -0x70(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x70(%rbp), %rsi
movl -0x30(%rbp), %edx
callq 0x67a0
cmpl $0x0, %eax
jle 0x6c70
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 0x6c79
jmp 0x6c72
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/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
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 $0x3f, %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 0x6d9b
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 0x6c90
cmpl $0x0, %eax
jg 0x6d81
movl $0x0, -0x4(%rbp)
jmp 0x6dc8
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 0x6d50
cmpl $0x0, -0x2c(%rbp)
jle 0x6dc1
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 0x6c90
movl %eax, -0x4(%rbp)
jmp 0x6dc8
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: 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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
leaq -0x14(%rbp), %rdi
xorl %esi, %esi
movl $0x4, %edx
callq 0x2110
cmpq $0x0, -0x10(%rbp)
jne 0x6e4c
movl $0x0, -0x4(%rbp)
jmp 0x6e78
movq -0x10(%rbp), %rdi
leaq -0x14(%rbp), %rsi
movl $0x8, %edx
movl $0x1, %ecx
callq 0x6e90
cmpl $0x0, %eax
je 0x6e71
movzbl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x6e78
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/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:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
leaq -0x22(%rbp), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x2110
movb $0x6, -0x22(%rbp)
movb $-0x37, -0x21(%rbp)
movl -0x14(%rbp), %eax
movb %al, -0x20(%rbp)
movl -0x18(%rbp), %eax
movb %al, -0x1f(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x22(%rbp), %rsi
movq -0x10(%rbp), %rcx
movl -0x18(%rbp), %r9d
movl $0xa, %edx
xorl %r8d, %r8d
callq 0x6be0
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)