LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx2/gtx2.cpp
// Function: GTx2Device::GetCfgVersion()
int GTx2Device::GetCfgVersion()
{
	int ret;
	unsigned char cfg_ver;
	unsigned char pid[5] = {0};
	int sensor_id;
	unsigned char fw_info[12] = {0};

	ret = Read(0x8050, &cfg_ver, 1);
	if (ret < 0) {
		gdix_err("Failed read cfg VERSION\n");
		return ret;
	}
	ret = Read(0x8140, fw_info, sizeof(fw_info));
	if (ret < 0) {
		gdix_err("Failed read VERSION\n");
		return ret;
	}

	memcpy(pid, fw_info, 4);
	sensor_id = fw_info[10] & 0x0f;
	fprintf(stdout, "PID:%s\n", pid);
	fprintf(stdout, "sensorID:%d\n", sensor_id);
	fprintf(stdout, "cfg version:%d\n", cfg_ver);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %r14
movb $0x0, 0x1c(%rsp)
movl $0x0, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
movq (%rdi), %rax
leaq 0x7(%rsp), %rdx
movl $0x8050, %esi           # imm = 0x8050
movl $0x1, %ecx
callq *0x20(%rax)
testl %eax, %eax
js 0xa852
movq (%r14), %rax
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
movl $0x8140, %esi           # imm = 0x8140
movl $0xc, %ecx
callq *0x20(%rax)
testl %eax, %eax
js 0xa867
movl 0x8(%rsp), %eax
leaq 0x18(%rsp), %rdx
movl %eax, (%rdx)
movzbl 0x12(%rsp), %ebp
andl $0xf, %ebp
movq 0x167a4(%rip), %r14     # 0x20fb8
movq (%r14), %rdi
leaq 0xe59b(%rip), %rsi      # 0x18db9
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x5180
movq (%r14), %rdi
leaq 0xe5cb(%rip), %rsi      # 0x18dfc
movl %ebp, %edx
xorl %eax, %eax
callq 0x5180
movq (%r14), %rdi
movzbl 0x7(%rsp), %edx
leaq 0xd2e4(%rip), %rsi      # 0x17b2d
xorl %eax, %eax
callq 0x5180
jmp 0xa875
movl %eax, %ebx
leaq 0x16a36(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0xa875
callq 0x56d3
jmp 0xa875
movl %eax, %ebx
leaq 0x16a21(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
je 0xa880
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
callq 0x56ab
jmp 0xa875
nop
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx2/gtx2_firmware_image.cpp
// Function: GTX2FirmwareImage::InitPid()
int GTX2FirmwareImage::InitPid()
{
	gdix_dbg("GTX2FirmwareImage %s run\n", __func__);
	int ret = -1;
	int i = 0;
	int j = 0;

	if (!m_firmwareData) {
		goto exit;
	}

	for (i = 0, j = 0; i < GTX2_FW_IMAGE_PID_LEN; i++)
		if (m_firmwareData[GTX2_FW_IMAGE_PID_OFFSET + i] != 0)
			m_pid[j++] = m_firmwareData[GTX2_FW_IMAGE_PID_OFFSET + i];
	m_pid[j] = '\0';
	ret = 0;
exit:
	gdix_dbg("GTX2FirmwareImage %s exit,exit code:%d\n", __func__, ret);
	return ret;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x16973(%rip), %r14     # 0x21291
cmpb $0x1, (%r14)
jne 0xa94b
movq 0x1668d(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xd273(%rip), %rsi      # 0x17ba8
leaq 0xb906(%rip), %rdx      # 0x16242
movl $0x21, %ecx
movq %rdx, %r8
xorl %eax, %eax
callq 0x5180
cmpq $0x0, 0x30(%rbx)
je 0xa980
xorl %eax, %eax
xorl %ecx, %ecx
movq 0x30(%rbx), %rdx
movb 0xf(%rdx,%rax), %dl
testb %dl, %dl
je 0xa96b
movslq %ecx, %rsi
incl %ecx
movb %dl, 0x19(%rbx,%rsi)
incq %rax
cmpq $0x6, %rax
jne 0xa956
movslq %ecx, %rax
movb $0x0, 0x19(%rbx,%rax)
xorl %ebx, %ebx
jmp 0xa985
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpb $0x1, (%r14)
jne 0xa9b5
movq 0x16626(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xd237(%rip), %rsi      # 0x17bd3
leaq 0xb89f(%rip), %rdx      # 0x16242
movl $0x30, %ecx
movq %rdx, %r8
movl %ebx, %r9d
xorl %eax, %eax
callq 0x5180
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx2/gtx2_firmware_image.cpp
// Function: GTX2FirmwareImage::InitVid()
int GTX2FirmwareImage::InitVid()
{
	gdix_dbg("GTX2FirmwareImage %s run\n", __func__);
	int ret = -1;

	if (!m_firmwareData)
		goto exit;

	m_firmwareVersionMajor = 0;
	m_firmwareVersionMinor =
		((m_firmwareData[GTX2_FW_IMAGE_VID_OFFSET] << 16) |
		 (m_firmwareData[GTX2_FW_IMAGE_VID_OFFSET + 1] << 8) |
		 (m_firmwareData[GTX2_FW_IMAGE_VID_OFFSET + 2]));
	gdix_dbg("vid 0x%02X,0x%02X,0x%02X\n",
			 m_firmwareData[GTX2_FW_IMAGE_VID_OFFSET],
			 m_firmwareData[GTX2_FW_IMAGE_VID_OFFSET + 1],
			 m_firmwareData[GTX2_FW_IMAGE_VID_OFFSET + 2]);
	ret = 0;
exit:
	gdix_dbg("GTX2FirmwareImage %s exit,exit code:%d\n", __func__, ret);
	return ret;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x168c3(%rip), %r14     # 0x21291
movb (%r14), %al
cmpb $0x1, %al
jne 0xa9ff
movq 0x165dc(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xd1c2(%rip), %rsi      # 0x17ba8
leaq 0xb885(%rip), %rdx      # 0x16272
movl $0x36, %ecx
movq %rdx, %r8
xorl %eax, %eax
callq 0x5180
movb (%r14), %al
movq 0x30(%rbx), %rcx
testq %rcx, %rcx
je 0xaa6a
movl $0x0, 0x24(%rbx)
movzbl 0x15(%rcx), %edx
shll $0x10, %edx
movzbl 0x16(%rcx), %esi
shll $0x8, %esi
orl %edx, %esi
movzbl 0x17(%rcx), %edx
orl %esi, %edx
movl %edx, 0x28(%rbx)
xorl %ebx, %ebx
testb $0x1, %al
je 0xaa6f
movq 0x16583(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
movzbl 0x15(%rcx), %r8d
movzbl 0x16(%rcx), %r9d
movzbl 0x17(%rcx), %eax
movl %eax, (%rsp)
leaq 0xd1bc(%rip), %rsi      # 0x17c0c
leaq 0xb81b(%rip), %rdx      # 0x16272
xorl %ebx, %ebx
movl $0x44, %ecx
xorl %eax, %eax
callq 0x5180
movb (%r14), %al
jmp 0xaa6f
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testb $0x1, %al
je 0xaa9d
movq 0x1653e(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xd14f(%rip), %rsi      # 0x17bd3
leaq 0xb7e7(%rip), %rdx      # 0x16272
movl $0x47, %ecx
movq %rdx, %r8
movl %ebx, %r9d
xorl %eax, %eax
callq 0x5180
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx3/gtx3_firmware_image.cpp
// Function: GTX3FirmwareImage::InitPid()
int GTX3FirmwareImage::InitPid()
{
	gdix_dbg("GTX3FirmwareImage::InitPid run\n");
	int ret = -1;
	int i = 0;
	int j = 0;

	if (!m_firmwareData) {
		goto exit;
	}
	for (i = 0, j = 0; i < GTX3_FW_IMAGE_PID_LEN; i++)
		if (m_firmwareData[GTX3_FW_IMAGE_PID_OFFSET + i] != 0)
			m_pid[j++] = m_firmwareData[GTX3_FW_IMAGE_PID_OFFSET + i];
	m_pid[j] = '\0';
	ret = 0;

exit:
	gdix_dbg("GTX3FirmwareImage::InitPid exit\n");
	return ret;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x15623(%rip), %r14     # 0x21291
cmpb $0x1, (%r14)
jne 0xbc98
movq 0x1533d(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xc2ef(%rip), %rsi      # 0x17f74
leaq 0xa5b6(%rip), %rdx      # 0x16242
movl $0x20, %ecx
xorl %eax, %eax
callq 0x5180
cmpq $0x0, 0x30(%rbx)
je 0xbccd
xorl %eax, %eax
xorl %ecx, %ecx
movq 0x30(%rbx), %rdx
movb 0xf(%rdx,%rax), %dl
testb %dl, %dl
je 0xbcb8
movslq %ecx, %rsi
incl %ecx
movb %dl, 0x19(%rbx,%rsi)
incq %rax
cmpq $0x8, %rax
jne 0xbca3
movslq %ecx, %rax
movb $0x0, 0x19(%rbx,%rax)
xorl %ebx, %ebx
jmp 0xbcd2
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpb $0x1, (%r14)
jne 0xbcfc
movq 0x152d9(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xc2bc(%rip), %rsi      # 0x17fa5
leaq 0xa552(%rip), %rdx      # 0x16242
movl $0x2f, %ecx
xorl %eax, %eax
callq 0x5180
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx3/gtx3_firmware_image.cpp
// Function: GTX3FirmwareImage::InitVid()
int GTX3FirmwareImage::InitVid()
{
	gdix_dbg("GTX3FirmwareImage InitVid run\n");
	int ret = -1;

	if (!m_firmwareData)
		goto exit;

	m_firmwareVersionMajor = m_firmwareData[GTX3_FW_IMAGE_VID_OFFSET];
	/* |--vid2--|--vid3--|--cfg_id--|
	 * reserve the last byte for config ID.
	 */
	m_firmwareVersionMinor =
		(m_firmwareData[GTX3_FW_IMAGE_VID_OFFSET + 1] << 16) |
		(m_firmwareData[GTX3_FW_IMAGE_VID_OFFSET + 2] << 8);
	gdix_dbg("cid:0x%02x,vid 0x%02X,0x%02X,0x%02X\n",
			 m_firmwareData[GTX3_FW_IMAGE_CID_OFFSET],
			 m_firmwareData[GTX3_FW_IMAGE_VID_OFFSET],
			 m_firmwareData[GTX3_FW_IMAGE_VID_OFFSET + 1],
			 m_firmwareData[GTX3_FW_IMAGE_VID_OFFSET + 2]);
	ret = 0;
exit:
	gdix_dbg("GTX3FirmwareImage InitVid exit,exit code:%d\n", ret);
	return ret;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x1557d(%rip), %r14     # 0x21291
movb (%r14), %al
cmpb $0x1, %al
jne 0xbd42
movq 0x15296(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xc2ab(%rip), %rsi      # 0x17fd7
leaq 0xa53f(%rip), %rdx      # 0x16272
movl $0x35, %ecx
xorl %eax, %eax
callq 0x5180
movb (%r14), %al
movq 0x30(%rbx), %rcx
testq %rcx, %rcx
je 0xbdb2
movzbl 0x18(%rcx), %edx
movl %edx, 0x24(%rbx)
movzbl 0x19(%rcx), %edx
shll $0x10, %edx
movzbl 0x1a(%rcx), %esi
shll $0x8, %esi
orl %edx, %esi
movl %esi, 0x28(%rbx)
xorl %ebx, %ebx
testb $0x1, %al
je 0xbdb7
movq 0x15246(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
movzbl 0x17(%rcx), %r8d
movzbl 0x18(%rcx), %r9d
movzbl 0x19(%rcx), %r10d
movzbl 0x1a(%rcx), %r11d
leaq 0xb1fb(%rip), %rsi      # 0x16f8b
leaq 0xa4db(%rip), %rdx      # 0x16272
xorl %ebx, %ebx
movl $0x46, %ecx
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x5180
addq $0x10, %rsp
movb (%r14), %al
jmp 0xbdb7
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testb $0x1, %al
je 0xbde2
movq 0x151f6(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xc23b(%rip), %rsi      # 0x18007
leaq 0xa49f(%rip), %rdx      # 0x16272
movl $0x49, %ecx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x5180
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx3/gtx3_update.cpp
// Function: need_upgrade_hid_subsystem(GTmodel*, FirmwareImage*)
bool need_upgrade_hid_subsystem(GTmodel *dev, FirmwareImage *fw_img)
{
	int dev_fw_ver = 0;
	int img_fw_ver = 0;
	int boundary_fw_ver =
		(HID_FORCE_UPDATE_VER_MAJOR << 16) | HID_FORCE_UPDATE_VER_MINOR;

	if (fw_img->GetUpdateFlag() & NEED_UPDATE_HID_SUBSYSTEM) {
		gdix_dbg("get hid subsystem update flag from fw_img file:0x%x\n",
				 fw_img->GetUpdateFlag());
		return true;
	}
	/* ignore the config_id byte */
	dev_fw_ver = (dev->GetFirmwareVersionMajor() << 16) |
				 ((dev->GetFirmwareVersionMinor() >> 8) & 0xFFFF);
	img_fw_ver = (fw_img->GetFirmwareVersionMajor() << 16) |
				 ((fw_img->GetFirmwareVersionMinor() >> 8) & 0xFFFF);

	gdix_dbg("boundery_ver 0x%x, dev_ver 0x%x, fw_ver 0x%x\n", boundary_fw_ver,
			 dev_fw_ver, img_fw_ver);
	if (dev_fw_ver < boundary_fw_ver || img_fw_ver < boundary_fw_ver) {
		gdix_dbg("hid subsystem need update judged by fw_ver\n");
		return true;
	}

	return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rax
movq %rsi, %rdi
callq *0xa8(%rax)
testb %al, %al
js 0xc181
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x60(%rax)
movl %eax, %ebp
shll $0x10, %ebp
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x68(%rax)
movl %eax, %ebx
shrl $0x8, %ebx
movl $0xffff, %r12d          # imm = 0xFFFF
andl %r12d, %ebx
orl %ebp, %ebx
movq (%r14), %rax
movq %r14, %rdi
callq *0x28(%rax)
movl %eax, %r15d
shll $0x10, %r15d
movq (%r14), %rax
movq %r14, %rdi
callq *0x30(%rax)
movl %eax, %ebp
shrl $0x8, %ebp
andl %r12d, %ebp
orl %r15d, %ebp
leaq 0x1515a(%rip), %r14     # 0x21291
cmpb $0x1, (%r14)
jne 0xc16d
movq 0x14e74(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
movl %ebp, (%rsp)
leaq 0xbf96(%rip), %rsi      # 0x180e7
leaq 0xbf74(%rip), %rdx      # 0x180cc
movl $0x91, %ecx
movl $0x117, %r8d            # imm = 0x117
movl %ebx, %r9d
xorl %eax, %eax
callq 0x5180
cmpl $0x117, %ebx            # imm = 0x117
jl 0xc1c7
cmpl $0x116, %ebp            # imm = 0x116
jle 0xc1c7
xorl %ebx, %ebx
jmp 0xc1f3
leaq 0x15109(%rip), %rax     # 0x21291
movb $0x1, %bl
cmpb $0x1, (%rax)
jne 0xc1f3
movq 0x14e22(%rip), %rax     # 0x20fb8
movq (%rax), %r15
movq (%r14), %rax
movq %r14, %rdi
callq *0xa8(%rax)
leaq 0xbeda(%rip), %rsi      # 0x18086
leaq 0xbf19(%rip), %rdx      # 0x180cc
movq %r15, %rdi
movl $0x87, %ecx
movl %eax, %r8d
xorl %eax, %eax
callq 0x5180
jmp 0xc1f3
movb $0x1, %bl
cmpb $0x1, (%r14)
jne 0xc1f3
movq 0x14de2(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xbf46(%rip), %rsi      # 0x18126
leaq 0xbee5(%rip), %rdx      # 0x180cc
movl $0x93, %ecx
xorl %eax, %eax
callq 0x5180
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx5/gtx5.cpp
// Function: GTx5Device::GetFirmwareProps(char const*, char*, int)
int GTx5Device::GetFirmwareProps(const char *deviceName, char *props_buf,
								 int len)
{
	int ret;

	ret = Open(deviceName);
	if (ret) {
		gdix_dbg("failed open device:%s\n", deviceName);
		return -1;
	}

	snprintf(props_buf, len, "%d.%d", GetFirmwareVersionMajor(),
			 GetFirmwareVersionMinor());
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq (%rdi), %rax
callq *0x10(%rax)
testl %eax, %eax
je 0xd202
leaq 0x140c2(%rip), %rax     # 0x21291
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpb $0x1, (%rax)
jne 0xd234
movq 0x13dd8(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xb156(%rip), %rsi      # 0x18340
leaq 0xb177(%rip), %rdx      # 0x18368
movl $0x3a, %ecx
movq %r15, %r8
xorl %eax, %eax
callq 0x5180
jmp 0xd234
movslq %ebp, %r15
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x60(%rax)
movl %eax, %ebp
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x68(%rax)
leaq 0xb159(%rip), %rdx      # 0x18379
xorl %ebx, %ebx
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %ecx
movl %eax, %r8d
xorl %eax, %eax
callq 0x51c0
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx5/gtx5.cpp
// Function: GTx5Device::Open(char const*)
int GTx5Device::Open(const char *filename)
{
	int rc;

	if (!filename)
		return -EINVAL;
	m_fd = open(filename, O_RDWR);
	if (m_fd < 0)
		return -1;
	m_deviceOpen = true;
	m_inputReportSize = 65;
	m_outputReportSize = 65;
	m_inputReport = new unsigned char[m_inputReportSize]();
	if (!m_inputReport) {
		errno = -ENOMEM;
		rc = -1;
		goto error;
	}
	m_outputReport = new unsigned char[m_outputReportSize]();
	if (!m_outputReport) {
		errno = -ENOMEM;
		rc = -1;
		goto error;
	}
	/* get active firmware info */
	return SetBasicProperties();
error:
	Close();
	return rc;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
testq %rsi, %rsi
je 0xd2d5
movq %rdi, %rbx
movq %rsi, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x51e0
movl %eax, 0xc(%rbx)
testl %eax, %eax
js 0xd2dc
movb $0x1, 0x8(%rbx)
movabsq $0x4100000041, %rax     # imm = 0x4100000041
movq %rax, 0x28(%rbx)
movl $0x41, %edi
callq 0x5030
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x30(%rax)
xorl %ebp, %ebp
movb %bpl, 0x40(%rax)
movq %rax, 0x30(%rbx)
movl $0x41, %edi
callq 0x5030
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x30(%rax)
movb %bpl, 0x40(%rax)
movq %rax, 0x38(%rbx)
movq (%rbx), %rax
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmpq *0xa0(%rax)
movl $0xffffffea, %eax       # imm = 0xFFFFFFEA
jmp 0xd2e1
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx5/gtx5.cpp
// Function: GTx5Device::Close()
void GTx5Device::Close()
{
	if (!m_deviceOpen)
		return;
	close(m_fd);
	m_fd = -1;
	m_deviceOpen = false;
	delete[] m_inputReport;
	m_inputReport = NULL;
	delete[] m_outputReport;
	m_outputReport = NULL;
}

// Assembly:
cmpb $0x1, 0x8(%rdi)
jne 0xd332
pushq %rbx
movq %rdi, %rbx
movl 0xc(%rdi), %edi
callq 0x5210
movl $0xffffffff, 0xc(%rbx)  # imm = 0xFFFFFFFF
movb $0x0, 0x8(%rbx)
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0xd313
callq 0x5130
movq $0x0, 0x30(%rbx)
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0xd329
callq 0x5130
movq $0x0, 0x38(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx5/gtx5.cpp
// Function: GTx5Device::GetReport(unsigned char, unsigned char*)
int GTx5Device::GetReport(unsigned char reportId, unsigned char *buf)
{
	int ret;
	unsigned char rcv_buf[66] = {0};
	if (!m_deviceOpen)
		return -1;

	rcv_buf[0] = reportId;
	ret = ioctl(m_fd, HIDIOCGFEATURE(m_inputReportSize), rcv_buf);
	if (ret < 0) {
		gdix_dbg("failed get feature retry, ret=%d\n", ret);
		return ret;
	} else {
		if (rcv_buf[0] == reportId) {
			memcpy(buf, rcv_buf, 65);
			return 0;
		} else {
			gdix_dbg("Get Wrong reportId:id=0x%x\n", rcv_buf[0]);
			return -1;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x50, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, (%rsp)
movw $0x0, 0x40(%rsp)
cmpb $0x1, 0x8(%rdi)
jne 0xd410
movq %rdx, %rbx
movl %esi, %r14d
movq %rsp, %rdx
movb %r14b, (%rdx)
movl 0xc(%rdi), %eax
movl 0x28(%rdi), %esi
shll $0x10, %esi
orl $0xc0004807, %esi       # imm = 0xC0004807
movl %eax, %edi
xorl %eax, %eax
callq 0x5160
testl %eax, %eax
js 0xd3a9
movzbl (%rsp), %r8d
cmpb %r14b, %r8b
jne 0xd3e0
movq %rsp, %rsi
movl $0x41, %edx
movq %rbx, %rdi
callq 0x5090
xorl %ebp, %ebp
jmp 0xd415
movl %eax, %ebp
leaq 0x13edf(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0xd415
movq 0x13bfa(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xafb7(%rip), %rsi      # 0x1837f
leaq 0xafe3(%rip), %rdx      # 0x183b2
movl $0x78, %ecx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x5180
jmp 0xd415
leaq 0x13eaa(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0xd410
movq 0x13bc5(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xafbf(%rip), %rsi      # 0x183bc
leaq 0xafae(%rip), %rdx      # 0x183b2
movl $0x7f, %ecx
xorl %eax, %eax
callq 0x5180
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x50, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx5/gtx5.cpp
// Function: GTx5Device::Read(unsigned int, unsigned char*, unsigned int)
int GTx5Device::Read(unsigned int addr, unsigned char *buf, unsigned int len)
{
	int ret = 0;
	int i = 0;
	unsigned short tmp_addr;
	int pkg_size = m_inputReportSize - 10;
	int pkg_num;
	int read_len;
	int code_len = len;

	pkg_num = code_len / pkg_size + 1;
	tmp_addr = addr;
	read_len = pkg_size;
	for (i = 0; i < pkg_num; i++) {
		if (read_len > code_len)
			read_len = code_len;
		/*read data*/
		ret = ReadPkg(tmp_addr, &buf[tmp_addr - addr], read_len);
		if (ret < 0)
			return ret;
		tmp_addr += read_len;
		code_len -= read_len;
		if (code_len <= 0)
			break;
	}
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, (%rsp)
movl 0x28(%rdi), %r12d
addl $-0xa, %r12d
movl %ecx, %eax
cltd
idivl %r12d
testl %eax, %eax
js 0xd726
movl %ecx, %ebx
movl %esi, %r14d
movq %rdi, %r15
movl %eax, %r13d
incl %r13d
movl %esi, %ebp
cmpl %ebx, %r12d
cmovgel %ebx, %r12d
movzwl %bp, %ebp
movl %ebp, %edx
subl %r14d, %edx
addq (%rsp), %rdx
movq %r15, %rdi
movl %ebp, %esi
movl %r12d, %ecx
callq 0xd420
testl %eax, %eax
js 0xd728
subl %r12d, %ebx
jle 0xd728
addl %r12d, %ebp
decl %r13d
jne 0xd6f3
jmp 0xd728
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx5/gtx5.cpp
// Function: GTx5Device::Write(unsigned char const*, unsigned int)
int GTx5Device::Write(const unsigned char *buf, unsigned int len)
{
	unsigned char temp_buf[65];
	int ret;
	int retry = GDIX_RETRY_TIMES;
	if (!m_deviceOpen)
		return -1;
	if (sizeof(temp_buf) < len)
		return -1;
	memset(temp_buf, 0, sizeof(temp_buf));
	memcpy(&temp_buf[0], buf, len);
	temp_buf[0] = 0x0E;
	gdix_dbg_array(temp_buf, len);
	do {
		ret = ioctl(m_fd, HIDIOCSFEATURE(len), temp_buf);
		if (ret < 0) {
			if (!m_deviceOpen || m_bCancel) {
				gdix_dbg("Operation beCancled or m_fd closed\n");
				break;
			}
			gdix_dbg("failed set feature, retry: ret=%d,retry:%d\n", ret,
					 retry);
			usleep(10000);
		} else {
			break;
		}
	} while (--retry);
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x41, %edx
ja 0xd94d
movq %rdi, %r14
cmpb $0x0, 0x8(%rdi)
je 0xd94d
movl %edx, %ebx
movl %edx, %edx
xorps %xmm0, %xmm0
movq %rsp, %r15
movaps %xmm0, 0x30(%r15)
movaps %xmm0, 0x20(%r15)
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
movb $0x0, 0x40(%r15)
movq %r15, %rdi
callq 0x5090
movb $0xe, (%r15)
shll $0x10, %ebx
orl $0xc0004806, %ebx       # imm = 0xC0004806
movl $0x6, %r12d
leaq 0x139d6(%rip), %r13     # 0x21291
movl 0xc(%r14), %edi
movq %rbx, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x5160
movl %eax, %ebp
testl %eax, %eax
jns 0xd94d
cmpb $0x1, 0x8(%r14)
jne 0xd922
cmpb $0x1, 0x40(%r14)
je 0xd922
cmpb $0x1, (%r13)
jne 0xd911
movq 0x136ca(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xac6d(%rip), %rsi      # 0x18565
leaq 0xac2b(%rip), %rdx      # 0x1852a
movl $0x12e, %ecx            # imm = 0x12E
movl %ebp, %r8d
movl %r12d, %r9d
xorl %eax, %eax
callq 0x5180
movl $0x2710, %edi           # imm = 0x2710
callq 0x5170
decl %r12d
jne 0xd8bb
jmp 0xd94d
cmpb $0x1, (%r13)
jne 0xd94d
movq 0x13688(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xabf6(%rip), %rsi      # 0x18530
leaq 0xabe9(%rip), %rdx      # 0x1852a
movl $0x12a, %ecx            # imm = 0x12A
xorl %eax, %eax
callq 0x5180
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx5/gtx5.cpp
// Function: GTx5Device::WriteSpeCmd(unsigned char const*, unsigned int)
int GTx5Device::WriteSpeCmd(const unsigned char *buf, unsigned int len)
{
	unsigned char temp_buf[65];
	int ret;
	int retry = GDIX_RETRY_TIMES;
	if (!m_deviceOpen)
		return -1;
	if (sizeof(temp_buf) < len)
		return -1;
	memset(temp_buf, 0, sizeof(temp_buf));
	memcpy(&temp_buf[0], buf, len);
	gdix_dbg_array(temp_buf, len);
	do {
		ret = ioctl(m_fd, HIDIOCSFEATURE(len), temp_buf);
		if (ret < 0) {
			if (!m_deviceOpen || m_bCancel) {
				gdix_dbg("Operation beCancled or m_fd closed\n");
				break;
			}
			gdix_dbg("failed set feature, retry: ret=%d,retry:%d\n", ret,
					 retry);
			usleep(10000);
		} else {
			break;
		}
	} while (--retry);
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x41, %edx
ja 0xda59
movq %rdi, %r14
cmpb $0x0, 0x8(%rdi)
je 0xda59
movl %edx, %ebx
movl %edx, %edx
xorps %xmm0, %xmm0
movq %rsp, %r15
movaps %xmm0, 0x30(%r15)
movaps %xmm0, 0x20(%r15)
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
movb $0x0, 0x40(%r15)
movq %r15, %rdi
callq 0x5090
shll $0x10, %ebx
orl $0xc0004806, %ebx       # imm = 0xC0004806
movl $0x6, %r12d
leaq 0x138ca(%rip), %r13     # 0x21291
movl 0xc(%r14), %edi
movq %rbx, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x5160
movl %eax, %ebp
testl %eax, %eax
jns 0xda59
cmpb $0x1, 0x8(%r14)
jne 0xda2e
cmpb $0x1, 0x40(%r14)
je 0xda2e
cmpb $0x1, (%r13)
jne 0xda1d
movq 0x135be(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xab61(%rip), %rsi      # 0x18565
leaq 0xab97(%rip), %rdx      # 0x185a2
movl $0x14f, %ecx            # imm = 0x14F
movl %ebp, %r8d
movl %r12d, %r9d
xorl %eax, %eax
callq 0x5180
movl $0x2710, %edi           # imm = 0x2710
callq 0x5170
decl %r12d
jne 0xd9c7
jmp 0xda59
cmpb $0x1, (%r13)
jne 0xda59
movq 0x1357c(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xaaea(%rip), %rsi      # 0x18530
leaq 0xab55(%rip), %rdx      # 0x185a2
movl $0x14b, %ecx            # imm = 0x14B
xorl %eax, %eax
callq 0x5180
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx5/gtx5.cpp
// Function: GTx5Device::SetBasicProperties()
int GTx5Device::SetBasicProperties()
{
	int ret;
	unsigned char fw_info[12] = {0};
	m_firmwareVersionMajor = 20;
	m_firmwareVersionMinor = 20;
	m_sensorID = 2;
	int retry = 10;
	if (!m_deviceOpen) {
		gdix_err("Please open device first\n");
		return -1;
	}

	do {
		ret = Read(GTX5_VERSION_ADDR, fw_info, sizeof(fw_info));
		if (ret < 0)
			gdix_dbg("Failed read VERSION, retry=%d\n", retry);
		else
			break;
	} while (--retry);
	if (!retry)
		return -1;
	memcpy(m_pid, fw_info, 4);
	m_pid[4] = '\0';
	m_sensorID = fw_info[10] & 0x0F;
	m_firmwareVersionMajor = (fw_info[5] >> 4) * 10 + (fw_info[5] & 0x0F);
	m_firmwareVersionMinor = (fw_info[6] >> 4) * 10 + (fw_info[6] & 0x0F);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl $0x0, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
movabsq $0x1400000014, %rax     # imm = 0x1400000014
movq %rax, 0x10(%rdi)
movl $0x2, 0x18(%rdi)
cmpb $0x1, 0x8(%rdi)
jne 0xdb11
movq %rdi, %rbx
movl $0xa, %ebp
leaq 0x8(%rsp), %r14
leaq 0x137d9(%rip), %r13     # 0x21291
leaq 0x9261(%rip), %r15      # 0x16d20
leaq 0x9193(%rip), %r12      # 0x16c59
movq (%rbx), %rax
movq %rbx, %rdi
movl $0x8240, %esi           # imm = 0x8240
movq %r14, %rdx
movl $0xc, %ecx
callq *0x20(%rax)
testl %eax, %eax
jns 0xdb29
cmpb $0x1, (%r13)
jne 0xdb06
movq 0x134ca(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
movq %r15, %rsi
movq %r12, %rdx
movl $0x168, %ecx            # imm = 0x168
movl %ebp, %r8d
xorl %eax, %eax
callq 0x5180
decl %ebp
jne 0xdac6
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0xdb78
leaq 0x13779(%rip), %rax     # 0x21291
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpb $0x1, (%rax)
jne 0xdb78
callq 0x5ab0
jmp 0xdb78
movl 0x8(%rsp), %eax
movl %eax, 0x1c(%rbx)
movb $0x0, 0x20(%rbx)
movzbl 0x12(%rsp), %eax
andl $0xf, %eax
movl %eax, 0x18(%rbx)
movzwl 0xd(%rsp), %eax
movd %eax, %xmm0
pxor %xmm1, %xmm1
punpcklbw %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3],xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
movdqa %xmm0, %xmm2
psrlw $0x4, %xmm2
pmullw 0xa7bf(%rip), %xmm2     # 0x18320
pand 0xa7c7(%rip), %xmm0     # 0x18330
paddw %xmm2, %xmm0
punpcklwd %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
movq %xmm0, 0x10(%rbx)
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx5/gtx5.cpp
// Function: GTx5Device::ChecksumU8(unsigned char*, int)
unsigned char GTx5Device::ChecksumU8(unsigned char *data, int len)
{
	unsigned char chksum = 0;
	int i = 0;
	for (i = 0; i < len; i++)
		chksum += data[i];
	return chksum;
}

// Assembly:
testl %edx, %edx
jle 0xdba0
movl %edx, %ecx
xorl %edx, %edx
xorl %eax, %eax
addb (%rsi,%rdx), %al
incq %rdx
cmpq %rdx, %rcx
jne 0xdb94
retq
xorl %eax, %eax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx5/gtx5_firmware_image.cpp
// Function: GTX5FirmwareImage::InitPid()
int GTX5FirmwareImage::InitPid()
{
	gdix_dbg("GTX5FirmwareImage::InitPid run\n");
	int ret = -1;
	int i = 0;
	int j = 0;

	if (!m_firmwareData) {
		goto exit;
	}
	for (i = 0, j = 0; i < GTX5_FW_IMAGE_PID_LEN; i++)
		if (m_firmwareData[GTX5_FW_IMAGE_PID_OFFSET + i] != 0)
			m_pid[j++] = m_firmwareData[GTX5_FW_IMAGE_PID_OFFSET + i];
	m_pid[j] = '\0';
	ret = 0;

exit:
	gdix_dbg("GTX5FirmwareImage::InitPid exit\n");
	return ret;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x1364f(%rip), %r14     # 0x21291
cmpb $0x1, (%r14)
jne 0xdc6c
movq 0x13369(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xa96b(%rip), %rsi      # 0x185c4
leaq 0x85e2(%rip), %rdx      # 0x16242
movl $0x25, %ecx
xorl %eax, %eax
callq 0x5180
cmpq $0x0, 0x30(%rbx)
je 0xdca1
xorl %eax, %eax
xorl %ecx, %ecx
movq 0x30(%rbx), %rdx
movb 0xf(%rdx,%rax), %dl
testb %dl, %dl
je 0xdc8c
movslq %ecx, %rsi
incl %ecx
movb %dl, 0x19(%rbx,%rsi)
incq %rax
cmpq $0x8, %rax
jne 0xdc77
movslq %ecx, %rax
movb $0x0, 0x19(%rbx,%rax)
xorl %ebx, %ebx
jmp 0xdca6
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpb $0x1, (%r14)
jne 0xdcd0
movq 0x13305(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xa938(%rip), %rsi      # 0x185f5
leaq 0x857e(%rip), %rdx      # 0x16242
movl $0x34, %ecx
xorl %eax, %eax
callq 0x5180
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx5/gtx5_firmware_image.cpp
// Function: GTX5FirmwareImage::InitVid()
int GTX5FirmwareImage::InitVid()
{
	gdix_dbg("GTX5FirmwareImage InitVid run\n");
	int ret = -1;

	if (!m_firmwareData)
		goto exit;

	m_firmwareVersionMajor = m_firmwareData[GTX5_FW_IMAGE_CID_OFFSET];
	m_firmwareVersionMinor =
		((m_firmwareData[GTX5_FW_IMAGE_VID_OFFSET] << 16) |
		 (m_firmwareData[GTX5_FW_IMAGE_VID_OFFSET + 1] << 8) |
		 (m_firmwareData[GTX5_FW_IMAGE_VID_OFFSET + 2]));
	gdix_dbg("cid:0x%02x,vid 0x%02X,0x%02X,0x%02X\n",
			 m_firmwareData[GTX5_FW_IMAGE_CID_OFFSET],
			 m_firmwareData[GTX5_FW_IMAGE_VID_OFFSET],
			 m_firmwareData[GTX5_FW_IMAGE_VID_OFFSET + 1],
			 m_firmwareData[GTX5_FW_IMAGE_VID_OFFSET + 2]);
	ret = 0;
exit:
	gdix_dbg("GTX5FirmwareImage InitVid exit,exit code:%d\n", ret);
	return ret;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x135a9(%rip), %r14     # 0x21291
movb (%r14), %al
cmpb $0x1, %al
jne 0xdd16
movq 0x132c2(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xa927(%rip), %rsi      # 0x18627
leaq 0x856b(%rip), %rdx      # 0x16272
movl $0x3a, %ecx
xorl %eax, %eax
callq 0x5180
movb (%r14), %al
movq 0x30(%rbx), %rcx
testq %rcx, %rcx
je 0xdd8c
movzbl 0x17(%rcx), %edx
movl %edx, 0x24(%rbx)
movzbl 0x18(%rcx), %edx
shll $0x10, %edx
movzbl 0x19(%rcx), %esi
shll $0x8, %esi
orl %edx, %esi
movzbl 0x1a(%rcx), %edx
orl %esi, %edx
movl %edx, 0x28(%rbx)
xorl %ebx, %ebx
testb $0x1, %al
je 0xdd91
movq 0x1326c(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
movzbl 0x17(%rcx), %r8d
movzbl 0x18(%rcx), %r9d
movzbl 0x19(%rcx), %r10d
movzbl 0x1a(%rcx), %r11d
leaq 0x9221(%rip), %rsi      # 0x16f8b
leaq 0x8501(%rip), %rdx      # 0x16272
xorl %ebx, %ebx
movl $0x49, %ecx
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x5180
addq $0x10, %rsp
movb (%r14), %al
jmp 0xdd91
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testb $0x1, %al
je 0xddbc
movq 0x1321c(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xa8b1(%rip), %rsi      # 0x18657
leaq 0x84c5(%rip), %rdx      # 0x16272
movl $0x4c, %ecx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x5180
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx5/gtx5_update.cpp
// Function: GTx5Update::Run(void*)
int GTx5Update::Run(void *para)
{
	int ret = 0;
	int retry = 0;
	if (!m_Initialized) {
		gdix_err("Can't Process Update Before Initialized.\n");
		return -1;
	}
	// get all parameter
	pGTUpdatePara parameter = (pGTUpdatePara)para;

	if (!parameter->force) {
		ret = check_update();
		if (ret) {
			gdix_err("Doesn't meet the update conditions\n");
			return -3;
		}
	}

	retry = 0;
	do {
		ret = fw_update(parameter->firmwareFlag);
		if (ret) {
			gdix_dbg("Update failed\n");
			usleep(200000);
		} else {
			usleep(300000);
			gdix_dbg("Update success\n");
			return 0;
		}
	} while (retry++ < 3);
	gdix_err("Firmware update err:ret=%d\n", ret);
	return -4;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpb $0x0, 0x18(%rdi)
je 0xde10
movq %rsi, %rbx
movq %rdi, %r14
cmpb $0x0, (%rsi)
jne 0xde2f
movq (%r14), %rax
movq %r14, %rdi
callq *0x20(%rax)
testl %eax, %eax
je 0xde2f
leaq 0x13499(%rip), %rax     # 0x21291
movl $0xfffffffd, %ebx       # imm = 0xFFFFFFFD
cmpb $0x1, (%rax)
jne 0xdef9
callq 0x5af6
jmp 0xdef9
leaq 0x1347a(%rip), %rax     # 0x21291
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpb $0x1, (%rax)
jne 0xdef9
callq 0x5ad4
jmp 0xdef9
movl $0x4, %r15d
leaq 0x13455(%rip), %r13     # 0x21291
leaq 0x9211(%rip), %r12      # 0x17054
movl 0x4(%rbx), %esi
movq (%r14), %rax
movq %r14, %rdi
callq *0x30(%rax)
testl %eax, %eax
je 0xdec0
movl %eax, %ebp
cmpb $0x1, (%r13)
jne 0xde7c
movq 0x13155(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0x9249(%rip), %rsi      # 0x170b6
movq %r12, %rdx
movl $0x3f, %ecx
xorl %eax, %eax
callq 0x5180
movl $0x30d40, %edi          # imm = 0x30D40
callq 0x5170
decl %r15d
jne 0xde43
movl $0xfffffffc, %ebx       # imm = 0xFFFFFFFC
cmpb $0x1, (%r13)
jne 0xdef9
movq 0x1313a(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
leaq 0x8a6a(%rip), %rsi      # 0x16912
leaq 0x91a5(%rip), %rdx      # 0x17054
movl $0x47, %ecx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x5180
jmp 0xdef9
movl $0x493e0, %edi          # imm = 0x493E0
callq 0x5170
xorl %ebx, %ebx
cmpb $0x1, (%r13)
jne 0xdef9
movq 0x130de(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0x91f2(%rip), %rsi      # 0x170d6
leaq 0x9169(%rip), %rdx      # 0x17054
xorl %ebx, %ebx
movl $0x43, %ecx
xorl %eax, %eax
callq 0x5180
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx8/gtx8_firmware_image.cpp
// Function: GTX8FirmwareImage::InitPid()
int GTX8FirmwareImage::InitPid()
{
	gdix_dbg("GTX8FirmwareImage::InitPid run\n");
	int ret = -1;
	int i = 0;
	int j = 0;

	if (!m_firmwareData) {
		goto exit;
	}
	for (i = 0, j = 0; i < GTX8_FW_IMAGE_PID_LEN; i++)
		if (m_firmwareData[GTX8_FW_IMAGE_PID_OFFSET + i] != 0)
			m_pid[j++] = m_firmwareData[GTX8_FW_IMAGE_PID_OFFSET + i];
	m_pid[j] = '\0';
	ret = 0;

exit:
	gdix_dbg("GTX8FirmwareImage::InitPid exit\n");
	return ret;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x127af(%rip), %r14     # 0x21291
cmpb $0x1, (%r14)
jne 0xeb0c
movq 0x124c9(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0x9c9d(%rip), %rsi      # 0x18796
leaq 0x7742(%rip), %rdx      # 0x16242
movl $0x20, %ecx
xorl %eax, %eax
callq 0x5180
cmpq $0x0, 0x30(%rbx)
je 0xeb41
xorl %eax, %eax
xorl %ecx, %ecx
movq 0x30(%rbx), %rdx
movb 0xf(%rdx,%rax), %dl
testb %dl, %dl
je 0xeb2c
movslq %ecx, %rsi
incl %ecx
movb %dl, 0x19(%rbx,%rsi)
incq %rax
cmpq $0x8, %rax
jne 0xeb17
movslq %ecx, %rax
movb $0x0, 0x19(%rbx,%rax)
xorl %ebx, %ebx
jmp 0xeb46
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpb $0x1, (%r14)
jne 0xeb70
movq 0x12465(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0x9c6a(%rip), %rsi      # 0x187c7
leaq 0x76de(%rip), %rdx      # 0x16242
movl $0x2f, %ecx
xorl %eax, %eax
callq 0x5180
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx8/gtx8_firmware_image.cpp
// Function: GTX8FirmwareImage::InitVid()
int GTX8FirmwareImage::InitVid()
{
	gdix_dbg("GTX8FirmwareImage InitVid run\n");
	int ret = -1;

	if (!m_firmwareData)
		goto exit;

	m_firmwareVersionMajor = m_firmwareData[GTX8_FW_IMAGE_VID_OFFSET];
	/* |--vid2--|--vid3--|--cfg_id--|
	 * reserve the last byte for config ID.
	 */
	m_firmwareVersionMinor =
		(m_firmwareData[GTX8_FW_IMAGE_VID_OFFSET + 1] << 16) |
		(m_firmwareData[GTX8_FW_IMAGE_VID_OFFSET + 2] << 8);
	gdix_dbg("cid:0x%02x,vid 0x%02X,0x%02X,0x%02X\n",
			 m_firmwareData[GTX8_FW_IMAGE_CID_OFFSET],
			 m_firmwareData[GTX8_FW_IMAGE_VID_OFFSET],
			 m_firmwareData[GTX8_FW_IMAGE_VID_OFFSET + 1],
			 m_firmwareData[GTX8_FW_IMAGE_VID_OFFSET + 2]);
	ret = 0;
exit:
	gdix_dbg("GTX8FirmwareImage InitVid exit,exit code:%d\n", ret);
	return ret;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x12709(%rip), %r14     # 0x21291
movb (%r14), %al
cmpb $0x1, %al
jne 0xebb6
movq 0x12422(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0x9c59(%rip), %rsi      # 0x187f9
leaq 0x76cb(%rip), %rdx      # 0x16272
movl $0x35, %ecx
xorl %eax, %eax
callq 0x5180
movb (%r14), %al
movq 0x30(%rbx), %rcx
testq %rcx, %rcx
je 0xec26
movzbl 0x18(%rcx), %edx
movl %edx, 0x24(%rbx)
movzbl 0x19(%rcx), %edx
shll $0x10, %edx
movzbl 0x1a(%rcx), %esi
shll $0x8, %esi
orl %edx, %esi
movl %esi, 0x28(%rbx)
xorl %ebx, %ebx
testb $0x1, %al
je 0xec2b
movq 0x123d2(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
movzbl 0x17(%rcx), %r8d
movzbl 0x18(%rcx), %r9d
movzbl 0x19(%rcx), %r10d
movzbl 0x1a(%rcx), %r11d
leaq 0x8387(%rip), %rsi      # 0x16f8b
leaq 0x7667(%rip), %rdx      # 0x16272
xorl %ebx, %ebx
movl $0x46, %ecx
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x5180
addq $0x10, %rsp
movb (%r14), %al
jmp 0xec2b
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testb $0x1, %al
je 0xec56
movq 0x12382(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0x9be9(%rip), %rsi      # 0x18829
leaq 0x762b(%rip), %rdx      # 0x16272
movl $0x49, %ecx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x5180
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx8/gtx8_update.cpp
// Function: GTx8Update::DisableReport()
int GTx8Update::DisableReport()
{
	unsigned char cmdDisable[] = {0x33, 0x00, 0xCD};
	unsigned char cmdConfirm[] = {0x35, 0x00, 0xCB};
	unsigned char buf[3] = {0};
	int ret;

	for (int i = 0; i < 3; i++) {
		ret = dev->Write(CMD_ADDR, cmdDisable, sizeof(cmdDisable));
		if (ret < 0) {
			gdix_err("send close report cmd failed\n");
			return ret;
		}
		usleep(10000);
	}

	ret = dev->Write(CMD_ADDR, cmdConfirm, sizeof(cmdConfirm));
	if (ret < 0) {
		gdix_err("send confirm cmd failed\n");
		return ret;
	}
	usleep(30000);
	ret = dev->Read(CMD_ADDR, buf, sizeof(buf));
	if (ret < 0) {
		gdix_err("read confirm flag failed\n");
		return ret;
	}

	if (buf[1] != 1) {
		gdix_err("close report failed, flag[0x%02X]\n", buf[1]);
		return -EINVAL;
	}

	gdix_info("close report success\n");
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
leaq 0x14(%rsp), %r15
movb $-0x33, 0x2(%r15)
movw $0x33, (%r15)
movb $-0x35, 0x12(%rsp)
movw $0x35, 0x10(%rsp)
movb $0x0, 0xe(%rsp)
movw $0x0, 0xc(%rsp)
movl $0x3, %ebp
movq 0x8(%r14), %rdi
movq (%rdi), %rax
movl $0x60cc, %esi           # imm = 0x60CC
movq %r15, %rdx
movl $0x3, %ecx
callq *0x30(%rax)
testl %eax, %eax
js 0xf022
movl $0x2710, %edi           # imm = 0x2710
callq 0x5170
decl %ebp
jne 0xef6e
movq 0x8(%r14), %rdi
movq (%rdi), %rax
leaq 0x10(%rsp), %rdx
movl $0x60cc, %esi           # imm = 0x60CC
movl $0x3, %ecx
callq *0x30(%rax)
testl %eax, %eax
js 0xf037
movl $0x7530, %edi           # imm = 0x7530
callq 0x5170
movq 0x8(%r14), %rdi
movq (%rdi), %rax
leaq 0xc(%rsp), %rdx
movl $0x60cc, %esi           # imm = 0x60CC
movl $0x3, %ecx
callq *0x20(%rax)
testl %eax, %eax
js 0xf04c
movzbl 0xd(%rsp), %r8d
leaq 0x122a5(%rip), %rax     # 0x21291
movb (%rax), %al
cmpl $0x1, %r8d
jne 0xf061
xorl %ebx, %ebx
testb %al, %al
je 0xf06a
movq 0x11fb7(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0x9936(%rip), %rsi      # 0x18941
leaq 0x9898(%rip), %rdx      # 0x188aa
xorl %ebx, %ebx
movl $0x9c, %ecx
xorl %eax, %eax
callq 0x5180
jmp 0xf06a
movl %eax, %ebx
leaq 0x12266(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0xf06a
callq 0x5caf
jmp 0xf06a
movl %eax, %ebx
leaq 0x12251(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0xf06a
callq 0x5c85
jmp 0xf06a
movl %eax, %ebx
leaq 0x1223c(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0xf06a
callq 0x5c5b
jmp 0xf06a
movl $0xffffffea, %ebx       # imm = 0xFFFFFFEA
testb %al, %al
jne 0xf077
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x11f5a(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
leaq 0x9885(%rip), %rsi      # 0x1890d
leaq 0x981b(%rip), %rdx      # 0x188aa
movl $0x98, %ecx
xorl %eax, %eax
callq 0x5180
jmp 0xf06a
nop
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx9/gtx9.cpp
// Function: GTx9Device::Open(char const*)
int GTx9Device::Open(const char *filename)
{
	if (!filename)
		return -EINVAL;

	m_fd = open(filename, O_RDWR);
	if (m_fd < 0)
		return -EINVAL;

	m_deviceOpen = true;

	return SetBasicProperties();
}

// Assembly:
pushq %rbx
testq %rsi, %rsi
je 0x10144
movq %rdi, %rbx
movq %rsi, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x51e0
movl %eax, 0xc(%rbx)
testl %eax, %eax
js 0x10144
movb $0x1, 0x8(%rbx)
movq (%rbx), %rax
movq %rbx, %rdi
popq %rbx
jmpq *0xa0(%rax)
movl $0xffffffea, %eax       # imm = 0xFFFFFFEA
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx9/gtx9.cpp
// Function: GTx9Device::Close()
void GTx9Device::Close()
{
	if (!m_deviceOpen)
		return;
	close(m_fd);
	m_fd = -1;
	m_deviceOpen = false;
}

// Assembly:
cmpb $0x1, 0x8(%rdi)
jne 0x1016a
pushq %rbx
movq %rdi, %rbx
movl 0xc(%rdi), %edi
callq 0x5210
movl $0xffffffff, 0xc(%rbx)  # imm = 0xFFFFFFFF
movb $0x0, 0x8(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx9/gtx9.cpp
// Function: GTx9Device::SetReport(unsigned char*, int)
int GTx9Device::SetReport(unsigned char *buf, int len)
{
	int retry = 5;
	int ret;

	while (retry--) {
		ret = ioctl(m_fd, HIDIOCSFEATURE(len), buf);
		if (ret == len)
			return 0;
		usleep(1000);
	}

	gdix_err("Failed set report, ret:%d\n", ret);
	return -EINVAL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, (%rsp)
movq %rdi, %r15
movl %edx, %r12d
shll $0x10, %r12d
orl $0xc0004806, %r12d      # imm = 0xC0004806
movl $0xfffffffb, %r14d      # imm = 0xFFFFFFFB
xorl %ebx, %ebx
movl 0xc(%r15), %edi
movq %r12, %rsi
movq (%rsp), %rdx
xorl %eax, %eax
callq 0x5160
cmpl %ebp, %eax
je 0x10363
movl %eax, %r13d
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x5170
incl %r14d
jne 0x1032a
leaq 0x10f38(%rip), %rax     # 0x21291
movl $0xffffffea, %ebx       # imm = 0xFFFFFFEA
cmpb $0x1, (%rax)
je 0x10374
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10c5d(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
leaq 0x86ac(%rip), %rsi      # 0x18a31
leaq 0x89bc(%rip), %rdx      # 0x18d48
movl $0x155, %ecx            # imm = 0x155
movl %r13d, %r8d
xorl %eax, %eax
callq 0x5180
jmp 0x10363
nop
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx9/gtx9.cpp
// Function: GTx9Device::GetReport(unsigned char*)
int GTx9Device::GetReport(unsigned char *buf)
{
	int ret;
	int retry = 5;
	uint8_t rcv_buf[PACKAGE_LEN + 1] = {0};

	while (retry--) {
		rcv_buf[0] = REPORT_ID;
		ret = ioctl(m_fd, HIDIOCGFEATURE(PACKAGE_LEN), rcv_buf);
		if (ret == PACKAGE_LEN && rcv_buf[0] == REPORT_ID) {
			memcpy(buf, rcv_buf, PACKAGE_LEN);
			return 0;
		}
		usleep(1000);
	}

	gdix_err("Failed get report ret:%d rcvbuf[0]:0x%02x\n", ret, rcv_buf[0]);
	return -EINVAL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rsi, %rbx
movq %rdi, %r14
xorps %xmm0, %xmm0
movq %rsp, %r15
movaps %xmm0, 0x30(%r15)
movaps %xmm0, 0x20(%r15)
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
movw $0x0, 0x40(%r15)
movl $0xfffffffb, %r12d      # imm = 0xFFFFFFFB
movb $0xe, (%rsp)
movl 0xc(%r14), %edi
movl $0xc0414807, %esi       # imm = 0xC0414807
movq %r15, %rdx
xorl %eax, %eax
callq 0x5160
movl %eax, %ebp
cmpl $0x41, %eax
jne 0x103fa
cmpb $0xe, (%rsp)
je 0x10448
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x5170
incl %r12d
jne 0x103d6
leaq 0x10e81(%rip), %rax     # 0x21291
movl $0xffffffea, %ebx       # imm = 0xFFFFFFEA
cmpb $0x1, (%rax)
jne 0x1045a
movq 0x10bb7(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movzbl (%rsp), %r9d
leaq 0x88dc(%rip), %rsi      # 0x18d0c
leaq 0x7f7b(%rip), %rdx      # 0x183b2
movl $0x145, %ecx            # imm = 0x145
movl %ebp, %r8d
xorl %eax, %eax
callq 0x5180
jmp 0x1045a
movq %rsp, %rsi
movl $0x41, %edx
movq %rbx, %rdi
callq 0x5090
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx9/gtx9.cpp
// Function: GTx9Device::Read(unsigned int, unsigned char*, unsigned int)
int GTx9Device::Read(unsigned int addr, unsigned char *buf, unsigned int len)
{
	int ret = 0;
	int i = 0;
	uint32_t tmp_addr = addr;
	int offset = 0;
	int pkg_size = PACKAGE_LEN - 12;
	int remain_size;
	int pkg_num;

	if (!m_deviceOpen) {
		gdix_err("Device not open\n");
		return -EINVAL;
	}

	pkg_num = len / pkg_size;
	remain_size = len % pkg_size;

	for (i = 0; i < pkg_num; i++) {
		ret = ReadPkg(tmp_addr + offset, &buf[offset], pkg_size);
		if (ret < 0)
			return ret;
		offset += pkg_size;
	}

	if (remain_size > 0) {
		ret = ReadPkg(tmp_addr + offset, &buf[offset], remain_size);
		if (ret < 0)
			return ret;
	}

	return len;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpb $0x0, 0x8(%rdi)
je 0x10505
movl %ecx, %ebp
movq %rdx, %r14
movq %rdi, %r15
movl %ecx, %eax
imulq $0x3521cfb3, %rax, %rax # imm = 0x3521CFB3
shrq $0x20, %rax
movl %ecx, %ebx
subl %eax, %ebx
shrl %ebx
addl %eax, %ebx
shrl $0x5, %ebx
xorl %r13d, %r13d
cmpl $0x35, %ecx
jb 0x104e0
movl %ebp, 0x4(%rsp)
movl %esi, (%rsp)
movl %esi, %ebp
xorl %r13d, %r13d
movl %ebx, %r12d
leal (%rbp,%r13), %esi
leaq (%r14,%r13), %rdx
movq %r15, %rdi
movl $0x35, %ecx
callq 0x10174
testl %eax, %eax
js 0x10501
addq $0x35, %r13
decl %r12d
jne 0x104b6
movl 0x4(%rsp), %ebp
movl (%rsp), %esi
imull $0x35, %ebx, %eax
movl %ebp, %ecx
subl %eax, %ecx
je 0x10516
addl %r13d, %esi
movl %r13d, %eax
addq %rax, %r14
movq %r15, %rdi
movq %r14, %rdx
callq 0x10174
testl %eax, %eax
jns 0x10516
movl %eax, %ebp
jmp 0x10516
leaq 0x10d85(%rip), %rax     # 0x21291
movl $0xffffffea, %ebp       # imm = 0xFFFFFFEA
cmpb $0x1, (%rax)
je 0x10527
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x5e8f
jmp 0x10516
// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gtx9/gtx9.cpp
// Function: GTx9Device::Write(unsigned int, unsigned char const*, unsigned int)
int GTx9Device::Write(unsigned int addr, const unsigned char *buf,
					  unsigned int len)
{
	uint8_t HidBuf[PACKAGE_LEN] = {0};
	uint32_t current_addr = addr;
	uint32_t transfer_length = 0;
	uint32_t pos = 0;
	uint8_t pkg_num = 0;
	int ret;

	if (!m_deviceOpen) {
		gdix_err("Device not open\n");
		return -EINVAL;
	}

	while (pos != len) {
		HidBuf[0] = REPORT_ID;
		HidBuf[1] = I2C_DIRECT_RW;
		if (len - pos > PACKAGE_LEN - 12) {
			transfer_length = PACKAGE_LEN - 12;
			HidBuf[2] = 0x01;
		} else {
			transfer_length = len - pos;
			HidBuf[2] = 0x00;
		}
		HidBuf[3] = pkg_num++;
		HidBuf[4] = transfer_length + 7;
		HidBuf[5] = I2C_WRITE_FLAG;
		HidBuf[6] = (current_addr >> 24) & 0xFF;
		HidBuf[7] = (current_addr >> 16) & 0xFF;
		HidBuf[8] = (current_addr >> 8) & 0xFF;
		HidBuf[9] = current_addr & 0xFF;
		HidBuf[10] = (transfer_length >> 8) & 0xFF;
		HidBuf[11] = transfer_length & 0xFF;
		memcpy(&HidBuf[12], &buf[pos], transfer_length);
		ret = SetReport(HidBuf, transfer_length + 12);
		if (ret < 0) {
			gdix_err("Failed write data to addr=0x%x, len=%d,ret = %d\n",
					 current_addr, transfer_length, ret);
			return ret;
		}
		pos += transfer_length;
		current_addr += transfer_length;
	}

	return len;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, 0x60(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movb $0x0, 0x50(%rsp)
movq %rdi, 0x58(%rsp)
cmpb $0x1, 0x8(%rdi)
jne 0x10618
movl %ecx, %ebp
testl %ecx, %ecx
je 0x10631
movl %esi, %ebx
xorl %r14d, %r14d
xorl %r15d, %r15d
movw $0x200e, 0x10(%rsp)     # imm = 0x200E
movl %ebp, %r12d
subl %r15d, %r12d
cmpl $0x35, %r12d
movl $0x35, %eax
cmovael %eax, %r12d
seta 0x12(%rsp)
movb %r14b, 0x13(%rsp)
leal 0x7(%r12), %eax
movb %al, 0x14(%rsp)
xorl %ecx, %ecx
movb %cl, 0x15(%rsp)
movl %ebx, %eax
shrl $0x18, %eax
movb %al, 0x16(%rsp)
movl %ebx, %eax
shrl $0x10, %eax
movb %al, 0x17(%rsp)
movb %bh, 0x18(%rsp)
movb %bl, 0x19(%rsp)
movb %cl, 0x1a(%rsp)
movb %r12b, 0x1b(%rsp)
movl %r15d, %esi
addq 0x60(%rsp), %rsi
leaq 0x1c(%rsp), %rdi
movq %r12, %rdx
callq 0x5090
leal 0xc(%r12), %edx
movq 0x58(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x10300
testl %eax, %eax
js 0x10636
incb %r14b
addl %r12d, %r15d
addl %r12d, %ebx
cmpl %ebp, %r15d
jne 0x1057e
movl %ebp, %r13d
jmp 0x10645
leaq 0x10c72(%rip), %rax     # 0x21291
movl $0xffffffea, %r13d      # imm = 0xFFFFFFEA
cmpb $0x1, (%rax)
jne 0x10645
callq 0x5eb1
jmp 0x10645
xorl %r13d, %r13d
jmp 0x10645
movl %eax, %r13d
leaq 0x10c51(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
je 0x10657
movl %r13d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1097a(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movl %r13d, (%rsp)
leaq 0x8444(%rip), %rsi      # 0x18ab0
leaq 0x7eb7(%rip), %rdx      # 0x1852a
movl %ebx, %r8d
movl $0xb9, %ecx
movl %r12d, %r9d
xorl %eax, %eax
callq 0x5180
jmp 0x10645
nop