// File: /workspace/github_cpp_makefile_star2_O1/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 0x7704
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
callq *0x90(%rax)
leaq 0x19ce0(%rip), %r12     # 0x21291
movb (%r12), %cl
testb %al, %al
je 0x771c
testb %cl, %cl
je 0x7605
movq 0x199f0(%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 0xecf6(%rip), %rsi      # 0x162df
leaq 0xecbd(%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 0x7725
cmpb $0x1, (%r12)
jne 0x7676
movq 0x1997e(%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 0xecb6(%rip), %rsi      # 0x16310
leaq 0xec4c(%rip), %rdx      # 0x162ad
movq %r14, %rdi
movl $0x28, %ecx
movl %ebp, %r8d
movl %eax, %r9d
xorl %eax, %eax
callq 0x5180
cmpb $0x1, (%r12)
jne 0x76c0
movq 0x19934(%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 0xeca0(%rip), %rsi      # 0x16344
leaq 0xec02(%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 0x7725
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 0x7725
leaq 0x19b86(%rip), %rax     # 0x21291
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
cmpb $0x1, (%rax)
jne 0x7725
callq 0x5230
jmp 0x7725
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
testb %cl, %cl
jne 0x7730
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x5252
jmp 0x7725
nop