LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: wh_get_chunk_info(void*, unsigned int, ChunkInfoEx*)
int wh_get_chunk_info(WH_HANDLE handle, UINT32 chunk_index, CHUNK_INFO_EX* pchunk_info_ex)
{
	WIF_FILE	*pcur_wif = (WIF_FILE*) handle;

	if (!pcur_wif)
		return 0;

	UINT32	chunk_four_cc = get_chunk_fourcc (chunk_index);

	if (!chunk_four_cc)
		return 0;

	if (!pcur_wif->pformat_chunk)
		return 0;

	/* check if the chunk is existed */
	if (pcur_wif->pformat_chunk->enableFlag | chunk_index) {
		
		/* 12 is the header size */
		UINT32	chunk_start_pos = 12 + sizeof (FORMAT_CHUNK);
		CHUNK_DATA*	pchunk_data = NULL;

		while (chunk_start_pos < pcur_wif->data_len) {
			pchunk_data = (CHUNK_DATA*) & pcur_wif->pdata[chunk_start_pos];

			/* we got it */
			if (pchunk_data->ckID == chunk_four_cc)	{
				memcpy((void*) &pchunk_info_ex->chuckInfo, (void*) &pchunk_data->chunkInfo, sizeof(CHUNK_INFO));
				pchunk_info_ex->length = pchunk_data->chunkInfo.length;
				pchunk_info_ex->pData = (BYTE*) &pcur_wif->pdata[chunk_start_pos + 8 + sizeof(CHUNK_INFO)];
				
				return 1;
			} else
				/* 8 is the header size */
				chunk_start_pos = chunk_start_pos + pchunk_data->ckSize + 8;
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x964e
movl $0x0, -0x4(%rbp)
jmp 0x9746
movl -0x14(%rbp), %edi
callq 0xb490
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x966b
movl $0x0, -0x4(%rbp)
jmp 0x9746
movq -0x28(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x9682
movl $0x0, -0x4(%rbp)
jmp 0x9746
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movl 0xc(%rax), %eax
orl -0x14(%rbp), %eax
cmpl $0x0, %eax
je 0x973f
movl $0x28, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movl -0x30(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jae 0x973d
movq -0x28(%rbp), %rax
movq (%rax), %rax
movl -0x30(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl (%rax), %eax
cmpl -0x2c(%rbp), %eax
jne 0x9728
movq -0x20(%rbp), %rax
movq -0x38(%rbp), %rcx
movq 0x8(%rcx), %rdx
movq %rdx, (%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movl -0x30(%rbp), %eax
addl $0x8, %eax
movl %eax, %eax
addq $0x18, %rax
addq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x9746
movl -0x30(%rbp), %eax
movq -0x38(%rbp), %rcx
addl 0x4(%rcx), %eax
addl $0x8, %eax
movl %eax, -0x30(%rbp)
jmp 0x96a8
jmp 0x973f
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: load_wif(WdtDevice*, char*)
int load_wif(WDT_DEV *pdev, char *path)
{
	if (!pdev || !path)
		return 0;

	strcpy(pdev->wif_access.wif_path, path);

	pdev->wif_access.wif_handle = pdev->func_wh_open_whiff(pdev->wif_access.wif_path);

	if (!pdev->wif_access.wif_handle) {
		wh_printf("Parse input file error");
		return 0;
	}

	memset(&pdev->wif_access.wif_chunk_info, 0, sizeof(CHUNK_INFO_EX));

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x976e
cmpq $0x0, -0x18(%rbp)
jne 0x9777
movl $0x0, -0x4(%rbp)
jmp 0x97f2
movq -0x10(%rbp), %rdi
addq $0x58, %rdi
movq -0x18(%rbp), %rsi
callq 0x2180
movq -0x10(%rbp), %rax
movq 0x308(%rax), %rax
movq -0x10(%rbp), %rdi
addq $0x58, %rdi
callq *%rax
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x158(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x158(%rax)
jne 0x97d0
leaq 0x6768(%rip), %rdi      # 0xff28
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0x97f2
movq -0x10(%rbp), %rdi
addq $0x58, %rdi
addq $0x108, %rdi            # imm = 0x108
xorl %esi, %esi
movl $0x28, %edx
callq 0x2110
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: close_wif(WdtDevice*)
int close_wif(WDT_DEV *pdev)
{
	if (!pdev->func_wh_close_whiff(pdev->wif_access.wif_handle)) {
		wh_printf("Close input file error");
		return 0;
	}
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x310(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x158(%rcx), %rdi
callq *%rax
cmpl $0x0, %eax
jne 0x9840
leaq 0x670f(%rip), %rdi      # 0xff3f
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0x9847
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: config_id_check(ExecParam*, BoardInfo*, ChunkInfoEx*)
int config_id_check(EXEC_PARAM *pparam, BOARD_INFO *pinfo, CHUNK_INFO_EX *pchunk_info)
{
	if (!pparam || !pinfo || !pchunk_info)
		return 0;

	unsigned int 	xmlId = 0;

	if (pchunk_info->chuckInfo.attribute & 0x2)
		xmlId = pchunk_info->chuckInfo.versionNumber;

	wh_printf("The config data in dev: %04x, wif: %04x\n", xmlId, pinfo->sys_param.xmls_id1);
	if (xmlId == pinfo->sys_param.xmls_id1) 
		return 2;

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x9d79
cmpq $0x0, -0x18(%rbp)
je 0x9d79
cmpq $0x0, -0x20(%rbp)
jne 0x9d82
movl $0x0, -0x4(%rbp)
jmp 0x9dda
movl $0x0, -0x24(%rbp)
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x9da2
movq -0x20(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %esi
movq -0x18(%rbp), %rax
movzwl 0x20(%rax), %edx
leaq 0x62d3(%rip), %rdi      # 0x10087
movb $0x0, %al
callq 0x24e0
movl -0x24(%rbp), %eax
movq -0x18(%rbp), %rcx
movzwl 0x20(%rcx), %ecx
cmpl %ecx, %eax
jne 0x9dd3
movl $0x2, -0x4(%rbp)
jmp 0x9dda
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/wdt_dev_api.cpp
// Function: program_one_chunk(WdtDevice*, char const*, unsigned int, unsigned int, ChunkInfoEx*)
int program_one_chunk(WDT_DEV *pdev, const char *chunk_name, UINT32 chunk_id, UINT32 option, CHUNK_INFO_EX *pinfo)
{
	CHUNK_INFO_EX	chunk_info;
	CHUNK_INFO_EX	*pchunk_info = NULL;

	if (!pdev)
		return 0;

	if (pinfo == NULL) {
		memset(&chunk_info, 0, sizeof(CHUNK_INFO_EX));
		if (pdev->func_wh_get_chunk_info(pdev->wif_access.wif_handle, chunk_id, &chunk_info))
			pchunk_info = &chunk_info;
		else
			return 1;
	} else
		pchunk_info = pinfo;

	if (!pchunk_info)
		return 0;
		
	printf("\n[%s] programming ....\n", chunk_name);
				
	if (!pdev->funcs_device_private.p_wh_program_chunk(pdev, pchunk_info, option ))	{
		char	msg[64];

		sprintf(msg, "[%s] Write chunk error", chunk_name);
		wh_printf(msg);
		return 0;	
	}

	printf("[%s] chunk program : pass...\n", chunk_name);
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq $0x0, -0x58(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x9e28
movl $0x0, -0x4(%rbp)
jmp 0x9f0b
cmpq $0x0, -0x28(%rbp)
jne 0x9e7b
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x2110
movq -0x10(%rbp), %rax
movq 0x318(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x158(%rcx), %rdi
movl -0x1c(%rbp), %esi
leaq -0x50(%rbp), %rdx
callq *%rax
cmpl $0x0, %eax
je 0x9e6d
leaq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x9e79
movl $0x1, -0x4(%rbp)
jmp 0x9f0b
jmp 0x9e83
movq -0x28(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x9e93
movl $0x0, -0x4(%rbp)
jmp 0x9f0b
movq -0x18(%rbp), %rsi
leaq 0x6212(%rip), %rdi      # 0x100b0
movb $0x0, %al
callq 0x2050
movq -0x10(%rbp), %rax
movq 0x2b0(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rsi
movl -0x20(%rbp), %edx
callq *%rax
cmpl $0x0, %eax
jne 0x9ef2
leaq -0xa0(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x61f4(%rip), %rsi      # 0x100c8
movb $0x0, %al
callq 0x2080
leaq -0xa0(%rbp), %rdi
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0x9f0b
movq -0x18(%rbp), %rsi
leaq 0x61e2(%rip), %rdi      # 0x100df
movb $0x0, %al
callq 0x2050
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: show_wif_info(WdtDevice*, ExecParam*)
int show_wif_info(WDT_DEV *pdev, EXEC_PARAM *pparam)
{
	if (!pdev || !pparam)
		return 0;
	if(show_wif2_info((char*)pparam->image_file))
		return 1;

	if (!load_wif(pdev, (char*)pparam->image_file))
		return 0;

	CHUNK_INFO_EX chunk_info_ex;
	if (pdev->func_wh_get_chunk_info(pdev->wif_access.wif_handle, CHUNK_ID_FRWR, &chunk_info_ex)) 
		printf("FW id: 0x%08x\n", chunk_info_ex.chuckInfo.versionNumber);

	if (pdev->func_wh_get_chunk_info(pdev->wif_access.wif_handle, CHUNK_ID_CNFG, &chunk_info_ex)) {
		UINT32	config_id = 0;
		
		if (chunk_info_ex.chuckInfo.attribute & 0x2)
			config_id = chunk_info_ex.chuckInfo.versionNumber;
		printf("Config id: 0x%x\n", config_id);		
	}
	
	if (!close_wif(pdev))
		return 0; 
	
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xadbe
cmpq $0x0, -0x18(%rbp)
jne 0xadca
movl $0x0, -0x4(%rbp)
jmp 0xaeae
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xe3b0
cmpl $0x0, %eax
je 0xade8
movl $0x1, -0x4(%rbp)
jmp 0xaeae
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x9750
cmpl $0x0, %eax
jne 0xae0a
movl $0x0, -0x4(%rbp)
jmp 0xaeae
movq -0x10(%rbp), %rax
movq 0x318(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x158(%rcx), %rdi
movl $0x1, %esi
leaq -0x40(%rbp), %rdx
callq *%rax
cmpl $0x0, %eax
je 0xae41
movl -0x34(%rbp), %esi
leaq 0x5780(%rip), %rdi      # 0x105ba
movb $0x0, %al
callq 0x2050
movq -0x10(%rbp), %rax
movq 0x318(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x158(%rcx), %rdi
movl $0x2, %esi
leaq -0x40(%rbp), %rdx
callq *%rax
cmpl $0x0, %eax
je 0xae90
movl $0x0, -0x44(%rbp)
movl -0x30(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xae7f
movl -0x34(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %esi
leaq 0x5740(%rip), %rdi      # 0x105c9
movb $0x0, %al
callq 0x2050
movq -0x10(%rbp), %rdi
callq 0x9800
cmpl $0x0, %eax
jne 0xaea7
movl $0x0, -0x4(%rbp)
jmp 0xaeae
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: find_hid_dev_name(int, int, int, char*)
int find_hid_dev_name(int bus, int vid, int pid, char *device_name)
{
	int ret = 0;
	struct dirent * dev_dir_entry;
	DIR * dev_dir;
	char device_ids[32];

	snprintf(device_ids, 15, "%04X:%04X:%04X", bus, vid, pid);

	dev_dir = opendir("/sys/bus/hid/devices");
	if (!dev_dir) {
		printf("open dev dir failed !\n");
		return 0;
	}

	while ((dev_dir_entry = readdir(dev_dir)) != NULL) {
		if (!strncmp(dev_dir_entry->d_name, device_ids, 14)) {
			strcpy(device_name, dev_dir_entry->d_name);
			ret = 1;
			break;
		}
	}
	closedir(dev_dir);

	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
leaq -0x50(%rbp), %rdi
movl -0x8(%rbp), %ecx
movl -0xc(%rbp), %r8d
movl -0x10(%rbp), %r9d
movl $0xf, %esi
leaq 0x56e3(%rip), %rdx      # 0x105da
movb $0x0, %al
callq 0x2270
leaq 0x56e4(%rip), %rdi      # 0x105e9
callq 0x2240
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0xaf2c
leaq 0x56e2(%rip), %rdi      # 0x105fe
movb $0x0, %al
callq 0x2050
movl $0x0, -0x4(%rbp)
jmp 0xaf87
jmp 0xaf2e
movq -0x30(%rbp), %rdi
callq 0x2250
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0xaf78
movq -0x28(%rbp), %rdi
addq $0x13, %rdi
leaq -0x50(%rbp), %rsi
movl $0xe, %edx
callq 0x20e0
cmpl $0x0, %eax
jne 0xaf76
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
addq $0x13, %rsi
callq 0x2180
movl $0x1, -0x1c(%rbp)
jmp 0xaf78
jmp 0xaf2e
movq -0x30(%rbp), %rdi
callq 0x2280
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: write_devname_to_sys_attr(char const*, char const*)
int write_devname_to_sys_attr(const char *attr, const char *action)
{
	int fd;
	ssize_t size;

	fd = open(attr, O_WRONLY);
	if (fd < 0) {
		printf("%s: open file error !", __func__);
		return 0;
	}

	for (;;) {
		size = write(fd, action, strlen(action));
		if (size < 0) {
			if (errno == EINTR)
				continue;

			return 0;
		}
		break;
	}

	close(fd);

	return (size == (ssize_t) strlen(action));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
movb $0x0, %al
callq 0x2140
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jge 0xb247
leaq 0x542e(%rip), %rdi      # 0x1065e
leaq 0x543d(%rip), %rsi      # 0x10674
movb $0x0, %al
callq 0x2050
movl $0x0, -0x4(%rbp)
jmp 0xb2bf
jmp 0xb249
movl -0x1c(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20d0
movl -0x34(%rbp), %edi
movq -0x30(%rbp), %rsi
movq %rax, %rdx
callq 0x20b0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jge 0xb28f
callq 0x2040
cmpl $0x4, (%rax)
jne 0xb286
jmp 0xb249
movl $0x0, -0x4(%rbp)
jmp 0xb2bf
jmp 0xb291
movl -0x1c(%rbp), %edi
callq 0x22c0
movq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20d0
movq %rax, %rcx
movq -0x40(%rbp), %rax
cmpq %rcx, %rax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: rebind_driver(WdtDevice*)
int rebind_driver(WDT_DEV *pdev)
{
	int 	bus = 0x18;
	int 	vendor = pdev->board_info.vid;
	int 	product = pdev->board_info.pid;
	char	hid_dev_name[64];
	char	driver_path[64];
	char	i2c_dev_name[64];
	char	attr_str[70];

	printf("Start to rebind driver !\n");

	if (!find_hid_dev_name(bus, vendor, product, hid_dev_name)) {
		printf("Not found hid device: 0x%x:0x%x:0x%x\n", bus, vendor, product);
		return 0;
	}



	strcpy(driver_path, "/sys/bus/i2c/drivers/");

	if (!find_device_name(hid_dev_name, i2c_dev_name, driver_path)) {
		printf("find device name failed %s\n", hid_dev_name);
		return 0;
	}


	sprintf(attr_str, "%s%s", driver_path, "unbind");


	if (!write_devname_to_sys_attr(attr_str, i2c_dev_name)) {
		printf("failed to unbind HID device %s %s\n", attr_str, i2c_dev_name);
		return 0;
	}
	
	wh_sleep(300);

	sprintf(attr_str, "%s%s", driver_path, "bind");

	if (!write_devname_to_sys_attr(attr_str, i2c_dev_name)) {
		printf("failed to bind HID device %s %s\n", attr_str, i2c_dev_name);
		return 0;
	}

	wh_sleep(300);

	printf("Rebind driver is done !\n");

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x10(%rbp)
movl $0x18, -0x14(%rbp)
movq -0x10(%rbp), %rax
movl 0x18c(%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x190(%rax), %eax
movl %eax, -0x1c(%rbp)
leaq 0x5387(%rip), %rdi      # 0x1068e
movb $0x0, %al
callq 0x2050
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
movl -0x1c(%rbp), %edx
leaq -0x60(%rbp), %rcx
callq 0xaec0
cmpl $0x0, %eax
jne 0xb348
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
movl -0x1c(%rbp), %ecx
leaq 0x5373(%rip), %rdi      # 0x106a8
movb $0x0, %al
callq 0x2050
movl $0x0, -0x4(%rbp)
jmp 0xb481
leaq -0xa0(%rbp), %rdi
leaq 0x5378(%rip), %rsi      # 0x106ce
callq 0x2180
leaq -0x60(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
callq 0xaf90
cmpl $0x0, %eax
jne 0xb395
leaq -0x60(%rbp), %rsi
leaq 0x5362(%rip), %rdi      # 0x106e4
movb $0x0, %al
callq 0x2050
movl $0x0, -0x4(%rbp)
jmp 0xb481
leaq -0x130(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
leaq 0x5289(%rip), %rsi      # 0x10633
leaq 0x534f(%rip), %rcx      # 0x10700
movb $0x0, %al
callq 0x2080
leaq -0x130(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0xb200
cmpl $0x0, %eax
jne 0xb3f8
leaq -0x130(%rbp), %rsi
leaq -0xe0(%rbp), %rdx
leaq 0x5322(%rip), %rdi      # 0x10707
movb $0x0, %al
callq 0x2050
movl $0x0, -0x4(%rbp)
jmp 0xb481
movl $0x12c, %edi            # imm = 0x12C
callq 0x2590
leaq -0x130(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
leaq 0x521c(%rip), %rsi      # 0x10633
leaq 0x3fc0(%rip), %rcx      # 0xf3de
movb $0x0, %al
callq 0x2080
leaq -0x130(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0xb200
cmpl $0x0, %eax
jne 0xb462
leaq -0x130(%rbp), %rsi
leaq -0xe0(%rbp), %rdx
leaq 0x52d8(%rip), %rdi      # 0x1072a
movb $0x0, %al
callq 0x2050
movl $0x0, -0x4(%rbp)
jmp 0xb481
movl $0x12c, %edi            # imm = 0x12C
callq 0x2590
leaq 0x52d8(%rip), %rdi      # 0x1074b
movb $0x0, %al
callq 0x2050
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nopl (%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: get_chunk_fourcc(unsigned int)
UINT32 get_chunk_fourcc(UINT32 chunk_index)
{
	switch (chunk_index) {
		case	CHUNK_ID_FRMT:
			return FOURCC_ID_FRMT;
		case	CHUNK_ID_FRWR:
			return FOURCC_ID_FRWR;
		case	CHUNK_ID_CNFG:
			return FOURCC_ID_CNFG;
		case	CHUNK_ID_HDRS:
			return FOURCC_ID_HDRS;
		case	CHUNK_ID_FSBT:
			return FOURCC_ID_FSBT;
		case	CHUNK_ID_BINF:
			return FOURCC_ID_BINF;
		case	CHUNK_ID_RCVY:
			return FOURCC_ID_RCVY;
		case	CHUNK_ID_TSTB:
			return FOURCC_ID_TSTB;
		case	CHUNK_ID_EXTB:
			return FOURCC_ID_EXTB;
		case	CHUNK_ID_FRWD:
			return FOURCC_ID_FRWD;
		case 	CHUNK_ID_CNFD:
			return FOURCC_ID_CNFD;
		default:
			return 0;
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x8(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0xc(%rbp)
testl %eax, %eax
je 0xb50d
jmp 0xb4a3
movl -0xc(%rbp), %eax
subl $0x1, %eax
je 0xb516
jmp 0xb4ad
movl -0xc(%rbp), %eax
subl $0x2, %eax
je 0xb51f
jmp 0xb4b7
movl -0xc(%rbp), %eax
subl $0x4, %eax
je 0xb528
jmp 0xb4c1
movl -0xc(%rbp), %eax
subl $0x8, %eax
je 0xb531
jmp 0xb4cb
movl -0xc(%rbp), %eax
subl $0x10, %eax
je 0xb53a
jmp 0xb4d5
movl -0xc(%rbp), %eax
subl $0x20, %eax
je 0xb543
jmp 0xb4df
movl -0xc(%rbp), %eax
subl $0x40, %eax
je 0xb54c
jmp 0xb4e9
movl -0xc(%rbp), %eax
subl $0x80, %eax
je 0xb555
jmp 0xb4f5
movl -0xc(%rbp), %eax
subl $0x200, %eax            # imm = 0x200
je 0xb55e
jmp 0xb501
movl -0xc(%rbp), %eax
subl $0x400, %eax            # imm = 0x400
je 0xb567
jmp 0xb570
movl $0x544d5246, -0x4(%rbp) # imm = 0x544D5246
jmp 0xb577
movl $0x52575246, -0x4(%rbp) # imm = 0x52575246
jmp 0xb577
movl $0x47464e43, -0x4(%rbp) # imm = 0x47464E43
jmp 0xb577
movl $0x53524448, -0x4(%rbp) # imm = 0x53524448
jmp 0xb577
movl $0x54425346, -0x4(%rbp) # imm = 0x54425346
jmp 0xb577
movl $0x464e4942, -0x4(%rbp) # imm = 0x464E4942
jmp 0xb577
movl $0x52435659, -0x4(%rbp) # imm = 0x52435659
jmp 0xb577
movl $0x54535442, -0x4(%rbp) # imm = 0x54535442
jmp 0xb577
movl $0x45585442, -0x4(%rbp) # imm = 0x45585442
jmp 0xb577
movl $0x44575246, -0x4(%rbp) # imm = 0x44575246
jmp 0xb577
movl $0x44464e43, -0x4(%rbp) # imm = 0x44464E43
jmp 0xb577
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: process_whiff_file(WifFile*)
int process_whiff_file(WIF_FILE *pcur_wif)
{
	UINT32*	pstruct = NULL;

	if (!pcur_wif)
		return 0;

	pstruct = (UINT32*) pcur_wif->pdata;

	if (pstruct[0] == FOURCC_ID_RIFF && pstruct[2] == FOURCC_ID_WHIF) {
		
		/* lengths should be the same */
		if (pcur_wif->data_len == pstruct[1]) {
			pcur_wif->pformat_chunk = (FORMAT_CHUNK*) &pstruct[3];
			return 1;
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xb5a0
movl $0x0, -0x4(%rbp)
jmp 0xb5f6
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x46464952, (%rax)     # imm = 0x46464952
jne 0xb5ef
movq -0x18(%rbp), %rax
cmpl $0x46494857, 0x8(%rax)  # imm = 0x46494857
jne 0xb5ef
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jne 0xb5ed
movq -0x18(%rbp), %rcx
addq $0xc, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movl $0x1, -0x4(%rbp)
jmp 0xb5f6
jmp 0xb5ef
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: misr_16b(unsigned short, unsigned short)
UINT16 misr_16b(UINT16 current_value, UINT16 new_value)
{
	unsigned int a, b;
	unsigned int bit0;
	UINT16 y;

	a = current_value;
	b = new_value;
	bit0 = a^(b&1);
	bit0 ^= a>>1;
	bit0 ^= a>>2;
	bit0 ^= a>>4;
	bit0 ^= a>>5;
	bit0 ^= a>>7;
	bit0 ^= a>>11;
	bit0 ^= a>>15;
	y = (a<<1)^b;
	y = (y&~1) | (bit0&1);

	return y;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movw %si, %ax
movw %di, %cx
movw %cx, -0x2(%rbp)
movw %ax, -0x4(%rbp)
movzwl -0x2(%rbp), %eax
movl %eax, -0x8(%rbp)
movzwl -0x4(%rbp), %eax
movl %eax, -0xc(%rbp)
movl -0x8(%rbp), %eax
movl -0xc(%rbp), %ecx
andl $0x1, %ecx
xorl %ecx, %eax
movl %eax, -0x10(%rbp)
movl -0x8(%rbp), %eax
shrl %eax
xorl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x8(%rbp), %eax
shrl $0x2, %eax
xorl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x8(%rbp), %eax
shrl $0x4, %eax
xorl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x8(%rbp), %eax
shrl $0x5, %eax
xorl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x8(%rbp), %eax
shrl $0x7, %eax
xorl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x8(%rbp), %eax
shrl $0xb, %eax
xorl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x8(%rbp), %eax
shrl $0xf, %eax
xorl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x8(%rbp), %eax
shll %eax
xorl -0xc(%rbp), %eax
movw %ax, -0x12(%rbp)
movzwl -0x12(%rbp), %eax
andl $-0x2, %eax
movl -0x10(%rbp), %ecx
andl $0x1, %ecx
orl %ecx, %eax
movw %ax, -0x12(%rbp)
movw -0x12(%rbp), %ax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: misr_for_halfwords(unsigned short, unsigned char*, int, int)
UINT16 misr_for_halfwords(UINT16 current_value, BYTE *buf, int start, int hword_count)
{
	int i;
	UINT32 checksum = current_value;
	UINT16 *p_hword = (UINT16 *)&buf[start];
	
	for (i = 0; i < hword_count; i++)
		checksum = misr_16b(checksum, *p_hword++);

	return checksum;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movw %di, %ax
movw %ax, -0x2(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movzwl -0x2(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0xb76f
movl -0x20(%rbp), %eax
movw %ax, %cx
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x2, %rdx
movq %rdx, -0x28(%rbp)
movzwl %cx, %edi
movzwl (%rax), %esi
callq 0xb600
movzwl %ax, %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xb736
movl -0x20(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: misr_for_bytes(unsigned short, unsigned char*, int, int)
UINT16 misr_for_bytes(UINT16 current_value, BYTE *bytes, int start, int size)
{
	UINT32 checksum = current_value;

	if (size / 2 > 0)
		checksum = misr_for_halfwords(checksum, bytes, start, size / 2);

	if ((size % 2) != 0)
		checksum = misr_16b(checksum, bytes[start + size - 1]);
	
	return checksum;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movw %di, %ax
movw %ax, -0x2(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movzwl -0x2(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %eax
jle 0xb7e3
movl -0x1c(%rbp), %eax
movw %ax, -0x1e(%rbp)
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x18(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl -0x24(%rbp), %edx
movl %eax, %ecx
movw -0x1e(%rbp), %ax
movzwl %ax, %edi
callq 0xb700
movzwl %ax, %eax
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0xb81e
movl -0x1c(%rbp), %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %edx
addl -0x18(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
movzbl (%rax,%rdx), %eax
movzwl %cx, %edi
movzwl %ax, %esi
callq 0xb600
movzwl %ax, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/dev_def.h
// Function: get_i2c_address_map(char const*)
inline BYTE get_i2c_address_map(const char* generic_hid_name){

       I2C_ADDRESS_TABLE address_map[] = {
            { "WDHT0002", DEFAULT_I2C_ADDR },
            { "WDHT1F01", DEFAULT_I2C_ADDR },
            { "WDHT1F02", DEFAULT_I2C_ADDR },
            { "WDHT1F03", DEFAULT_I2C_ADDR },
            { "WDHT1F04", DEFAULT_I2C_ADDR },
            { "WDHT2001", DEFAULT_I2C_ADDR },
            { "WDHT2002", DEFAULT_I2C_ADDR },
            { "WDHT2601", 0x3c },
            { "WDHT2602", 0x3c },
       };
       for(size_t i =0;i< (sizeof (address_map) / sizeof (address_map[0]));i++){
           if(strncmp(generic_hid_name, address_map[i].generic_hid, 8) == 0 ){
               return address_map[i].address;
           }
       }
       return DEFAULT_I2C_ADDR;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
leaq -0xa0(%rbp), %rdi
leaq 0x9443(%rip), %rsi      # 0x14c90
movl $0x90, %edx
callq 0x2150
movq $0x0, -0xa8(%rbp)
cmpq $0x9, -0xa8(%rbp)
jae 0xb8ca
movq -0x10(%rbp), %rdi
movq -0xa8(%rbp), %rcx
leaq -0xa0(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movl $0x8, %edx
callq 0x20e0
cmpl $0x0, %eax
jne 0xb8b4
movq -0xa8(%rbp), %rcx
leaq -0xa0(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movb 0x8(%rax), %al
movb %al, -0x1(%rbp)
jmp 0xb8ce
jmp 0xb8b6
movq -0xa8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa8(%rbp)
jmp 0xb862
movb $0x2c, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0xb0, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/func_i2c.cpp
// Function: wh_i2c_scan_driver_path(WdtDevice*, int*)
int wh_i2c_scan_driver_path(WDT_DEV* pdev, int *adaptor_no)
{
	DIR *d;
	struct dirent *dir = NULL;
	int found = 0;
	int dev_addr = 0;

	/* weida driver path in sysfs */
	char dev_sysfs_path[] = "/sys/bus/i2c/drivers/wdt87xx_i2c";

	d = opendir(dev_sysfs_path);	
	if (d) {
		if (pdev->pparam->argus & OPTION_INFO)
			printf("Scan I2C device in driver path...\n");
		while ((dir = readdir(d)) != NULL) {
			sscanf(dir->d_name, "%d-%x", adaptor_no, &dev_addr);
			if (dev_addr == DEFAULT_I2C_ADDR) {
				found = 1;
				pdev->board_info.i2c_address = DEFAULT_I2C_ADDR;
				pdev->is_legacy = 1;
				break;	
			}
		}
		closedir(d);
	}

	return found;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
leaq -0x50(%rbp), %rdi
leaq 0x4f0f(%rip), %rsi      # 0x10820
movl $0x21, %edx
callq 0x2150
leaq -0x50(%rbp), %rdi
callq 0x2240
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0xb9b9
movq -0x8(%rbp), %rax
movq 0x280(%rax), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0xb956
leaq 0x4f7e(%rip), %rdi      # 0x108cd
movb $0x0, %al
callq 0x2050
jmp 0xb958
movq -0x18(%rbp), %rdi
callq 0x2250
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0xb9b0
movq -0x20(%rbp), %rdi
addq $0x13, %rdi
movq -0x10(%rbp), %rdx
leaq 0x4f72(%rip), %rsi      # 0x108f0
leaq -0x28(%rbp), %rcx
movb $0x0, %al
callq 0x2190
cmpl $0x2c, -0x28(%rbp)
jne 0xb9ae
movl $0x1, -0x24(%rbp)
movq -0x8(%rbp), %rax
movb $0x2c, 0x1d6(%rax)
movq -0x8(%rbp), %rax
movl $0x1, 0x4(%rax)
jmp 0xb9b0
jmp 0xb958
movq -0x18(%rbp), %rdi
callq 0x2280
movl -0x24(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/func_i2c.cpp
// Function: get_i2c_dev_count()
int get_i2c_dev_count(){
	char dev_sys_class_path[] = "/sys/class/i2c-adapter";
	int count = 0;
	struct dirent *dir = NULL;
	DIR *d;
	d = opendir(dev_sys_class_path);
	if(d){
		while ((dir = readdir(d)) != NULL) {
                    if(strncmp("i2c", dir->d_name, 3) == 0)
                        count ++;
		}
		closedir(d);
	}
	if(count == 0)
		return 16;
	else
		return count;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq 0x4e71(%rip), %rax      # 0x10850
movq %rax, -0x20(%rbp)
movq 0x4e6e(%rip), %rax      # 0x10858
movq %rax, -0x18(%rbp)
movl 0x4e6c(%rip), %eax      # 0x10860
movl %eax, -0x10(%rbp)
movw 0x4e66(%rip), %ax       # 0x10864
movw %ax, -0xc(%rbp)
movb 0x4e5e(%rip), %al       # 0x10866
movb %al, -0xa(%rbp)
movl $0x0, -0x24(%rbp)
movq $0x0, -0x30(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x2240
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xba75
jmp 0xba30
movq -0x38(%rbp), %rdi
callq 0x2250
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
je 0xba6c
movq -0x30(%rbp), %rsi
addq $0x13, %rsi
leaq 0x4ea4(%rip), %rdi      # 0x108f6
movl $0x3, %edx
callq 0x20e0
cmpl $0x0, %eax
jne 0xba6a
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xba30
movq -0x38(%rbp), %rdi
callq 0x2280
cmpl $0x0, -0x24(%rbp)
jne 0xba84
movl $0x10, -0x4(%rbp)
jmp 0xba8a
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/func_i2c.cpp
// Function: wh_i2c_scan_hid_of_path(WdtDevice*, int*)
int wh_i2c_scan_hid_of_path(WDT_DEV* pdev, int *adaptor_no)
{
        DIR     *d;
        struct dirent *dir = NULL;
        int found = 0;
        int dev_addr = 0;

        /* hid over i2c driver path in sysfs */
        char dev_sysfs_hid_path[] = "/sys/bus/i2c/drivers/i2c_hid_of";

        d = opendir(dev_sysfs_hid_path);
        if (d) {
                if (pdev->pparam->argus & OPTION_INFO)
                        printf("Scan I2C device in hid of path...\n");

                while ((dir = readdir(d)) != NULL) {
                        sscanf(dir->d_name, "%d-%x", adaptor_no, &dev_addr);
                        if (dev_addr == DEFAULT_I2C_ADDR) {
                                found = 1;
				pdev->board_info.i2c_address = DEFAULT_I2C_ADDR;
                                break;
                        }
                }
                closedir(d);
        }

        return found;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movq 0x4be3(%rip), %rax      # 0x10890
movq %rax, -0x50(%rbp)
movq 0x4be0(%rip), %rax      # 0x10898
movq %rax, -0x48(%rbp)
movq 0x4bdd(%rip), %rax      # 0x108a0
movq %rax, -0x40(%rbp)
movq 0x4bda(%rip), %rax      # 0x108a8
movq %rax, -0x38(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x2240
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0xbd61
movq -0x8(%rbp), %rax
movq 0x280(%rax), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0xbd09
leaq 0x4c55(%rip), %rdi      # 0x10957
movb $0x0, %al
callq 0x2050
jmp 0xbd0b
movq -0x18(%rbp), %rdi
callq 0x2250
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0xbd58
movq -0x20(%rbp), %rdi
addq $0x13, %rdi
movq -0x10(%rbp), %rdx
leaq 0x4bbf(%rip), %rsi      # 0x108f0
leaq -0x28(%rbp), %rcx
movb $0x0, %al
callq 0x2190
cmpl $0x2c, -0x28(%rbp)
jne 0xbd56
movl $0x1, -0x24(%rbp)
movq -0x8(%rbp), %rax
movb $0x2c, 0x1d6(%rax)
jmp 0xbd58
jmp 0xbd0b
movq -0x18(%rbp), %rdi
callq 0x2280
movl -0x24(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/func_i2c.cpp
// Function: wh_i2c_scan_hid_path(WdtDevice*, int*)
int wh_i2c_scan_hid_path(WDT_DEV* pdev, int *adaptor_no)
{
	DIR *d;
	struct dirent *dir = NULL;
	int found = 0;
	int dev_addr = 0;

	/* hid over i2c driver path in sysfs */
	char dev_sysfs_hid_path[] = "/sys/bus/i2c/drivers/i2c_hid";	

	d = opendir(dev_sysfs_hid_path);	
	if (d) {
		if (pdev->pparam->argus & OPTION_INFO)
			printf("Scan I2C device in hid path...\n");
		
		while ((dir = readdir(d)) != NULL) {
			sscanf(dir->d_name, "%d-%x", adaptor_no, &dev_addr);
			if (dev_addr == DEFAULT_I2C_ADDR) {
				found = 1;
				pdev->board_info.i2c_address = DEFAULT_I2C_ADDR;
				break;	
			}
		}
		closedir(d);
	}		

	return found;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movq 0x4b13(%rip), %rax      # 0x108b0
movq %rax, -0x50(%rbp)
movq 0x4b10(%rip), %rax      # 0x108b8
movq %rax, -0x48(%rbp)
movq 0x4b0d(%rip), %rax      # 0x108c0
movq %rax, -0x40(%rbp)
movl 0x4b0b(%rip), %eax      # 0x108c8
movl %eax, -0x38(%rbp)
movb 0x4b06(%rip), %al       # 0x108cc
movb %al, -0x34(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x2240
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0xbe58
movq -0x8(%rbp), %rax
movq 0x280(%rax), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0xbe00
leaq 0x4b81(%rip), %rdi      # 0x1097a
movb $0x0, %al
callq 0x2050
jmp 0xbe02
movq -0x18(%rbp), %rdi
callq 0x2250
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0xbe4f
movq -0x20(%rbp), %rdi
addq $0x13, %rdi
movq -0x10(%rbp), %rdx
leaq 0x4ac8(%rip), %rsi      # 0x108f0
leaq -0x28(%rbp), %rcx
movb $0x0, %al
callq 0x2190
cmpl $0x2c, -0x28(%rbp)
jne 0xbe4d
movl $0x1, -0x24(%rbp)
movq -0x8(%rbp), %rax
movb $0x2c, 0x1d6(%rax)
jmp 0xbe4f
jmp 0xbe02
movq -0x18(%rbp), %rdi
callq 0x2280
movl -0x24(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/func_i2c.cpp
// Function: wh_i2c_scan_device(WdtDevice*)
int wh_i2c_scan_device(WDT_DEV* pdev)
{
	int found = 0;
	int adaptor_no = -1;
	long file_no = 0;

	if (!pdev)
		return 0;

	strcpy(g_dev_path, "/dev/i2c-2");

	pdev->dev_state = DS_ENUM;

	found = wh_i2c_scan_adaptor_path(pdev, &adaptor_no);

	if(!found)
		found = wh_i2c_scan_hid_of_path(pdev, &adaptor_no);

	if (!found)
                found = wh_i2c_scan_hid_path(pdev, &adaptor_no);

	if(!found)
	        found = wh_i2c_scan_driver_path(pdev, &adaptor_no);

	if (!found)
		printf("Use the default i2c-dev: %s\n", g_dev_path);
	else
		sprintf(g_dev_path, "/dev/i2c-%d", adaptor_no);

	file_no = open(g_dev_path, O_RDWR);

	if (file_no < 0) {
		printf("Open device failed! file_no %ld \n", file_no);
		perror("Error: ");
		return 0;
	}

	pdev->adaptor_no = adaptor_no;

	close(file_no);

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl $0xffffffff, -0x18(%rbp) # imm = 0xFFFFFFFF
movq $0x0, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xbea5
movl $0x0, -0x4(%rbp)
jmp 0xbfb0
leaq 0x9534(%rip), %rdi      # 0x153e0
leaq 0x4ae7(%rip), %rsi      # 0x1099a
callq 0x2180
movq -0x10(%rbp), %rax
movl $0x1, 0x278(%rax)
movq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0xbaa0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0xbeec
movq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0xbc80
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0xbf02
movq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0xbd70
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0xbf18
movq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0xb8e0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0xbf35
leaq 0x4a80(%rip), %rdi      # 0x109a5
leaq 0x94b4(%rip), %rsi      # 0x153e0
movb $0x0, %al
callq 0x2050
jmp 0xbf4d
movl -0x18(%rbp), %edx
leaq 0x94a1(%rip), %rdi      # 0x153e0
leaq 0x4a7c(%rip), %rsi      # 0x109c2
movb $0x0, %al
callq 0x2080
leaq 0x948c(%rip), %rdi      # 0x153e0
movl $0x2, %esi
movb $0x0, %al
callq 0x2140
cltq
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jge 0xbf94
movq -0x20(%rbp), %rsi
leaq 0x4a56(%rip), %rdi      # 0x109ce
movb $0x0, %al
callq 0x2050
leaq 0x4a6a(%rip), %rdi      # 0x109f0
callq 0x2160
movl $0x0, -0x4(%rbp)
jmp 0xbfb0
movl -0x18(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x20(%rbp), %rax
movl %eax, %edi
callq 0x22c0
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/func_i2c.cpp
// Function: wh_i2c_get_device(WdtDevice*, WdtDeviceInfo*, int)
int wh_i2c_get_device(WDT_DEV* pdev, WDT_DEVICE_INFO *pDevInfo, int flag)
{
	if (pdev && pDevInfo) {
		strcpy(pDevInfo->path, g_dev_path);
		return 1;
	}

	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)
je 0xbffe
cmpq $0x0, -0x18(%rbp)
je 0xbffe
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
leaq 0x93f0(%rip), %rsi      # 0x153e0
callq 0x2180
movl $0x1, -0x4(%rbp)
jmp 0xc005
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop
// File: chenhn123[P]wdt_util_src/wdt_ct/func_i2c.cpp
// Function: wh_i2c_open_device(WdtDevice*)
int wh_i2c_open_device(WDT_DEV* pdev)
{
	long		fileno = 0;
	unsigned long	funcs = 0;

	if (!pdev)
		return 0;
	else 
		fileno = open(pdev->dev_path, O_RDWR);


	if (fileno >= 0) {
		if (ioctl(fileno, I2C_FUNCS, &funcs) < 0) {
			wh_printf("Can't get the i2c funcs !\n");
			wh_printf("strerror(errno): %s\n", strerror(errno));
			close(fileno);
			fileno = 0;
		}

		if (!(funcs & I2C_FUNC_I2C)) {
			wh_printf("Oops, no I2C function support !\n");
			close(fileno);
			fileno = 0;
		}

		pdev->dev_handle = (WH_HANDLE) fileno;
	} else
		printf("Can't open device %s\n", pdev->dev_path);

	return (fileno >= 0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xc03f
movl $0x0, -0x4(%rbp)
jmp 0xc120
movq -0x10(%rbp), %rdi
addq $0xc, %rdi
movl $0x2, %esi
movb $0x0, %al
callq 0x2140
cltq
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jl 0xc0fa
movq -0x18(%rbp), %rax
movl %eax, %edi
movl $0x705, %esi            # imm = 0x705
leaq -0x20(%rbp), %rdx
movb $0x0, %al
callq 0x2210
cmpl $0x0, %eax
jge 0xc0bd
leaq 0x4972(%rip), %rdi      # 0x109f8
movb $0x0, %al
callq 0x24e0
callq 0x2040
movl (%rax), %edi
callq 0x20a0
movq %rax, %rsi
leaq 0x4970(%rip), %rdi      # 0x10a13
movb $0x0, %al
callq 0x24e0
movq -0x18(%rbp), %rax
movl %eax, %edi
callq 0x22c0
movq $0x0, -0x18(%rbp)
movq -0x20(%rbp), %rax
andq $0x1, %rax
cmpq $0x0, %rax
jne 0xc0ec
leaq 0x4956(%rip), %rdi      # 0x10a28
movb $0x0, %al
callq 0x24e0
movq -0x18(%rbp), %rax
movl %eax, %edi
callq 0x22c0
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x50(%rax)
jmp 0xc110
movq -0x10(%rbp), %rsi
addq $0xc, %rsi
leaq 0x4940(%rip), %rdi      # 0x10a49
movb $0x0, %al
callq 0x2050
cmpq $0x0, -0x18(%rbp)
setge %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/func_i2c.cpp
// Function: wh_i2c_close_device(WdtDevice*)
int wh_i2c_close_device(WDT_DEV* pdev)
{
	if (pdev && pdev->dev_handle) {
		close((long) pdev->dev_handle);
		return 1;
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xc166
movq -0x10(%rbp), %rax
cmpq $0x0, 0x50(%rax)
je 0xc166
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movl %eax, %edi
callq 0x22c0
movl $0x1, -0x4(%rbp)
jmp 0xc16d
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/func_i2c.cpp
// Function: wh_i2c_get_param_hid(WdtDevice*, BoardInfo*)
int wh_i2c_get_param_hid(WDT_DEV *pdev, BOARD_INFO *pinfo)
{
	BYTE buf[80] = {0};

	buf[0] = HID_DESC_REG_OFFSET;
	buf[1] = 0x00;

	if (!wh_i2c_xfer(pdev, pdev->board_info.i2c_address, buf, 2, (BYTE*) &pinfo->dev_hid_desc, sizeof(I2C_HID_DESC))) {
		wh_printf("failed to get hid desc\n");
		return 0;
	}

	pinfo->vid = pinfo->dev_hid_desc.wVendorID;
	pinfo->pid = pinfo->dev_hid_desc.wProductID;
	pdev->board_info.vid = pinfo->vid;
	pdev->board_info.pid = pinfo->pid;
	pdev->board_info.dev_hid_desc = pinfo->dev_hid_desc;


	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x50, %edx
callq 0x2110
movb $0x20, -0x70(%rbp)
movb $0x0, -0x6f(%rbp)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movb 0x1d6(%rax), %al
leaq -0x70(%rbp), %rdx
movq -0x18(%rbp), %r8
addq $0x4f, %r8
movl $0x2, %ecx
movl $0x1e, %r9d
movzbl %al, %esi
callq 0xc290
cmpl $0x0, %eax
jne 0xc1f4
leaq 0x487e(%rip), %rdi      # 0x10a5f
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0xc278
movq -0x18(%rbp), %rax
movzwl 0x63(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x18(%rbp), %rax
movzwl 0x65(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x18c(%rax)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x190(%rax)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x4f(%rcx), %rdx
movq %rdx, 0x1d7(%rax)
movq 0x57(%rcx), %rdx
movq %rdx, 0x1df(%rax)
movq 0x5f(%rcx), %rdx
movq %rdx, 0x1e7(%rax)
movl 0x67(%rcx), %edx
movl %edx, 0x1ef(%rax)
movw 0x6b(%rcx), %cx
movw %cx, 0x1f3(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/func_i2c.cpp
// Function: wh_i2c_xfer(WdtDevice*, unsigned char, unsigned char*, unsigned int, unsigned char*, unsigned int)
int wh_i2c_xfer(WDT_DEV *pdev, BYTE slave_addr, BYTE* txbuf, UINT32 tx_len,
		BYTE* rxbuf, UINT32 rx_len)	
{
	int err = 0;
	struct i2c_rdwr_ioctl_data	i2c_rdwr_data;
	struct i2c_msg msgs[2];		
	
	if (!txbuf || !rxbuf || !pdev) {
		wh_printf("%s : pointer is null\n", __func__);
		return 0;
	}
		
	msgs[0].addr	= slave_addr;
	msgs[0].flags	= 0;
	msgs[0].len = tx_len;
	msgs[0].buf = (char*) txbuf;
	
	msgs[1].addr	= slave_addr;
	msgs[1].flags	= I2C_M_RD;
	msgs[1].len = rx_len;
	msgs[1].buf = (char*) rxbuf;
	
	i2c_rdwr_data.msgs = msgs;
	i2c_rdwr_data.nmsgs = 2;

	err = ioctl( (long) pdev->dev_handle, I2C_RDWR, &i2c_rdwr_data);	
	
	if (err < 0) {
		wh_printf("%s: ioctl operation failed: (%d)\n", __func__, err);
		wh_printf("strerror(errno): %s\n", strerror(errno));
		return 0;

	}
	
//	wh_udelay(I2C_OPERATION_DELAY_US);
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xc2cd
cmpq $0x0, -0x30(%rbp)
je 0xc2cd
cmpq $0x0, -0x10(%rbp)
jne 0xc2ee
leaq 0x489c(%rip), %rdi      # 0x10b70
leaq 0x48e1(%rip), %rsi      # 0x10bbc
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0xc39f
movzbl -0x11(%rbp), %eax
movw %ax, -0x70(%rbp)
movw $0x0, -0x6e(%rbp)
movl -0x24(%rbp), %eax
movw %ax, -0x6c(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
movzbl -0x11(%rbp), %eax
movw %ax, -0x60(%rbp)
movw $0x1, -0x5e(%rbp)
movl -0x34(%rbp), %eax
movw %ax, -0x5c(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x70(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x2, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movl %eax, %edi
movl $0x707, %esi            # imm = 0x707
leaq -0x48(%rbp), %rdx
movb $0x0, %al
callq 0x2210
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jge 0xc398
movl -0x38(%rbp), %edx
leaq 0x482c(%rip), %rdi      # 0x10b90
leaq 0x4851(%rip), %rsi      # 0x10bbc
movb $0x0, %al
callq 0x24e0
callq 0x2040
movl (%rax), %edi
callq 0x20a0
movq %rax, %rsi
leaq 0x468b(%rip), %rdi      # 0x10a13
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0xc39f
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/func_i2c.cpp
// Function: wh_i2c_tx(WdtDevice*, unsigned char, unsigned char*, unsigned int)
int wh_i2c_tx(WDT_DEV *pdev, BYTE slave_addr, BYTE* pbuf, UINT32 buf_size)
{
	int err;
	struct i2c_rdwr_ioctl_data	i2c_rdwr_data;
	struct i2c_msg msgs[1];	
	
	if (!pbuf || !pdev) {
		wh_printf("%s : pointer is null\n", __func__);
		return 0;
	}
	
	msgs[0].addr	= slave_addr;
	msgs[0].flags	= 0; //I2C_M_IGNORE_NAK;
	msgs[0].len = buf_size;
	msgs[0].buf = (char*) pbuf;
	
	i2c_rdwr_data.msgs = msgs;
	i2c_rdwr_data.nmsgs = 1;

	err = ioctl( (long) pdev->dev_handle, I2C_RDWR, &i2c_rdwr_data);
	
	if (err < 0) {
		wh_printf("%s: ioctl operation failed: (%d)\n", __func__, err);
		wh_printf("strerror(errno): %s\n", strerror(errno));
		return 0;
	}

	
	//wh_udelay(I2C_OPERATION_DELAY_US);

	return buf_size;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xcfa7
cmpq $0x0, -0x10(%rbp)
jne 0xcfc8
leaq 0x3bc2(%rip), %rdi      # 0x10b70
leaq 0x3bd1(%rip), %rsi      # 0x10b86
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0xd05b
movzbl -0x11(%rbp), %eax
movw %ax, -0x50(%rbp)
movw $0x0, -0x4e(%rbp)
movl -0x24(%rbp), %eax
movw %ax, -0x4c(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x50(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x1, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movl %eax, %edi
movl $0x707, %esi            # imm = 0x707
leaq -0x38(%rbp), %rdx
movb $0x0, %al
callq 0x2210
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jge 0xd055
movl -0x28(%rbp), %edx
leaq 0x3b6f(%rip), %rdi      # 0x10b90
leaq 0x3b5e(%rip), %rsi      # 0x10b86
movb $0x0, %al
callq 0x24e0
callq 0x2040
movl (%rax), %edi
callq 0x20a0
movq %rax, %rsi
leaq 0x39ce(%rip), %rdi      # 0x10a13
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0xd05b
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/wif2_handler.cpp
// Function: process_wif2(WifFile2*)
int process_wif2(WIF_FILE2 *pcur_wif)
{
	UINT32 *pstruct = NULL;

	if (!pcur_wif)
		return 0;

	pstruct = (UINT32 *)pcur_wif->pdata;

	if (pstruct[0] == FOURCC_ID_RIFF && pstruct[2] == FOURCC_ID_WIF2) {
		/* lengths should be the same */
		if (pcur_wif->data_len == pstruct[1]) {
			return 1;
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xd4e0
movl $0x0, -0x4(%rbp)
jmp 0xd526
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x46464952, (%rax)     # imm = 0x46464952
jne 0xd51f
movq -0x18(%rbp), %rax
cmpl $0x32464957, 0x8(%rax)  # imm = 0x32464957
jne 0xd51f
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jne 0xd51d
movl $0x1, -0x4(%rbp)
jmp 0xd526
jmp 0xd51f
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax,%rax)
// File: chenhn123[P]wdt_util_src/wdt_ct/wif2_handler.cpp
// Function: free_wif2(WifFile2*)
int free_wif2(WIF_FILE2 *pcur_wif)
{
	if (pcur_wif->pdata) {
		free(pcur_wif->pdata);
		return 1;
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0xd55b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x21e0
movl $0x1, -0x4(%rbp)
jmp 0xd562
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)