// File: /workspace/github_cpp_makefile_star2_O3/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, %r14
movq 0x10(%rdi), %rdi
movq (%rdi), %rax
callq *0x78(%rax)
movl %eax, %r13d
movb $0x33, 0x24(%rsp)
movl $0x33, 0x20(%rsp)
movb $0x34, 0x1c(%rsp)
movl $0x34, 0x18(%rsp)
movq 0x10(%r14), %rdi
movq (%rdi), %rax
callq *0x80(%rax)
movl %eax, %ebx
movq 0x10(%r14), %rdi
movq (%rdi), %rax
callq *0x88(%rax)
testl %r13d, %r13d
je 0x9e11
movl %eax, %ebp
movq %r14, 0x8(%rsp)
leaq 0x1762f(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0x9c8b
movq 0x1734a(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xd9e7(%rip), %rsi      # 0x1765f
leaq 0xda14(%rip), %rdx      # 0x17693
movl $0x1a1, %ecx            # imm = 0x1A1
xorl %eax, %eax
callq 0x5180
movl $0xfffffffd, %r12d      # imm = 0xFFFFFFFD
leaq 0x20(%rsp), %r15
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movq %r15, %rdx
movl $0x5, %ecx
callq *0x30(%rax)
movl %eax, %r14d
testl %eax, %eax
jns 0x9cc5
leaq 0x175d1(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
je 0x9ccc
incl %r12d
jne 0x9c96
jmp 0x9cd3
callq 0x54a9
jmp 0x9cc5
movq 0x8(%rsp), %r15
movq 0x8(%r15), %rdi
movq (%rdi), %rax
leaq 0x12(%rsp), %rdx
movl $0x96f8, %esi           # imm = 0x96F8
movl $0x3, %ecx
callq *0x20(%rax)
leaq 0x17599(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0x9d3d
movq 0x172b4(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
movzbl 0x12(%rsp), %r8d
movzbl 0x13(%rsp), %r9d
movzbl 0x14(%rsp), %r10d
subq $0x8, %rsp
leaq 0xd97a(%rip), %rsi      # 0x1769e
leaq 0xd968(%rip), %rdx      # 0x17693
movl $0x1ae, %ecx            # imm = 0x1AE
xorl %eax, %eax
pushq %r10
callq 0x5180
addq $0x10, %rsp
movq 0x10(%r15), %rdi
movq (%rdi), %rax
callq *0x38(%rax)
movq %rax, %r12
leaq 0x17540(%rip), %rax     # 0x21291
movb (%rax), %al
testq %r12, %r12
je 0x9e1c
testb %al, %al
je 0x9d87
movq 0x17251(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xd79e(%rip), %rsi      # 0x1750f
leaq 0xd91b(%rip), %rdx      # 0x17693
movl $0x1b9, %ecx            # imm = 0x1B9
movl %r13d, %r8d
xorl %eax, %eax
callq 0x5180
testl %r13d, %r13d
jle 0x9f42
movq %r12, 0x28(%rsp)
movl %ebx, %eax
movzbl (%r12,%rax), %r15d
leaq 0x174ee(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0x9dcf
movq 0x17209(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xd788(%rip), %rsi      # 0x17541
leaq 0xd8d3(%rip), %rdx      # 0x17693
movl $0x1bc, %ecx            # imm = 0x1BC
movl %r15d, %r8d
xorl %eax, %eax
callq 0x5180
leal 0x1(%rbx), %eax
movzbl (%r12,%rax), %eax
shll $0x8, %eax
leal 0x2(%rbx), %ecx
movzbl (%r12,%rcx), %r12d
orl %eax, %r12d
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x80(%rax)
cmpb %r15b, %al
je 0x9e34
addl %r12d, %ebp
addl $0x3, %ebx
decl %r13d
movq 0x28(%rsp), %r12
jne 0x9d95
jmp 0x9f3d
movl $0xfffffffb, %r14d      # imm = 0xFFFFFFFB
jmp 0x9f9f
movl $0xfffffffc, %r14d      # imm = 0xFFFFFFFC
testb %al, %al
je 0x9f42
callq 0x5635
jmp 0x9f42
leaq 0x17456(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0x9e8b
movl %ebp, %eax
movq 0x28(%rsp), %rcx
movzbl (%rcx,%rax), %ebx
movq 0x17166(%rip), %rax     # 0x20fb8
movq (%rax), %r14
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x80(%rax)
movzbl %al, %r8d
leaq 0xd870(%rip), %rsi      # 0x176e2
leaq 0xd81a(%rip), %rdx      # 0x17693
movq %r14, %rdi
movl $0x1c6, %ecx            # imm = 0x1C6
movl %ebx, %r9d
xorl %eax, %eax
callq 0x5180
movl $0xfffffff6, %r15d      # imm = 0xFFFFFFF6
leaq 0x30(%rsp), %rbx
leaq 0xd7f6(%rip), %r13      # 0x17693
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movq %rbx, %rdx
movl $0x1, %ecx
callq *0x20(%rax)
testl %eax, %eax
js 0x9f2a
movzbl 0x30(%rsp), %r9d
cmpl $0xff, %r9d
je 0x9fb4
leaq 0x173ba(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0x9f02
movq 0x170d5(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xd866(%rip), %rsi      # 0x17753
movq %r13, %rdx
movl $0x1d9, %ecx            # imm = 0x1D9
movl $0x4160, %r8d           # imm = 0x4160
xorl %eax, %eax
callq 0x5180
movl $0x2710, %edi           # imm = 0x2710
callq 0x5170
incl %r15d
jne 0x9e9d
movl $0xfffffffe, %r14d      # imm = 0xFFFFFFFE
leaq 0x17373(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0x9f3d
callq 0x54d3
jmp 0x9f3d
movl %eax, %r14d
leaq 0x1735d(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
je 0xa32f
movq 0x8(%rsp), %r15
leaq 0x17348(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0x9f72
movq 0x17063(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xcf15(%rip), %rsi      # 0x16e74
leaq 0xd72d(%rip), %rdx      # 0x17693
movl $0x24a, %ecx            # imm = 0x24A
xorl %eax, %eax
callq 0x5180
movq 0x8(%r15), %rdi
movq (%rdi), %rax
leaq 0x18(%rsp), %rdx
movl $0x4160, %esi           # imm = 0x4160
movl $0x5, %ecx
callq *0x30(%rax)
testl %eax, %eax
jns 0x9f9f
leaq 0x172fb(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
je 0xa105
movl %r14d, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x30(%rsp), %rdx
movl $0x80, (%rdx)
movb $-0x80, 0x4(%rdx)
movq 0x8(%rsp), %r15
movq 0x8(%r15), %rdi
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movl $0x5, %ecx
callq *0x30(%rax)
testl %eax, %eax
js 0xa0e8
movl $0x3d090, %edi          # imm = 0x3D090
callq 0x5170
movl $0xfffffffa, %r14d      # imm = 0xFFFFFFFA
leaq 0x30(%rsp), %rbx
leaq 0xd693(%rip), %r13      # 0x17693
movq 0x8(%r15), %rdi
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movq %rbx, %rdx
movl $0x1, %ecx
callq *0x20(%rax)
movl %eax, %r15d
leaq 0x17270(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0xa046
movq 0x16f8b(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xd79f(%rip), %rsi      # 0x177d6
movq %r13, %rdx
movl $0x1ef, %ecx            # imm = 0x1EF
xorl %eax, %eax
callq 0x5180
testl %r15d, %r15d
jns 0xa057
leaq 0x1723f(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
je 0xa0ba
movzbl 0x30(%rsp), %r9d
leaq 0x1722d(%rip), %rax     # 0x21291
movb (%rax), %al
cmpl $0x82, %r9d
je 0xa10f
testb %al, %al
movq 0x8(%rsp), %r15
je 0xa0a2
movq 0x16f35(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xd774(%rip), %rsi      # 0x17801
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 %r14d
jne 0xa000
jmp 0xa2af
movq 0x16f17(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
leaq 0xd142(%rip), %rsi      # 0x1720d
movq %r13, %rdx
movl $0x1f1, %ecx            # imm = 0x1F1
movl $0x4160, %r8d           # imm = 0x4160
movl %r15d, %r9d
xorl %eax, %eax
callq 0x5180
jmp 0xa057
movl %eax, %r14d
leaq 0x1719f(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0x9f42
callq 0x560b
jmp 0x9f42
callq 0x565f
jmp 0x9f9f
testb %al, %al
movq 0x8(%rsp), %r15
je 0xa13c
movq 0x16e99(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xd72f(%rip), %rsi      # 0x17858
leaq 0xd563(%rip), %rdx      # 0x17693
movl $0x1ff, %ecx            # imm = 0x1FF
xorl %eax, %eax
callq 0x5180
movq 0x8(%r15), %rdi
movl %ebp, %eax
movq 0x28(%rsp), %rdx
addq %rax, %rdx
movq (%rdi), %rax
movl $0x96f8, %esi           # imm = 0x96F8
movl %r12d, %ecx
callq *0x30(%rax)
testl %eax, %eax
js 0xa2cf
movl $0x186a0, %edi          # imm = 0x186A0
callq 0x5170
leaq 0x30(%rsp), %rdx
movl $0x83, (%rdx)
movb $-0x7d, 0x4(%rdx)
movq 0x8(%r15), %rdi
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movl $0x5, %ecx
callq *0x30(%rax)
testl %eax, %eax
js 0xa30e
movl $0x13880, %edi          # imm = 0x13880
callq 0x5170
movl $0xfffffffa, %r12d      # imm = 0xFFFFFFFA
leaq 0x30(%rsp), %rbx
leaq 0xd73f(%rip), %r14      # 0x178f0
leaq 0xd4db(%rip), %r15      # 0x17693
leaq 0xd75c(%rip), %r13      # 0x1791b
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movq %rbx, %rdx
movl $0x5, %ecx
callq *0x20(%rax)
movl %eax, %ebp
leaq 0x170ad(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0xa205
movq 0x16dc8(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
movq %r14, %rsi
movq %r15, %rdx
movl $0x216, %ecx            # imm = 0x216
xorl %eax, %eax
callq 0x5180
testl %ebp, %ebp
js 0xa22c
movb 0x30(%rsp), %al
cmpb $0x7f, %al
je 0xa32b
cmpb $0x7e, %al
jne 0xa238
cmpb $0x0, 0x31(%rsp)
jne 0xa238
cmpb $0x7, 0x32(%rsp)
jne 0xa238
jmp 0xa32b
leaq 0x1705e(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
je 0xa284
leaq 0x17052(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0xa26c
movq 0x16d6d(%rip), %rax     # 0x20fb8
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 %r12d
jne 0xa1bf
jmp 0xa35b
movq 0x16d4d(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
leaq 0xcf78(%rip), %rsi      # 0x1720d
movq %r15, %rdx
movl $0x218, %ecx            # imm = 0x218
movl $0x4160, %r8d           # imm = 0x4160
movl %ebp, %r9d
xorl %eax, %eax
callq 0x5180
jmp 0xa238
movl $0xfffffffe, %r14d      # imm = 0xFFFFFFFE
leaq 0x16fd5(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0x9f42
callq 0x5503
jmp 0x9f42
movl %eax, %r14d
leaq 0x16fb8(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0x9f42
movq 0x16cef(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
leaq 0xd596(%rip), %rsi      # 0x17889
leaq 0xd399(%rip), %rdx      # 0x17693
movl $0x204, %ecx            # imm = 0x204
movl %r14d, %r8d
xorl %eax, %eax
callq 0x5180
jmp 0x9f42
movl %eax, %r14d
leaq 0x16f79(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0x9f42
callq 0x55e1
jmp 0x9f42
xorl %ebx, %ebx
jmp 0xa35d
movq 0x16ca2(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
leaq 0xd3e3(%rip), %rsi      # 0x17723
leaq 0xd34c(%rip), %rdx      # 0x17693
movl $0x1d3, %ecx            # imm = 0x1D3
movl %r14d, %r8d
xorl %eax, %eax
callq 0x5180
jmp 0x9f3d
movb $0x1, %bl
leaq 0x16f2d(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0xa3bd
movq 0x16c48(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
movzbl 0x30(%rsp), %r9d
movzbl 0x31(%rsp), %r10d
movzbl 0x32(%rsp), %r11d
movzbl 0x33(%rsp), %r14d
movzbl 0x34(%rsp), %r15d
leaq 0xd5af(%rip), %rsi      # 0x17947
leaq 0xd2f4(%rip), %rdx      # 0x17693
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), %r15
movq 0x8(%r15), %rdi
movq (%rdi), %rax
movl $0x4160, %esi           # imm = 0x4160
movl $0x5, %ecx
callq *0x30(%rax)
testl %eax, %eax
js 0xa410
testb %bl, %bl
je 0xa42d
movl $0xfffffffe, %r14d      # imm = 0xFFFFFFFE
leaq 0x16e94(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0x9f42
callq 0x5587
jmp 0x9f42
movl %eax, %r14d
leaq 0x16e77(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0x9f42
callq 0x55b7
jmp 0x9f42
movzbl 0x30(%rsp), %eax
cmpl $0x7f, %eax
je 0xa487
cmpl $0x7e, %eax
jne 0xa52b
cmpb $0x0, 0x31(%rsp)
leaq 0x16e45(%rip), %rax     # 0x21291
movb (%rax), %al
jne 0xa54b
cmpb $0x7, 0x32(%rsp)
jne 0xa54b
testb %al, %al
je 0xa487
movq 0x16b4e(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xd57a(%rip), %rsi      # 0x179ee
leaq 0xd218(%rip), %rdx      # 0x17693
movl $0x234, %ecx            # imm = 0x234
xorl %eax, %eax
callq 0x5180
leaq 0x16e03(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0xa4b7
movq 0x16b1e(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
leaq 0xd59e(%rip), %rsi      # 0x17a42
leaq 0xd1e8(%rip), %rdx      # 0x17693
movl $0x240, %ecx            # imm = 0x240
xorl %eax, %eax
callq 0x5180
movq 0x8(%r15), %rdi
movq (%rdi), %rax
leaq 0x15(%rsp), %rdx
movl $0x96f8, %esi           # imm = 0x96F8
movl $0x3, %ecx
callq *0x20(%rax)
xorl %r14d, %r14d
leaq 0x16db7(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0x9f42
movq 0x16ace(%rip), %rax     # 0x20fb8
movq (%rax), %rdi
movzbl 0x15(%rsp), %r8d
movzbl 0x16(%rsp), %r9d
movzbl 0x17(%rsp), %r10d
subq $0x8, %rsp
leaq 0xd564(%rip), %rsi      # 0x17a6e
leaq 0xd182(%rip), %rdx      # 0x17693
xorl %r14d, %r14d
movl $0x244, %ecx            # imm = 0x244
xorl %eax, %eax
pushq %r10
callq 0x5180
addq $0x10, %rsp
jmp 0x9f42
movl $0xfffffffb, %r14d      # imm = 0xFFFFFFFB
leaq 0x16d59(%rip), %rax     # 0x21291
cmpb $0x1, (%rax)
jne 0x9f42
callq 0x555d
jmp 0x9f42
movl $0xfffffffd, %r14d      # imm = 0xFFFFFFFD
testb %al, %al
je 0x9f42
callq 0x5533
jmp 0x9f42
nop