// File: goodix[P]gdix_hid_firmware_update/gt7868q/gt7868q_update.cpp
// Function: GT7868QUpdate::cfg_update()
int GT7868QUpdate::cfg_update()
{
	int retry;
	int ret = -1, i;
	unsigned char temp_buf[65];
	unsigned char *fw_data = NULL;
	unsigned char cfg_ver_after[3];
	unsigned char cfg_ver_before[3];
	unsigned char tmp_cmd_buf[5];
	unsigned char cfg_ver_infile;
	bool findMatchCfg = false;
	unsigned char *cfg = NULL;

	int sub_cfg_num = image->GetConfigSubCfgNum();
	unsigned char sub_cfg_id;
	unsigned int sub_cfg_len;
	unsigned char buf_dis_report_coor[] = {0x33, 0x00, 0x00, 0x00, 0x33};
	unsigned char buf_en_report_coor[] = {0x34, 0x00, 0x00, 0x00, 0x34};
	unsigned int sub_cfg_info_pos = image->GetConfigSubCfgInfoOffset();
	unsigned int cfg_offset = image->GetConfigSubCfgDataOffset();

	if (sub_cfg_num == 0)
		return -5;
	/*dis report coor*/
	gdix_info("disable report coor in cfg update\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);

	// before update config,read curr config version
	dev->Read(CFG_START_ADDR, cfg_ver_before, 3);
	gdix_dbg("Before update,cfg version is 0x%02x 0x%02x 0x%02x\n",
			 cfg_ver_before[0], cfg_ver_before[1], cfg_ver_before[2]);

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

	// fw_data[FW_IMAGE_SUB_FWNUM_OFFSET];
	gdix_dbg("load sub config, sub_cfg_num=%d\n", sub_cfg_num);
	for (i = 0; i < sub_cfg_num; i++) {
		sub_cfg_id = fw_data[sub_cfg_info_pos];
		gdix_dbg("load sub config, sub_cfg_id=0x%x\n", sub_cfg_id);

		sub_cfg_len = (fw_data[sub_cfg_info_pos + 1] << 8) |
					  fw_data[sub_cfg_info_pos + 2];

		if (dev->GetSensorID() == sub_cfg_id) {
			findMatchCfg = true;
			cfg = &fw_data[cfg_offset];
			cfg_ver_infile = cfg[0];
			gdix_info("Find a cfg match sensorID:ID=%d,cfg version=%d\n",
					  dev->GetSensorID(), cfg_ver_infile);
			break;
		}
		cfg_offset += sub_cfg_len;
		sub_cfg_info_pos += 3;
	}

	if (findMatchCfg) {
		// wait untill ic is free
		retry = 10;
		do {
			ret = dev->Read(CMD_ADDR, temp_buf, 1);
			if (ret < 0) {
				gdix_err("Failed read cfg cmd, ret = %d\n", ret);
				goto update_err;
			}
			if (temp_buf[0] == 0xff)
				break;
			gdix_info("0x%x value is 0x%x != 0xff, retry\n", CMD_ADDR,
					  temp_buf[0]);
			usleep(10000);
		} while (--retry);
		if (!retry) {
			gdix_err("Reg 0x%x != 0xff\n", CMD_ADDR);
			ret = -2;
			goto update_err;
		}

		// tell ic i want to send cfg
		cmd_init(temp_buf, 0x80, 0x0);
		ret = dev->Write(CMD_ADDR, temp_buf, 5);
		if (ret < 0) {
			gdix_err("Failed write send cfg cmd\n");
			goto update_err;
		}

		// wait ic to comfirm
		usleep(250000);
		retry = GDIX_RETRY_TIMES;
		do {
			ret = dev->Read(CMD_ADDR, temp_buf, 1);
			gdix_dbg("Wait CMD_ADDR == 0x82...\n");
			if (ret < 0) {
				gdix_err("Failed read 0x%x, ret = %d\n", CMD_ADDR, ret);
			}
			if (temp_buf[0] == 0x82)
				break;
			gdix_info("0x%x value is 0x%x != 0x82, retry\n", CMD_ADDR,
					  temp_buf[0]);
			usleep(30000);
		} while (--retry);

		if (!retry) {
			gdix_err("Reg 0x%x != 0x82\n", CMD_ADDR);
			ret = -2;
			goto update_err;
		}
		gdix_dbg("Wait CMD_ADDR == 0x82 success.\n");

		/* Start load config */
		ret = dev->Write(CFG_START_ADDR, &fw_data[cfg_offset], sub_cfg_len);
		if (ret < 0) {
			gdix_err("Failed write cfg to xdata, ret=%d\n", ret);
			goto update_err;
		}
		usleep(100000);

		// tell ic cfg is ready in xdata
		cmd_init(temp_buf, 0x83, 0);
		ret = dev->Write(CMD_ADDR, temp_buf, 5);
		if (ret < 0) {
			gdix_err("Failed write send cfg finish cmd\n");
			goto update_err;
		}

		// check if ic is ok with the cfg
		usleep(80000);
		retry = GDIX_RETRY_TIMES;
		do {
			ret = dev->Read(CMD_ADDR, temp_buf, 5);
			gdix_dbg("Wait CMD_ADDR == 0x7F...\n");
			if (ret < 0) {
				gdix_err("Failed read 0x%x, ret = %d\n", CMD_ADDR, ret);
			} else if (temp_buf[0] == 0x7f ||
					   (temp_buf[0] == 0x7e && temp_buf[1] == 0x00 &&
						temp_buf[2] == 0x07)) {
				break;
			}
			gdix_info("0x%x value is 0x%x, retry\n", CMD_ADDR, temp_buf[0]);
			usleep(30000);
		} while (--retry);
		gdix_info("check 0x%x value is: 0x%x,0x%x,0x%x,0x%x,0x%x.\n", CMD_ADDR,
				  temp_buf[0], temp_buf[1], temp_buf[2], temp_buf[3],
				  temp_buf[4]);

		/*set 0x7D to end send cfg */
		cmd_init(tmp_cmd_buf, 0x7D, 0);
		ret = dev->Write(CMD_ADDR, tmp_cmd_buf, 5);
		if (ret < 0) {
			gdix_err("Failed write send cfg end cmd\n");
			goto update_err;
		}

		if (!retry) {
			gdix_err("read 0x%x for config send end error\n", CMD_ADDR);
			ret = -2;
			goto update_err;
		}
		if (temp_buf[0] == 0x7e) {
			if (temp_buf[1] == 0x00 && temp_buf[2] == 0x07) {
				gdix_info("config data is equal with falsh\n");
			} else {
				gdix_err("failed send cfg\n");
				ret = -3;
				goto update_err;
			}
		} else if (temp_buf[0] != 0x7f) {
			gdix_err("failed send cfg\n");
			ret = -5;
			goto update_err;
		}

		gdix_info("send config data success!\n");
		// after update config,read curr config version
		dev->Read(CFG_START_ADDR, cfg_ver_after, 3);
		gdix_dbg("After update,cfg version is 0x%02x 0x%02x 0x%02x\n",
				 cfg_ver_after[0], cfg_ver_after[1], cfg_ver_after[2]);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0xd8, %rsp
movq %rdi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xb8(%rbp)
movl $0xffffffff, -0x20(%rbp) # imm = 0xFFFFFFFF
movq $0x0, -0x78(%rbp)
movb $0x0, -0x85(%rbp)
movq $0x0, -0x90(%rbp)
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *0x78(%rax)
movl %eax, %ecx
movq -0xb8(%rbp), %rax
movl %ecx, -0x94(%rbp)
movl 0x13d37(%rip), %ecx     # 0x1db62
movl %ecx, -0xa1(%rbp)
movb 0x13d2f(%rip), %cl      # 0x1db66
movb %cl, -0x9d(%rbp)
movl 0x13d24(%rip), %ecx     # 0x1db67
movl %ecx, -0xa6(%rbp)
movb 0x13d1c(%rip), %cl      # 0x1db6b
movb %cl, -0xa2(%rbp)
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *0x80(%rax)
movl %eax, %ecx
movq -0xb8(%rbp), %rax
movl %ecx, -0xac(%rbp)
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *0x88(%rax)
movl %eax, -0xb0(%rbp)
cmpl $0x0, -0x94(%rbp)
jne 0x9e99
movl $0xfffffffb, -0xc(%rbp) # imm = 0xFFFFFFFB
jmp 0xaa4e
jmp 0x9e9b
leaq 0x1c3f7(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x9ecb
movq 0x1c10a(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
leaq 0x137fd(%rip), %rsi     # 0x1d6b5
leaq 0x1382a(%rip), %rdx     # 0x1d6e9
movl $0x1a1, %ecx            # imm = 0x1A1
movb $0x0, %al
callq 0x5190
jmp 0x9ecd
movl $0x3, -0x1c(%rbp)
movq -0xb8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0xa1(%rbp), %rdx
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movl $0x5, %ecx
callq *0x30(%rax)
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x9f35
jmp 0x9f01
leaq 0x1c391(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x9f31
movq 0x1c0c4(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0x12dd5(%rip), %rsi     # 0x1ccf3
leaq 0x137c4(%rip), %rdx     # 0x1d6e9
movl $0x1a7, %ecx            # imm = 0x1A7
movb $0x0, %al
callq 0x5190
jmp 0x9f33
jmp 0x9f35
jmp 0x9f37
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, %eax
jne 0x9ed4
movq -0xb8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x7e(%rbp), %rdx
movq (%rdi), %rax
movl $0x96f8, %esi           # imm = 0x96F8
movl $0x3, %ecx
callq *0x20(%rax)
leaq 0x1c32e(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x9fa5
movq 0x1c041(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
movzbl -0x7e(%rbp), %r8d
movzbl -0x7d(%rbp), %r9d
movzbl -0x7c(%rbp), %eax
leaq 0x13765(%rip), %rsi     # 0x1d6f4
leaq 0x13753(%rip), %rdx     # 0x1d6e9
movl $0x1ae, %ecx            # imm = 0x1AE
movl %eax, (%rsp)
movb $0x0, %al
callq 0x5190
jmp 0x9fa7
movq -0xb8(%rbp), %rax
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *0x38(%rax)
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
jne 0xa003
jmp 0x9fc5
leaq 0x1c2cd(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x9ff5
movq 0x1c000(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0x13333(%rip), %rsi     # 0x1d315
leaq 0x13700(%rip), %rdx     # 0x1d6e9
movl $0x1b3, %ecx            # imm = 0x1B3
movb $0x0, %al
callq 0x5190
jmp 0x9ff7
movl $0xfffffffc, -0x20(%rbp) # imm = 0xFFFFFFFC
jmp 0xa9b7
jmp 0xa005
leaq 0x1c28d(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa03c
movq 0x1bfa0(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
movl -0x94(%rbp), %r8d
leaq 0x1353c(%rip), %rsi     # 0x1d565
leaq 0x136b9(%rip), %rdx     # 0x1d6e9
movl $0x1b9, %ecx            # imm = 0x1B9
movb $0x0, %al
callq 0x5190
jmp 0xa03e
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x94(%rbp), %eax
jge 0xa1b3
movq -0x78(%rbp), %rax
movl -0xac(%rbp), %ecx
movb (%rax,%rcx), %al
movb %al, -0x95(%rbp)
leaq 0x1c22b(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa09f
movq 0x1bf3e(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
movzbl -0x95(%rbp), %r8d
leaq 0x1350b(%rip), %rsi     # 0x1d597
leaq 0x13656(%rip), %rdx     # 0x1d6e9
movl $0x1bc, %ecx            # imm = 0x1BC
movb $0x0, %al
callq 0x5190
jmp 0xa0a1
movq -0xb8(%rbp), %rax
movq -0x78(%rbp), %rcx
movl -0xac(%rbp), %edx
addl $0x1, %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
shll $0x8, %ecx
movq -0x78(%rbp), %rdx
movl -0xac(%rbp), %esi
addl $0x2, %esi
movl %esi, %esi
movzbl (%rdx,%rsi), %edx
orl %edx, %ecx
movl %ecx, -0x9c(%rbp)
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x80(%rax)
movzbl %al, %eax
movzbl -0x95(%rbp), %ecx
cmpl %ecx, %eax
jne 0xa184
movb $0x1, -0x85(%rbp)
movq -0x78(%rbp), %rax
movl -0xb0(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movb (%rax), %al
movb %al, -0x84(%rbp)
leaq 0x1c170(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa180
movq -0xb8(%rbp), %rax
movq 0x1be7c(%rip), %rcx     # 0x25fb8
movq (%rcx), %rcx
movq %rcx, -0xc0(%rbp)
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x80(%rax)
movq -0xc0(%rbp), %rdi
movzbl %al, %r8d
movzbl -0x84(%rbp), %r9d
leaq 0x135cb(%rip), %rsi     # 0x1d738
leaq 0x13575(%rip), %rdx     # 0x1d6e9
movl $0x1c6, %ecx            # imm = 0x1C6
movb $0x0, %al
callq 0x5190
jmp 0xa182
jmp 0xa1b3
movl -0x9c(%rbp), %eax
addl -0xb0(%rbp), %eax
movl %eax, -0xb0(%rbp)
movl -0xac(%rbp), %eax
addl $0x3, %eax
movl %eax, -0xac(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xa045
testb $0x1, -0x85(%rbp)
je 0xa9b5
movl $0xa, -0x1c(%rbp)
movq -0xb8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x70(%rbp), %rdx
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movl $0x1, %ecx
callq *0x20(%rax)
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0xa22c
jmp 0xa1f1
leaq 0x1c0a1(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa225
movq 0x1bdd4(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
movl -0x20(%rbp), %r8d
leaq 0x13567(%rip), %rsi     # 0x1d779
leaq 0x134d0(%rip), %rdx     # 0x1d6e9
movl $0x1d3, %ecx            # imm = 0x1D3
movb $0x0, %al
callq 0x5190
jmp 0xa227
jmp 0xa9b7
movzbl -0x70(%rbp), %eax
cmpl $0xff, %eax
jne 0xa239
jmp 0xa294
jmp 0xa23b
leaq 0x1c057(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa276
movq 0x1bd6a(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
movzbl -0x70(%rbp), %r9d
leaq 0x1354c(%rip), %rsi     # 0x1d7a9
leaq 0x13485(%rip), %rdx     # 0x1d6e9
movl $0x1d9, %ecx            # imm = 0x1D9
movl $0x4160, %r8d           # imm = 0x4160
movb $0x0, %al
callq 0x5190
jmp 0xa278
movl $0x2710, %edi           # imm = 0x2710
callq 0x5180
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, %eax
jne 0xa1c7
cmpl $0x0, -0x1c(%rbp)
jne 0xa2e0
jmp 0xa29c
leaq 0x1bff6(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa2d2
movq 0x1bd29(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0x13524(%rip), %rsi     # 0x1d7dd
leaq 0x13429(%rip), %rdx     # 0x1d6e9
movl $0x1dd, %ecx            # imm = 0x1DD
movl $0x4160, %r8d           # imm = 0x4160
movb $0x0, %al
callq 0x5190
jmp 0xa2d4
movl $0xfffffffe, -0x20(%rbp) # imm = 0xFFFFFFFE
jmp 0xa9b7
movq -0xb8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
movl $0x80, %edx
xorl %ecx, %ecx
callq 0x9d40
movq -0xb8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x70(%rbp), %rdx
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movl $0x5, %ecx
callq *0x30(%rax)
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0xa358
jmp 0xa321
leaq 0x1bf71(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa351
movq 0x1bca4(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0x134c2(%rip), %rsi     # 0x1d800
leaq 0x133a4(%rip), %rdx     # 0x1d6e9
movl $0x1e6, %ecx            # imm = 0x1E6
movb $0x0, %al
callq 0x5190
jmp 0xa353
jmp 0xa9b7
movl $0x3d090, %edi          # imm = 0x3D090
callq 0x5180
movl $0x6, -0x1c(%rbp)
movq -0xb8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x70(%rbp), %rdx
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movl $0x1, %ecx
callq *0x20(%rax)
movl %eax, -0x20(%rbp)
leaq 0x1bf07(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa3bb
movq 0x1bc1a(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
leaq 0x13484(%rip), %rsi     # 0x1d82c
leaq 0x1333a(%rip), %rdx     # 0x1d6e9
movl $0x1ef, %ecx            # imm = 0x1EF
movb $0x0, %al
callq 0x5190
jmp 0xa3bd
cmpl $0x0, -0x20(%rbp)
jge 0xa403
jmp 0xa3c5
leaq 0x1becd(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa3ff
movq 0x1bc00(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
movl -0x20(%rbp), %r9d
leaq 0x12e7d(%rip), %rsi     # 0x1d263
leaq 0x132fc(%rip), %rdx     # 0x1d6e9
movl $0x1f1, %ecx            # imm = 0x1F1
movl $0x4160, %r8d           # imm = 0x4160
movb $0x0, %al
callq 0x5190
jmp 0xa401
jmp 0xa403
movzbl -0x70(%rbp), %eax
cmpl $0x82, %eax
jne 0xa410
jmp 0xa46b
jmp 0xa412
leaq 0x1be80(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa44d
movq 0x1bb93(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
movzbl -0x70(%rbp), %r9d
leaq 0x13423(%rip), %rsi     # 0x1d857
leaq 0x132ae(%rip), %rdx     # 0x1d6e9
movl $0x1f6, %ecx            # imm = 0x1F6
movl $0x4160, %r8d           # imm = 0x4160
movb $0x0, %al
callq 0x5190
jmp 0xa44f
movl $0x7530, %edi           # imm = 0x7530
callq 0x5180
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, %eax
jne 0xa369
cmpl $0x0, -0x1c(%rbp)
jne 0xa4b7
jmp 0xa473
leaq 0x1be1f(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa4a9
movq 0x1bb52(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0x133fb(%rip), %rsi     # 0x1d88b
leaq 0x13252(%rip), %rdx     # 0x1d6e9
movl $0x1fb, %ecx            # imm = 0x1FB
movl $0x4160, %r8d           # imm = 0x4160
movb $0x0, %al
callq 0x5190
jmp 0xa4ab
movl $0xfffffffe, -0x20(%rbp) # imm = 0xFFFFFFFE
jmp 0xa9b7
jmp 0xa4b9
leaq 0x1bdd9(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa4e9
movq 0x1baec(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
leaq 0x133d8(%rip), %rsi     # 0x1d8ae
leaq 0x1320c(%rip), %rdx     # 0x1d6e9
movl $0x1ff, %ecx            # imm = 0x1FF
movb $0x0, %al
callq 0x5190
jmp 0xa4eb
movq -0xb8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x78(%rbp), %rdx
movl -0xb0(%rbp), %eax
addq %rax, %rdx
movl -0x9c(%rbp), %ecx
movq (%rdi), %rax
movl $0x96f8, %esi           # imm = 0x96F8
callq *0x30(%rax)
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0xa55a
jmp 0xa51f
leaq 0x1bd73(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa553
movq 0x1baa6(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
movl -0x20(%rbp), %r8d
leaq 0x1339f(%rip), %rsi     # 0x1d8df
leaq 0x131a2(%rip), %rdx     # 0x1d6e9
movl $0x204, %ecx            # imm = 0x204
movb $0x0, %al
callq 0x5190
jmp 0xa555
jmp 0xa9b7
movl $0x186a0, %edi          # imm = 0x186A0
callq 0x5180
movq -0xb8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
movl $0x83, %edx
xorl %ecx, %ecx
callq 0x9d40
movq -0xb8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x70(%rbp), %rdx
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movl $0x5, %ecx
callq *0x30(%rax)
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0xa5dc
jmp 0xa5a5
leaq 0x1bced(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa5d5
movq 0x1ba20(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0x13351(%rip), %rsi     # 0x1d913
leaq 0x13120(%rip), %rdx     # 0x1d6e9
movl $0x20d, %ecx            # imm = 0x20D
movb $0x0, %al
callq 0x5190
jmp 0xa5d7
jmp 0xa9b7
movl $0x13880, %edi          # imm = 0x13880
callq 0x5180
movl $0x6, -0x1c(%rbp)
movq -0xb8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x70(%rbp), %rdx
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movl $0x5, %ecx
callq *0x20(%rax)
movl %eax, -0x20(%rbp)
leaq 0x1bc83(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa63f
movq 0x1b996(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
leaq 0x1331a(%rip), %rsi     # 0x1d946
leaq 0x130b6(%rip), %rdx     # 0x1d6e9
movl $0x216, %ecx            # imm = 0x216
movb $0x0, %al
callq 0x5190
jmp 0xa641
cmpl $0x0, -0x20(%rbp)
jge 0xa687
jmp 0xa649
leaq 0x1bc49(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa683
movq 0x1b97c(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
movl -0x20(%rbp), %r9d
leaq 0x12bf9(%rip), %rsi     # 0x1d263
leaq 0x13078(%rip), %rdx     # 0x1d6e9
movl $0x218, %ecx            # imm = 0x218
movl $0x4160, %r8d           # imm = 0x4160
movb $0x0, %al
callq 0x5190
jmp 0xa685
jmp 0xa6af
movzbl -0x70(%rbp), %eax
cmpl $0x7f, %eax
je 0xa6ab
movzbl -0x70(%rbp), %eax
cmpl $0x7e, %eax
jne 0xa6ad
movzbl -0x6f(%rbp), %eax
cmpl $0x0, %eax
jne 0xa6ad
movzbl -0x6e(%rbp), %eax
cmpl $0x7, %eax
jne 0xa6ad
jmp 0xa70a
jmp 0xa6af
jmp 0xa6b1
leaq 0x1bbe1(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa6ec
movq 0x1b8f4(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
movzbl -0x70(%rbp), %r9d
leaq 0x1329e(%rip), %rsi     # 0x1d971
leaq 0x1300f(%rip), %rdx     # 0x1d6e9
movl $0x21e, %ecx            # imm = 0x21E
movl $0x4160, %r8d           # imm = 0x4160
movb $0x0, %al
callq 0x5190
jmp 0xa6ee
movl $0x7530, %edi           # imm = 0x7530
callq 0x5180
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, %eax
jne 0xa5ed
jmp 0xa70c
leaq 0x1bb86(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa76a
movq 0x1b899(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
movzbl -0x70(%rbp), %r9d
movzbl -0x6f(%rbp), %ebx
movzbl -0x6e(%rbp), %r11d
movzbl -0x6d(%rbp), %r10d
movzbl -0x6c(%rbp), %eax
leaq 0x1325d(%rip), %rsi     # 0x1d99d
leaq 0x12fa2(%rip), %rdx     # 0x1d6e9
movl $0x223, %ecx            # imm = 0x223
movl $0x4160, %r8d           # imm = 0x4160
movl %ebx, (%rsp)
movl %r11d, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movb $0x0, %al
callq 0x5190
jmp 0xa76c
movq -0xb8(%rbp), %rdi
leaq -0x83(%rbp), %rsi
movl $0x7d, %edx
xorl %ecx, %ecx
callq 0x9d40
movq -0xb8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x83(%rbp), %rdx
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movl $0x5, %ecx
callq *0x30(%rax)
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0xa7ea
jmp 0xa7b3
leaq 0x1badf(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa7e3
movq 0x1b812(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0x1320e(%rip), %rsi     # 0x1d9de
leaq 0x12f12(%rip), %rdx     # 0x1d6e9
movl $0x229, %ecx            # imm = 0x229
movb $0x0, %al
callq 0x5190
jmp 0xa7e5
jmp 0xa9b7
cmpl $0x0, -0x1c(%rbp)
jne 0xa836
jmp 0xa7f2
leaq 0x1baa0(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa828
movq 0x1b7d3(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0x131ff(%rip), %rsi     # 0x1da0e
leaq 0x12ed3(%rip), %rdx     # 0x1d6e9
movl $0x22e, %ecx            # imm = 0x22E
movl $0x4160, %r8d           # imm = 0x4160
movb $0x0, %al
callq 0x5190
jmp 0xa82a
movl $0xfffffffe, -0x20(%rbp) # imm = 0xFFFFFFFE
jmp 0xa9b7
movzbl -0x70(%rbp), %eax
cmpl $0x7e, %eax
jne 0xa8cd
movzbl -0x6f(%rbp), %eax
cmpl $0x0, %eax
jne 0xa88b
movzbl -0x6e(%rbp), %eax
cmpl $0x7, %eax
jne 0xa88b
jmp 0xa857
leaq 0x1ba3b(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa887
movq 0x1b74e(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
leaq 0x131d0(%rip), %rsi     # 0x1da44
leaq 0x12e6e(%rip), %rdx     # 0x1d6e9
movl $0x234, %ecx            # imm = 0x234
movb $0x0, %al
callq 0x5190
jmp 0xa889
jmp 0xa8cb
jmp 0xa88d
leaq 0x1ba05(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa8bd
movq 0x1b738(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0x131cc(%rip), %rsi     # 0x1da76
leaq 0x12e38(%rip), %rdx     # 0x1d6e9
movl $0x236, %ecx            # imm = 0x236
movb $0x0, %al
callq 0x5190
jmp 0xa8bf
movl $0xfffffffd, -0x20(%rbp) # imm = 0xFFFFFFFD
jmp 0xa9b7
jmp 0xa918
movzbl -0x70(%rbp), %eax
cmpl $0x7f, %eax
je 0xa916
jmp 0xa8d8
leaq 0x1b9ba(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa908
movq 0x1b6ed(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0x13181(%rip), %rsi     # 0x1da76
leaq 0x12ded(%rip), %rdx     # 0x1d6e9
movl $0x23b, %ecx            # imm = 0x23B
movb $0x0, %al
callq 0x5190
jmp 0xa90a
movl $0xfffffffb, -0x20(%rbp) # imm = 0xFFFFFFFB
jmp 0xa9b7
jmp 0xa918
jmp 0xa91a
leaq 0x1b978(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa94a
movq 0x1b68b(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
leaq 0x13161(%rip), %rsi     # 0x1da98
leaq 0x12dab(%rip), %rdx     # 0x1d6e9
movl $0x240, %ecx            # imm = 0x240
movb $0x0, %al
callq 0x5190
jmp 0xa94c
movq -0xb8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x7b(%rbp), %rdx
movq (%rdi), %rax
movl $0x96f8, %esi           # imm = 0x96F8
movl $0x3, %ecx
callq *0x20(%rax)
leaq 0x1b927(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa9ac
movq 0x1b63a(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
movzbl -0x7b(%rbp), %r8d
movzbl -0x7a(%rbp), %r9d
movzbl -0x79(%rbp), %eax
leaq 0x1312e(%rip), %rsi     # 0x1dac4
leaq 0x12d4c(%rip), %rdx     # 0x1d6e9
movl $0x244, %ecx            # imm = 0x244
movl %eax, (%rsp)
movb $0x0, %al
callq 0x5190
jmp 0xa9ae
movl $0x0, -0x20(%rbp)
jmp 0xa9b7
jmp 0xa9b9
leaq 0x1b8d9(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xa9e9
movq 0x1b5ec(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
leaq 0x124f4(%rip), %rsi     # 0x1ceca
leaq 0x12d0c(%rip), %rdx     # 0x1d6e9
movl $0x24a, %ecx            # imm = 0x24A
movb $0x0, %al
callq 0x5190
jmp 0xa9eb
movq -0xb8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0xa6(%rbp), %rdx
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movl $0x5, %ecx
callq *0x30(%rax)
cmpl $0x0, %eax
jge 0xaa48
jmp 0xaa14
leaq 0x1b87e(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0xaa44
movq 0x1b5b1(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0x130d6(%rip), %rsi     # 0x1db07
leaq 0x12cb1(%rip), %rdx     # 0x1d6e9
movl $0x24d, %ecx            # imm = 0x24D
movb $0x0, %al
callq 0x5190
jmp 0xaa46
jmp 0xaa48
movl -0x20(%rbp), %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
addq $0xd8, %rsp
popq %rbx
popq %rbp
retq
nopl (%rax,%rax)