// File: /workspace/github_cpp_makefile_star2_O3/goodix[P]gdix_hid_firmware_update/main.cpp
// Function: main
int main(int argc, char **argv)
{
	int ret = 0;
	int opt;
	int index;
	int chipType = -1;
	GTmodel *gt_model = NULL;
	FirmwareImage *fw_image = NULL;
	GTupdate *gt_update = NULL;
	GTUpdatePara *gt_update_para = NULL;
	unsigned int firmware_flag = 0xFFFFFFFF;
	uint8_t i2cAddr = 0;

	regex_t reg_x3xx;
	regex_t reg_x5xx;
	regex_t reg_x2xx;
	regex_t reg_x8xx;
	regex_t reg_x9xx;
	regex_t reg_7868;
	regex_t reg_brla;
	regmatch_t pamtch[1]; // match container

	char *deviceName = NULL;
	const char *firmwareName = NULL;
	const char *pid = NULL;
	const char *productionTypeName = NULL;
	bool force = false;
	static struct option long_options[] = {
		{"help", 0, NULL, 'h'},
		{"force", 0, NULL, 'f'},
		{"device", 1, NULL, 'd'},
		{"fw-props", 0, NULL, 'p'},
		{"version", 0, NULL, 'v'},
		{"type", 1, NULL, 't'},
		{"series", 1, NULL, 's'},
		{"info", 0, NULL, 'i'},
		{"module", 0, NULL, 'm'},
		{"i2c-addr", 1, NULL, 'a'},
		{0, 0, 0, 0},
	};
	bool printFirmwareProps = false;
	bool printModuleId = false;
	while ((opt = getopt_long(argc, argv, GTPUPDATE_GETOPTS, long_options,
							  &index)) != -1) {
		switch (opt) {
		case 'h':
			printHelp(argv[0]);
			return 0;
		case 'f':
			force = true;
			break;
		case 'd':
			deviceName = optarg;
			break;
		case 'p':
			printFirmwareProps = true;
			break;
		case 'v':
			printVersion();
			return 0;
		case 't':
			lowercase_str((unsigned char *)optarg);
			pid = optarg;
			gdix_dbg("pid is %s\n", pid);
			break;
		case 's':
			productionTypeName = optarg;
			gdix_dbg("product type is %s\n", productionTypeName);
			break;
		case 'i':
			pdebug = true;
			break;
		case 'm':
			printModuleId = true;
			break;
		case 'a':
			i2cAddr = strtol(optarg, NULL, 16);
			break;
		default:
			break;
		}
	}

	if (optind < argc) {
		firmwareName = argv[optind];
		gdix_dbg("firmware name:%s\n", firmwareName);
	}
	if (NULL == productionTypeName && NULL == pid) {
		gdix_err("please input pid or product type\n");
		return -1;
	}
	if (!printModuleId && !printFirmwareProps && NULL == firmwareName) {
		gdix_err("file name not found\n");
		return -1;
	}

	// check chip type
	if (pid != NULL) {
		regex_t reg_pid;
		regcomp(&reg_pid, "^011[0-9A-Fa-f]$", REG_EXTENDED); // phoenix pid
															 // 011x
		if (REG_NOERROR == regexec(&reg_pid, pid, 1, pamtch, 0)) {
			gdix_dbg("pid match phoenix pid 011x\n");
			chipType = TYPE_PHOENIX;
		}
		regfree(&reg_pid);

		regcomp(&reg_pid, "^0[eE][0-9A-Fa-f]{2}$",
				REG_EXTENDED); // phoenix pid 0exx
		if (REG_NOERROR == regexec(&reg_pid, pid, 1, pamtch, 0)) {
			gdix_dbg("pid match phoenix pid 0exx\n");
			chipType = TYPE_PHOENIX;
		}
		regfree(&reg_pid);

		regcomp(&reg_pid, "^01[fF][0-9A-Fa-f]$",
				REG_EXTENDED); // mouse pad pid 01fx
		if (REG_NOERROR == regexec(&reg_pid, pid, 1, pamtch, 0)) {
			gdix_dbg("pid match mousepad pid 01fx\n");
			chipType = TYPE_MOUSEPAD;
		}
		regfree(&reg_pid);

		regcomp(&reg_pid, "^0[fF][0-9A-Fa-f]{2}$",
				REG_EXTENDED); // mouse pad pid 0fxx
		if (REG_NOERROR == regexec(&reg_pid, pid, 1, pamtch, 0)) {
			gdix_dbg("pid match mousepad pid 0fxx\n");
			chipType = TYPE_MOUSEPAD;
		}
		regfree(&reg_pid);

		regcomp(&reg_pid, "^01[eE][0-7]$",
				REG_EXTENDED); // 7863 windows pid 01e0~01e7
		if (REG_NOERROR == regexec(&reg_pid, pid, 1, pamtch, 0)) {
			gdix_dbg("pid match GT7863 pid 01e0_01e7\n");
			chipType = TYPE_NORMANDYL;
		}
		regfree(&reg_pid);

		regcomp(&reg_pid, "^0[dD][0-7][0-9A-Fa-f]$",
				REG_EXTENDED); // 7863 chrome pid 0d00~0d7f
		if (REG_NOERROR == regexec(&reg_pid, pid, 1, pamtch, 0)) {
			gdix_dbg("pid match GT7863 pid 0d00_0d7f\n");
			chipType = TYPE_NORMANDYL;
		}
		regfree(&reg_pid);

		regcomp(&reg_pid, "^0[dD][8-9A-Ba-b][0-9A-Fa-f]$",
				REG_EXTENDED); // 7868Q chrome pid 0d80~0dbf
		if (REG_NOERROR == regexec(&reg_pid, pid, 1, pamtch, 0)) {
			gdix_dbg("pid match GT7868Q pid 0d80_0dbf\n");
			chipType = TYPE_YELLOWSTONE;
		}
		regfree(&reg_pid);

		/* 0EB* 0EC* is BerlinB */
		regcomp(&reg_pid, "^0[eE][bBcC][0-9A-Fa-f]$", REG_EXTENDED);
		if (REG_NOERROR == regexec(&reg_pid, pid, 1, pamtch, 0)) {
			gdix_dbg("pid match BerlinB pid 0EBx\n");
			chipType = TYPE_BERLINB;
		}
		regfree(&reg_pid);

		/* 0EA5~0EAF is BerlinB */
		regcomp(&reg_pid, "^0[eE][aA][5-9A-Fa-f]$", REG_EXTENDED);
		if (REG_NOERROR == regexec(&reg_pid, pid, 1, pamtch, 0)) {
			gdix_dbg("pid match BerlinB pid 0EA5~0EAF\n");
			chipType = TYPE_BERLINB;
		}
		regfree(&reg_pid);

		/* 0Cxx is BerlinB */
		regcomp(&reg_pid, "^0[cC][0-9A-Fa-f]{2}$", REG_EXTENDED);
		if (REG_NOERROR == regexec(&reg_pid, pid, 1, pamtch, 0)) {
			gdix_dbg("pid match BerlinB pid 0Cxx\n");
			chipType = TYPE_BERLINB;
		}
		regfree(&reg_pid);

		/* 0F60~0F7F is BerlinA */
		regcomp(&reg_pid, "^0[fF][6-7][0-9A-Fa-f]$", REG_EXTENDED);
		if (REG_NOERROR == regexec(&reg_pid, pid, 1, pamtch, 0)) {
			gdix_dbg("pid match BerlinA pid 0F60~0F7F\n");
			chipType = TYPE_BERLINA;
		}
		regfree(&reg_pid);		
	} else if (productionTypeName != NULL) {
		regcomp(&reg_x3xx, "^[0-9]3[0-9]{2}", REG_EXTENDED);
		regcomp(&reg_x5xx, "^[0-9]5[0-9]{2}", REG_EXTENDED);
		regcomp(&reg_x2xx, "^[0-9]2[0-9]{2}", REG_EXTENDED);
		regcomp(&reg_x8xx, "^[0-9]8[0-9]{2}", REG_EXTENDED);
		regcomp(&reg_x9xx, "^[0-9]9[0-9]{2}", REG_EXTENDED);
		regcomp(&reg_7868, "^7868", REG_EXTENDED);
		regcomp(&reg_brla, "^7726", REG_EXTENDED);

		if (REG_NOERROR == regexec(&reg_x3xx, productionTypeName, 1, pamtch, 0))
			chipType = TYPE_PHOENIX; // 7388 match
		else if (REG_NOERROR ==
				 regexec(&reg_x5xx, productionTypeName, 1, pamtch, 0))
			chipType = TYPE_NANJING; // 8589 match
		else if (REG_NOERROR ==
				 regexec(&reg_x2xx, productionTypeName, 1, pamtch, 0))
			chipType = TYPE_MOUSEPAD; // 7288 match
		else if (REG_NOERROR ==
				 regexec(&reg_x8xx, productionTypeName, 1, pamtch, 0))
			chipType = TYPE_NORMANDYL; // 7863 match
		else if (REG_NOERROR ==
				 regexec(&reg_x9xx, productionTypeName, 1, pamtch, 0))
			chipType = TYPE_BERLINB; // 9966 match
		else if (REG_NOERROR ==
				 regexec(&reg_7868, productionTypeName, 1, pamtch, 0))
			chipType = TYPE_YELLOWSTONE; // 7868 match
		else if (REG_NOERROR ==
				 regexec(&reg_brla, productionTypeName, 1, pamtch, 0))
			chipType = TYPE_BERLINA; // 7726 match
		else
			chipType = -1; // no match

		regfree(&reg_x3xx);
		regfree(&reg_x5xx);
		regfree(&reg_x2xx);
		regfree(&reg_x8xx);
		regfree(&reg_x9xx);
		regfree(&reg_7868);
		regfree(&reg_brla);
	}

	if (chipType < 0) {
		gdix_err("Find No match pid or product\n");
		delete gt_model;
		return -6;
	}

	/* i2c update */
	if (i2cAddr > 0 && chipType == TYPE_BERLINB) {
		gdix_do_fw_update(deviceName, firmwareName, i2cAddr);
		return 0;
	}

	if (chipType == TYPE_MOUSEPAD) {
		gt_model = new GTx2Device;
		fw_image = new GTX2FirmwareImage;
		gt_update = new GTx2Update;
		firmware_flag = 0x1400C; // update type:0x02,0x03,0x0e,0x10
	} else if (chipType == TYPE_NANJING) {
		gt_model = new GTx5Device;
		fw_image = new GTX5FirmwareImage;
		gt_update = new GTx5Update;
		firmware_flag = 0x1400C; // update type:0x02,0x03,0x03,0x10;
	} else if (chipType == TYPE_PHOENIX) {
		gt_model = new GTx3Device;
		fw_image = new GTX3FirmwareImage;
		gt_update = new GTx3Update;
		firmware_flag = 0x844; // update type:0x02,0x03,0x03,0x10;
	} else if (chipType == TYPE_NORMANDYL) {
		gt_model = new GTx8Device;
		fw_image = new GTX8FirmwareImage;
		gt_update = new GTx8Update;
		firmware_flag = 0x0C; // update type:0x02,0x03;
	} else if (chipType == TYPE_BERLINB) {
		gt_model = new GTx9Device;
		fw_image = new GTX9FirmwareImage;
		gt_update = new GTx9Update;
		firmware_flag = 0x0B; // don't update type:0x0B;
	} else if (chipType == TYPE_YELLOWSTONE) {
		gt_model = new GT7868QDevice;
		fw_image = new GT7868QFirmwareImage;
		gt_update = new GT7868QUpdate;
		firmware_flag = 0x0C; // update type:0x02,0x03;
	} else if (chipType == TYPE_BERLINA) {
		gt_model = new BrlADevice;
		fw_image = new BrlAFirmwareImage;
		gt_update = new BrlAUpdate;
	} else {
		if (pid != NULL)
			gdix_err("unsupported pid number:%s\n", pid);
		else
			gdix_err("unsupported product type number:%s\n",
					 productionTypeName);
		return -1;
	}

	/* get and print active FW version */
	if (printFirmwareProps) {
		char props_buf[60] = {0};
		ret = gt_model->GetFirmwareProps(deviceName, props_buf,
										 sizeof(props_buf));
		if (ret) {
			printf("Failed to read properties from device %s\n", deviceName);
			delete gt_model;
			return 1;
		} else {
			printf("%s\n", props_buf);
			delete gt_model;
			return 0;
		}
	}

	ret = gt_model->Open(deviceName);
	if (ret) {
		gdix_err("failed open device:%s\n", deviceName);
		delete gt_model;
		return -1;
	}

	if (printModuleId) {
		printf("module_id:%d\n", gt_model->GetSensorID());
		delete gt_model;
		return 0;
	}

	ret = fw_image->Initialize(firmwareName);
	if (ret) {
		gdix_err("Failed read firmware file:%s\n", firmwareName);
		delete gt_model;
		return -2;
	}

	ret = gt_update->Initialize(gt_model, fw_image);
	if (ret) {
		// gdix_err("Failed read firmware file:%s\n", firmwareName);
		delete gt_model;
		return -2;
	}

	// run update
	gt_update_para = new GTUpdatePara;
	gt_update_para->force = force;
	gt_update_para->firmwareFlag = firmware_flag;

	ret = gt_update->Run(gt_update_para);
	if (ret) {
		gdix_err("Firmware update err:ret=%d\n", ret);
		delete gt_model;
		return -4;
	}

	delete gt_model;
	delete fw_image;
	delete gt_update;

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq %rsi, %r14
movl %edi, %ebp
movq $0x0, 0x20(%rsp)
leaq 0x19a66(%rip), %r15     # 0x21120
leaq 0x3c(%rsp), %r13
leaq 0xecc2(%rip), %rbx      # 0x16388
movq $0x0, 0x30(%rsp)
movq $0x0, 0x8(%rsp)
xorl %r12d, %r12d
movq $0x0, 0x10(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x18(%rsp)
movl %ebp, %edi
movq %r14, %rsi
leaq 0xed2a(%rip), %rdx      # 0x1642c
movq %r15, %rcx
movq %r13, %r8
callq 0x51d0
leal -0x61(%rax), %ecx
cmpl $0x15, %ecx
ja 0x782a
movslq (%rbx,%rcx,4), %rax
addq %rbx, %rax
jmpq *%rax
movq 0x1989f(%rip), %rax     # 0x20fc8
movq (%rax), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x5150
movq %rax, 0x30(%rsp)
jmp 0x76f6
movb $0x1, %al
movq %rax, 0x18(%rsp)
jmp 0x76f6
movb $0x1, %al
movq %rax, 0x28(%rsp)
jmp 0x76f6
movb $0x1, 0x19b39(%rip)     # 0x21291
jmp 0x76f6
movq 0x19867(%rip), %rax     # 0x20fc8
movq (%rax), %r12
movb (%r12), %al
testb %al, %al
je 0x7791
incq %r12
movzbl %al, %edi
callq 0x51a0
movb %al, -0x1(%r12)
movb (%r12), %al
incq %r12
testb %al, %al
jne 0x776f
movq 0x1983a(%rip), %rax     # 0x20fc8
movq (%rax), %r12
cmpb $0x1, 0x19af9(%rip)     # 0x21291
jne 0x76f6
movq 0x19813(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xec8c(%rip), %rsi      # 0x1643b
leaq 0xeca1(%rip), %rdx      # 0x16457
movl $0xb5, %ecx
movq %r12, %r8
jmp 0x781e
movq 0x19801(%rip), %rax     # 0x20fc8
movq (%rax), %rax
movq %rax, 0x8(%rsp)
jmp 0x76f6
movb $0x1, %al
movq %rax, 0x20(%rsp)
jmp 0x76f6
movq 0x197e1(%rip), %rax     # 0x20fc8
movq (%rax), %rax
movq %rax, 0x10(%rsp)
cmpb $0x1, 0x19a9b(%rip)     # 0x21291
jne 0x76f6
movq 0x197b5(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xec4f(%rip), %rsi      # 0x1645c
leaq 0xec43(%rip), %rdx      # 0x16457
movl $0xb9, %ecx
movq 0x10(%rsp), %r8
xorl %eax, %eax
callq 0x5180
jmp 0x76f6
cmpl $-0x1, %eax
jne 0x76f6
movq 0x197a6(%rip), %rax     # 0x20fe0
movslq (%rax), %rax
cmpl %ebp, %eax
jge 0x79d8
movq (%r14,%rax,8), %r14
cmpb $0x1, 0x19a41(%rip)     # 0x21291
movq 0x10(%rsp), %r15
jne 0x79e0
movq 0x19756(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xec15(%rip), %rsi      # 0x16481
leaq 0xebe4(%rip), %rdx      # 0x16457
movl $0xcb, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0x5180
jmp 0x79e0
movq 0x1972a(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xf2ff(%rip), %rsi      # 0x16b97
leaq 0xf311(%rip), %rdx      # 0x16bb0
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x5180
jmp 0x79c4
movq (%r14), %rdx
movq 0x19701(%rip), %r14     # 0x20fb8
movq (%r14), %rdi
leaq 0xf07e(%rip), %rsi      # 0x1693f
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x5180
movq (%r14), %rcx
leaq 0xf08d(%rip), %rdi      # 0x16961
movl $0x1f, %esi
movl $0x1, %edx
callq 0x5200
movq (%r14), %rcx
leaq 0xf094(%rip), %rdi      # 0x16981
movl $0x3c, %esi
movl $0x1, %edx
callq 0x5200
movq (%r14), %rcx
leaq 0xf0b8(%rip), %rdi      # 0x169be
movl $0x4b, %esi
movl $0x1, %edx
callq 0x5200
movq (%r14), %rcx
leaq 0xf0eb(%rip), %rdi      # 0x16a0a
movl $0x4d, %esi
movl $0x1, %edx
callq 0x5200
movq (%r14), %rcx
leaq 0xf120(%rip), %rdi      # 0x16a58
movl $0x25, %esi
movl $0x1, %edx
callq 0x5200
movq (%r14), %rcx
leaq 0xf12d(%rip), %rdi      # 0x16a7e
movl $0x20, %esi
movl $0x1, %edx
callq 0x5200
movq (%r14), %rcx
leaq 0xf135(%rip), %rdi      # 0x16a9f
movl $0x3c, %esi
movl $0x1, %edx
callq 0x5200
movq (%r14), %rcx
leaq 0xf159(%rip), %rdi      # 0x16adc
movl $0x3a, %esi
movl $0x1, %edx
callq 0x5200
movq (%r14), %rcx
leaq 0xf17b(%rip), %rdi      # 0x16b17
movl $0x27, %esi
movl $0x1, %edx
callq 0x5200
movq (%r14), %rcx
leaq 0xf18a(%rip), %rdi      # 0x16b3f
movl $0x57, %esi
movl $0x1, %edx
callq 0x5200
movl %ebx, %eax
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r14d, %r14d
movq 0x10(%rsp), %r15
movq %r15, %rax
orq %r12, %rax
jne 0x79fd
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpb $0x1, 0x1989d(%rip)     # 0x21291
jne 0x79c4
callq 0x52c8
jmp 0x79c4
movq 0x18(%rsp), %rax
orb 0x20(%rsp), %al
testb $0x1, %al
jne 0x7a24
testq %r14, %r14
jne 0x7a24
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpb $0x1, 0x19876(%rip)     # 0x21291
jne 0x79c4
callq 0x5274
jmp 0x79c4
testq %r12, %r12
je 0x7ee7
leaq 0xeac9(%rip), %rsi      # 0x164fd
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
movl $0x1, %edx
callq 0x5100
movq %rsp, %rcx
movl $0x1, %edx
movq %rbx, %rdi
movq %r12, %rsi
xorl %r8d, %r8d
callq 0x5120
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x7a99
cmpb $0x1, 0x19825(%rip)     # 0x21291
movl $0x0, %ebp
jne 0x7a99
movq 0x1953e(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xea8a(%rip), %rsi      # 0x1650e
leaq 0xe9cc(%rip), %rdx      # 0x16457
xorl %ebp, %ebp
movl $0xdc, %ecx
xorl %eax, %eax
callq 0x5180
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x50d0
leaq 0xea8e(%rip), %rsi      # 0x1653b
movq %rbx, %rdi
movl $0x1, %edx
callq 0x5100
movq %rsp, %rcx
movl $0x1, %edx
movq %rbx, %rdi
movq %r12, %rsi
xorl %r8d, %r8d
callq 0x5120
testl %eax, %eax
jne 0x7b08
cmpb $0x1, 0x197b6(%rip)     # 0x21291
movl $0x0, %ebp
jne 0x7b08
movq 0x194cf(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xea5e(%rip), %rsi      # 0x16551
leaq 0xe95d(%rip), %rdx      # 0x16457
xorl %ebp, %ebp
movl $0xe4, %ecx
xorl %eax, %eax
callq 0x5180
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x50d0
leaq 0xea62(%rip), %rsi      # 0x1657e
movq %rbx, %rdi
movl $0x1, %edx
callq 0x5100
movq %rsp, %rcx
movl $0x1, %edx
movq %rbx, %rdi
movq %r12, %rsi
xorl %r8d, %r8d
callq 0x5120
testl %eax, %eax
jne 0x7b75
movl $0x2, %ebp
cmpb $0x1, 0x19742(%rip)     # 0x21291
jne 0x7b75
movq 0x19460(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xea30(%rip), %rsi      # 0x16592
leaq 0xe8ee(%rip), %rdx      # 0x16457
movl $0xec, %ecx
xorl %eax, %eax
callq 0x5180
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x50d0
leaq 0xea37(%rip), %rsi      # 0x165c0
movq %rbx, %rdi
movl $0x1, %edx
callq 0x5100
movq %rsp, %rcx
movl $0x1, %edx
movq %rbx, %rdi
movq %r12, %rsi
xorl %r8d, %r8d
callq 0x5120
testl %eax, %eax
jne 0x7be2
movl $0x2, %ebp
cmpb $0x1, 0x196d5(%rip)     # 0x21291
jne 0x7be2
movq 0x193f3(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xea07(%rip), %rsi      # 0x165d6
leaq 0xe881(%rip), %rdx      # 0x16457
movl $0xf4, %ecx
xorl %eax, %eax
callq 0x5180
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x50d0
leaq 0xea0e(%rip), %rsi      # 0x16604
movq %rbx, %rdi
movl $0x1, %edx
callq 0x5100
movq %rsp, %rcx
movl $0x1, %edx
movq %rbx, %rdi
movq %r12, %rsi
xorl %r8d, %r8d
callq 0x5120
testl %eax, %eax
jne 0x7c4f
movl $0x3, %ebp
cmpb $0x1, 0x19668(%rip)     # 0x21291
jne 0x7c4f
movq 0x19386(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xe9d6(%rip), %rsi      # 0x16612
leaq 0xe814(%rip), %rdx      # 0x16457
movl $0xfc, %ecx
xorl %eax, %eax
callq 0x5180
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x50d0
leaq 0xe9e0(%rip), %rsi      # 0x16643
movq %rbx, %rdi
movl $0x1, %edx
callq 0x5100
movq %rsp, %rcx
movl $0x1, %edx
movq %rbx, %rdi
movq %r12, %rsi
xorl %r8d, %r8d
callq 0x5120
testl %eax, %eax
jne 0x7cbc
movl $0x3, %ebp
cmpb $0x1, 0x195fb(%rip)     # 0x21291
jne 0x7cbc
movq 0x19319(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xe9b2(%rip), %rsi      # 0x1665b
leaq 0xe7a7(%rip), %rdx      # 0x16457
movl $0x104, %ecx            # imm = 0x104
xorl %eax, %eax
callq 0x5180
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x50d0
leaq 0xe9bc(%rip), %rsi      # 0x1668c
movq %rbx, %rdi
movl $0x1, %edx
callq 0x5100
movq %rsp, %rcx
movl $0x1, %edx
movq %rbx, %rdi
movq %r12, %rsi
xorl %r8d, %r8d
callq 0x5120
testl %eax, %eax
jne 0x7d29
movl $0x4, %ebp
cmpb $0x1, 0x1958e(%rip)     # 0x21291
jne 0x7d29
movq 0x192ac(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xe994(%rip), %rsi      # 0x166aa
leaq 0xe73a(%rip), %rdx      # 0x16457
movl $0x10c, %ecx            # imm = 0x10C
xorl %eax, %eax
callq 0x5180
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x50d0
leaq 0xe99f(%rip), %rsi      # 0x166dc
movq %rbx, %rdi
movl $0x1, %edx
callq 0x5100
movq %rsp, %rcx
movl $0x1, %edx
movq %rbx, %rdi
movq %r12, %rsi
xorl %r8d, %r8d
callq 0x5120
testl %eax, %eax
jne 0x7d96
movl $0x6, %ebp
cmpb $0x1, 0x19521(%rip)     # 0x21291
jne 0x7d96
movq 0x1923f(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xe972(%rip), %rsi      # 0x166f5
leaq 0xe6cd(%rip), %rdx      # 0x16457
movl $0x114, %ecx            # imm = 0x114
xorl %eax, %eax
callq 0x5180
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x50d0
leaq 0xe978(%rip), %rsi      # 0x16722
movq %rbx, %rdi
movl $0x1, %edx
callq 0x5100
movq %rsp, %rcx
movl $0x1, %edx
movq %rbx, %rdi
movq %r12, %rsi
xorl %r8d, %r8d
callq 0x5120
testl %eax, %eax
jne 0x7e03
movl $0x6, %ebp
cmpb $0x1, 0x194b4(%rip)     # 0x21291
jne 0x7e03
movq 0x191d2(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xe949(%rip), %rsi      # 0x16739
leaq 0xe660(%rip), %rdx      # 0x16457
movl $0x11c, %ecx            # imm = 0x11C
xorl %eax, %eax
callq 0x5180
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x50d0
leaq 0xe954(%rip), %rsi      # 0x1676b
movq %rbx, %rdi
movl $0x1, %edx
callq 0x5100
movq %rsp, %rcx
movl $0x1, %edx
movq %rbx, %rdi
movq %r12, %rsi
xorl %r8d, %r8d
callq 0x5120
testl %eax, %eax
jne 0x7e70
movl $0x6, %ebp
cmpb $0x1, 0x19447(%rip)     # 0x21291
jne 0x7e70
movq 0x19165(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xe924(%rip), %rsi      # 0x16781
leaq 0xe5f3(%rip), %rdx      # 0x16457
movl $0x124, %ecx            # imm = 0x124
xorl %eax, %eax
callq 0x5180
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x50d0
leaq 0xe92a(%rip), %rsi      # 0x167ae
movq %rbx, %rdi
movl $0x1, %edx
callq 0x5100
movq %rsp, %rcx
movl $0x1, %edx
movq %rbx, %rdi
movq %r12, %rsi
xorl %r8d, %r8d
callq 0x5120
testl %eax, %eax
jne 0x7edd
movl $0x5, %ebp
cmpb $0x1, 0x193da(%rip)     # 0x21291
jne 0x7edd
movq 0x190f8(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xe8fc(%rip), %rsi      # 0x167c6
leaq 0xe586(%rip), %rdx      # 0x16457
movl $0x12c, %ecx            # imm = 0x12C
xorl %eax, %eax
callq 0x5180
leaq 0x40(%rsp), %rdi
jmp 0x8100
testq %r15, %r15
je 0x812e
leaq 0xe901(%rip), %rsi      # 0x167f8
leaq 0x208(%rsp), %rbx
movq %rbx, %rdi
movl $0x1, %edx
callq 0x5100
leaq 0xe8f5(%rip), %rsi      # 0x16808
leaq 0x1c8(%rsp), %rdi
movl $0x1, %edx
callq 0x5100
leaq 0xe8ec(%rip), %rsi      # 0x16818
leaq 0x188(%rsp), %rdi
movl $0x1, %edx
callq 0x5100
leaq 0xe8e3(%rip), %rsi      # 0x16828
leaq 0x148(%rsp), %rdi
movl $0x1, %edx
callq 0x5100
leaq 0xe8da(%rip), %rsi      # 0x16838
leaq 0x108(%rsp), %rdi
movl $0x1, %edx
callq 0x5100
leaq 0xe8d1(%rip), %rsi      # 0x16848
leaq 0xc8(%rsp), %rdi
movl $0x1, %edx
callq 0x5100
leaq 0xe8be(%rip), %rsi      # 0x1684e
leaq 0x88(%rsp), %rdi
movl $0x1, %edx
callq 0x5100
movq %rsp, %rcx
xorl %ebp, %ebp
movl $0x1, %edx
movq %rbx, %rdi
movq %r15, %rsi
xorl %r8d, %r8d
callq 0x5120
testl %eax, %eax
je 0x80aa
leaq 0x1c8(%rsp), %rdi
movq %rsp, %rcx
movl $0x1, %edx
movq %r15, %rsi
xorl %r8d, %r8d
callq 0x5120
movl $0x1, %ebp
testl %eax, %eax
je 0x80aa
leaq 0x188(%rsp), %rdi
movq %rsp, %rcx
movl $0x1, %edx
movq %r15, %rsi
xorl %r8d, %r8d
callq 0x5120
testl %eax, %eax
je 0x8090
leaq 0x148(%rsp), %rdi
movq %rsp, %rcx
movl $0x1, %edx
movq %r15, %rsi
xorl %r8d, %r8d
callq 0x5120
testl %eax, %eax
je 0x8097
leaq 0x108(%rsp), %rdi
movq %rsp, %rcx
movl $0x1, %edx
movq %r15, %rsi
xorl %r8d, %r8d
callq 0x5120
testl %eax, %eax
je 0x809e
leaq 0xc8(%rsp), %rdi
movq %rsp, %rcx
xorl %ebp, %ebp
movl $0x1, %edx
movq %r15, %rsi
xorl %r8d, %r8d
callq 0x5120
testl %eax, %eax
je 0x80a5
leaq 0x88(%rsp), %rdi
movq %rsp, %rcx
movl $0x1, %edx
movq %r15, %rsi
xorl %r8d, %r8d
callq 0x5120
negl %eax
sbbl %ebp, %ebp
orl $0x5, %ebp
jmp 0x80aa
movl $0x2, %ebp
jmp 0x80aa
movl $0x3, %ebp
jmp 0x80aa
movl $0x6, %ebp
jmp 0x80aa
movl $0x4, %ebp
leaq 0x208(%rsp), %rdi
callq 0x50d0
leaq 0x1c8(%rsp), %rdi
callq 0x50d0
leaq 0x188(%rsp), %rdi
callq 0x50d0
leaq 0x148(%rsp), %rdi
callq 0x50d0
leaq 0x108(%rsp), %rdi
callq 0x50d0
leaq 0xc8(%rsp), %rdi
callq 0x50d0
leaq 0x88(%rsp), %rdi
callq 0x50d0
testl %ebp, %ebp
js 0x812e
movq 0x30(%rsp), %rax
testb %al, %al
je 0x814a
cmpl $0x6, %ebp
jne 0x814a
movzbl %al, %edx
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x113d9
xorl %ebx, %ebx
jmp 0x79c4
movl $0xfffffffa, %ebx       # imm = 0xFFFFFFFA
cmpb $0x1, 0x19157(%rip)     # 0x21291
jne 0x79c4
callq 0x529e
jmp 0x79c4
cmpl $0x3, %ebp
ja 0x82ba
movl %ebp, %eax
leaq 0xe284(%rip), %rcx      # 0x163e0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x48, %edi
callq 0x50c0
movq %rax, %r15
movq %rax, %rdi
callq 0xb880
movq 0x8(%rsp), %rbp
movl $0x38, %edi
callq 0x50c0
movq %rax, %r12
movq %rax, %rdi
callq 0xbc14
movl $0x20, %edi
callq 0x50c0
movq %rax, %r13
movl $0x844, %ebx            # imm = 0x844
movq %rax, %rdi
callq 0xbdec
jmp 0x83c4
movl $0x48, %edi
callq 0x50c0
movq %rax, %r15
movq %rax, %rdi
callq 0xd16c
movq 0x8(%rsp), %rbp
leaq 0x17e64(%rip), %rax     # 0x20038
addq $0x10, %rax
movq %rax, (%r15)
movl $0x38, %edi
callq 0x50c0
movq %rax, %r12
movq %rax, %rdi
callq 0xa894
movl $0x20, %edi
callq 0x50c0
movq %rax, %r13
movl $0x1400c, %ebx          # imm = 0x1400C
movq %rax, %rdi
callq 0xaab4
jmp 0x83c4
movl $0x48, %edi
callq 0x50c0
movq %rax, %r15
movq %rax, %rdi
callq 0xe61c
movq 0x8(%rsp), %rbp
movl $0x38, %edi
callq 0x50c0
movq %rax, %r12
movq %rax, %rdi
callq 0xea88
movl $0x20, %edi
callq 0x50c0
movq %rax, %r13
movl $0xc, %ebx
movq %rax, %rdi
callq 0xec60
jmp 0x83c4
movl $0x48, %edi
callq 0x50c0
movq %rax, %r15
movq %rax, %rdi
callq 0xd16c
movq 0x8(%rsp), %rbp
movl $0x38, %edi
callq 0x50c0
movq %rax, %r12
movq %rax, %rdi
callq 0xdbb8
movl $0x20, %edi
callq 0x50c0
movq %rax, %r13
movq %rax, %rdi
callq 0x7450
leaq 0x183e8(%rip), %rax     # 0x20690
addq $0x10, %rax
movq %rax, (%r13)
movl $0x1400c, %ebx          # imm = 0x1400C
jmp 0x83c4
cmpl $0x6, %ebp
jne 0x831c
movl $0x30, %edi
callq 0x50c0
movq %rax, %r15
movq %rax, %rdi
callq 0x100ec
movl $0x4e0, %edi            # imm = 0x4E0
callq 0x50c0
movq %rax, %r12
movq %rax, %rdi
callq 0x10cd4
movq 0x8(%rsp), %rbp
movl $0x20, %edi
callq 0x50c0
movq %rax, %r13
movq %rax, %rdi
callq 0x7450
leaq 0x187fe(%rip), %rax     # 0x20b08
addq $0x10, %rax
movq %rax, (%r13)
movl $0xb, %ebx
jmp 0x83c4
cmpl $0x4, %ebp
jne 0x836c
movl $0x48, %edi
callq 0x50c0
movq %rax, %r15
movq %rax, %rdi
callq 0x8608
movq 0x8(%rsp), %rbp
movl $0x38, %edi
callq 0x50c0
movq %rax, %r12
movq %rax, %rdi
callq 0x8c60
movl $0x20, %edi
callq 0x50c0
movq %rax, %r13
movl $0xc, %ebx
movq %rax, %rdi
callq 0x8e38
jmp 0x83c4
movl $0x30, %edi
callq 0x50c0
movq %rax, %r15
movq %rax, %rdi
callq 0x13858
movq 0x8(%rsp), %rbp
movl $0x4e0, %edi            # imm = 0x4E0
callq 0x50c0
movq %rax, %r12
movq %rax, %rdi
callq 0x14434
movl $0x20, %edi
callq 0x50c0
movq %rax, %r13
movq %rax, %rdi
callq 0x7450
leaq 0x18989(%rip), %rax     # 0x20d40
addq $0x10, %rax
movq %rax, (%r13)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testb $0x1, 0x20(%rsp)
je 0x840f
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %rdx
movups %xmm0, 0x2c(%rdx)
movaps %xmm0, 0x20(%rdx)
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, (%rdx)
movq (%r15), %rax
movq %r15, %rdi
movq %rbp, %rsi
movl $0x3c, %ecx
callq *0x58(%rax)
testl %eax, %eax
je 0x843f
leaq 0xe485(%rip), %rdi      # 0x16883
movq %rbp, %rsi
xorl %eax, %eax
callq 0x5040
movl $0x1, %ebx
jmp 0x8473
movq (%r15), %rax
movq %r15, %rdi
movq %rbp, %rsi
callq *0x10(%rax)
testl %eax, %eax
je 0x844d
cmpb $0x1, 0x18e6b(%rip)     # 0x21291
je 0x84ea
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x79c4
leaq 0x40(%rsp), %rdi
callq 0x51b0
xorl %ebx, %ebx
jmp 0x8473
testb $0x1, 0x18(%rsp)
je 0x8481
movq (%r15), %rax
movq %r15, %rdi
callq *0x80(%rax)
movzbl %al, %esi
leaq 0xe46b(%rip), %rdi      # 0x168d5
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x5040
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
jmp 0x79c4
movq (%r12), %rax
movq %r12, %rdi
movq %r14, %rsi
callq *(%rax)
testl %eax, %eax
je 0x84c3
cmpb $0x1, 0x18df9(%rip)     # 0x21291
jne 0x84d7
movq 0x18b37(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
leaq 0xe438(%rip), %rsi      # 0x168e3
leaq 0xdfa5(%rip), %rdx      # 0x16457
movl $0x1af, %ecx            # imm = 0x1AF
movq %r14, %r8
xorl %eax, %eax
callq 0x5180
jmp 0x84d7
movq (%r13), %rax
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *0x10(%rax)
testl %eax, %eax
je 0x8516
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
jmp 0x79c4
movq 0x18ae7(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
leaq 0xe3b2(%rip), %rsi      # 0x168ad
leaq 0xdf55(%rip), %rdx      # 0x16457
movl $0x1a2, %ecx            # imm = 0x1A2
movq %rbp, %r8
xorl %eax, %eax
callq 0x5180
jmp 0x842c
movl $0x8, %edi
callq 0x50c0
movq 0x28(%rsp), %rcx
movb %cl, (%rax)
movl %ebx, 0x4(%rax)
movq (%r13), %rcx
movq %r13, %rdi
movq %rax, %rsi
callq *0x18(%rcx)
testl %eax, %eax
je 0x8557
cmpb $0x1, 0x18d4f(%rip)     # 0x21291
je 0x8579
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
movl $0xfffffffc, %ebx       # imm = 0xFFFFFFFC
jmp 0x79c4
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
movq (%r12), %rax
movq %r12, %rdi
callq *0x50(%rax)
movq (%r13), %rax
movq %r13, %rdi
callq *0x8(%rax)
jmp 0x8127
movq 0x18a58(%rip), %rcx     # 0x20fd8
movq (%rcx), %rdi
leaq 0xe388(%rip), %rsi      # 0x16912
leaq 0xdec6(%rip), %rdx      # 0x16457
movl $0x1c2, %ecx            # imm = 0x1C2
movl %eax, %r8d
xorl %eax, %eax
callq 0x5180
jmp 0x8544
jmp 0x85d6
jmp 0x85b0
jmp 0x85ba
jmp 0x85d6
jmp 0x85e3
jmp 0x85f0
jmp 0x85d6
movq %rax, %rbx
movl $0x4e0, %esi            # imm = 0x4E0
jmp 0x85eb
movq %rax, %rbx
movl $0x30, %esi
jmp 0x85f8
jmp 0x85d6
jmp 0x85e3
jmp 0x85f0
jmp 0x85d6
jmp 0x85e3
jmp 0x85f0
jmp 0x85d6
jmp 0x85e3
jmp 0x85f0
movq %rax, %rbx
movl $0x20, %esi
movq %r13, %rdi
jmp 0x85fb
movq %rax, %rbx
movl $0x38, %esi
movq %r12, %rdi
jmp 0x85fb
movq %rax, %rbx
movl $0x48, %esi
movq %r15, %rdi
callq 0x50e0
movq %rbx, %rdi
callq 0x51f0