// File: /workspace/github_cpp_makefile_star2_O2/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 0x5abe
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
callq *0x90(%rax)
leaq 0x1a848(%rip), %r12     # 0x20291
movb (%r12), %cl
testb %al, %al
je 0x5aec
testb %cl, %cl
je 0x5a9b
movq 0x1a558(%rip), %rax     # 0x1ffb8
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 0xf85e(%rip), %rsi      # 0x152df
leaq 0xf825(%rip), %rdx      # 0x152ad
pushq $0x20
popq %rcx
movq %r14, %rdi
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
cmpl (%rax), %ecx
je 0x5b02
pushq $-0x1
popq %rbp
jmp 0x5af7
leaq 0x1a7cc(%rip), %rax     # 0x20291
pushq $-0x2
popq %rbp
cmpb $0x1, (%rax)
jne 0x5af7
movq 0x1a504(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0xf7ac(%rip), %rsi      # 0x1528a
leaq 0xf7c8(%rip), %rdx      # 0x152ad
pushq $0x18
jmp 0x5bf9
pushq $-0x2
popq %rbp
testb %cl, %cl
jne 0x5bdf
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movb (%r12), %al
cmpb $0x1, %al
jne 0x5b4f
movq 0x1a4a7(%rip), %rax     # 0x1ffb8
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 0xf7df(%rip), %rsi      # 0x15310
leaq 0xf775(%rip), %rdx      # 0x152ad
pushq $0x28
popq %rcx
movq %r14, %rdi
movl %ebp, %r8d
movl %eax, %r9d
xorl %eax, %eax
callq 0x5180
movb (%r12), %al
testb $0x1, %al
je 0x5b94
movq 0x1a45e(%rip), %rax     # 0x1ffb8
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 0xf7ca(%rip), %rsi      # 0x15344
leaq 0xf72c(%rip), %rdx      # 0x152ad
pushq $0x2b
popq %rcx
movq %r14, %rdi
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 0x5af7
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 0x5af7
movq 0x1a3f2(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0xf6ca(%rip), %rsi      # 0x152ba
leaq 0xf6b6(%rip), %rdx      # 0x152ad
pushq $0x1c
popq %rcx
xorl %eax, %eax
callq 0x5180
jmp 0x5af7