// File: /workspace/github_c_makefile_star2_O3/seuscq[P]rtk_hciattach/hciattach_rtk.c
// Function: rtk_config
static int rtk_config(int fd, int proto, int speed, struct termios *ti)
{
	int final_speed = 0;
	int ret = 0;
	struct btrtl_info *btrtl = &rtk_hw_cfg;

	btrtl->proto = proto;

	/* Get Local Version Information and RTK ROM version */
	if (proto == HCI_UART_3WIRE) {
		RS_INFO("H5 IC");
		rtk_get_lmp_version(fd);
		rtk_get_eversion(fd);
	} else {
		RS_INFO("H4 IC");
		ti->c_cflag &= ~PARENB;
		ti->c_cflag |= CRTSCTS;
		if (tcsetattr(fd, TCSANOW, ti) < 0) {
			RS_ERR("H4 Can't enable RTSCTS");
			return -1;
		}
		usleep(20 * 1000);
		rtk_hci_local_ver(fd);
		rtk_hci_rom_ver(fd);
		if (rtk_hw_cfg.lmp_subver == ROM_LMP_8761btc) {
			rtk_hw_cfg.chip_type = CHIP_8761BTC;
			rtk_hw_cfg.hw_flow_control = 1;
			/* TODO: Change to different uart baud */
			uart_speed_to_rtk_speed(1500000, &rtk_hw_cfg.baudrate);
			goto change_baud;
		} else if (rtk_hw_cfg.lmp_subver == ROM_LMP_8761a) {
			if (rtk_hw_cfg.hci_rev == 0x000b) {
				rtk_hw_cfg.chip_type = CHIP_8761B;
				rtk_hw_cfg.hw_flow_control = 1;
				/* TODO: Change to different uart baud */
				uart_speed_to_rtk_speed(1500000, &rtk_hw_cfg.baudrate);
				goto change_baud;
			} else if (rtk_hw_cfg.hci_rev == 0x000a) {
				if (rtk_hw_cfg.eversion == 3)
					rtk_hw_cfg.chip_type = CHIP_8761ATF;
				else if (rtk_hw_cfg.eversion == 2)
					rtk_hw_cfg.chip_type = CHIP_8761AT;
				else
					rtk_hw_cfg.chip_type = CHIP_UNKNOWN;
			}
		} else if (rtk_hw_cfg.lmp_subver == ROM_LMP_8723b) {
			if (rtk_hw_cfg.hci_ver == 0x08 &&
			    rtk_hw_cfg.hci_rev == 0x000d) {
				rtk_hw_cfg.chip_type = CHIP_8723DS;
			} else if (rtk_hw_cfg.hci_ver == 0x06 &&
				 rtk_hw_cfg.hci_rev == 0x000b) {
				rtk_hw_cfg.chip_type = CHIP_8723BS;
			} else {
				RS_ERR("H4: unknown chip");
				return -1;
			}
		}

	}

	RS_INFO("LMP Subversion 0x%04x", btrtl->lmp_subver);
	RS_INFO("EVersion %d", btrtl->eversion);

	switch (rtk_hw_cfg.lmp_subver) {
	case ROM_LMP_8723a:
		break;
	case ROM_LMP_8723b:
#ifdef RTL_8703A_SUPPORT
		/* Set chip type for matching fw/config entry */
		rtl->chip_type = CHIP_8703AS;
#endif
		break;
	case ROM_LMP_8821a:
		break;
	case ROM_LMP_8761a:
		break;
	case ROM_LMP_8703b:
		rtk_get_chip_type(fd);
		break;
	}

	btrtl->patch_ent = get_patch_entry(btrtl);
	if (btrtl->patch_ent) {
		RS_INFO("IC: %s\n", btrtl->patch_ent->ic_name);
		RS_INFO("Firmware/config: %s, %s\n",
			btrtl->patch_ent->patch_file,
			btrtl->patch_ent->config_file);
	} else {
		RS_ERR("Can not find firmware/config entry\n");
		return -1;
	}

	rtk_hw_cfg.config_len =
	    rtk_get_bt_config(btrtl, &btrtl->config_buf, &btrtl->baudrate);
	if (rtk_hw_cfg.config_len < 0) {
		RS_ERR("Get Config file error, just use efuse settings");
		rtk_hw_cfg.config_len = 0;
	}

	rtk_hw_cfg.fw_len = rtk_get_bt_firmware(btrtl, &btrtl->fw_buf);
	if (rtk_hw_cfg.fw_len < 0) {
		RS_ERR("Get BT firmware error");
		rtk_hw_cfg.fw_len = 0;
		return -1;
	} else {
		rtk_get_final_patch(fd, proto);
	}

	if (rtk_hw_cfg.total_len > RTK_PATCH_LENGTH_MAX) {
		RS_ERR("total length of fw&config larger than allowed");
		return -1;
	}

	RS_INFO("Total len %d for fw/config", rtk_hw_cfg.total_len);

	if (rtk_hw_cfg.chip_type == CHIP_8723DS &&
	    rtk_hw_cfg.proto == HCI_UART_H4) {
		if (rtk_hw_cfg.parity_en) {
			/* set parity */
			ti->c_cflag |= PARENB;
			if (rtk_hw_cfg.parity_even)
				ti->c_cflag &= ~(PARODD);
			else
				ti->c_cflag |= PARODD;
			if (tcsetattr(fd, TCSANOW, ti) < 0) {
				RS_ERR("8723DSH4 Can't set parity");
				return -1;
			}
		}
	}

change_baud:
	/* change baudrate if needed
	 * rtk_hw_cfg.baudrate is a __u32/__u16 vendor-specific variable
	 * parsed from config file
	 * */
	if (rtk_hw_cfg.baudrate == 0) {
		uart_speed_to_rtk_speed(speed, &rtk_hw_cfg.baudrate);
		RS_DBG("No cfg file, set baudrate, : %u, 0x%08x",
		       (unsigned int)speed, (unsigned int)rtk_hw_cfg.baudrate);
		goto SET_FLOW_CONTRL;
	} else
		rtk_speed_to_uart_speed(rtk_hw_cfg.baudrate,
					(RT_U32 *) & (rtk_hw_cfg.final_speed));

	if (proto == HCI_UART_3WIRE)
		rtk_vendor_change_speed_h5(fd, rtk_hw_cfg.baudrate);
	else
		rtk_vendor_change_speed_h4(fd, rtk_hw_cfg.baudrate);

	usleep(50000);
	final_speed = rtk_hw_cfg.final_speed ? rtk_hw_cfg.final_speed : speed;
	RS_DBG("final_speed %d\n", final_speed);
	if (set_speed(fd, ti, final_speed) < 0) {
		RS_ERR("Can't set baud rate:%x, %x, %x", final_speed,
		       rtk_hw_cfg.final_speed, speed);
		return -1;
	}

SET_FLOW_CONTRL:
	if (rtk_hw_cfg.hw_flow_control) {
		RS_DBG("hw flow control enable");
		ti->c_cflag |= CRTSCTS;

		if (tcsetattr(fd, TCSANOW, ti) < 0) {
			RS_ERR("Can't set port settings");
			return -1;
		}
	} else {
		RS_DBG("hw flow control disable");
		ti->c_cflag &= ~CRTSCTS;
	}

	/* wait for while for controller to setup */
	usleep(10000);

	/* For 8761B Test chip, no patch to download */
	if (rtk_hw_cfg.chip_type == CHIP_8761BTC ||
	    rtk_hw_cfg.chip_type == CHIP_8761B)
		goto done;

	if ((rtk_hw_cfg.total_len > 0) && (rtk_hw_cfg.dl_fw_flag)) {
		rtk_hw_cfg.link_estab_state = H5_PATCH;
		rtk_hw_cfg.rx_index = -1;

		ret =
		    rtk_download_fw_config(fd, rtk_hw_cfg.total_buf,
					   rtk_hw_cfg.total_len,
					   rtk_hw_cfg.baudrate, proto, ti);
		free(rtk_hw_cfg.total_buf);

		if (ret < 0)
			return ret;
	}

done:
	RS_DBG("Init Process finished");
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2f8, %rsp            # imm = 0x2F8
movq %rcx, %r12
movl %edi, %ebx
movl %esi, 0x8387(%rip)      # 0xf778
movq 0x7c00(%rip), %r13      # 0xeff8
movq (%r13), %rdi
movl %esi, -0x2c(%rbp)
cmpl $0x2, %esi
movl %ebx, -0x30(%rbp)
movl %edx, -0x40(%rbp)
jne 0x752f
leaq 0x371b(%rip), %rsi      # 0xab30
leaq 0x211d(%rip), %rdx      # 0x9539
xorl %eax, %eax
callq 0x2150
movl %ebx, %edi
callq 0x6cd3
movl %ebx, %edi
callq 0x6b3f
movzwl 0x82d2(%rip), %eax      # 0xf70a
movq (%r13), %rdi
movzwl %ax, %ecx
leaq 0x3343(%rip), %rsi      # 0xa789
leaq 0x20ec(%rip), %r14      # 0x9539
movq %r14, %rdx
xorl %eax, %eax
callq 0x2150
movq (%r13), %rdi
movzbl 0x82ad(%rip), %ecx      # 0xf70f
leaq 0x371b(%rip), %rsi      # 0xab84
movq %r14, %rdx
xorl %eax, %eax
callq 0x2150
cmpw $0x8703, 0x828e(%rip)   # imm = 0x8703
jne 0x7485
movl %ebx, %edi
callq 0x2490
leaq 0x8254(%rip), %r14      # 0xf6e0
movq %r14, %rdi
callq 0x503c
movq %rax, 0x82d5(%rip)      # 0xf770
movq (%r13), %rdi
movq 0x20(%rax), %rcx
leaq 0x36eb(%rip), %rsi      # 0xab95
leaq 0x2088(%rip), %r15      # 0x9539
movq %r15, %rdx
xorl %eax, %eax
callq 0x2150
movq (%r13), %rdi
movq 0x82aa(%rip), %rax      # 0xf770
movq 0x10(%rax), %rcx
movq 0x18(%rax), %r8
leaq 0x36cd(%rip), %rsi      # 0xaba2
movq %r15, %rdx
xorl %eax, %eax
callq 0x2150
leaq 0x826a(%rip), %rsi      # 0xf750
leaq 0x822b(%rip), %rdx      # 0xf718
movq %r14, %rdi
callq 0x589d
movl %eax, 0x8245(%rip)      # 0xf740
testl %eax, %eax
jns 0x7504
callq 0x37b4
leaq 0x81d5(%rip), %rdi      # 0xf6e0
leaq 0x8236(%rip), %rsi      # 0xf748
callq 0x6a42
movl %eax, 0x821f(%rip)      # 0xf73c
testl %eax, %eax
jns 0x7790
callq 0x3b5c
jmp 0x77bf
leaq 0x3605(%rip), %rsi      # 0xab3b
leaq 0x1ffc(%rip), %rdx      # 0x9539
xorl %eax, %eax
callq 0x2150
movl $0x7ffffeff, %eax       # imm = 0x7FFFFEFF
andl 0x8(%r12), %eax
orl $0x80000000, %eax       # imm = 0x80000000
movl %eax, 0x8(%r12)
movl %ebx, %edi
xorl %esi, %esi
movq %r12, %rdx
callq 0x21f0
testl %eax, %eax
js 0x7f66
movq %r12, -0x48(%rbp)
movl $0x4e20, %edi           # imm = 0x4E20
callq 0x22f0
xorl %edi, %edi
callq 0x20f0
leaq -0x268(%rbp), %r14
movl $0x90, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x20d0
movl $0x1, 0x80(%r14)
leaq 0x12b5(%rip), %rax      # 0x885e
movq %rax, -0x8(%r14)
leaq -0x270(%rbp), %rsi
movl $0xe, %edi
xorl %edx, %edx
callq 0x2060
callq 0x885e
leaq -0x160(%rbp), %rsi
movl %ebx, %edi
movl $0xe, %edx
callq 0x524f
testl %eax, %eax
jns 0x7619
leaq 0x379b(%rip), %r15      # 0xad7e
leaq -0x160(%rbp), %r14
movq (%r13), %rdi
leaq 0x3764(%rip), %rsi      # 0xad59
leaq 0x1f3d(%rip), %rdx      # 0x9539
movq %r15, %rcx
xorl %eax, %eax
callq 0x2150
movl %ebx, %edi
movq %r14, %rsi
movl $0xe, %edx
callq 0x524f
testl %eax, %eax
js 0x75ea
movl %eax, %r12d
xorl %edi, %edi
callq 0x20f0
cmpl $0xf, %r12d
jne 0x8165
movb -0x15a(%rbp), %al
testb %al, %al
jne 0x816d
leaq -0x160(%rbp), %r14
movb 0x7(%r14), %al
movb %al, 0x80c2(%rip)       # 0xf70e
movzwl 0x8(%r14), %eax
movw %ax, 0x80b4(%rip)       # 0xf70c
movzwl 0xd(%r14), %eax
movw %ax, 0x80a6(%rip)       # 0xf70a
xorl %edi, %edi
callq 0x20f0
leaq -0x268(%rbp), %r15
movl $0x90, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x20d0
movl $0x1, 0x80(%r15)
leaq 0x1210(%rip), %rax      # 0x88a3
movq %rax, -0x8(%r15)
leaq -0x270(%rbp), %rsi
movl $0xe, %edi
xorl %edx, %edx
callq 0x2060
callq 0x88a3
movl %ebx, %edi
movq %r14, %rsi
movl $0xe, %edx
callq 0x524f
testl %eax, %eax
jns 0x76f8
leaq 0x3747(%rip), %r15      # 0xae10
movq (%r13), %rdi
leaq 0x3685(%rip), %rsi      # 0xad59
leaq 0x1e5e(%rip), %rdx      # 0x9539
movq %r15, %rcx
xorl %eax, %eax
callq 0x2150
movl %ebx, %edi
movq %r14, %rsi
movl $0xe, %edx
callq 0x524f
testl %eax, %eax
js 0x76c9
movl %eax, %r12d
xorl %edi, %edi
callq 0x20f0
cmpl $0x8, %r12d
jne 0x8175
movzbl -0x15a(%rbp), %r8d
testl %r8d, %r8d
jne 0x7f70
movb -0x159(%rbp), %bl
movl -0x2c(%rbp), %edx
movq -0x48(%rbp), %r12
movb %bl, 0x7fdf(%rip)       # 0xf70f
movzwl 0x7fd3(%rip), %eax      # 0xf70a
cmpl $0x8761, %eax           # imm = 0x8761
je 0x77ca
cmpl $0x8763, %eax           # imm = 0x8763
movl -0x30(%rbp), %ebx
jne 0x7f97
movb $0x3f, 0x7fbd(%rip)     # 0xf714
movl $0x1, 0x7fc3(%rip)      # 0xf724
movl $0x701d, 0x7fad(%rip)   # imm = 0x701D
xorl %eax, %eax
leaq 0x7e6c(%rip), %rcx      # 0xf5e0
cmpl $0x16e360, 0x4(%rcx,%rax,8) # imm = 0x16E360
je 0x7816
incq %rax
cmpq $0xb, %rax
jne 0x7774
jmp 0x783e
movl -0x2c(%rbp), %esi
callq 0x70eb
movl 0x7fa6(%rip), %esi      # 0xf744
movq (%r13), %rdi
cmpl $0xa001, %esi           # imm = 0xA001
jl 0x7823
leaq 0x346a(%rip), %rsi      # 0xac1b
leaq 0x1d81(%rip), %rdx      # 0x9539
xorl %eax, %eax
callq 0x2150
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x7f51
movzwl 0x7f3b(%rip), %ecx      # 0xf70c
cmpl $0xb, %ecx
jne 0x7fdf
movb $0x4f, 0x7f33(%rip)     # 0xf714
movl $0x1, 0x7f39(%rip)      # 0xf724
movl $0x701d, 0x7f23(%rip)   # imm = 0x701D
xorl %eax, %eax
leaq 0x7de2(%rip), %rcx      # 0xf5e0
movl -0x30(%rbp), %ebx
cmpl $0x16e360, 0x4(%rcx,%rax,8) # imm = 0x16E360
je 0x7816
incq %rax
cmpq $0xb, %rax
jne 0x7801
jmp 0x783e
movl (%rcx,%rax,8), %r14d
movl %r14d, 0x7ef7(%rip)     # 0xf718
jmp 0x7845
movq %r12, %rdx
movl %ebx, %ecx
callq 0x37e0
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testb $0x1, %al
movl -0x2c(%rbp), %edx
je 0x7f51
movl 0x7ed3(%rip), %r14d     # 0xf718
testl %r14d, %r14d
je 0x786e
movl $0x1c200, 0x7ed8(%rip)  # imm = 0x1C200
xorl %eax, %eax
leaq 0x7d83(%rip), %rcx      # 0xf5e0
cmpl %r14d, (%rcx,%rax,8)
je 0x78a2
incq %rax
cmpq $0xb, %rax
jne 0x785d
jmp 0x78ac
movl $0x701d, 0x7ea0(%rip)   # imm = 0x701D
xorl %eax, %eax
leaq 0x7d5f(%rip), %rdx      # 0xf5e0
movl -0x40(%rbp), %ecx
cmpl %ecx, 0x4(%rdx,%rax,8)
je 0x79b9
incq %rax
cmpq $0xb, %rax
jne 0x7884
movl $0x701d, %r8d           # imm = 0x701D
jmp 0x79c4
movl 0x4(%rcx,%rax,8), %eax
movl %eax, 0x7e80(%rip)      # 0xf72c
cmpl $0x2, %edx
jne 0x78c0
movl %ebx, %edi
movl %r14d, %esi
callq 0x5edd
jmp 0x7956
movq $0x4fc1701, -0x270(%rbp) # imm = 0x4FC1701
movl %r14d, -0x26c(%rbp)
movl $0x1, %edi
callq 0x22c0
cmpb $0x0, 0x79fd(%rip)      # 0xf2e0
jne 0x80ba
leaq -0x270(%rbp), %rsi
movl $0x8, %edx
movl %ebx, %edi
callq 0x2070
cmpq $0x8, %rax
jne 0x80c7
cmpb $0x0, 0x79d3(%rip)      # 0xf2e0
jne 0x80d1
leaq -0x160(%rbp), %rsi
movl %ebx, %edi
movl $0xe, %edx
callq 0x524f
testl %eax, %eax
js 0x80db
cmpb $0x4, -0x160(%rbp)
jne 0x7956
cmpb $0x17, -0x15c(%rbp)
jne 0x7956
cmpb $-0x4, -0x15b(%rbp)
jne 0x7956
cmpb $0x0, 0x7990(%rip)      # 0xf2e0
jne 0x80e5
movl $0xc350, %edi           # imm = 0xC350
callq 0x22f0
movl 0x7dc5(%rip), %r14d     # 0xf72c
testl %r14d, %r14d
cmovel -0x40(%rbp), %r14d
cmpb $0x0, 0x796a(%rip)      # 0xf2e0
jne 0x800d
movl %ebx, %edi
movq %r12, %rsi
movl %r14d, %edx
callq 0x411c
testl %eax, %eax
jns 0x79d1
movq (%r13), %rdi
movl 0x7d94(%rip), %r8d      # 0xf72c
leaq 0x333c(%rip), %rsi      # 0xacdb
leaq 0x1b93(%rip), %rdx      # 0x9539
movl %r14d, %ecx
movl -0x40(%rbp), %r9d
xorl %eax, %eax
callq 0x2150
jmp 0x77bf
movl (%rdx,%rax,8), %r8d
movl %r8d, 0x7d54(%rip)      # 0xf718
cmpb $0x0, 0x7915(%rip)      # 0xf2e0
jne 0x8092
cmpl $0x0, 0x7d4c(%rip)      # 0xf724
movb 0x7902(%rip), %al       # 0xf2e0
je 0x7a08
testb %al, %al
jne 0x802e
orb $-0x80, 0xb(%r12)
movl %ebx, %edi
xorl %esi, %esi
movq %r12, %rdx
callq 0x21f0
testl %eax, %eax
jns 0x7a16
callq 0x399d
jmp 0x77bf
testb %al, %al
jne 0x80b0
andb $0x7f, 0xb(%r12)
movl $0x2710, %edi           # imm = 0x2710
callq 0x22f0
movzbl 0x7ced(%rip), %eax      # 0xf714
cmpl $0x3f, %eax
je 0x7f41
cmpl $0x4f, %eax
je 0x7f41
movl 0x7d05(%rip), %ebx      # 0xf744
testl %ebx, %ebx
jle 0x7f41
cmpb $0x0, 0x7cce(%rip)      # 0xf71c
je 0x7f41
movl $0x3, 0x7c96(%rip)      # 0xf6f4
movl $0xffffffff, 0x7cd0(%rip) # imm = 0xFFFFFFFF
movq 0x7ce9(%rip), %r8       # 0xf758
leal -0x1(%rbx), %eax
shrl $0x2, %eax
imulq $0x20820821, %rax, %rsi # imm = 0x20820821
shrq $0x23, %rsi
movl %ebx, %eax
shrl $0x2, %eax
imulq $0x20820821, %rax, %rax # imm = 0x20820821
shrq $0x23, %rax
imull $0xfc, %eax, %eax
subl %eax, %ebx
movl $0xff, %edx
movl %esi, %ecx
andl %edx, %ecx
movl 0x7c61(%rip), %eax      # 0xf708
addl %esi, %eax
incl %eax
andl $0x7, %eax
movl $0x8, %r9d
subl %eax, %r9d
testl %eax, %eax
cmovel %eax, %r9d
addl %r9d, %esi
movq %rsi, -0x48(%rbp)
andl %esi, %edx
movl %edx, -0x4c(%rbp)
movl %edx, 0x7c61(%rip)      # 0xf730
cmpb $0x0, 0x780a(%rip)      # 0xf2e0
movl %ecx, -0x34(%rbp)
jne 0x8119
testl %ebx, %ebx
movl $0xfc, %eax
cmovel %eax, %ebx
movq %rbx, -0x58(%rbp)
xorl %edi, %edi
xorl %r13d, %r13d
movl -0x2c(%rbp), %edx
movl %r13d, %eax
andb $0x7f, %al
incb %al
testb %r13b, %r13b
movzbl %r13b, %esi
movzbl %al, %r15d
cmovnsl %esi, %r15d
cmpl %edi, %ecx
jbe 0x7b1a
movl %r15d, %ebx
movl $0xfc, %r14d
jmp 0x7b67
jne 0x7b34
movl %r15d, %eax
orb $-0x80, %al
cmpl %ecx, -0x4c(%rbp)
movzbl %r15b, %esi
movzbl %al, %ebx
cmovnel %esi, %ebx
movq -0x58(%rbp), %r14
jmp 0x7b67
cmpl %edi, -0x4c(%rbp)
jbe 0x7b4e
cmpb $0x0, 0x77a0(%rip)      # 0xf2e0
jne 0x7efa
xorl %r14d, %r14d
movl %r15d, %ebx
jmp 0x7b64
movl %r15d, %ebx
orb $-0x80, %bl
cmpb $0x0, 0x7785(%rip)      # 0xf2e0
jne 0x7f12
xorl %r14d, %r14d
xorl %r8d, %r8d
testb %bl, %bl
jns 0x7b78
cmpb $0x0, 0x776e(%rip)      # 0xf2e0
jne 0x7e50
movzbl %bl, %r12d
cmpl $0x2, %edx
je 0x7cd5
testl %edx, %edx
jne 0x7e23
movl %edi, -0x50(%rbp)
movq %r8, -0x40(%rbp)
movl $0x101, %edx            # imm = 0x101
leaq -0x160(%rbp), %rdi
xorl %esi, %esi
callq 0x20d0
movl $0x101, %edx            # imm = 0x101
leaq -0x270(%rbp), %rdi
xorl %esi, %esi
callq 0x20d0
movw $0x2001, -0x270(%rbp)   # imm = 0x2001
movb $-0x4, -0x26e(%rbp)
cmpb $0x0, 0x770f(%rip)      # 0xf2e0
jne 0x7e6e
movq -0x40(%rbp), %rsi
testq %rsi, %rsi
je 0x7bef
movl %r14d, %edx
leaq -0x26b(%rbp), %rdi
callq 0x2180
leal 0x1(%r14), %eax
movb %al, -0x26d(%rbp)
movb %bl, -0x26c(%rbp)
addl $0x5, %r14d
movl -0x30(%rbp), %ebx
movl %ebx, %edi
leaq -0x270(%rbp), %rsi
movq %r14, %rdx
callq 0x2070
cmpb $0x0, 0x76c2(%rip)      # 0xf2e0
jne 0x7e9b
movl %ebx, %edi
leaq -0x160(%rbp), %rsi
movl $0xe, %edx
callq 0x524f
testl %eax, %eax
js 0x7ea8
cmpb $0x4, -0x160(%rbp)
jne 0x7eb9
cmpb $0x20, -0x15c(%rbp)
jne 0x7eb9
cmpb $-0x4, -0x15b(%rbp)
jne 0x7eb9
movzbl -0x159(%rbp), %r14d
movzbl -0x15a(%rbp), %r12d
cmpb $0x0, 0x7663(%rip)      # 0xf2e0
jne 0x7ec0
testl %r12d, %r12d
jne 0x7eea
movzbl %r14b, %r8d
movzbl %r15b, %ecx
cmpl %ecx, %r8d
je 0x7ca8
movl -0x50(%rbp), %eax
cmpl %eax, 0x7a8e(%rip)      # 0xf730
jne 0x8038
movl -0x34(%rbp), %ecx
cmpl %r8d, %ecx
movl $0x0, %eax
movl $0xfc, %edx
cmovaq %rdx, %rax
incb %r13b
cmpb -0x48(%rbp), %r13b
movl -0x2c(%rbp), %edx
movq -0x40(%rbp), %r8
jbe 0x7e44
jmp 0x7f35
movl $0x100, %edx            # imm = 0x100
leaq -0x160(%rbp), %rdi
xorl %esi, %esi
movq %r8, %r15
callq 0x20d0
movw $0xfc20, -0x160(%rbp)   # imm = 0xFC20
leaq 0xbed(%rip), %rax       # 0x88e8
movq %rax, -0x318(%rbp)
movl $0xe, %edi
leaq -0x318(%rbp), %rsi
xorl %edx, %edx
callq 0x2060
movl $0x2, %edi
callq 0x20f0
movl $0xfc, %edx
leaq -0x26f(%rbp), %rdi
xorl %esi, %esi
callq 0x20d0
movb %bl, -0x270(%rbp)
testq %r15, %r15
je 0x7d4f
movl %r14d, %edx
leaq -0x26f(%rbp), %rdi
movq %r15, %rsi
callq 0x2180
movl %r12d, %eax
andl $0x7f, %eax
testb %bl, %bl
cmovnsl %r12d, %eax
movl %eax, 0x79d3(%rip)      # 0xf734
leal 0x1(%r14), %edx
movb %dl, -0x15e(%rbp)
leaq -0x15d(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x2180
addl $0x4, %r14d
leaq -0x160(%rbp), %rdi
movl %r14d, %esi
movl $0x1, %edx
callq 0x603c
movq %rax, %r14
movq 0x7960(%rip), %rdi      # 0xf700
testq %rdi, %rdi
je 0x7daa
callq 0x2030
movq %r14, 0x794f(%rip)      # 0xf700
movq %r14, %rsi
addq $0x8, %rsi
movl 0x4(%r14), %edx
movl -0x30(%rbp), %ebx
movl %ebx, %edi
callq 0x2070
cmpb $0x0, 0x7513(%rip)      # 0xf2e0
jne 0x7eaf
movl 0x795f(%rip), %eax      # 0xf738
cmpl 0x7955(%rip), %eax      # 0xf734
leaq -0x280(%rbp), %r14
je 0x7e13
movl %ebx, %edi
movq %r14, %rsi
callq 0x6241
cmpl $-0x1, %eax
je 0x8062
movq %r14, %rdi
movl %eax, %esi
callq 0x6298
movl 0x792d(%rip), %eax      # 0xf738
cmpl 0x7923(%rip), %eax      # 0xf734
jne 0x7de8
xorl %edi, %edi
callq 0x20f0
movl -0x2c(%rbp), %edx
movl -0x34(%rbp), %ecx
movq %r15, %r8
cmpl %r12d, %ecx
movl $0x0, %eax
movl $0xfc, %esi
cmovaq %rsi, %rax
incb %r13b
cmpb -0x48(%rbp), %r13b
movl -0x30(%rbp), %edi
ja 0x7f2b
addq %rax, %r8
movzbl %r13b, %edi
jmp 0x7af5
movq %r8, -0x40(%rbp)
movl %edi, %r12d
callq 0x3a3f
movl %r12d, %edi
movq -0x40(%rbp), %r8
movl -0x34(%rbp), %ecx
movl -0x2c(%rbp), %edx
jmp 0x7b78
movq 0x7183(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x316d(%rip), %rsi      # 0xafec
leaq 0x16b3(%rip), %rdx      # 0x9539
movl -0x30(%rbp), %ecx
movl %r12d, %r8d
movl %r14d, %r9d
xorl %eax, %eax
callq 0x2150
jmp 0x7bd7
movq %rax, %rdi
callq 0x3a96
jmp 0x7c24
callq 0x3b0b
jmp 0x7eef
callq 0x3a64
jmp 0x7dd3
callq 0x3ac1
jmp 0x7eef
movq 0x7131(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x3196(%rip), %rsi      # 0xb067
leaq 0x1661(%rip), %rdx      # 0x9539
movl %r14d, %ecx
movl %r12d, %r8d
xorl %eax, %eax
callq 0x2150
jmp 0x7c83
callq 0x3ae6
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x7c8c
movl %edi, %ebx
movzbl %r15b, %edi
callq 0x3a13
movl %ebx, %edi
movl -0x34(%rbp), %ecx
movl -0x2c(%rbp), %edx
jmp 0x7b46
movl %edi, %r14d
movzbl %bl, %edi
callq 0x39e7
movl %r14d, %edi
movl -0x34(%rbp), %ecx
movl -0x2c(%rbp), %edx
jmp 0x7b61
cmpl $0x2, %edx
jne 0x7f35
callq 0x6a11
movq 0x781c(%rip), %rdi      # 0xf758
callq 0x2030
xorl %r14d, %r14d
cmpb $0x0, 0x7395(%rip)      # 0xf2e0
jne 0x7fd5
movl %r14d, %eax
addq $0x2f8, %rsp            # imm = 0x2F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3790
jmp 0x77bf
movq (%r13), %rdi
leaq 0x2e45(%rip), %rsi      # 0xadc0
leaq 0x15b7(%rip), %rdx      # 0x9539
leaq 0x2e87(%rip), %rcx      # 0xae10
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2150
jmp 0x7723
cmpl $0x8723, %eax           # imm = 0x8723
jne 0x7438
movb 0x7766(%rip), %al       # 0xf70e
cmpb $0x8, %al
sete %dl
movzwl 0x7758(%rip), %ecx      # 0xf70c
cmpw $0xd, %cx
sete %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x80f6
movb $0x71, 0x7744(%rip)     # 0xf714
jmp 0x8110
callq 0x3b37
jmp 0x7f51
movw $0x8761, %ax            # imm = 0x8761
cmpl $0xa, %ecx
jne 0x8153
cmpb $0x2, %bl
je 0x8143
movzbl %bl, %ecx
cmpl $0x3, %ecx
jne 0x814c
movb $0x2f, 0x770c(%rip)     # 0xf714
jmp 0x8153
movq (%r13), %rdi
leaq 0x2cae(%rip), %rsi      # 0xacc6
leaq 0x151a(%rip), %rdx      # 0x9539
movl %r14d, %ecx
xorl %eax, %eax
callq 0x2150
jmp 0x797c
callq 0x3978
jmp 0x79e8
cmpb $0x0, 0x72a1(%rip)      # 0xf2e0
je 0x8081
movq 0x6fb0(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x2f6c(%rip), %rsi      # 0xafbe
leaq 0x14e0(%rip), %rdx      # 0x9539
xorl %eax, %eax
callq 0x2150
jmp 0x8081
movq 0x6f8f(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x30ab(%rip), %rsi      # 0xb11e
leaq 0x14bf(%rip), %rdx      # 0x9539
xorl %eax, %eax
callq 0x2150
movq 0x76d0(%rip), %rdi      # 0xf758
callq 0x2030
jmp 0x77bf
movq (%r13), %rdi
leaq 0x2bfc(%rip), %rsi      # 0xac99
leaq 0x1495(%rip), %rdx      # 0x9539
xorl %eax, %eax
callq 0x2150
jmp 0x79d1
callq 0x39c2
jmp 0x7a10
movl %r14d, %edi
callq 0x3884
jmp 0x78e9
callq 0x38d6
jmp 0x7956
callq 0x38fb
jmp 0x7913
callq 0x394c
jmp 0x7956
leaq -0x160(%rbp), %rdi
callq 0x3920
jmp 0x7956
cmpb $0x6, %al
sete %al
cmpw $0xb, %cx
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x815b
movb $0x5f, 0x7604(%rip)     # 0xf714
movw $0x8723, %ax            # imm = 0x8723
jmp 0x7438
movq (%r13), %rdi
leaq 0x2e13(%rip), %rsi      # 0xaf37
leaq 0x140e(%rip), %rdx      # 0x9539
movq %r8, %r14
movl %ebx, %r8d
xorl %eax, %eax
callq 0x2150
movq %r14, %r8
movl -0x34(%rbp), %ecx
jmp 0x7adf
movb $0x1f, 0x75ca(%rip)     # 0xf714
jmp 0x8153
movb $0x0, 0x75c1(%rip)      # 0xf714
movl -0x30(%rbp), %ebx
jmp 0x7438
callq 0x376b
jmp 0x77bf
movl %r12d, %edi
callq 0x36c8
movzbl %al, %edi
callq 0x36fd
movl %r12d, %edi
callq 0x3736