// File: /workspace/github_cpp_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %r14
leaq 0xc(%rsp), %r15
movb $-0x33, 0x2(%r15)
movw $0x33, (%r15)
movb $-0x35, 0xa(%rsp)
andw $0x0, 0x4(%rsp)
movw $0x35, 0x8(%rsp)
movb $0x0, 0x6(%rsp)
pushq $0x3
popq %rbp
movl %ebp, %r12d
movq 0x8(%r14), %rdi
movq (%rdi), %rax
movq 0x30(%rax), %rax
subl $0x1, %r12d
jb 0xda3d
movl $0x60cc, %esi           # imm = 0x60CC
movq %r15, %rdx
movl %ebp, %ecx
callq *%rax
testl %eax, %eax
js 0xdac4
movl $0x2710, %edi           # imm = 0x2710
callq 0x5170
jmp 0xda0c
leaq 0x8(%rsp), %rdx
pushq $0x3
popq %rcx
movl $0x60cc, %esi           # imm = 0x60CC
callq *%rax
testl %eax, %eax
js 0xdaf5
movl $0x7530, %edi           # imm = 0x7530
callq 0x5170
movq 0x8(%r14), %rdi
movq (%rdi), %rax
leaq 0x4(%rsp), %rdx
pushq $0x3
popq %rcx
movl $0x60cc, %esi           # imm = 0x60CC
callq *0x20(%rax)
testl %eax, %eax
js 0xdb22
movzbl 0x5(%rsp), %r8d
leaq 0x12807(%rip), %rax     # 0x20291
movb (%rax), %al
cmpl $0x1, %r8d
jne 0xdb56
xorl %ebx, %ebx
testb %al, %al
je 0xdb5d
movq 0x12511(%rip), %rax     # 0x1ffb8
movq (%rax), %rdi
leaq 0x9e90(%rip), %rsi      # 0x17941
leaq 0x9df2(%rip), %rdx      # 0x178aa
xorl %ebx, %ebx
movl $0x9c, %ecx
jmp 0xdb4d
movl %eax, %ebx
leaq 0x127c4(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0xdb5d
movq 0x124fb(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0x9d94(%rip), %rsi      # 0x1787b
leaq 0x9dbc(%rip), %rdx      # 0x178aa
movl $0x85, %ecx
jmp 0xdb4d
movl %eax, %ebx
leaq 0x12793(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0xdb5d
movq 0x124ce(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0x9da4(%rip), %rsi      # 0x178b8
leaq 0x9d8f(%rip), %rdx      # 0x178aa
movl $0x8d, %ecx
jmp 0xdb4d
movl %eax, %ebx
leaq 0x12766(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0xdb5d
movq 0x124a1(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0x9da1(%rip), %rsi      # 0x178e2
leaq 0x9d62(%rip), %rdx      # 0x178aa
movl $0x93, %ecx
xorl %eax, %eax
callq 0x5180
jmp 0xdb5d
pushq $-0x16
popq %rbx
testb %al, %al
jne 0xdb6c
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x12465(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0x9d90(%rip), %rsi      # 0x1790d
leaq 0x9d26(%rip), %rdx      # 0x178aa
movl $0x98, %ecx
xorl %eax, %eax
callq 0x5180
jmp 0xdb5d