// File: goodix[P]gdix_hid_firmware_update/gtx9/gtx9_update.cpp
// Function: GTx9Update::check_update()
int GTx9Update::check_update()
{
	int ret;

	ret = memcmp(dev->GetProductID(), image->GetProductID(), 8);
	if (ret != 0) {
		gdix_info("Product ID mismatch %s != %s\n", dev->GetProductID(),
				  image->GetProductID());
		return -1;
	}

	if ((dev->GetFirmwareVersionMajor() != image->GetFirmwareVersionMajor()) ||
		(dev->GetFirmwareVersionMinor() != image->GetFirmwareVersionMinor())) {
		gdix_info("Current version:%d.%d\n", dev->GetFirmwareVersionMajor(),
				  dev->GetFirmwareVersionMinor());
		gdix_info("Firmware version:%d.%d\n", image->GetFirmwareVersionMajor(),
				  image->GetFirmwareVersionMinor());
		return 1;
	}

	gdix_info("No need to upgrade\n");
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x70(%rax)
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, -0x20(%rbp)
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq -0x20(%rbp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0x5090
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x17def
jmp 0x17d7f
leaq 0xe513(%rip), %rax      # 0x26299
testb $0x1, (%rax)
je 0x17de1
movq -0x28(%rbp), %rax
movq 0xe222(%rip), %rcx      # 0x25fb8
movq (%rcx), %rcx
movq %rcx, -0x38(%rbp)
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x70(%rax)
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, -0x30(%rbp)
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %r8
movq %rax, %r9
leaq 0x833c(%rip), %rsi      # 0x2010a
leaq 0x44d8(%rip), %rdx      # 0x1c2ad
movl $0x57, %ecx
movb $0x0, %al
callq 0x5190
jmp 0x17de3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x17f53
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x60(%rax)
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, -0x3c(%rbp)
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
movl %eax, %ecx
movl -0x3c(%rbp), %eax
cmpl %ecx, %eax
jne 0x17e47
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x68(%rax)
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, -0x40(%rbp)
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *0x30(%rax)
movl %eax, %ecx
movl -0x40(%rbp), %eax
cmpl %ecx, %eax
je 0x17f18
jmp 0x17e49
leaq 0xe449(%rip), %rax      # 0x26299
testb $0x1, (%rax)
je 0x17ea9
movq -0x28(%rbp), %rax
movq 0xe158(%rip), %rcx      # 0x25fb8
movq (%rcx), %rcx
movq %rcx, -0x50(%rbp)
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x60(%rax)
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, -0x44(%rbp)
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x68(%rax)
movq -0x50(%rbp), %rdi
movl -0x44(%rbp), %r8d
movl %eax, %r9d
leaq 0x82a3(%rip), %rsi      # 0x20139
leaq 0x4410(%rip), %rdx      # 0x1c2ad
movl $0x5e, %ecx
movb $0x0, %al
callq 0x5190
jmp 0x17eab
jmp 0x17ead
leaq 0xe3e5(%rip), %rax      # 0x26299
testb $0x1, (%rax)
je 0x17f0d
movq -0x28(%rbp), %rax
movq 0xe0f4(%rip), %rcx      # 0x25fb8
movq (%rcx), %rcx
movq %rcx, -0x60(%rbp)
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, -0x54(%rbp)
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *0x30(%rax)
movq -0x60(%rbp), %rdi
movl -0x54(%rbp), %r8d
movl %eax, %r9d
leaq 0x8267(%rip), %rsi      # 0x20161
leaq 0x43ac(%rip), %rdx      # 0x1c2ad
movl $0x60, %ecx
movb $0x0, %al
callq 0x5190
jmp 0x17f0f
movl $0x1, -0x4(%rbp)
jmp 0x17f53
jmp 0x17f1a
leaq 0xe378(%rip), %rax      # 0x26299
testb $0x1, (%rax)
je 0x17f4a
movq 0xe08b(%rip), %rax      # 0x25fb8
movq (%rax), %rdi
leaq 0x8253(%rip), %rsi      # 0x2018a
leaq 0x436f(%rip), %rdx      # 0x1c2ad
movl $0x64, %ecx
movb $0x0, %al
callq 0x5190
jmp 0x17f4c
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)