// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
movq (%rdi), %rax
callq *0x78(%rax)
movl %eax, %r12d
movb $0x33, 0x2c(%rsp)
movl $0x33, 0x28(%rsp)
movb $0x34, 0x24(%rsp)
movl $0x34, 0x20(%rsp)
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
callq *0x80(%rax)
movl %eax, %r13d
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
callq *0x88(%rax)
testl %r12d, %r12d
je 0x8497
movl %eax, 0x18(%rsp)
movq %rbx, 0x8(%rsp)
leaq 0x17fbe(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0x82fc
movq 0x17cd9(%rip), %rax     # 0x1ffb8
movq (%rax), %rdi
leaq 0xe376(%rip), %rsi      # 0x1665f
leaq 0xe3a3(%rip), %rdx      # 0x16693
movl $0x1a1, %ecx            # imm = 0x1A1
xorl %eax, %eax
callq 0x5180
pushq $-0x3
popq %rbx
leaq 0x28(%rsp), %r14
pushq $0x5
popq %r15
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movq %r14, %rdx
movl %r15d, %ecx
callq *0x30(%rax)
movl %eax, %ebp
testl %eax, %eax
jns 0x8334
leaq 0x17f62(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
je 0x833a
incl %ebx
jne 0x8308
jmp 0x8360
movq 0x17c97(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0xd957(%rip), %rsi      # 0x15ca2
leaq 0xe341(%rip), %rdx      # 0x16693
movl $0x1a7, %ecx            # imm = 0x1A7
xorl %eax, %eax
callq 0x5180
jmp 0x8334
movq 0x8(%rsp), %rbx
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
leaq 0x12(%rsp), %rdx
pushq $0x3
popq %rcx
movl $0x96f8, %esi           # imm = 0x96F8
callq *0x20(%rax)
leaq 0x17f0e(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0x83c6
movq 0x17c29(%rip), %rax     # 0x1ffb8
movq (%rax), %rdi
movzbl 0x12(%rsp), %r8d
movzbl 0x13(%rsp), %r9d
movzbl 0x14(%rsp), %r10d
subq $0x8, %rsp
leaq 0xe2ef(%rip), %rsi      # 0x1669e
leaq 0xe2dd(%rip), %rdx      # 0x16693
movl $0x1ae, %ecx            # imm = 0x1AE
xorl %eax, %eax
pushq %r10
callq 0x5180
popq %rcx
popq %rdx
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
callq *0x38(%rax)
movq %rax, %r14
leaq 0x17eb7(%rip), %rax     # 0x20291
movb (%rax), %al
testq %r14, %r14
je 0x849f
testb %al, %al
je 0x8410
movq 0x17bc8(%rip), %rax     # 0x1ffb8
movq (%rax), %rdi
leaq 0xe115(%rip), %rsi      # 0x1650f
leaq 0xe292(%rip), %rdx      # 0x16693
movl $0x1b9, %ecx            # imm = 0x1B9
movl %r12d, %r8d
xorl %eax, %eax
callq 0x5180
xorl %eax, %eax
testl %r12d, %r12d
cmovlel %eax, %r12d
subl $0x1, %r12d
jb 0x8ab3
movl %r13d, %eax
movzbl (%r14,%rax), %ebx
leaq 0x17e5f(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0x845e
movq 0x17b7a(%rip), %rax     # 0x1ffb8
movq (%rax), %rdi
leaq 0xe0f9(%rip), %rsi      # 0x16541
leaq 0xe244(%rip), %rdx      # 0x16693
movl $0x1bc, %ecx            # imm = 0x1BC
movl %ebx, %r8d
xorl %eax, %eax
callq 0x5180
leal 0x1(%r13), %eax
movzbl (%r14,%rax), %eax
shll $0x8, %eax
leal 0x2(%r13), %ecx
movzbl (%r14,%rcx), %r15d
orl %eax, %r15d
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x80(%rax)
cmpb %bl, %al
je 0x84d3
addl %r15d, 0x18(%rsp)
addl $0x3, %r13d
jmp 0x8419
pushq $-0x5
popq %rbp
jmp 0x8b0f
pushq $-0x4
popq %rbp
testb %al, %al
je 0x8ab8
movq 0x17b27(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0xde04(%rip), %rsi      # 0x162bf
leaq 0xe1d1(%rip), %rdx      # 0x16693
movl $0x1b3, %ecx            # imm = 0x1B3
xorl %eax, %eax
callq 0x5180
jmp 0x8ab8
leaq 0x17db7(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
movl 0x18(%rsp), %r13d
jne 0x8529
movzbl (%r14,%r13), %ebx
movq 0x17ac8(%rip), %rax     # 0x1ffb8
movq (%rax), %r12
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x80(%rax)
movzbl %al, %r8d
leaq 0xe1d2(%rip), %rsi      # 0x166e2
leaq 0xe17c(%rip), %rdx      # 0x16693
movq %r12, %rdi
movl $0x1c6, %ecx            # imm = 0x1C6
movl %ebx, %r9d
xorl %eax, %eax
callq 0x5180
movq %r13, 0x18(%rsp)
pushq $-0xa
popq %r13
leaq 0x30(%rsp), %rbx
pushq $0x1
popq %r12
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movq %rbx, %rdx
movl %r12d, %ecx
callq *0x20(%rax)
testl %eax, %eax
js 0x85ea
movzbl 0x30(%rsp), %r9d
cmpl $0xff, %r9d
je 0x8621
leaq 0x17d1a(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0x85a6
movq 0x17a35(%rip), %rax     # 0x1ffb8
movq (%rax), %rdi
leaq 0xe1c6(%rip), %rsi      # 0x16753
leaq 0xe0ff(%rip), %rdx      # 0x16693
movl $0x1d9, %ecx            # imm = 0x1D9
movl $0x4160, %r8d           # imm = 0x4160
xorl %eax, %eax
callq 0x5180
movl $0x2710, %edi           # imm = 0x2710
callq 0x5170
incl %r13d
jne 0x853b
pushq $-0x2
popq %rbp
leaq 0x17cd2(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0x8ab3
movq 0x17a09(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0xe1ae(%rip), %rsi      # 0x16787
leaq 0xe0b3(%rip), %rdx      # 0x16693
movl $0x1dd, %ecx            # imm = 0x1DD
jmp 0x8949
movl %eax, %ebp
leaq 0x17c9e(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0x8ab3
movq 0x179d5(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0xe116(%rip), %rsi      # 0x16723
leaq 0xe07f(%rip), %rdx      # 0x16693
movl $0x1d3, %ecx            # imm = 0x1D3
movl %ebp, %r8d
jmp 0x894f
leaq 0x30(%rsp), %rdx
movl $0x80, (%rdx)
movb $-0x80, 0x4(%rdx)
movq 0x8(%rsp), %rbx
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
pushq $0x5
popq %rcx
movl $0x4160, %esi           # imm = 0x4160
callq *0x30(%rax)
testl %eax, %eax
js 0x874c
movl $0x3d090, %edi          # imm = 0x3D090
callq 0x5170
pushq $-0x6
popq %rbx
pushq $0x1
popq %rbp
leaq 0xe02d(%rip), %r13      # 0x16693
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
leaq 0x30(%rsp), %rdx
movl %ebp, %ecx
callq *0x20(%rax)
movl %eax, %r12d
leaq 0x17c06(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0x86b0
movq 0x17921(%rip), %rax     # 0x1ffb8
movq (%rax), %rdi
leaq 0xe135(%rip), %rsi      # 0x167d6
movq %r13, %rdx
movl $0x1ef, %ecx            # imm = 0x1EF
xorl %eax, %eax
callq 0x5180
testl %r12d, %r12d
jns 0x86c1
leaq 0x17bd5(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
je 0x871e
movzbl 0x30(%rsp), %r9d
leaq 0x17bc3(%rip), %rax     # 0x20291
movb (%rax), %al
cmpl $0x82, %r9d
je 0x8780
testb %al, %al
je 0x8707
movq 0x178d0(%rip), %rax     # 0x1ffb8
movq (%rax), %rdi
leaq 0xe10f(%rip), %rsi      # 0x16801
movq %r13, %rdx
movl $0x1f6, %ecx            # imm = 0x1F6
movl $0x4160, %r8d           # imm = 0x4160
xorl %eax, %eax
callq 0x5180
movl $0x7530, %edi           # imm = 0x7530
callq 0x5170
incl %ebx
jne 0x8666
jmp 0x8919
movq 0x178b3(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0xdade(%rip), %rsi      # 0x1620d
movq %r13, %rdx
movl $0x1f1, %ecx            # imm = 0x1F1
movl $0x4160, %r8d           # imm = 0x4160
movl %r12d, %r9d
xorl %eax, %eax
callq 0x5180
jmp 0x86c1
movl %eax, %ebp
leaq 0x17b3c(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0x8ab8
movq 0x17873(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0xe03b(%rip), %rsi      # 0x167aa
leaq 0xdf1d(%rip), %rdx      # 0x16693
movl $0x1e6, %ecx            # imm = 0x1E6
jmp 0x84c7
testb %al, %al
je 0x87a8
movq 0x1782d(%rip), %rax     # 0x1ffb8
movq (%rax), %rdi
leaq 0xe0c3(%rip), %rsi      # 0x16858
leaq 0xdef7(%rip), %rdx      # 0x16693
movl $0x1ff, %ecx            # imm = 0x1FF
xorl %eax, %eax
callq 0x5180
movq 0x8(%rsp), %rbx
movq 0x8(%rbx), %rdi
addq 0x18(%rsp), %r14
movq (%rdi), %rax
movl $0x96f8, %esi           # imm = 0x96F8
movq %r14, %rdx
movl %r15d, %ecx
callq *0x30(%rax)
testl %eax, %eax
js 0x895b
movl $0x186a0, %edi          # imm = 0x186A0
callq 0x5170
leaq 0x30(%rsp), %rdx
movl $0x83, (%rdx)
movb $-0x7d, 0x4(%rdx)
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
pushq $0x5
popq %rcx
movl $0x4160, %esi           # imm = 0x4160
callq *0x30(%rax)
testl %eax, %eax
js 0x8992
movl $0x13880, %edi          # imm = 0x13880
callq 0x5170
pushq $-0x6
popq %r14
leaq 0x30(%rsp), %rbx
pushq $0x5
popq %rbp
leaq 0xde74(%rip), %r15      # 0x16693
leaq 0xe0f5(%rip), %r13      # 0x1691b
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movq %rbx, %rdx
movl %ebp, %ecx
callq *0x20(%rax)
movl %eax, %r12d
leaq 0x17a48(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0x886e
movq 0x17763(%rip), %rax     # 0x1ffb8
movq (%rax), %rdi
leaq 0xe091(%rip), %rsi      # 0x168f0
movq %r15, %rdx
movl $0x216, %ecx            # imm = 0x216
xorl %eax, %eax
callq 0x5180
testl %r12d, %r12d
js 0x8896
movb 0x30(%rsp), %al
cmpb $0x7f, %al
je 0x89c6
cmpb $0x7e, %al
jne 0x88a2
cmpb $0x0, 0x31(%rsp)
jne 0x88a2
cmpb $0x7, 0x32(%rsp)
jne 0x88a2
jmp 0x89c6
leaq 0x179f4(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
je 0x88ee
leaq 0x179e8(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0x88d6
movq 0x17703(%rip), %rax     # 0x1ffb8
movq (%rax), %rdi
movzbl 0x30(%rsp), %r9d
movq %r13, %rsi
movq %r15, %rdx
movl $0x21e, %ecx            # imm = 0x21E
movl $0x4160, %r8d           # imm = 0x4160
xorl %eax, %eax
callq 0x5180
movl $0x7530, %edi           # imm = 0x7530
callq 0x5170
incl %r14d
jne 0x8826
jmp 0x89ca
movq 0x176e3(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0xd90e(%rip), %rsi      # 0x1620d
movq %r15, %rdx
movl $0x218, %ecx            # imm = 0x218
movl $0x4160, %r8d           # imm = 0x4160
movl %r12d, %r9d
xorl %eax, %eax
callq 0x5180
jmp 0x88a2
pushq $-0x2
popq %rbp
leaq 0x1796e(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0x8ab3
movq 0x176a5(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0xdef8(%rip), %rsi      # 0x16835
leaq 0xdd4f(%rip), %rdx      # 0x16693
movl $0x1fb, %ecx            # imm = 0x1FB
movl $0x4160, %r8d           # imm = 0x4160
xorl %eax, %eax
callq 0x5180
jmp 0x8ab3
movl %eax, %ebp
leaq 0x1792d(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0x8ab8
movq 0x17664(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0xdf0b(%rip), %rsi      # 0x16889
leaq 0xdd0e(%rip), %rdx      # 0x16693
movl $0x204, %ecx            # imm = 0x204
movl %ebp, %r8d
jmp 0x8a98
movl %eax, %ebp
leaq 0x178f6(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0x8ab8
movq 0x1762d(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0xdf08(%rip), %rsi      # 0x168bd
leaq 0xdcd7(%rip), %rdx      # 0x16693
movl $0x20d, %ecx            # imm = 0x20D
jmp 0x84c7
xorl %ebx, %ebx
jmp 0x89cc
movb $0x1, %bl
leaq 0x178be(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0x8a2c
movq 0x175d9(%rip), %rax     # 0x1ffb8
movq (%rax), %rdi
movzbl 0x30(%rsp), %r9d
movzbl 0x31(%rsp), %r10d
movzbl 0x32(%rsp), %r11d
movzbl 0x33(%rsp), %r14d
movzbl 0x34(%rsp), %r15d
leaq 0xdf40(%rip), %rsi      # 0x16947
leaq 0xdc85(%rip), %rdx      # 0x16693
movl $0x223, %ecx            # imm = 0x223
movl $0x4160, %r8d           # imm = 0x4160
xorl %eax, %eax
pushq %r15
pushq %r14
pushq %r11
pushq %r10
callq 0x5180
addq $0x20, %rsp
leaq 0x80(%rsp), %rdx
movl $0x7d, (%rdx)
movb $0x7d, 0x4(%rdx)
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
pushq $0x5
popq %rcx
movl $0x4160, %esi           # imm = 0x4160
callq *0x30(%rax)
testl %eax, %eax
js 0x8aa1
testb %bl, %bl
je 0x8b49
pushq $-0x2
popq %rbp
leaq 0x17826(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
movq 0x8(%rsp), %rbx
jne 0x8ab8
movq 0x1755c(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0xdf32(%rip), %rsi      # 0x169b8
leaq 0xdc06(%rip), %rdx      # 0x16693
movl $0x22e, %ecx            # imm = 0x22E
movl $0x4160, %r8d           # imm = 0x4160
xorl %eax, %eax
callq 0x5180
jmp 0x8ab8
movl %eax, %ebp
leaq 0x177e7(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
je 0x8ca8
movq 0x8(%rsp), %rbx
leaq 0x177d2(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0x8ae8
movq 0x174ed(%rip), %rax     # 0x1ffb8
movq (%rax), %rdi
leaq 0xd39f(%rip), %rsi      # 0x15e74
leaq 0xdbb7(%rip), %rdx      # 0x16693
movl $0x24a, %ecx            # imm = 0x24A
xorl %eax, %eax
callq 0x5180
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
leaq 0x20(%rsp), %rdx
pushq $0x5
popq %rcx
movl $0x4160, %esi           # imm = 0x4160
callq *0x30(%rax)
testl %eax, %eax
jns 0x8b0f
leaq 0x17787(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
je 0x8b23
movl %ebp, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x174ae(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0xdf7d(%rip), %rsi      # 0x16ab1
leaq 0xdb58(%rip), %rdx      # 0x16693
movl $0x24d, %ecx            # imm = 0x24D
xorl %eax, %eax
callq 0x5180
jmp 0x8b0f
movzbl 0x30(%rsp), %eax
cmpl $0x7f, %eax
movq 0x8(%rsp), %rbx
je 0x8ba8
cmpl $0x7e, %eax
jne 0x8c46
cmpb $0x0, 0x31(%rsp)
leaq 0x17724(%rip), %rax     # 0x20291
movb (%rax), %al
jne 0x8c7b
cmpb $0x7, 0x32(%rsp)
jne 0x8c7b
testb %al, %al
je 0x8ba8
movq 0x1742d(%rip), %rax     # 0x1ffb8
movq (%rax), %rdi
leaq 0xde59(%rip), %rsi      # 0x169ee
leaq 0xdaf7(%rip), %rdx      # 0x16693
movl $0x234, %ecx            # imm = 0x234
xorl %eax, %eax
callq 0x5180
leaq 0x176e2(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0x8bd8
movq 0x173fd(%rip), %rax     # 0x1ffb8
movq (%rax), %rdi
leaq 0xde7d(%rip), %rsi      # 0x16a42
leaq 0xdac7(%rip), %rdx      # 0x16693
movl $0x240, %ecx            # imm = 0x240
xorl %eax, %eax
callq 0x5180
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
leaq 0x15(%rsp), %rdx
pushq $0x3
popq %rcx
movl $0x96f8, %esi           # imm = 0x96F8
callq *0x20(%rax)
xorl %ebp, %ebp
leaq 0x17699(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0x8ab8
movq 0x173b0(%rip), %rax     # 0x1ffb8
movq (%rax), %rdi
movzbl 0x15(%rsp), %r8d
movzbl 0x16(%rsp), %r9d
movzbl 0x17(%rsp), %r10d
subq $0x8, %rsp
leaq 0xde46(%rip), %rsi      # 0x16a6e
leaq 0xda64(%rip), %rdx      # 0x16693
xorl %ebp, %ebp
movl $0x244, %ecx            # imm = 0x244
xorl %eax, %eax
pushq %r10
callq 0x5180
popq %rcx
popq %rdx
jmp 0x8ab8
pushq $-0x5
popq %rbp
leaq 0x17641(%rip), %rax     # 0x20291
cmpb $0x1, (%rax)
jne 0x8ab8
movq 0x17378(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0xddb6(%rip), %rsi      # 0x16a20
leaq 0xda22(%rip), %rdx      # 0x16693
movl $0x23b, %ecx            # imm = 0x23B
jmp 0x84c7
pushq $-0x3
popq %rbp
testb %al, %al
je 0x8ab8
movq 0x1734b(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0xdd89(%rip), %rsi      # 0x16a20
leaq 0xd9f5(%rip), %rdx      # 0x16693
movl $0x236, %ecx            # imm = 0x236
jmp 0x84c7
movq 0x17329(%rip), %rax     # 0x1ffd8
movq (%rax), %rdi
leaq 0xdccf(%rip), %rsi      # 0x16988
leaq 0xd9d3(%rip), %rdx      # 0x16693
movl $0x229, %ecx            # imm = 0x229
xorl %eax, %eax
callq 0x5180
jmp 0x8ab3
nopl (%rax)