LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_set_flash_address(WdtDevice*, unsigned int)
int wh_w8790_dev_set_flash_address(WDT_DEV* pdev, UINT32 address)
{
	BYTE cmd[10] = { 0 };

	cmd[0] = W8790_COMMAND9;
	cmd[1] = W8790_SET_FLASH_ADDRESS;
	put_unaligned_le32(address, &cmd[2]);

	return wh_w8790_dev_command_write(pdev, cmd, 0, sizeof(cmd));

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
leaq -0x16(%rbp), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x2110
movb $0x6, -0x16(%rbp)
movb $-0x30, -0x15(%rbp)
movl -0xc(%rbp), %edi
leaq -0x16(%rbp), %rsi
addq $0x2, %rsi
callq 0x9200
movq -0x8(%rbp), %rdi
leaq -0x16(%rbp), %rsi
xorl %edx, %edx
movl $0xa, %ecx
callq 0x68a0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_section_header_valid(FlashSectionHeader_8790_t*)
int wh_w8790_section_header_valid(W8790_FLASH_SECTION_HEADER* psec_header)
{
	if (!psec_header)
		return 0;

	UINT16 sum = 0;
	sum = misr_for_bytes(sum, (BYTE*)&psec_header->PayloadSize, 0, 12);

	return (sum == psec_header->HeaderChecksum);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x6f6c
movl $0x0, -0x4(%rbp)
jmp 0x6faa
movw $0x0, -0x12(%rbp)
movw -0x12(%rbp), %ax
movq -0x10(%rbp), %rsi
addq $0x4, %rsi
xorl %edx, %edx
movl $0xc, %ecx
movzwl %ax, %edi
callq 0xb780
movw %ax, -0x12(%rbp)
movzwl -0x12(%rbp), %eax
movq -0x10(%rbp), %rcx
movzwl 0x2(%rcx), %ecx
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -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_n_check_device_mode(WdtDevice*, unsigned char, int, int)
int wh_w8790_dev_set_n_check_device_mode(WDT_DEV* pdev, BYTE mode, int timeout_ms, int intv_ms)
{
	int polling_timeout_ms = 100;
	int polling_intv_ms = 5;

	// if device in isp mode, we don't check mode
	if (pdev->board_info.dev_type & FW_MAYBE_ISP)
		return 1;

	if (timeout_ms)
		polling_timeout_ms = timeout_ms;
	if (intv_ms)
		polling_intv_ms = intv_ms;

	do {
		wh_w8790_dev_set_device_mode(pdev, mode);

		if (wh_w8790_dev_get_device_mode(pdev) == mode)
			return 1;

		usleep(polling_intv_ms*1000);
		polling_timeout_ms -= polling_intv_ms;
	} while (polling_timeout_ms > 0);

	return 0;
}

// Assembly:
pushq %rbp
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 $0x1, %eax
cmpl $0x0, %eax
je 0x71a1
movl $0x1, -0x4(%rbp)
jmp 0x7206
cmpl $0x0, -0x18(%rbp)
je 0x71ad
movl -0x18(%rbp), %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x71b9
movl -0x1c(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x71bb
movq -0x10(%rbp), %rdi
movzbl -0x11(%rbp), %esi
callq 0x7210
movq -0x10(%rbp), %rdi
callq 0x6e20
movzbl -0x11(%rbp), %ecx
cmpl %ecx, %eax
jne 0x71e2
movl $0x1, -0x4(%rbp)
jmp 0x7206
imull $0x3e8, -0x24(%rbp), %edi # imm = 0x3E8
callq 0x2220
movl -0x24(%rbp), %ecx
movl -0x20(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jg 0x71bb
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_set_device_mode(WdtDevice*, unsigned char)
int wh_w8790_dev_set_device_mode(WDT_DEV* pdev, BYTE mode)
{
	BYTE cmd[10] = { 0 };

	cmd[0] = W8790_COMMAND9;
	cmd[1] = W8790_SET_DEVICE_MODE;
	cmd[2] = mode;

	return wh_w8790_dev_command_write(pdev, cmd, 0, 3);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
movb %al, -0x9(%rbp)
leaq -0x13(%rbp), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x2110
movb $0x6, -0x13(%rbp)
movb $-0x36, -0x12(%rbp)
movb -0x9(%rbp), %al
movb %al, -0x11(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x13(%rbp), %rsi
xorl %edx, %edx
movl $0x3, %ecx
callq 0x68a0
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_read_parameter_table_info(WdtDevice*, ParameterTableInfo_8790_t*)
int wh_w8790_dev_read_parameter_table_info(WDT_DEV* pdev, W8790_PARAMETER_INFO* p_out_parameter_info)
{
	BYTE cmd[10] = { 0 };

	cmd[0] = W8790_COMMAND9;
	cmd[1] = W8790_READ_PARAMETER_TABLE_INFO;
	BYTE buf[64];
	

	if (wh_w8790_dev_command_read(pdev, cmd, sizeof(cmd), buf, 0, sizeof(W8790_PARAMETER_INFO))) {
		p_out_parameter_info->PMapID = get_unaligned_le16(&buf[0]);
		p_out_parameter_info->PrimarySector = get_unaligned_le16(&buf[2]);
		p_out_parameter_info->PrimarySize = get_unaligned_le16(&buf[4]);
		p_out_parameter_info->ExtendedSector = get_unaligned_le16(&buf[6]);
		p_out_parameter_info->ExtendedSize = get_unaligned_le16(&buf[8]);
		return 1;
	}
	
	
	return 0;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x22(%rbp), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x2110
movb $0x6, -0x22(%rbp)
movb $-0x33, -0x21(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x22(%rbp), %rsi
leaq -0x70(%rbp), %rcx
movl $0xa, %r9d
xorl %r8d, %r8d
movl %r9d, %edx
callq 0x6be0
cmpl $0x0, %eax
je 0x7326
leaq -0x70(%rbp), %rdi
callq 0x9140
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, (%rax)
leaq -0x70(%rbp), %rdi
addq $0x2, %rdi
callq 0x9140
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x2(%rax)
leaq -0x70(%rbp), %rdi
addq $0x4, %rdi
callq 0x9140
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x4(%rax)
leaq -0x70(%rbp), %rdi
addq $0x6, %rdi
callq 0x9140
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x6(%rax)
leaq -0x70(%rbp), %rdi
addq $0x8, %rdi
callq 0x9140
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x8(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x732d
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_one_block_fast_write(WdtDevice*, unsigned char*, int, int)
int wh_w8790_dev_one_block_fast_write(WDT_DEV* pdev, BYTE* data, int start, int size)
{
	BYTE cmd[64] = { 0 };
	int write_size = size;

	if (size > W8790_USB_MAX_PAYLOAD_SIZE)
		write_size = W8790_USB_MAX_PAYLOAD_SIZE;

	cmd[0] = W8790_BLOCK63;
	memcpy(&cmd[1], &data[start], write_size);

	return wh_w8790_dev_set_feature(pdev, cmd, write_size);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x2110
movl -0x18(%rbp), %eax
movl %eax, -0x64(%rbp)
cmpl $0x3f, -0x18(%rbp)
jle 0x7379
movl $0x3f, -0x64(%rbp)
movb $0xb, -0x60(%rbp)
leaq -0x60(%rbp), %rdi
addq $0x1, %rdi
movq -0x10(%rbp), %rsi
movslq -0x14(%rbp), %rax
addq %rax, %rsi
movslq -0x64(%rbp), %rdx
callq 0x2150
movq -0x8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl -0x64(%rbp), %edx
callq 0x66f0
addq $0x70, %rsp
popq %rbp
retq
nop
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_block_fast_write(WdtDevice*, unsigned char*, int, int)
int wh_w8790_dev_block_fast_write(WDT_DEV* pdev, BYTE* data, int start, int size)
{
	int payload_size = W8790_USB_MAX_PAYLOAD_SIZE;
	while (size > payload_size) {
		if (wh_w8790_dev_one_block_fast_write(pdev, data, start, payload_size) <= 0)
			return 0;
		start += payload_size;
		size -= payload_size;
	}
	if (size > 0)
		return wh_w8790_dev_one_block_fast_write(pdev, data, start, size);
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl $0x3f, -0x24(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
jle 0x740c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl -0x24(%rbp), %ecx
callq 0x7340
cmpl $0x0, %eax
jg 0x73f6
movl $0x0, -0x4(%rbp)
jmp 0x7431
movl -0x24(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %ecx
movl -0x20(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x20(%rbp)
jmp 0x73cd
cmpl $0x0, -0x20(%rbp)
jle 0x742a
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
callq 0x7340
movl %eax, -0x4(%rbp)
jmp 0x7431
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_one_block_fast_read(WdtDevice*, unsigned char*, int, int)
int wh_w8790_dev_one_block_fast_read(WDT_DEV* pdev, BYTE* data, int start, int size)
{
	BYTE cmd[64] = { 0 };
	int read_size = size;

	if (size > W8790_USB_MAX_PAYLOAD_SIZE)
		read_size = W8790_USB_MAX_PAYLOAD_SIZE;

	cmd[0] = W8790_BLOCK63;

	if (wh_w8790_dev_get_feature(pdev, cmd, read_size) > 0) {
		memcpy(&data[start], &cmd[1], read_size);
		return 1;
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x2110
movl -0x20(%rbp), %eax
movl %eax, -0x64(%rbp)
cmpl $0x3f, -0x20(%rbp)
jle 0x7479
movl $0x3f, -0x64(%rbp)
movb $0xb, -0x60(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl -0x64(%rbp), %edx
callq 0x67a0
cmpl $0x0, %eax
jle 0x74b7
movq -0x18(%rbp), %rdi
movslq -0x1c(%rbp), %rax
addq %rax, %rdi
leaq -0x60(%rbp), %rsi
addq $0x1, %rsi
movslq -0x64(%rbp), %rdx
callq 0x2150
movl $0x1, -0x4(%rbp)
jmp 0x74be
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_block_fast_read(WdtDevice*, unsigned char*, int, int)
int wh_w8790_dev_block_fast_read(WDT_DEV* pdev, BYTE* data, int start, int size)
{
	int payload_size = W8790_USB_MAX_PAYLOAD_SIZE;

	while (size > payload_size) {
		if (wh_w8790_dev_one_block_fast_read(pdev, data, start, payload_size) <= 0)
			return 0;
		start += payload_size;
		size -= payload_size;
	}

	if (size > 0)
		return wh_w8790_dev_one_block_fast_read(pdev, data, start, size);

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl $0x3f, -0x24(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
jle 0x752c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl -0x24(%rbp), %ecx
callq 0x7440
cmpl $0x0, %eax
jg 0x7516
movl $0x0, -0x4(%rbp)
jmp 0x7551
movl -0x24(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %ecx
movl -0x20(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x20(%rbp)
jmp 0x74ed
cmpl $0x0, -0x20(%rbp)
jle 0x754a
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
callq 0x7440
movl %eax, -0x4(%rbp)
jmp 0x7551
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_write_items(WdtDevice*, int, unsigned char*, int, int, int)
int wh_w8790_dev_write_items(WDT_DEV* pdev, int cmd_id, BYTE* buffer, int start, int item_size, int item_count)
{
	int size = item_count * item_size;
	BYTE cmd[64] = { 0 };

	cmd[0] = W8790_COMMAND9;
	cmd[1] = cmd_id;
	cmd[2] = item_count;
	memcpy(&cmd[3], &buffer[start], size);

	return wh_w8790_dev_command_write(pdev, cmd, 0, size + 3);
}

// Assembly:
pushq %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)
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x2110
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 0x68a0
addq $0x70, %rsp
popq %rbp
retq
nop
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_write_array(WdtDevice*, int, unsigned char*, int, int, int)
int wh_w8790_dev_write_array(WDT_DEV* pdev, int cmd_id, BYTE* buffer, int start, int item_size, int item_count)
{
	int max_write_batch = (W8790_USB_MAX_PAYLOAD_SIZE - 2) / item_size;
	int i = start;

	while (item_count >= max_write_batch) {
		if (wh_w8790_dev_write_items(pdev, cmd_id, buffer, i, item_size, max_write_batch) <= 0)
			return 0;

		i += max_write_batch * item_size;
		item_count -= max_write_batch;
	}

	if (item_count > 0)
		return wh_w8790_dev_write_items(pdev, cmd_id, buffer, i, item_size, item_count);

	return 1;
}

// Assembly:
pushq %rbp
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 0x765b
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 0x7560
cmpl $0x0, %eax
jg 0x7641
movl $0x0, -0x4(%rbp)
jmp 0x7688
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 0x7610
cmpl $0x0, -0x2c(%rbp)
jle 0x7681
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 0x7560
movl %eax, -0x4(%rbp)
jmp 0x7688
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_wait_cmd_end(WdtDevice*, int, int)
int wh_w8790_dev_wait_cmd_end(WDT_DEV* pdev, int timeout_ms, int invt_ms)
{
	int polling_timeout_ms = 5000;
	int polling_intv_ms = 10;
	int status;
	BYTE	status_buf[4] = { 0 };

	unsigned long 	start_tick = get_current_ms();
	unsigned long 	time_period;

	if (timeout_ms)
		polling_timeout_ms = timeout_ms;
	if (invt_ms)
		polling_intv_ms = invt_ms;

	do
	{
		if (wh_w8790_dev_get_device_status(pdev, &status_buf[0], 0, 1) <= 0)
			return 0;

		status = status_buf[0];
		if ((status & W8790_COMMAND_BUSY) == 0) {
			time_period = (get_current_ms() - start_tick);
			if (time_period)
				wh_printf("leave %s : %lums\n", __FUNCTION__, time_period);

			return 1;
		}

		wh_sleep(polling_intv_ms);
		polling_timeout_ms -= polling_intv_ms;
	} while (polling_timeout_ms > 0);

	wh_printf("%s: timeout occured (%d)!\n", __FUNCTION__, polling_timeout_ms * polling_intv_ms);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl $0x1388, -0x1c(%rbp)    # imm = 0x1388
movl $0xa, -0x20(%rbp)
leaq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x4, %edx
callq 0x2110
callq 0x25d0
movq %rax, -0x30(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x76e5
movl -0x14(%rbp), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x18(%rbp)
je 0x76f1
movl -0x18(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x76f3
movq -0x10(%rbp), %rdi
leaq -0x28(%rbp), %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x6e90
cmpl $0x0, %eax
jg 0x7718
movl $0x0, -0x4(%rbp)
jmp 0x77a0
movzbl -0x28(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x7760
callq 0x25d0
subq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x7757
movq -0x38(%rbp), %rdx
leaq 0x8448(%rip), %rdi      # 0xfb91
leaq 0x8453(%rip), %rsi      # 0xfba3
movb $0x0, %al
callq 0x24e0
movl $0x1, -0x4(%rbp)
jmp 0x77a0
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 0x76f3
movl -0x1c(%rbp), %edx
imull -0x20(%rbp), %edx
leaq 0x8166(%rip), %rdi      # 0xf8f1
leaq 0x8411(%rip), %rsi      # 0xfba3
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_flash_erase_cmd(WdtDevice*, unsigned int, unsigned int)
int wh_w8790_dev_flash_erase_cmd(WDT_DEV* pdev, UINT32 address, UINT32 size)
{
	BYTE cmd[10] = { 0 };

	cmd[0] = W8790_COMMAND9;
	cmd[1] = (BYTE)W8790_ERASE_FLASH;
	cmd[2] = (BYTE)(address >> 12);
	cmd[3] = (BYTE)(((address & 0x0FFF) + size + 4095) >> 12);

	if (wh_w8790_dev_command_write(pdev, cmd, 0, sizeof(cmd)) > 0)
		return wh_w8790_dev_wait_cmd_end(pdev, 6000, 0);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
leaq -0x22(%rbp), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x2110
movb $0x6, -0x22(%rbp)
movb $-0x2e, -0x21(%rbp)
movl -0x14(%rbp), %eax
shrl $0xc, %eax
movb %al, -0x20(%rbp)
movl -0x14(%rbp), %eax
andl $0xfff, %eax            # imm = 0xFFF
addl -0x18(%rbp), %eax
addl $0xfff, %eax            # imm = 0xFFF
shrl $0xc, %eax
movb %al, -0x1f(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x22(%rbp), %rsi
xorl %edx, %edx
movl $0xa, %ecx
callq 0x68a0
cmpl $0x0, %eax
jle 0x78a7
movq -0x10(%rbp), %rdi
movl $0x1770, %esi           # imm = 0x1770
xorl %edx, %edx
callq 0x76a0
movl %eax, -0x4(%rbp)
jmp 0x78ae
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_write_flash_cmd(WdtDevice*, unsigned char*, int, int)
int wh_w8790_dev_write_flash_cmd(WDT_DEV* pdev, BYTE* buf, int start, int size)
{
	if (size > W8790_USB_MAX_PAYLOAD_SIZE - 2) {
		wh_printf("%s: payload data overrun\n", __FUNCTION__);
		return 0;
	}

	BYTE cmd[W8790_USB_MAX_PAYLOAD_SIZE + 1] = { 0 };

	cmd[0] = W8790_COMMAND63;
	cmd[1] = (BYTE)W8790_WRITE_FLASH;
	cmd[2] = (BYTE)size;
	memcpy(&cmd[3], &buf[start], size);

	if (wh_w8790_dev_command_write(pdev, cmd, 0, size + 3) > 0)
		return wh_w8790_dev_wait_cmd_end(pdev, 0, 0);
	wh_printf("w8790_write_cmd fail \n)");
	return 0;
}

// Assembly:
pushq %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 0x78fa
leaq 0x806d(%rip), %rdi      # 0xf950
leaq 0x82d3(%rip), %rsi      # 0xfbbd
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0x7975
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x2110
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 0x68a0
cmpl $0x0, %eax
jle 0x7960
movq -0x10(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x76a0
movl %eax, -0x4(%rbp)
jmp 0x7975
leaq 0x8273(%rip), %rdi      # 0xfbda
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nop
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_write_flash_page(WdtDevice*, unsigned char*, int, int)
int wh_w8790_dev_write_flash_page(WDT_DEV* pdev, BYTE* buf, int addr, int size)
{
	int retval = 0;
	unsigned int	write_base;
	unsigned int	write_size;

	write_base = W8790_FLASH_PAGE_SIZE;

	if (addr & 0xFF) {
		unsigned int 	size_partial;
		size_partial = write_base - (addr & 0xFF);

		if (size > (int)size_partial) {
			write_size = size_partial;
			size = size - size_partial;
		}
		else {
			write_size = size;
			size = 0;
		}
		retval = wh_w8790_dev_write_flash(pdev, addr, (BYTE*)buf, 0/*offset*/, write_size);
		if (!retval)
			return retval;
		buf = buf + size_partial;
		addr = addr + size_partial;
	}

	while (size)
	{
		if (size > (int)write_base) {
			write_size = write_base;
			size = size - write_base;
		}
		else {
			write_size = size;
			size = 0;
		}
		retval = wh_w8790_dev_write_flash(pdev, addr, (BYTE*)buf, 0/*offset*/, write_size);
		if (!retval)
			return retval;
		buf = buf + write_base;
		addr = addr + 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 0x7b99
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 0x7b4b
movl -0x30(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x20(%rbp), %eax
subl -0x30(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x7b58
movl -0x20(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x18(%rbp), %rdx
movl -0x2c(%rbp), %r8d
xorl %ecx, %ecx
callq 0x7980
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x7b82
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7c0e
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 0x7b9b
cmpl $0x0, -0x20(%rbp)
je 0x7c07
movl -0x20(%rbp), %eax
cmpl -0x28(%rbp), %eax
jle 0x7bba
movl -0x28(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x20(%rbp), %eax
subl -0x28(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x7bc7
movl -0x20(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x18(%rbp), %rdx
movl -0x2c(%rbp), %r8d
xorl %ecx, %ecx
callq 0x7980
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x7bee
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7c0e
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 0x7b9b
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_protect_flash(WdtDevice*, unsigned short)
int wh_w8790_dev_protect_flash(WDT_DEV* pdev, UINT16 protect_mask)
{
	UINT16 mask = protect_mask;

	BYTE cmd[10] = { W8790_COMMAND9, (BYTE)W8790_PROTECT_FLASH, 0, 0, 0, 0 };
	put_unaligned_le16(mask, &cmd[2]);
	put_unaligned_le16((UINT16)~mask, &cmd[4]);

	return wh_w8790_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)
movq 0x7f00(%rip), %rax      # 0xfb42
movq %rax, -0x16(%rbp)
movw 0x7efd(%rip), %ax       # 0xfb4a
movw %ax, -0xe(%rbp)
movw -0xc(%rbp), %ax
leaq -0x16(%rbp), %rsi
addq $0x2, %rsi
movzwl %ax, %edi
callq 0x91b0
movzwl -0xc(%rbp), %eax
xorl $-0x1, %eax
leaq -0x16(%rbp), %rsi
addq $0x4, %rsi
movzwl %ax, %edi
callq 0x91b0
movq -0x8(%rbp), %rdi
leaq -0x16(%rbp), %rsi
xorl %edx, %edx
movl $0xa, %ecx
callq 0x68a0
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_flash_get_checksum(WdtDevice*, unsigned int*, unsigned int, int, unsigned int)
int wh_w8790_dev_flash_get_checksum(WDT_DEV* pdev, UINT32* pchksum, UINT32 flash_address,
	int size, UINT32 init_sum)
{
	BYTE cmd[10] = { 0 };
	BYTE buf[2] = { 0 };

	*pchksum = 0;

	cmd[0] = W8790_COMMAND9;
	cmd[1] = (BYTE)W8790_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_w8790_dev_command_write(pdev, cmd, 0, sizeof(cmd)) <= 0)
		return 0;

	if (wh_w8790_dev_wait_cmd_end(pdev, 0, 0) <= 0)
		return 0;

	if (wh_w8790_dev_read_buf_response(pdev, buf, 2) <= 0)
		return 0;

	*pchksum = get_unaligned_le16(buf);
	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 %r8d, -0x24(%rbp)
leaq -0x2e(%rbp), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x2110
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2110
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 0x68a0
cmpl $0x0, %eax
jg 0x7d41
movl $0x0, -0x4(%rbp)
jmp 0x7d95
movq -0x10(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x76a0
cmpl $0x0, %eax
jg 0x7d5c
movl $0x0, -0x4(%rbp)
jmp 0x7d95
movq -0x10(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movl $0x2, %edx
callq 0x77f0
cmpl $0x0, %eax
jg 0x7d7c
movl $0x0, -0x4(%rbp)
jmp 0x7d95
leaq -0x30(%rbp), %rdi
callq 0x9140
movzwl %ax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_set_block_access(WdtDevice*, unsigned char, unsigned int, unsigned int*)
int wh_w8790_dev_set_block_access(WDT_DEV* pdev, BYTE type, UINT32 offset, UINT32* pblk_size)
{
	BYTE response[4] = { 0 };
	BYTE cmd[10] = { 0 };
	int block_size = 0;

	*pblk_size = 0;

	cmd[0] = W8790_COMMAND9;
	cmd[1] = (BYTE)W8790_SET_BLOCK_ACCESS;
	cmd[2] = type;
	cmd[3] = (BYTE)(offset >> 0);
	cmd[4] = (BYTE)(offset >> 8);
	cmd[5] = (BYTE)(offset >> 16);

	if (wh_w8790_dev_command_read(pdev, cmd, sizeof(cmd), response, 0, 4) <= 0)
	{
		wh_printf("%s: Failed !\n", __FUNCTION__);
		return 0;
	}
		

	block_size = response[1] | (response[2] << 8) | (response[3] << 16);

	if (response[0] == (BYTE)type && block_size != 0x00FFFFFF)
		*pblk_size = block_size;

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
leaq -0x24(%rbp), %rdi
xorl %esi, %esi
movl $0x4, %edx
callq 0x2110
leaq -0x2e(%rbp), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x2110
movl $0x0, -0x34(%rbp)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movb $0x6, -0x2e(%rbp)
movb $-0x20, -0x2d(%rbp)
movb -0x11(%rbp), %al
movb %al, -0x2c(%rbp)
movl -0x18(%rbp), %eax
shrl $0x0, %eax
movb %al, -0x2b(%rbp)
movl -0x18(%rbp), %eax
shrl $0x8, %eax
movb %al, -0x2a(%rbp)
movl -0x18(%rbp), %eax
shrl $0x10, %eax
movb %al, -0x29(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x2e(%rbp), %rsi
leaq -0x24(%rbp), %rcx
movl $0xa, %edx
xorl %r8d, %r8d
movl $0x4, %r9d
callq 0x6be0
cmpl $0x0, %eax
jg 0x7e55
leaq 0x7db4(%rip), %rdi      # 0xfbf2
leaq 0x7dbb(%rip), %rsi      # 0xfc00
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0x7e93
movzbl -0x23(%rbp), %eax
movzbl -0x22(%rbp), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movzbl -0x21(%rbp), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movl %eax, -0x34(%rbp)
movzbl -0x24(%rbp), %eax
movzbl -0x11(%rbp), %ecx
cmpl %ecx, %eax
jne 0x7e8c
cmpl $0xffffff, -0x34(%rbp)  # imm = 0xFFFFFF
je 0x7e8c
movl -0x34(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_block_checksum(WdtDevice*, unsigned int*, unsigned int, unsigned int)
int wh_w8790_dev_block_checksum(WDT_DEV* pdev, UINT32* pchksum, UINT32 size, UINT32 init_value)
{
	BYTE cmd[10] = { 0 };
	BYTE buf[8] = { 0 };

	cmd[0] = W8790_COMMAND9;
	cmd[1] = W8790_BLOCK_CHECKSUM;
	put_unaligned_le32(size, &cmd[2]);
	put_unaligned_le16(init_value, &cmd[5]);

	if (wh_w8790_dev_command_write(pdev, cmd, 0, sizeof(cmd)) <= 0)
		return 0;

	if (wh_w8790_dev_wait_cmd_end(pdev, 0, 0) <= 0)
		return 0;

	if (wh_w8790_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)
leaq -0x2a(%rbp), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x2110
leaq -0x32(%rbp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x2110
movb $0x6, -0x2a(%rbp)
movb $-0x1d, -0x29(%rbp)
movl -0x1c(%rbp), %edi
leaq -0x2a(%rbp), %rsi
addq $0x2, %rsi
callq 0x9200
movl -0x20(%rbp), %eax
leaq -0x2a(%rbp), %rsi
addq $0x5, %rsi
movzwl %ax, %edi
callq 0x91b0
movq -0x10(%rbp), %rdi
leaq -0x2a(%rbp), %rsi
xorl %edx, %edx
movl $0xa, %ecx
callq 0x68a0
cmpl $0x0, %eax
jg 0x7f83
movl $0x0, -0x4(%rbp)
jmp 0x7fd7
movq -0x10(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x76a0
cmpl $0x0, %eax
jg 0x7f9e
movl $0x0, -0x4(%rbp)
jmp 0x7fd7
movq -0x10(%rbp), %rdi
leaq -0x32(%rbp), %rsi
movl $0x2, %edx
callq 0x77f0
cmpl $0x0, %eax
jg 0x7fbe
movl $0x0, -0x4(%rbp)
jmp 0x7fd7
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
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_flash_read_data(WdtDevice*, unsigned char*, unsigned int, int)
int wh_w8790_dev_flash_read_data(WDT_DEV* pdev, BYTE* data, UINT32 address, int length)
{
	if (!pdev || !data)
		return 0;

	// address and length should be align to 4
	if ((address & 0x3) != 0 || (length & 0x3) != 0)
		return 0;


	if (!wh_w8790_dev_set_flash_address(pdev, address))
		return 0;

	return wh_w8790_dev_read_flash(pdev, 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 0x8004
cmpq $0x0, -0x18(%rbp)
jne 0x800d
movl $0x0, -0x4(%rbp)
jmp 0x8059
movl -0x1c(%rbp), %eax
andl $0x3, %eax
cmpl $0x0, %eax
jne 0x8023
movl -0x20(%rbp), %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x802c
movl $0x0, -0x4(%rbp)
jmp 0x8059
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x6ef0
cmpl $0x0, %eax
jne 0x8046
movl $0x0, -0x4(%rbp)
jmp 0x8059
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x20(%rbp), %edx
callq 0x6de0
movl %eax, -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_flash_erase(WdtDevice*, unsigned int, int)
int wh_w8790_dev_flash_erase(WDT_DEV* pdev, UINT32 address, int size)
{
	int ret = wh_w8790_dev_flash_erase_cmd(pdev, address, size);

	if (ret <= 0)
		printf("%s: addr: %x, size: %x\n", __FUNCTION__, 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 0x7830
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jg 0x84c5
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
leaq 0x754b(%rip), %rdi      # 0xfa02
leaq 0x7760(%rip), %rsi      # 0xfc1e
movb $0x0, %al
callq 0x2050
movl -0x14(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_dev_write_register(WdtDevice*, unsigned int, unsigned int)
int wh_w8790_dev_write_register(WDT_DEV* pdev, UINT32 address, UINT32 reg_value)
{
    BYTE cmd[10] = { 0 };
    
    cmd[0] = W8790_COMMAND9;
    cmd[1] = (BYTE)W8790_WRITE_REGISTER;
    put_unaligned_le32(address, &cmd[2]);
    put_unaligned_le32(reg_value, &cmd[6]);

    return wh_w8790_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 0x68a0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_flash_section_header_checksum(FlashSectionHeader_8790_t)
UINT16 wh_w8790_flash_section_header_checksum(W8790_FLASH_SECTION_HEADER header)
{
	UINT16 sum = 0;
	sum = misr_32b(sum, header.PayloadSize);
	sum = misr_32b(sum, header.Param0);
	sum = misr_32b(sum, header.Param1);
	return sum;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x8(%rbp)
movw $0x0, -0x12(%rbp)
movw -0x12(%rbp), %ax
movl -0xc(%rbp), %esi
movzwl %ax, %edi
callq 0xb6b0
movw %ax, -0x12(%rbp)
movw -0x12(%rbp), %ax
movl -0x8(%rbp), %esi
movzwl %ax, %edi
callq 0xb6b0
movw %ax, -0x12(%rbp)
movw -0x12(%rbp), %ax
movl -0x4(%rbp), %esi
movzwl %ax, %edi
callq 0xb6b0
movw %ax, -0x12(%rbp)
movw -0x12(%rbp), %ax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: wh_get_device_access_func(int, FuncPtrStructDevAccess*)
int wh_get_device_access_func(int interfaceIndex, FUNC_PTR_STRUCT_DEV_ACCESS*  pFuncs)
{
	if (!pFuncs)
		return 0;

	if (interfaceIndex == INTERFACE_I2C) {
		pFuncs->p_wh_scan_device = (LPFUNC_wh_scan_device) wh_i2c_scan_device;
		pFuncs->p_wh_get_device = (LPFUNC_wh_get_device) wh_i2c_get_device;
		pFuncs->p_wh_open_device = (LPFUNC_wh_open_device) wh_i2c_open_device;
		pFuncs->p_wh_close_device = (LPFUNC_wh_close_device) wh_i2c_close_device;
		pFuncs->p_wh_prepare_data = (LPFUNC_wh_prepare_data) wh_i2c_prepare_data;			
		return 1;
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x8cfb
movl $0x0, -0x4(%rbp)
jmp 0x8d5b
cmpl $0x2, -0x8(%rbp)
jne 0x8d54
movq -0x10(%rbp), %rax
leaq 0x3164(%rip), %rcx      # 0xbe70
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
leaq 0x32a6(%rip), %rcx      # 0xbfc0
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
leaq 0x32e7(%rip), %rcx      # 0xc010
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
leaq 0x33f8(%rip), %rcx      # 0xc130
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
leaq 0x3669(%rip), %rcx      # 0xc3b0
movq %rcx, 0x20(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x8d5b
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: wh_get_device_basic_access_func(WdtDevice*, FuncPtrStructDevBasic*)
int wh_get_device_basic_access_func(WDT_DEV* pdev,  FUNC_PTR_STRUCT_DEV_BASIC*  pFuncs)
{
	if (!pFuncs || !pdev)
		return 0;


	if (pdev->board_info.dev_type & FW_WDT8755) {
		pFuncs->p_wh_get_feature = (LPFUNC_wh_get_feature) wh_w8755_dev_get_feature;
		pFuncs->p_wh_set_feature = (LPFUNC_wh_set_feature) wh_w8755_dev_set_feature;
		pFuncs->p_wh_read_report = (LPFUNC_wh_read_report) wh_w8755_dev_read_report;

		return 1;
	}
	
	if (pdev->board_info.dev_type & FW_WDT8760_2) {
		pFuncs->p_wh_get_feature = (LPFUNC_wh_get_feature) wh_w8760_dev_get_feature;
		pFuncs->p_wh_set_feature = (LPFUNC_wh_set_feature) wh_w8760_dev_set_feature;
		pFuncs->p_wh_read_report = (LPFUNC_wh_read_report) wh_w8760_dev_read_report;

		return 1;
	}

	if (pdev->board_info.dev_type & FW_WDT8790) {
		pFuncs->p_wh_get_feature = (LPFUNC_wh_get_feature) wh_w8790_dev_get_feature;
                pFuncs->p_wh_set_feature = (LPFUNC_wh_set_feature) wh_w8790_dev_set_feature;
                pFuncs->p_wh_read_report = (LPFUNC_wh_read_report) wh_w8790_dev_read_report;

		return 1;

        }



	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x8efa
cmpq $0x0, -0x10(%rbp)
jne 0x8f06
movl $0x0, -0x4(%rbp)
jmp 0x8fe9
movq -0x10(%rbp), %rax
movl 0x188(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x8f50
movq -0x18(%rbp), %rax
leaq -0x4d13(%rip), %rcx     # 0x4210
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
leaq -0x4d82(%rip), %rcx     # 0x41b0
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
leaq -0x4cd0(%rip), %rcx     # 0x4270
movq %rcx, 0x18(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x8fe9
movq -0x10(%rbp), %rax
movl 0x188(%rax), %eax
andl $0x2800, %eax           # imm = 0x2800
cmpl $0x0, %eax
je 0x8f99
movq -0x18(%rbp), %rax
leaq -0x458f(%rip), %rcx     # 0x49e0
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
leaq -0x466e(%rip), %rcx     # 0x4910
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
leaq -0x46dc(%rip), %rcx     # 0x48b0
movq %rcx, 0x18(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x8fe9
movq -0x10(%rbp), %rax
movl 0x188(%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x8fe2
movq -0x18(%rbp), %rax
leaq -0x2818(%rip), %rcx     # 0x67a0
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
leaq -0x28d7(%rip), %rcx     # 0x66f0
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
leaq -0x2945(%rip), %rcx     # 0x6690
movq %rcx, 0x18(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x8fe9
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nop
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: check_firmware_id(WdtDevice*, unsigned int)
int check_firmware_id(WDT_DEV *pdev, UINT32 fwid)
{
	if ((fwid & 0xF0000000) == 0x30000000) {
		if (pdev->pparam->argus & OPTION_INFO)		
			printf("It is WDT8755 or WDT8752 !\n");	
		return FW_WDT8755;
	}

	if ((fwid & 0xFFFF0000) == 0xFFFF0000) {
		if (pdev->pparam->argus & OPTION_INFO)		
			printf("It is WDT8752 recovery fw !\n");	
		return FW_WDT8755;
	}	

	if ((fwid & 0xF0000000) == 0x40000000) {
		if (pdev->pparam->argus & OPTION_INFO)	
			printf("It is WDT8760 alike !\n");	
		return FW_WDT8760;
	}

	if ((fwid & 0xFF000000) == 0x51000000) {
                if(pdev->pparam->argus & OPTION_INFO)
                        printf("It is WDT8730 !\n");
                return FW_NOT_SUPPORT;

        }

	//TODO: We will add new devices here and should before FW_WDT8970 for compatibility.

	if ((fwid & 0xFF000000) == 0x50000000) {
		if(pdev->pparam->argus & OPTION_INFO)
			printf("It is WDT8790 !\n");
		return FW_WDT8790;

	}
	
	return FW_WITH_CMD;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl -0x14(%rbp), %eax
andl $0xf0000000, %eax       # imm = 0xF0000000
cmpl $0x30000000, %eax       # imm = 0x30000000
jne 0x903d
movq -0x10(%rbp), %rax
movq 0x280(%rax), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x9031
leaq 0x6db3(%rip), %rdi      # 0xfddd
movb $0x0, %al
callq 0x2050
movl $0x20, -0x4(%rbp)
jmp 0x9133
movl -0x14(%rbp), %eax
andl $0xffff0000, %eax       # imm = 0xFFFF0000
cmpl $0xffff0000, %eax       # imm = 0xFFFF0000
jne 0x907b
movq -0x10(%rbp), %rax
movq 0x280(%rax), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x906f
leaq 0x6d91(%rip), %rdi      # 0xfdf9
movb $0x0, %al
callq 0x2050
movl $0x20, -0x4(%rbp)
jmp 0x9133
movl -0x14(%rbp), %eax
andl $0xf0000000, %eax       # imm = 0xF0000000
cmpl $0x40000000, %eax       # imm = 0x40000000
jne 0x90b6
movq -0x10(%rbp), %rax
movq 0x280(%rax), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x90ad
leaq 0x6d70(%rip), %rdi      # 0xfe16
movb $0x0, %al
callq 0x2050
movl $0x800, -0x4(%rbp)      # imm = 0x800
jmp 0x9133
movl -0x14(%rbp), %eax
andl $0xff000000, %eax       # imm = 0xFF000000
cmpl $0x51000000, %eax       # imm = 0x51000000
jne 0x90f1
movq -0x10(%rbp), %rax
movq 0x280(%rax), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x90e8
leaq 0x6d4c(%rip), %rdi      # 0xfe2d
movb $0x0, %al
callq 0x2050
movl $0x4, -0x4(%rbp)
jmp 0x9133
movl -0x14(%rbp), %eax
andl $0xff000000, %eax       # imm = 0xFF000000
cmpl $0x50000000, %eax       # imm = 0x50000000
jne 0x912c
movq -0x10(%rbp), %rax
movq 0x280(%rax), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x9123
leaq 0x6d22(%rip), %rdi      # 0xfe3e
movb $0x0, %al
callq 0x2050
movl $0x200, -0x4(%rbp)      # imm = 0x200
jmp 0x9133
movl $0x2, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: check_is_all_ff(unsigned char*, int)
int check_is_all_ff(BYTE* data, int length)
{
	if (data == 0)
		return 0;

	int idx;

	for (idx = 0; idx < length; idx++)
		if (data[idx] != 0xFF)
			return 0;
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x925b
movl $0x0, -0x4(%rbp)
jmp 0x929a
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x9293
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xff, %eax
je 0x9286
movl $0x0, -0x4(%rbp)
jmp 0x929a
jmp 0x9288
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x9262
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nop
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: count_ff_bytes(unsigned char*, int, int)
int count_ff_bytes(BYTE* data, int start, int size)
{
	int count = 0;
	for (int i = 0; i < size; i++)
	{
		if (data[start + i] == 0xFF)
			count++;
	}
	return count;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x92f2
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
addl -0x18(%rbp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xff, %eax
jne 0x92e5
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x92e7
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x92bc
movl -0x14(%rbp), %eax
popq %rbp
retq
nopw (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: load_lib_func_address(WdtDevice*, ExecParam*)
int load_lib_func_address(WDT_DEV *pdev, EXEC_PARAM *pparam)
{
	if (!pdev)
		return 0;

	pdev->func_wh_open_whiff = (LPFUNC_wh_open_whiff) wh_open_whiff_file;
	if (!pdev->func_wh_open_whiff) {
		printf("Not found: wh_open_whiff \n");
		return 0;
	}

	pdev->func_wh_close_whiff = (LPFUNC_wh_close_whiff) wh_close_whiff_file;
	if (!pdev->func_wh_close_whiff)	{
		printf("Not found: wh_close_whiff \n");
		return 0;
	}

	pdev->func_wh_get_chunk_info = (LPFUNC_wh_get_chunk_info) wh_get_chunk_info;
	if (!pdev->func_wh_get_chunk_info) {
		printf("Not found: wh_get_chunk_info \n");
		return 0;
	}

	pdev->func_wh_get_device_access_func = (LPFUNC_wh_get_device_access_func) wh_get_device_access_func;
	if (!pdev->func_wh_get_device_access_func) {
		printf("Not found: wh_get_device_access_func \n");
		return 0;
	}

	pdev->func_wh_get_device_private_access_func = (LPFUNC_wh_get_device_private_access_func) wh_get_device_private_access_func;
	if (!pdev->func_wh_get_device_private_access_func) {
		printf("Not found: wh_get_device_private_access_func \n");
		return 0;
	}

	pdev->func_wh_get_device_basic_access_func = (LPFUNC_wh_get_device_basic_access_func) wh_get_device_basic_access_func;
	if (!pdev->func_wh_get_device_basic_access_func) {
		printf("Not found: wh_get_device_basic_access_func \n");
		return 0;
	}
	
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x9323
movl $0x0, -0x4(%rbp)
jmp 0x947d
movq -0x10(%rbp), %rax
leaq 0x162(%rip), %rcx       # 0x9490
movq %rcx, 0x308(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x308(%rax)
jne 0x935d
leaq 0x6b05(%rip), %rdi      # 0xfe4f
movb $0x0, %al
callq 0x2050
movl $0x0, -0x4(%rbp)
jmp 0x947d
movq -0x10(%rbp), %rax
leaq 0x258(%rip), %rcx       # 0x95c0
movq %rcx, 0x310(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x310(%rax)
jne 0x9397
leaq 0x6ae6(%rip), %rdi      # 0xfe6a
movb $0x0, %al
callq 0x2050
movl $0x0, -0x4(%rbp)
jmp 0x947d
movq -0x10(%rbp), %rax
leaq 0x27e(%rip), %rcx       # 0x9620
movq %rcx, 0x318(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x318(%rax)
jne 0x93d1
leaq 0x6ac8(%rip), %rdi      # 0xfe86
movb $0x0, %al
callq 0x2050
movl $0x0, -0x4(%rbp)
jmp 0x947d
movq -0x10(%rbp), %rax
leaq -0x6fc(%rip), %rcx      # 0x8ce0
movq %rcx, 0x320(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x320(%rax)
jne 0x9408
leaq 0x6aad(%rip), %rdi      # 0xfea5
movb $0x0, %al
callq 0x2050
movl $0x0, -0x4(%rbp)
jmp 0x947d
movq -0x10(%rbp), %rax
leaq -0x6b3(%rip), %rcx      # 0x8d60
movq %rcx, 0x328(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x328(%rax)
jne 0x943f
leaq 0x6a9d(%rip), %rdi      # 0xfecc
movb $0x0, %al
callq 0x2050
movl $0x0, -0x4(%rbp)
jmp 0x947d
movq -0x10(%rbp), %rax
leaq -0x56a(%rip), %rcx      # 0x8ee0
movq %rcx, 0x330(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x330(%rax)
jne 0x9476
leaq 0x6a95(%rip), %rdi      # 0xfefb
movb $0x0, %al
callq 0x2050
movl $0x0, -0x4(%rbp)
jmp 0x947d
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/wdt_dev_api.cpp
// Function: wh_open_whiff_file(char*)
WH_HANDLE wh_open_whiff_file(char* path)
{
	FILE*			pfile = NULL;
	WIF_FILE 		*pcur_wif = NULL;

	pfile = fopen(path, "rb");
	if (!pfile)
		return NULL;

	pcur_wif = (WIF_FILE*) malloc(sizeof(WIF_FILE));
	if (!pcur_wif) {
		fclose(pfile);
		return NULL;
	}

	/* set file ptr to the end */
	fseek(pfile, 0, SEEK_END);
	pcur_wif->data_len = ftell(pfile);

	/* set the file ptr the beginning */
	rewind(pfile);		

	pcur_wif->pdata = (BYTE*) malloc(pcur_wif->data_len + 32);

	if (!pcur_wif->pdata)
		goto failed;

	if (fread(pcur_wif->pdata, 1, pcur_wif->data_len, pfile) == pcur_wif->data_len)	{	
		process_whiff_file(pcur_wif);
		fclose(pfile);

		return (WH_HANDLE) pcur_wif;
	}

failed:
	wh_close_whiff_file((WH_HANDLE) pcur_wif);
		
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x72ad(%rip), %rsi      # 0x10764
callq 0x21d0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x94d4
movq $0x0, -0x8(%rbp)
jmp 0x95ae
movl $0x18, %edi
callq 0x21f0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x94ff
movq -0x18(%rbp), %rdi
callq 0x21a0
movq $0x0, -0x8(%rbp)
jmp 0x95ae
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
callq 0x21c0
movq -0x18(%rbp), %rdi
callq 0x2030
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rdi
callq 0x2070
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x20, %eax
movl %eax, %eax
movl %eax, %edi
callq 0x21f0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x9555
jmp 0x959d
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %edx
movq -0x18(%rbp), %rcx
movl $0x1, %esi
callq 0x2230
movq -0x20(%rbp), %rcx
movl 0x8(%rcx), %ecx
cmpq %rcx, %rax
jne 0x959b
movq -0x20(%rbp), %rdi
callq 0xb580
movq -0x18(%rbp), %rdi
callq 0x21a0
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x95ae
jmp 0x959d
movq -0x20(%rbp), %rdi
callq 0x95c0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: wh_close_whiff_file(void*)
int wh_close_whiff_file(WH_HANDLE handle)
{
	WIF_FILE	*pcur_wif = (WIF_FILE*) handle;

	if (pcur_wif) {
		if (pcur_wif->pdata)
			free(pcur_wif->pdata);

		free(pcur_wif);
		return 1;
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x9603
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
je 0x95f1
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x21e0
movq -0x18(%rbp), %rdi
callq 0x21e0
movl $0x1, -0x4(%rbp)
jmp 0x960a
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)