// File: goodix[P]gdix_hid_firmware_update/gt7868q/gt7868q_update.cpp
// Function: GT7868QUpdate::fw_update(unsigned int)
int GT7868QUpdate::fw_update(unsigned int firmware_flag)
{
	int retry;
	int ret, i;
	unsigned char temp_buf[65];
	unsigned char *fw_data = NULL;
	unsigned char buf_switch_to_patch[] = {0x00, 0x10, 0x00, 0x00, 0x01, 0x01};
	unsigned char buf_start_update[] = {0x00, 0x11, 0x00, 0x00, 0x01, 0x01};
	unsigned char buf_restart[] = {0x0E, 0x13, 0x00, 0x00, 0x01, 0x01};
	unsigned char buf_switch_ptp_mode[] = {0x32, 0x00, 0x00, 0x00, 0x32};
	unsigned char buf_dis_report_coor[] = {0x33, 0x00, 0x00, 0x00, 0x33};
	unsigned char buf_en_report_coor[] = {0x34, 0x00, 0x00, 0x00, 0x34};

	int sub_fw_num = 0;
	unsigned char sub_fw_type;
	unsigned int sub_fw_len;
	unsigned int sub_fw_flash_addr;
	unsigned int sub_fw_info_pos =
		image->GetFirmwareSubFwInfoOffset(); // SUB_FW_INFO_OFFSET;
	unsigned int fw_image_offset =
		image->GetFirmwareSubFwDataOffset(); // SUB_FW_DATA_OFFSET;

	ret = dev->Write(buf_switch_to_patch, sizeof(buf_switch_to_patch));
	if (ret < 0) {
		gdix_err("Failed switch to patch\n");
		goto update_err;
	}
	usleep(250000);

	/*dis report coor*/
	gdix_info("disable report coor\n");
	retry = 3;
	do {
		ret = dev->Write(CMD_ADDR, buf_dis_report_coor,
						 sizeof(buf_dis_report_coor));
		if (ret < 0) {
			gdix_err("Failed disable report coor\n");
		}
	} while (--retry);

	retry = GDIX_RETRY_TIMES;
	do {
		ret = dev->Read(BL_STATE_ADDR, temp_buf, 1);
		gdix_dbg("BL_STATE_ADDR:0x%x\n", BL_STATE_ADDR);
		if (ret < 0) {
			gdix_err("Failed read 0x%x, ret = %d\n", BL_STATE_ADDR, ret);
			goto update_err;
		}
		if (temp_buf[0] == 0xDD)
			break;
		gdix_info("0x%x value is 0x%x != 0xDD, retry\n", BL_STATE_ADDR,
				  temp_buf[0]);
		usleep(30000);
	} while (--retry);

	if (!retry) {
		gdix_err("Reg 0x%x != 0xDD\n", BL_STATE_ADDR);
		ret = -2;
		goto update_err;
	}

	/* Start update */
	ret = dev->Write(buf_start_update, sizeof(buf_start_update));
	if (ret < 0) {
		gdix_err("Failed start update, ret=%d\n", ret);
		goto update_err;
	}
	usleep(100000);

	/* Start load firmware */
	fw_data = image->GetFirmwareData();
	if (!fw_data) {
		gdix_err("No valid fw data \n");
		ret = -4;
		goto update_err;
	}

	sub_fw_num =
		image->GetFirmwareSubFwNum(); // fw_data[FW_IMAGE_SUB_FWNUM_OFFSET];
	sub_fw_info_pos =
		image->GetFirmwareSubFwInfoOffset(); // SUB_FW_INFO_OFFSET;
	fw_image_offset =
		image->GetFirmwareSubFwDataOffset(); // SUB_FW_DATA_OFFSET;
	gdix_dbg("load sub firmware, sub_fw_num=%d\n", sub_fw_num);
	if (sub_fw_num == 0) {
		ret = -5;
		goto update_err;
	}

	/* load normal firmware package */
	for (i = 0; i < sub_fw_num; i++) {
		sub_fw_type = fw_data[sub_fw_info_pos];
		gdix_dbg("load sub firmware, sub_fw_type=0x%x\n", sub_fw_type);
		sub_fw_len = (fw_data[sub_fw_info_pos + 1] << 24) |
					 (fw_data[sub_fw_info_pos + 2] << 16) |
					 (fw_data[sub_fw_info_pos + 3] << 8) |
					 fw_data[sub_fw_info_pos + 4];

		sub_fw_flash_addr =
			(fw_data[sub_fw_info_pos + 5] << 8) | fw_data[sub_fw_info_pos + 6];
		sub_fw_flash_addr = sub_fw_flash_addr << 8;
		if (!(firmware_flag & (0x01 << sub_fw_type))) {
			gdix_info("Sub firmware type does not math:type=%d\n", sub_fw_type);
			fw_image_offset += sub_fw_len;
			sub_fw_info_pos += 8;
			continue;
		}

		/* if sub fw type is HID subsystem we need compare version before update
		 */
		// TODO update hid subsystem
		gdix_dbg("load sub firmware addr:0x%x,len:0x%x\n", sub_fw_flash_addr,
				 sub_fw_len);
		ret = load_sub_firmware(sub_fw_flash_addr, &fw_data[fw_image_offset],
								sub_fw_len);
		if (ret < 0) {
			gdix_dbg("Failed load sub firmware, ret=%d\n", ret);
			goto update_err;
		}
		fw_image_offset += sub_fw_len;
		sub_fw_info_pos += 8;
	}

	/* flash config with isp if NEED_UPDATE_CONFIG_WITH_ISP flag is setted or
	 * hid subsystem updated.
	 */
	if (image->GetUpdateFlag() & NEED_UPDATE_CONFIG_WITH_ISP) {
		this->is_cfg_flashed_with_isp = true;
		ret = flash_cfg_with_isp();
		if (ret < 0) {
			gdix_err("failed flash config with isp, ret %d\n", ret);
			goto update_err;
		}
	}

	/*en report coor*/
	gdix_info("enable report coor\n");
	ret = dev->Write(CMD_ADDR, buf_en_report_coor, sizeof(buf_en_report_coor));
	if (ret < 0) {
		gdix_err("Failed enable report coor\n");
	}

	/* reset IC */
	gdix_dbg("reset ic\n");
	retry = 3;
	do {
		ret = dev->Write(buf_restart, sizeof(buf_restart));
		if (ret >= 0)
			break;
		usleep(20000);
	} while (--retry);
	if (retry == 0 && ret < 0)
		gdix_dbg("Failed write restart command, ret=%d\n", ret);
	else
		ret = 0;

	usleep(300000);

	if (dev->Write(CMD_ADDR, buf_switch_ptp_mode, sizeof(buf_switch_ptp_mode)) <
		0) {
		gdix_err("Failed switch to ptp mode\n");
	}
	return ret;

update_err:
	/*en report coor*/
	gdix_info("enable report coor\n");
	ret = dev->Write(CMD_ADDR, buf_en_report_coor, sizeof(buf_en_report_coor));
	if (ret < 0) {
		gdix_err("Failed enable report coor\n");
	}

	/* reset IC */
	gdix_dbg("reset ic\n");
	retry = 3;
	do {
		if (dev->Write(buf_restart, sizeof(buf_restart)) >= 0)
			break;
		usleep(20000);
	} while (--retry);
	if (retry == 0 && ret < 0)
		gdix_dbg("Failed write restart command, ret=%d\n", ret);

	usleep(300000);
	if (dev->Write(CMD_ADDR, buf_switch_ptp_mode, sizeof(buf_switch_ptp_mode)) <
		0) {
		gdix_err("Failed switch to ptp mode\n");
	}
	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq $0x0, -0x78(%rbp)
movl 0x14cd6(%rip), %ecx     # 0x1db41
movl %ecx, -0x7e(%rbp)
movw 0x14cd0(%rip), %cx      # 0x1db45
movw %cx, -0x7a(%rbp)
movl 0x14cc8(%rip), %ecx     # 0x1db47
movl %ecx, -0x84(%rbp)
movw 0x14cbf(%rip), %cx      # 0x1db4b
movw %cx, -0x80(%rbp)
movl 0x14cb7(%rip), %ecx     # 0x1db4d
movl %ecx, -0x8a(%rbp)
movw 0x14cae(%rip), %cx      # 0x1db51
movw %cx, -0x86(%rbp)
movl 0x14ca3(%rip), %ecx     # 0x1db53
movl %ecx, -0x8f(%rbp)
movb 0x14c9b(%rip), %cl      # 0x1db57
movb %cl, -0x8b(%rbp)
movl 0x14c90(%rip), %ecx     # 0x1db58
movl %ecx, -0x94(%rbp)
movb 0x14c88(%rip), %cl      # 0x1db5c
movb %cl, -0x90(%rbp)
movl 0x14c7d(%rip), %ecx     # 0x1db5d
movl %ecx, -0x99(%rbp)
movb 0x14c75(%rip), %cl      # 0x1db61
movb %cl, -0x95(%rbp)
movl $0x0, -0xa0(%rbp)
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *0x60(%rax)
movl %eax, %ecx
movq -0xc0(%rbp), %rax
movl %ecx, -0xb0(%rbp)
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *0x68(%rax)
movl %eax, %ecx
movq -0xc0(%rbp), %rax
movl %ecx, -0xb4(%rbp)
movq 0x8(%rax), %rdi
leaq -0x7e(%rbp), %rsi
movq (%rdi), %rax
movl $0x6, %edx
callq *0x38(%rax)
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jge 0x8f83
jmp 0x8f4c
leaq 0x1d346(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x8f7c
movq 0x1d079(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0x14286(%rip), %rsi     # 0x1d1ef
leaq 0x1628c(%rip), %rdx     # 0x1f1fc
movl $0x92, %ecx
movb $0x0, %al
callq 0x5190
jmp 0x8f7e
jmp 0x9796
movl $0x3d090, %edi          # imm = 0x3D090
callq 0x5180
leaq 0x1d305(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x8fbd
movq 0x1d018(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
leaq 0x1426e(%rip), %rsi     # 0x1d218
leaq 0x1624b(%rip), %rdx     # 0x1f1fc
movl $0x98, %ecx
movb $0x0, %al
callq 0x5190
jmp 0x8fbf
movl $0x3, -0x18(%rbp)
movq -0xc0(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x94(%rbp), %rdx
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movl $0x5, %ecx
callq *0x30(%rax)
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jge 0x9027
jmp 0x8ff3
leaq 0x1d29f(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x9023
movq 0x1cfd2(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0x13ce3(%rip), %rsi     # 0x1ccf3
leaq 0x161e5(%rip), %rdx     # 0x1f1fc
movl $0x9e, %ecx
movb $0x0, %al
callq 0x5190
jmp 0x9025
jmp 0x9027
jmp 0x9029
movl -0x18(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, %eax
jne 0x8fc6
movl $0x6, -0x18(%rbp)
movq -0xc0(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x70(%rbp), %rdx
movq (%rdi), %rax
movl $0x5095, %esi           # imm = 0x5095
movl $0x1, %ecx
callq *0x20(%rax)
movl %eax, -0x1c(%rbp)
leaq 0x1d232(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x9096
movq 0x1cf45(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
leaq 0x141c1(%rip), %rsi     # 0x1d23e
leaq 0x16178(%rip), %rdx     # 0x1f1fc
movl $0xa5, %ecx
movl $0x5095, %r8d           # imm = 0x5095
movb $0x0, %al
callq 0x5190
jmp 0x9098
cmpl $0x0, -0x1c(%rbp)
jge 0x90e1
jmp 0x90a0
leaq 0x1d1f2(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x90da
movq 0x1cf25(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
movl -0x1c(%rbp), %r9d
leaq 0x141a2(%rip), %rsi     # 0x1d263
leaq 0x16134(%rip), %rdx     # 0x1f1fc
movl $0xa7, %ecx
movl $0x5095, %r8d           # imm = 0x5095
movb $0x0, %al
callq 0x5190
jmp 0x90dc
jmp 0x9796
movzbl -0x70(%rbp), %eax
cmpl $0xdd, %eax
jne 0x90ee
jmp 0x9149
jmp 0x90f0
leaq 0x1d1a2(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x912b
movq 0x1ceb5(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
movzbl -0x70(%rbp), %r9d
leaq 0x1417e(%rip), %rsi     # 0x1d290
leaq 0x160e3(%rip), %rdx     # 0x1f1fc
movl $0xad, %ecx
movl $0x5095, %r8d           # imm = 0x5095
movb $0x0, %al
callq 0x5190
jmp 0x912d
movl $0x7530, %edi           # imm = 0x7530
callq 0x5180
movl -0x18(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, %eax
jne 0x903e
cmpl $0x0, -0x18(%rbp)
jne 0x9195
jmp 0x9151
leaq 0x1d141(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x9187
movq 0x1ce74(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0x14156(%rip), %rsi     # 0x1d2c4
leaq 0x16087(%rip), %rdx     # 0x1f1fc
movl $0xb2, %ecx
movl $0x5095, %r8d           # imm = 0x5095
movb $0x0, %al
callq 0x5190
jmp 0x9189
movl $0xfffffffe, -0x1c(%rbp) # imm = 0xFFFFFFFE
jmp 0x9796
movq -0xc0(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x84(%rbp), %rsi
movq (%rdi), %rax
movl $0x6, %edx
callq *0x38(%rax)
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jge 0x91f8
jmp 0x91bd
leaq 0x1d0d5(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x91f1
movq 0x1ce08(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
movl -0x1c(%rbp), %r8d
leaq 0x14109(%rip), %rsi     # 0x1d2e7
leaq 0x16017(%rip), %rdx     # 0x1f1fc
movl $0xba, %ecx
movb $0x0, %al
callq 0x5190
jmp 0x91f3
jmp 0x9796
movl $0x186a0, %edi          # imm = 0x186A0
callq 0x5180
movq -0xc0(%rbp), %rax
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *0x38(%rax)
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
jne 0x925e
jmp 0x9220
leaq 0x1d072(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x9250
movq 0x1cda5(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0x140d8(%rip), %rsi     # 0x1d315
leaq 0x15fb8(%rip), %rdx     # 0x1f1fc
movl $0xc2, %ecx
movb $0x0, %al
callq 0x5190
jmp 0x9252
movl $0xfffffffc, -0x1c(%rbp) # imm = 0xFFFFFFFC
jmp 0x9796
movq -0xc0(%rbp), %rax
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *0x58(%rax)
movl %eax, %ecx
movq -0xc0(%rbp), %rax
movl %ecx, -0xa0(%rbp)
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *0x60(%rax)
movl %eax, %ecx
movq -0xc0(%rbp), %rax
movl %ecx, -0xb0(%rbp)
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *0x68(%rax)
movl %eax, -0xb4(%rbp)
leaq 0x1cfeb(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x92de
movq 0x1ccfe(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
movl -0xa0(%rbp), %r8d
leaq 0x1406e(%rip), %rsi     # 0x1d339
leaq 0x15f2a(%rip), %rdx     # 0x1f1fc
movl $0xcd, %ecx
movb $0x0, %al
callq 0x5190
jmp 0x92e0
cmpl $0x0, -0xa0(%rbp)
jne 0x92f5
movl $0xfffffffb, -0x1c(%rbp) # imm = 0xFFFFFFFB
jmp 0x9796
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0xa0(%rbp), %eax
jge 0x9552
movq -0x78(%rbp), %rax
movl -0xb0(%rbp), %ecx
movb (%rax,%rcx), %al
movb %al, -0xa1(%rbp)
leaq 0x1cf74(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x9356
movq 0x1cc87(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
movzbl -0xa1(%rbp), %r8d
leaq 0x14029(%rip), %rsi     # 0x1d36c
leaq 0x15eb2(%rip), %rdx     # 0x1f1fc
movl $0xd6, %ecx
movb $0x0, %al
callq 0x5190
jmp 0x9358
movq -0x78(%rbp), %rax
movl -0xb0(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
shll $0x18, %eax
movq -0x78(%rbp), %rcx
movl -0xb0(%rbp), %edx
addl $0x2, %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x78(%rbp), %rcx
movl -0xb0(%rbp), %edx
addl $0x3, %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x78(%rbp), %rcx
movl -0xb0(%rbp), %edx
addl $0x4, %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
orl %ecx, %eax
movl %eax, -0xa8(%rbp)
movq -0x78(%rbp), %rax
movl -0xb0(%rbp), %ecx
addl $0x5, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
shll $0x8, %eax
movq -0x78(%rbp), %rcx
movl -0xb0(%rbp), %edx
addl $0x6, %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
orl %ecx, %eax
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %eax
shll $0x8, %eax
movl %eax, -0xac(%rbp)
movl -0x14(%rbp), %eax
movzbl -0xa1(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
jne 0x9475
jmp 0x9415
leaq 0x1ce7d(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x944d
movq 0x1cb90(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
movzbl -0xa1(%rbp), %r8d
leaq 0x13f68(%rip), %rsi     # 0x1d3a2
leaq 0x15dbb(%rip), %rdx     # 0x1f1fc
movl $0xe0, %ecx
movb $0x0, %al
callq 0x5190
jmp 0x944f
movl -0xa8(%rbp), %eax
addl -0xb4(%rbp), %eax
movl %eax, -0xb4(%rbp)
movl -0xb0(%rbp), %eax
addl $0x8, %eax
movl %eax, -0xb0(%rbp)
jmp 0x9544
jmp 0x9477
leaq 0x1ce1b(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x94b5
movq 0x1cb2e(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
movl -0xac(%rbp), %r8d
movl -0xa8(%rbp), %r9d
leaq 0x13f3a(%rip), %rsi     # 0x1d3dc
leaq 0x15d53(%rip), %rdx     # 0x1f1fc
movl $0xea, %ecx
movb $0x0, %al
callq 0x5190
jmp 0x94b7
movq -0xc0(%rbp), %rdi
movl -0xac(%rbp), %esi
movq -0x78(%rbp), %rdx
movl -0xb4(%rbp), %eax
addq %rax, %rdx
movl -0xa8(%rbp), %ecx
movq (%rdi), %rax
callq *0x28(%rax)
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jge 0x9523
jmp 0x94e8
leaq 0x1cdaa(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x951c
movq 0x1cabd(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
movl -0x1c(%rbp), %r8d
leaq 0x13f0a(%rip), %rsi     # 0x1d413
leaq 0x15cec(%rip), %rdx     # 0x1f1fc
movl $0xee, %ecx
movb $0x0, %al
callq 0x5190
jmp 0x951e
jmp 0x9796
movl -0xa8(%rbp), %eax
addl -0xb4(%rbp), %eax
movl %eax, -0xb4(%rbp)
movl -0xb0(%rbp), %eax
addl $0x8, %eax
movl %eax, -0xb0(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x92fc
movq -0xc0(%rbp), %rax
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *0xa8(%rax)
andl $0x10, %eax
cmpl $0x0, %eax
je 0x95c7
movq -0xc0(%rbp), %rdi
movb $0x1, 0x1a(%rdi)
movq (%rdi), %rax
callq *0x40(%rax)
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jge 0x95c5
jmp 0x958a
leaq 0x1cd08(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x95be
movq 0x1ca3b(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
movl -0x1c(%rbp), %r8d
leaq 0x13e9b(%rip), %rsi     # 0x1d446
leaq 0x15c4a(%rip), %rdx     # 0x1f1fc
movl $0xfc, %ecx
movb $0x0, %al
callq 0x5190
jmp 0x95c0
jmp 0x9796
jmp 0x95c7
jmp 0x95c9
leaq 0x1ccc9(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x95f9
movq 0x1c9dc(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
leaq 0x138e4(%rip), %rsi     # 0x1ceca
leaq 0x15c0f(%rip), %rdx     # 0x1f1fc
movl $0x102, %ecx            # imm = 0x102
movb $0x0, %al
callq 0x5190
jmp 0x95fb
movq -0xc0(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x99(%rbp), %rdx
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movl $0x5, %ecx
callq *0x30(%rax)
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jge 0x965c
jmp 0x9628
leaq 0x1cc6a(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x9658
movq 0x1c99d(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0x13e38(%rip), %rsi     # 0x1d47d
leaq 0x15bb0(%rip), %rdx     # 0x1f1fc
movl $0x105, %ecx            # imm = 0x105
movb $0x0, %al
callq 0x5190
jmp 0x965a
jmp 0x965c
jmp 0x965e
leaq 0x1cc34(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x968e
movq 0x1c947(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
leaq 0x13e2e(%rip), %rsi     # 0x1d4a9
leaq 0x15b7a(%rip), %rdx     # 0x1f1fc
movl $0x109, %ecx            # imm = 0x109
movb $0x0, %al
callq 0x5190
jmp 0x9690
movl $0x3, -0x18(%rbp)
movq -0xc0(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x8a(%rbp), %rsi
movq (%rdi), %rax
movl $0x6, %edx
callq *0x38(%rax)
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jl 0x96bf
jmp 0x96d7
movl $0x4e20, %edi           # imm = 0x4E20
callq 0x5180
movl -0x18(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, %eax
jne 0x9697
cmpl $0x0, -0x18(%rbp)
jne 0x971d
cmpl $0x0, -0x1c(%rbp)
jge 0x971d
jmp 0x96e5
leaq 0x1cbad(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x9719
movq 0x1c8c0(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
movl -0x1c(%rbp), %r8d
leaq 0x13dbe(%rip), %rsi     # 0x1d4c4
leaq 0x15aef(%rip), %rdx     # 0x1f1fc
movl $0x112, %ecx            # imm = 0x112
movb $0x0, %al
callq 0x5190
jmp 0x971b
jmp 0x9724
movl $0x0, -0x1c(%rbp)
movl $0x493e0, %edi          # imm = 0x493E0
callq 0x5180
movq -0xc0(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x8f(%rbp), %rdx
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movl $0x5, %ecx
callq *0x30(%rax)
cmpl $0x0, %eax
jge 0x978b
jmp 0x9757
leaq 0x1cb3b(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x9787
movq 0x1c86e(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0x13d87(%rip), %rsi     # 0x1d4fb
leaq 0x15a81(%rip), %rdx     # 0x1f1fc
movl $0x11a, %ecx            # imm = 0x11A
movb $0x0, %al
callq 0x5190
jmp 0x9789
jmp 0x978b
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x9955
jmp 0x9798
leaq 0x1cafa(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x97c8
movq 0x1c80d(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
leaq 0x13715(%rip), %rsi     # 0x1ceca
leaq 0x15a40(%rip), %rdx     # 0x1f1fc
movl $0x120, %ecx            # imm = 0x120
movb $0x0, %al
callq 0x5190
jmp 0x97ca
movq -0xc0(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x99(%rbp), %rdx
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movl $0x5, %ecx
callq *0x30(%rax)
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jge 0x982b
jmp 0x97f7
leaq 0x1ca9b(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x9827
movq 0x1c7ce(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0x13c69(%rip), %rsi     # 0x1d47d
leaq 0x159e1(%rip), %rdx     # 0x1f1fc
movl $0x123, %ecx            # imm = 0x123
movb $0x0, %al
callq 0x5190
jmp 0x9829
jmp 0x982b
jmp 0x982d
leaq 0x1ca65(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x985d
movq 0x1c778(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
leaq 0x13c5f(%rip), %rsi     # 0x1d4a9
leaq 0x159ab(%rip), %rdx     # 0x1f1fc
movl $0x127, %ecx            # imm = 0x127
movb $0x0, %al
callq 0x5190
jmp 0x985f
movl $0x3, -0x18(%rbp)
movq -0xc0(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x8a(%rbp), %rsi
movq (%rdi), %rax
movl $0x6, %edx
callq *0x38(%rax)
cmpl $0x0, %eax
jl 0x988a
jmp 0x98a2
movl $0x4e20, %edi           # imm = 0x4E20
callq 0x5180
movl -0x18(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, %eax
jne 0x9866
cmpl $0x0, -0x18(%rbp)
jne 0x98e8
cmpl $0x0, -0x1c(%rbp)
jge 0x98e8
jmp 0x98b0
leaq 0x1c9e2(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x98e4
movq 0x1c6f5(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
movl -0x1c(%rbp), %r8d
leaq 0x13bf3(%rip), %rsi     # 0x1d4c4
leaq 0x15924(%rip), %rdx     # 0x1f1fc
movl $0x12f, %ecx            # imm = 0x12F
movb $0x0, %al
callq 0x5190
jmp 0x98e6
jmp 0x98e8
movl $0x493e0, %edi          # imm = 0x493E0
callq 0x5180
movq -0xc0(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x8f(%rbp), %rdx
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movl $0x5, %ecx
callq *0x30(%rax)
cmpl $0x0, %eax
jge 0x994f
jmp 0x991b
leaq 0x1c977(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x994b
movq 0x1c6aa(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0x13bc3(%rip), %rsi     # 0x1d4fb
leaq 0x158bd(%rip), %rdx     # 0x1f1fc
movl $0x134, %ecx            # imm = 0x134
movb $0x0, %al
callq 0x5190
jmp 0x994d
jmp 0x994f
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)