// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/gt_update.cpp
// Function: GTupdate::check_update()
int GTupdate::check_update()
{
	int ret;
	if (!dev->IsOpened()) {
		gdix_err("No dev is Opened.");
		return -2;
	}
	if (!image->IsOpened()) {
		gdix_err("No image is Opened.");
		return -2;
	}
	gdix_dbg("dev PID is %s, image PID is %s\n", dev->GetProductID(),
			 image->GetProductID());

	/* compare PID */
	ret = memcmp(dev->GetProductID(), image->GetProductID(), 4);
	if (ret)
		return -1;

	gdix_dbg("dev major ver:0x%x,Minor ver:0x%x\n",
			 dev->GetFirmwareVersionMajor(), dev->GetFirmwareVersionMinor());
	gdix_dbg("fw_image major ver:0x%x,Minor ver:0x%x\n",
			 image->GetFirmwareVersionMajor(),
			 image->GetFirmwareVersionMinor());
	if (dev->GetFirmwareVersionMajor() != image->GetFirmwareVersionMajor() ||
		dev->GetFirmwareVersionMinor() != image->GetFirmwareVersionMinor()) {
		return 0;
	} else {
		return -2;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
testb %al, %al
je 0x7646
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
callq *0x90(%rax)
leaq 0x19da0(%rip), %r12     # 0x21291
movb (%r12), %cl
testb %al, %al
je 0x765e
testb %cl, %cl
je 0x7545
movq 0x19ab0(%rip), %rax     # 0x20fb8
movq (%rax), %r14
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
callq *0x70(%rax)
movq %rax, %r15
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
leaq 0xedb6(%rip), %rsi      # 0x162df
leaq 0xed7d(%rip), %rdx      # 0x162ad
movq %r14, %rdi
movl $0x20, %ecx
movq %r15, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x5180
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
callq *0x70(%rax)
movq %rax, %r14
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movl (%r14), %ecx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl (%rax), %ecx
jne 0x7667
movb (%r12), %al
cmpb $0x1, %al
jne 0x75bb
movq 0x19a3d(%rip), %rax     # 0x20fb8
movq (%rax), %r14
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
callq *0x60(%rax)
movl %eax, %ebp
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
callq *0x68(%rax)
leaq 0xed75(%rip), %rsi      # 0x16310
leaq 0xed0b(%rip), %rdx      # 0x162ad
movq %r14, %rdi
movl $0x28, %ecx
movl %ebp, %r8d
movl %eax, %r9d
xorl %eax, %eax
callq 0x5180
movb (%r12), %al
testb $0x1, %al
je 0x7602
movq 0x199f2(%rip), %rax     # 0x20fb8
movq (%rax), %r14
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
movl %eax, %ebp
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
callq *0x30(%rax)
leaq 0xed5e(%rip), %rsi      # 0x16344
leaq 0xecc0(%rip), %rdx      # 0x162ad
movq %r14, %rdi
movl $0x2b, %ecx
movl %ebp, %r8d
movl %eax, %r9d
xorl %eax, %eax
callq 0x5180
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
callq *0x60(%rax)
movl %eax, %r14d
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
xorl %ebp, %ebp
cmpl %eax, %r14d
jne 0x7667
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
callq *0x68(%rax)
movl %eax, %ebp
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
callq *0x30(%rax)
xorl %ecx, %ecx
cmpl %eax, %ebp
setne %cl
leal -0x2(,%rcx,2), %ebp
jmp 0x7667
leaq 0x19c44(%rip), %rax     # 0x21291
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
cmpb $0x1, (%rax)
jne 0x7667
callq 0x5230
jmp 0x7667
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
testb %cl, %cl
jne 0x7672
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x5252
jmp 0x7667
nop