// File: /workspace/github_cpp_makefile_star2_O2/goodix[P]gdix_hid_firmware_update/gtx9/gtx9_update.cpp
// Function: GTx9Update::Run(void*)
int GTx9Update::Run(void *para)
{
	int ret;

	if (!m_Initialized) {
		gdix_err("Can't Process Update Before Initialized.\n");
		return -EINVAL;
	}
	// get all parameter
	pGTUpdatePara parameter = (pGTUpdatePara)para;

	if (!parameter->force) {
		ret = check_update();
		if (ret < 0) {
			gdix_info("Upgrades are not allowed\n");
			return ret;
		} else if (ret == 0) {
			gdix_info("Skip upgrade\n");
			return 0;
		}
		gdix_info("Ready to upgrade\n");
	} else {
		gdix_info("Force to upgrade\n");
	}

	ret = prepareUpdate();
	if (ret < 0) {
		gdix_err("Failed prepare update\n");
		return ret;
	}

	ret = fw_update(parameter->firmwareFlag);
	if (ret < 0) {
		gdix_err("Failed update\n");
		return ret;
	}

	gdix_info("Success update\n");

	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
cmpb $0x0, 0x18(%rdi)
je 0x11c7a
movq %rsi, %r15
movq %rdi, %r14
cmpb $0x0, (%rsi)
je 0x11cac
leaq 0xe63c(%rip), %rax      # 0x20291
cmpb $0x1, (%rax)
jne 0x11cf2
movq 0xe353(%rip), %rax      # 0x1ffb8
movq (%rax), %rdi
leaq 0x73c9(%rip), %rsi      # 0x19038
leaq 0x43de(%rip), %rdx      # 0x16054
pushq $0x3c
jmp 0x11cea
leaq 0xe610(%rip), %rax      # 0x20291
pushq $-0x16
popq %rbx
cmpb $0x1, (%rax)
jne 0x11deb
movq 0xe344(%rip), %rax      # 0x1ffd8
movq (%rax), %rdi
leaq 0x437b(%rip), %rsi      # 0x16019
leaq 0x43af(%rip), %rdx      # 0x16054
pushq $0x2b
jmp 0x11ddf
movq (%r14), %rax
movq %r14, %rdi
callq *0x20(%rax)
testl %eax, %eax
js 0x11d75
leaq 0xe5cd(%rip), %rax      # 0x20291
movb (%rax), %al
je 0x11dbf
testb %al, %al
je 0x11cf2
movq 0xe2e1(%rip), %rax      # 0x1ffb8
movq (%rax), %rdi
leaq 0x7334(%rip), %rsi      # 0x19015
leaq 0x436c(%rip), %rdx      # 0x16054
pushq $0x3a
popq %rcx
xorl %eax, %eax
callq 0x5180
movq %r14, %rdi
callq 0x11df4
testl %eax, %eax
js 0x11d47
movl 0x4(%r15), %esi
movq (%r14), %rax
movq %r14, %rdi
callq *0x30(%rax)
movl %eax, %ebx
leaq 0xe57d(%rip), %rax      # 0x20291
movb (%rax), %al
testl %ebx, %ebx
js 0x11d9f
testb %al, %al
je 0x11de9
movq 0xe28b(%rip), %rax      # 0x1ffb8
movq (%rax), %rdi
leaq 0x736c(%rip), %rsi      # 0x190a3
leaq 0x4316(%rip), %rdx      # 0x16054
xorl %ebx, %ebx
pushq $0x4b
jmp 0x11ddf
movl %eax, %ebx
leaq 0xe541(%rip), %rax      # 0x20291
cmpb $0x1, (%rax)
jne 0x11deb
movq 0xe278(%rip), %rax      # 0x1ffd8
movq (%rax), %rdi
leaq 0x72f1(%rip), %rsi      # 0x1905b
leaq 0x42e3(%rip), %rdx      # 0x16054
pushq $0x41
jmp 0x11ddf
movl %eax, %ebx
leaq 0xe513(%rip), %rax      # 0x20291
cmpb $0x1, (%rax)
jne 0x11deb
movq 0xe22e(%rip), %rax      # 0x1ffb8
movq (%rax), %rdi
leaq 0x7237(%rip), %rsi      # 0x18fcb
leaq 0x42b9(%rip), %rdx      # 0x16054
pushq $0x34
jmp 0x11ddf
testb %al, %al
je 0x11deb
movq 0xe22e(%rip), %rax      # 0x1ffd8
movq (%rax), %rdi
leaq 0x72cf(%rip), %rsi      # 0x19083
leaq 0x4299(%rip), %rdx      # 0x16054
pushq $0x47
jmp 0x11ddf
testb %al, %al
je 0x11de9
movq 0xe1ee(%rip), %rax      # 0x1ffb8
movq (%rax), %rdi
leaq 0x7222(%rip), %rsi      # 0x18ff6
leaq 0x4279(%rip), %rdx      # 0x16054
xorl %ebx, %ebx
pushq $0x37
popq %rcx
xorl %eax, %eax
callq 0x5180
jmp 0x11deb
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
nop