// File: /workspace/github_c_makefile_star2_O0/TeaInside[P]teavpn/src/teavpn/client/tcp.c
// Function: teavpn_tcp_client
__attribute__((force_align_arg_pointer)) uint8_t teavpn_tcp_client(client_config *config)
{
	fd_set rd_set;
	uint64_t seq = 0;
	int fd_ret, max_fd;
	teavpn_packet packet;
	register ssize_t nwrite, nread;

	/**
	 * To store config file buffer (parsing).
	 *
	 * Avoid to use heap as long as it
	 * is still eligible to use stack.
	 *
	 * (heap is slower than stack)
	 */
	char config_buffer[4096];

	/**
	 * Use packet buffer as struct sockadd_in.
	 */
	#define server_addr ((struct sockaddr_in *)&(packet.data.data))


	if (teavpn_tcp_client_init(config_buffer, config)) {
		return 1;
	}


	/**
	 * Prepare server address.
	 */
	memset(server_addr, 0, sizeof(struct sockaddr_in));
	server_addr->sin_family = AF_INET;
	server_addr->sin_port = htons(config->server_port);
	server_addr->sin_addr.s_addr = inet_addr(config->server_ip);



	/**
	 * Conncet to TeaVPN server.
	 */
	debug_log(0, "Connecting to %s:%d...", config->server_ip, config->server_port);
	if (connect(net_fd, (struct sockaddr *)server_addr, sizeof(struct sockaddr_in)) < 0) {
		debug_log(0, "Error on connect");
		perror("Error on connect");
		goto close;
	}


	/**
	 * Prepare auth packet.
	 */
	packet.info.type = TEAVPN_PACKET_AUTH;
	packet.info.len = OFFSETOF(teavpn_packet, data) + sizeof(struct teavpn_packet_auth);
	packet.data.auth.username_len = config->username_len;
	packet.data.auth.password_len = config->password_len;
	strcpy(packet.data.auth.username, config->username);
	strcpy(packet.data.auth.password, config->password);

	/**
	 * Debug only.
	 */
	#ifdef TEAVPN_DEBUG
	debug_log(3, "username: \"%s\"", packet.data.auth.username);
	debug_log(3, "password: \"%s\"", packet.data.auth.password);
	debug_log(3, "username_len: %d", packet.data.auth.username_len);
	debug_log(3, "password_len: %d", packet.data.auth.password_len);
	#endif

	/**
	 * Send auth packet to server.
	 */
	packet.info.seq = ++seq; // seq 1
	nwrite = write(net_fd, &packet, TEAVPN_PACK(sizeof(packet.data.auth)));

	debug_log(3, "[%ld] Write auth packet to server %ld bytes", seq, nwrite);

	if (nwrite == 0) {
		debug_log(0, "Connection reset by peer");
		goto close;
	}

	if (nwrite < 0) {
		debug_log(0, "Error write to net_fd");
		perror("Error write to net_fd");
		goto close;
	}



	/**
	 * Read server response.
	 */
	seq++; // seq 2
	nread = read(net_fd, &packet, sizeof(packet));

	debug_log(
		3,
		"[%ld] Read server signal %ld bytes (client_seq: %ld) (server_seq: %ld) (seq %s)",
		seq, nread, seq, packet.info.seq, (seq == packet.info.seq) ? "match" : "invalid"
	);

	if (nread == 0) {
		debug_log(0, "Connection reset by peer");
		goto close;
	}

	if (seq != packet.info.seq) {
		debug_log(0, "Invalid packet sequence (client_seq: %ld) (server_seq: %ld)",
			seq, packet.info.seq);
		goto close;
	}

	/**
	 * Check server response.
	 */
	if (packet.info.type == TEAVPN_PACKET_SIG) {
		if (packet.data.sig.sig == TEAVPN_SIG_AUTH_OK) {
			debug_log(0, "Auth OK");
		} else {
			print_err_sig(packet.data.sig.sig);
			goto close;
		}
	} else {
		debug_log(0, "Invalid server response");
		goto close;
	}



	/**
	 * Send sig ack to server.
	 */
	packet.info.type = TEAVPN_PACKET_SIG;
	packet.data.sig.sig = TEAVPN_SIG_ACK;
	packet.info.seq = ++seq; // seq 3

	printf("info.type: %d = %d\n", packet.info.type, TEAVPN_PACKET_SIG);
	printf("sig.sig: %d = %d\n", packet.data.sig.sig, TEAVPN_SIG_ACK);
	fflush(stdout);
	nwrite = write(net_fd, &packet, TEAVPN_PACK(sizeof(packet.data.sig)));

	debug_log(3, "[%ld] Write sig ack to server %ld bytes", seq, nwrite);

	if (nwrite == 0) {
		debug_log(0, "Connection reset by peer");
		goto close;
	}

	if (nwrite < 0) {
		debug_log(0, "Error write to net_fd");
		perror("Error write to net_fd");
		goto close;
	}



	/**
	 * Read network interface configuration.
	 */
	seq++; // seq 4
	nread = read(net_fd, &packet, sizeof(packet));

	if (seq != packet.info.seq) {
		debug_log(0, "Invalid packet sequence (client_seq: %ld) (server_seq: %ld)",
			seq, packet.info.seq);
		goto close;
	}

	if (packet.info.type != TEAVPN_PACKET_CONF) {
		debug_log(0, "Invalid packet");
		goto close;
	}

	/**
	 * Debug only.
	 */
	#ifdef TEAVPN_DEBUG
	debug_log(3, "inet4: \"%s\"\n", packet.data.conf.inet4);
	debug_log(3, "inet4_bc: \"%s\"\n", packet.data.conf.inet4_broadcast);
	#endif



	/**
	 * Apply network interface configuration to TUN/TAP interface.
	 */
	if (!teavpn_tcp_client_init_iface(config, &(packet.data.conf))) {
		debug_log(0, "Cannot init TUN/TAP interface\n");
		goto close;
	}



	/**
	 * Calculate maximum value between tap_fd and net_fd.
	 */
	max_fd = (tap_fd > net_fd) ? tap_fd : net_fd;

	packet.info.type = TEAVPN_PACKET_DATA;

	/**
	 * TeaVPN client event loop.
	 */
	while (true) {
		/**
		 * Set rd_set to zero.
		 *
		 * This is a compulsory step in using
		 * select(2) inside of an event loop.
		 */
		FD_ZERO(&rd_set);


		/**
		 * Add file descriptors to rd_set.
		 */
		FD_SET(net_fd, &rd_set);
		FD_SET(tap_fd, &rd_set);


		/**
		 * Block main process until there is one or more ready fd.
		 * Read `man 2 select_tut` for details.
		 */
		fd_ret = select(max_fd + 1, &rd_set, NULL, NULL, NULL);

		/**
		 * Got interrupt signal.
		 */
		if ((fd_ret < 0) && (errno == EINTR)) {
			debug_log(2, "select(2) got interrupt signal");
			continue;
		}

		/**
		 * Got an error.
		 */
		if (fd_ret < 0) {
			debug_log(0, "select(2) got an error");
			perror("select()");
			continue;
		}


		/**
		 * Read data from client TUN/TAP and write it to server fd.
		 */
		if (FD_ISSET(tap_fd, &rd_set)) {
			/**
			 * Read from TUN/TAP.
			 */
			nread = read(tap_fd, &(packet.data.data), TEAVPN_TAP_READ_SIZE);
			debug_log(4, "Read from tap_fd %ld bytes", nread);
			if (nread < 0) {
				debug_log(0, "Error read from tap_fd");
				perror("Error read from tap_fd");
				goto next_1;
			}

			/**
			 * Write to server fd.
			 */
			packet.info.seq = ++seq;
			packet.info.len = TEAVPN_PACK(nread);
			nwrite = write(net_fd, &packet, TEAVPN_PACK(nread));
			debug_log(3, "[%ld] Write data to server %ld bytes", seq, nwrite);
			if (nwrite == 0) {
				debug_log(0, "Connection reset by peer");
				goto close;
			}
			if (nwrite < 0) {
				debug_log(0, "Error write to net_fd");
				perror("Error write to net_fd");
				goto next_1;
			}
		}


		next_1:
		/**
		 * Read data from server and write it to TUN/TAP interface.
		 */
		if (FD_ISSET(net_fd, &rd_set)) {
			/**
			 * Read from server fd.
			 */
			seq++;
			nread = read(net_fd, &packet, sizeof(packet));

			if (nread == 0) {
				debug_log(0, "Connection reset by peer");
				goto close;
			}
			if (nread < 0) {
				debug_log(0, "Error read from net_fd");
				perror("Error read from net_fd");
				goto next_2;
			}

			if (packet.info.type == TEAVPN_PACKET_DATA) {

				while (nread < (packet.info.len)) {
					register ssize_t tmp_nread;

					debug_log(3, "Read extra %ld/%ld bytes", nread, packet.info.len);
					tmp_nread = read(
						net_fd,
						&(((char *)&packet)[nread]),
						packet.info.len - nread
					);

					if (tmp_nread < 0) {
						perror("Error read extra");

					} else {
						nread += tmp_nread;
					}
				}

				debug_log(3, "[%ld] Read data from server %ld bytes (client_seq: %ld) (server_seq: %ld) (seq %s)",
					seq, nread, seq, packet.info.seq, (seq == packet.info.seq) ? "match" : "invalid");

				/**
				 * Write to TUN/TAP.
				 */
				nwrite = write(tap_fd, &(packet.data.data), nread - OFFSETOF(teavpn_packet, data));
				debug_log(4, "Write to tap_fd %ld bytes", nwrite);
				if (nread < 0) {
					debug_log(0, "Error read from tap_fd");
					perror("Error read from tap_fd");
					goto next_2;
				}
			}
		}

		next_2:
		(void)1;
	}

close:
	close(tap_fd);
	close(net_fd);

	return 1;

	#undef server_addr
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
andq $-0x10, %rsp
subq $0x2110, %rsp           # imm = 0x2110
movq %fs:0x28, %rax
movq %rax, 0x2108(%rsp)
movq %rdi, 0x60(%rsp)
movq $0x0, 0x58(%rsp)
leaq 0x70(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x4dc0
testb $0x1, %al
jne 0x4163
jmp 0x416d
movb $0x1, 0x6f(%rsp)
jmp 0x4d8e
leaq 0x1078(%rsp), %rdi
addq $0x10, %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x2190
movw $0x2, 0x1088(%rsp)
movq 0x60(%rsp), %rax
movzwl 0x3a(%rax), %edi
callq 0x2140
movw %ax, 0x108a(%rsp)
movq 0x60(%rsp), %rax
movq (%rax), %rdi
callq 0x2210
movl %eax, 0x108c(%rsp)
leaq 0xa264(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x41e8
movq 0x60(%rsp), %rax
movq (%rax), %rsi
movq 0x60(%rsp), %rax
movzwl 0x3a(%rax), %edx
leaq 0x6213(%rip), %rdi      # 0xa3f4
movb $0x0, %al
callq 0x84c0
movl 0xa172(%rip), %edi      # 0xe360
leaq 0x1078(%rsp), %rsi
addq $0x10, %rsi
movl $0x10, %edx
callq 0x23c0
cmpl $0x0, %eax
jge 0x4238
leaq 0xa214(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x4227
leaq 0x61eb(%rip), %rdi      # 0xa40b
movb $0x0, %al
callq 0x84c0
leaq 0x61dd(%rip), %rdi      # 0xa40b
callq 0x2360
jmp 0x4d73
movl $0x1, 0x1078(%rsp)
xorl %eax, %eax
addq $0x10, %rax
addq $0x202, %rax            # imm = 0x202
movw %ax, 0x107c(%rsp)
movq 0x60(%rsp), %rax
movb 0x38(%rax), %al
movb %al, 0x1088(%rsp)
movq 0x60(%rsp), %rax
movb 0x39(%rax), %al
movb %al, 0x1089(%rsp)
leaq 0x1078(%rsp), %rdi
addq $0x10, %rdi
addq $0x2, %rdi
movq 0x60(%rsp), %rax
movq 0x28(%rax), %rsi
callq 0x2070
leaq 0x1078(%rsp), %rdi
addq $0x10, %rdi
addq $0x102, %rdi            # imm = 0x102
movq 0x60(%rsp), %rax
movq 0x30(%rax), %rsi
callq 0x2070
leaq 0xa169(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
movl $0x3, %eax
cmpl %ecx, %eax
jg 0x42e5
leaq 0x1078(%rsp), %rsi
addq $0x10, %rsi
addq $0x2, %rsi
leaq 0x613e(%rip), %rdi      # 0xa41c
movb $0x0, %al
callq 0x84c0
leaq 0xa138(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
movl $0x3, %eax
cmpl %ecx, %eax
jg 0x4319
leaq 0x1078(%rsp), %rsi
addq $0x10, %rsi
addq $0x102, %rsi            # imm = 0x102
leaq 0x6119(%rip), %rdi      # 0xa42b
movb $0x0, %al
callq 0x84c0
leaq 0xa104(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
movl $0x3, %eax
cmpl %ecx, %eax
jg 0x4342
movzbl 0x1088(%rsp), %esi
leaq 0x60ff(%rip), %rdi      # 0xa43a
movb $0x0, %al
callq 0x84c0
leaq 0xa0db(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
movl $0x3, %eax
cmpl %ecx, %eax
jg 0x436b
movzbl 0x1089(%rsp), %esi
leaq 0x60e7(%rip), %rdi      # 0xa44b
movb $0x0, %al
callq 0x84c0
movq 0x58(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x58(%rsp)
movq %rax, 0x1080(%rsp)
movl 0x9fd9(%rip), %edi      # 0xe360
leaq 0x1078(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
addq $0x10, %rdx
addq $0x202, %rdx            # imm = 0x202
callq 0x20b0
movq %rax, 0x48(%rsp)
leaq 0xa075(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
movl $0x3, %eax
cmpl %ecx, %eax
jg 0x43d3
movq 0x58(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0x6090(%rip), %rdi      # 0xa45c
movb $0x0, %al
callq 0x84c0
cmpq $0x0, 0x48(%rsp)
jne 0x43fe
leaq 0xa042(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x43f9
leaq 0x6096(%rip), %rdi      # 0xa488
movb $0x0, %al
callq 0x84c0
jmp 0x4d73
cmpq $0x0, 0x48(%rsp)
jge 0x4435
leaq 0xa017(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x4424
leaq 0x6084(%rip), %rdi      # 0xa4a1
movb $0x0, %al
callq 0x84c0
leaq 0x6076(%rip), %rdi      # 0xa4a1
callq 0x2360
jmp 0x4d73
movq 0x58(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x58(%rsp)
movl 0x9f17(%rip), %edi      # 0xe360
leaq 0x1078(%rsp), %rsi
movl $0x1010, %edx           # imm = 0x1010
callq 0x21d0
movq %rax, 0x40(%rsp)
leaq 0x9fbd(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
movl $0x3, %eax
cmpl %ecx, %eax
jg 0x44ba
movq 0x58(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq 0x58(%rsp), %rcx
movq 0x1080(%rsp), %r8
movq 0x58(%rsp), %rdi
movq 0x1080(%rsp), %r10
leaq 0x606f(%rip), %r9       # 0xa50d
leaq 0x6062(%rip), %rax      # 0xa507
cmpq %r10, %rdi
cmoveq %rax, %r9
leaq 0x6004(%rip), %rdi      # 0xa4b7
movb $0x0, %al
callq 0x84c0
cmpq $0x0, 0x40(%rsp)
jne 0x44e5
leaq 0x9f5b(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x44e0
leaq 0x5faf(%rip), %rdi      # 0xa488
movb $0x0, %al
callq 0x84c0
jmp 0x4d73
movq 0x58(%rsp), %rax
cmpq 0x1080(%rsp), %rax
je 0x4524
leaq 0x9f29(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x451f
movq 0x58(%rsp), %rsi
movq 0x1080(%rsp), %rdx
leaq 0x5ffd(%rip), %rdi      # 0xa515
movb $0x0, %al
callq 0x84c0
jmp 0x4d73
cmpl $0x4, 0x1078(%rsp)
jne 0x456e
cmpl $0x2, 0x1088(%rsp)
jne 0x4558
leaq 0x9ee5(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x4556
leaq 0x6002(%rip), %rdi      # 0xa551
movb $0x0, %al
callq 0x84c0
jmp 0x456c
movl 0x1088(%rsp), %eax
movzbl %al, %edi
callq 0x5040
jmp 0x4d73
jmp 0x4591
leaq 0x9eaf(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x458c
leaq 0x5fd4(%rip), %rdi      # 0xa559
movb $0x0, %al
callq 0x84c0
jmp 0x4d73
movl $0x4, 0x1078(%rsp)
movl $0x10, 0x1088(%rsp)
movq 0x58(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x58(%rsp)
movq %rax, 0x1080(%rsp)
movl 0x1078(%rsp), %esi
leaq 0x5fa6(%rip), %rdi      # 0xa571
movl $0x4, %edx
movb $0x0, %al
callq 0x2150
movl 0x1088(%rsp), %esi
leaq 0x5fa0(%rip), %rdi      # 0xa585
movl $0x10, %edx
movb $0x0, %al
callq 0x2150
movq 0x99d8(%rip), %rax      # 0xdfd0
movq (%rax), %rdi
callq 0x22d0
movl 0x9d5a(%rip), %edi      # 0xe360
leaq 0x1078(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
addq $0x10, %rdx
addq $0x4, %rdx
callq 0x20b0
movq %rax, 0x48(%rsp)
leaq 0x9df9(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
movl $0x3, %eax
cmpl %ecx, %eax
jg 0x464f
movq 0x58(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0x5f4f(%rip), %rdi      # 0xa597
movb $0x0, %al
callq 0x84c0
cmpq $0x0, 0x48(%rsp)
jne 0x467a
leaq 0x9dc6(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x4675
leaq 0x5e1a(%rip), %rdi      # 0xa488
movb $0x0, %al
callq 0x84c0
jmp 0x4d73
cmpq $0x0, 0x48(%rsp)
jge 0x46b1
leaq 0x9d9b(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x46a0
leaq 0x5e08(%rip), %rdi      # 0xa4a1
movb $0x0, %al
callq 0x84c0
leaq 0x5dfa(%rip), %rdi      # 0xa4a1
callq 0x2360
jmp 0x4d73
movq 0x58(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x58(%rsp)
movl 0x9c9b(%rip), %edi      # 0xe360
leaq 0x1078(%rsp), %rsi
movl $0x1010, %edx           # imm = 0x1010
callq 0x21d0
movq %rax, 0x40(%rsp)
movq 0x58(%rsp), %rax
cmpq 0x1080(%rsp), %rax
je 0x471b
leaq 0x9d32(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x4716
movq 0x58(%rsp), %rsi
movq 0x1080(%rsp), %rdx
leaq 0x5e06(%rip), %rdi      # 0xa515
movb $0x0, %al
callq 0x84c0
jmp 0x4d73
cmpl $0x8, 0x1078(%rsp)
je 0x4748
leaq 0x9cf8(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x4743
leaq 0x5e83(%rip), %rdi      # 0xa5bf
movb $0x0, %al
callq 0x84c0
jmp 0x4d73
leaq 0x9cd5(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
movl $0x3, %eax
cmpl %ecx, %eax
jg 0x4775
leaq 0x1078(%rsp), %rsi
addq $0x10, %rsi
leaq 0x5e60(%rip), %rdi      # 0xa5ce
movb $0x0, %al
callq 0x84c0
leaq 0x9ca8(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
movl $0x3, %eax
cmpl %ecx, %eax
jg 0x47a6
leaq 0x1078(%rsp), %rsi
addq $0x10, %rsi
addq $0x13, %rsi
leaq 0x5e3c(%rip), %rdi      # 0xa5db
movb $0x0, %al
callq 0x84c0
movq 0x60(%rsp), %rdi
leaq 0x1078(%rsp), %rsi
addq $0x10, %rsi
callq 0x5120
testb $0x1, %al
jne 0x47e3
leaq 0x9c5d(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x47de
leaq 0x5e14(%rip), %rdi      # 0xa5eb
movb $0x0, %al
callq 0x84c0
jmp 0x4d73
movl 0x9b7b(%rip), %eax      # 0xe364
cmpl 0x9b71(%rip), %eax      # 0xe360
jle 0x47fd
movl 0x9b6d(%rip), %eax      # 0xe364
movl %eax, 0x24(%rsp)
jmp 0x4807
movl 0x9b5d(%rip), %eax      # 0xe360
movl %eax, 0x24(%rsp)
movl 0x24(%rsp), %eax
movl %eax, 0x50(%rsp)
movl $0x2, 0x1078(%rsp)
jmp 0x481c
leaq 0x2088(%rsp), %rax
movq %rax, 0x30(%rsp)
movl $0x0, 0x3c(%rsp)
movl 0x3c(%rsp), %eax
cmpq $0x10, %rax
jae 0x4859
movq 0x30(%rsp), %rax
movl 0x3c(%rsp), %ecx
movq $0x0, (%rax,%rcx,8)
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x4831
jmp 0x485b
movl 0x9aff(%rip), %eax      # 0xe360
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
movl 0x9ae2(%rip), %eax      # 0xe360
movl $0x40, %esi
cltd
idivl %esi
cltq
orq 0x2088(%rsp,%rax,8), %rcx
movq %rcx, 0x2088(%rsp,%rax,8)
movl 0x9ac6(%rip), %eax      # 0xe364
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
movl 0x9aa9(%rip), %eax      # 0xe364
movl $0x40, %esi
cltd
idivl %esi
cltq
orq 0x2088(%rsp,%rax,8), %rcx
movq %rcx, 0x2088(%rsp,%rax,8)
movl 0x50(%rsp), %edi
addl $0x1, %edi
leaq 0x2088(%rsp), %rsi
xorl %eax, %eax
movl %eax, %r8d
movq %r8, %rdx
movq %r8, %rcx
callq 0x2290
movl %eax, 0x54(%rsp)
cmpl $0x0, 0x54(%rsp)
jge 0x492f
callq 0x2050
cmpl $0x4, (%rax)
jne 0x492f
leaq 0x9b14(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
movl $0x2, %eax
cmpl %ecx, %eax
jg 0x492a
leaq 0x5ce7(%rip), %rdi      # 0xa60a
movb $0x0, %al
callq 0x84c0
jmp 0x481a
cmpl $0x0, 0x54(%rsp)
jge 0x4965
leaq 0x9ae7(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x4954
leaq 0x5cdc(%rip), %rdi      # 0xa629
movb $0x0, %al
callq 0x84c0
leaq 0x5ce5(%rip), %rdi      # 0xa640
callq 0x2360
jmp 0x481a
movl 0x99f9(%rip), %eax      # 0xe364
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq 0x2088(%rsp,%rax,8), %rax
movq %rax, 0x18(%rsp)
movl 0x99dc(%rip), %eax      # 0xe364
movl $0x40, %ecx
cltd
idivl %ecx
movq 0x18(%rsp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x4b07
movl 0x99af(%rip), %edi      # 0xe364
leaq 0x1078(%rsp), %rsi
addq $0x10, %rsi
movl $0xbb8, %edx            # imm = 0xBB8
callq 0x21d0
movq %rax, 0x40(%rsp)
leaq 0x9a4d(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
movl $0x4, %eax
cmpl %ecx, %eax
jg 0x49f6
movq 0x40(%rsp), %rsi
leaq 0x5c5a(%rip), %rdi      # 0xa649
movb $0x0, %al
callq 0x84c0
cmpq $0x0, 0x40(%rsp)
jge 0x4a2d
leaq 0x9a1f(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x4a1c
leaq 0x5c4f(%rip), %rdi      # 0xa664
movb $0x0, %al
callq 0x84c0
leaq 0x5c41(%rip), %rdi      # 0xa664
callq 0x2360
jmp 0x4b09
movq 0x58(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x58(%rsp)
movq %rax, 0x1080(%rsp)
xorl %eax, %eax
addq $0x10, %rax
addq 0x40(%rsp), %rax
movw %ax, 0x107c(%rsp)
movl 0x9904(%rip), %edi      # 0xe360
xorl %eax, %eax
movl %eax, %edx
addq $0x10, %rdx
addq 0x40(%rsp), %rdx
leaq 0x1078(%rsp), %rsi
callq 0x20b0
movq %rax, 0x48(%rsp)
leaq 0x99a2(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
movl $0x3, %eax
cmpl %ecx, %eax
jg 0x4aa6
movq 0x58(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0x5bdc(%rip), %rdi      # 0xa67b
movb $0x0, %al
callq 0x84c0
cmpq $0x0, 0x48(%rsp)
jne 0x4ad1
leaq 0x996f(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x4acc
leaq 0x59c3(%rip), %rdi      # 0xa488
movb $0x0, %al
callq 0x84c0
jmp 0x4d73
cmpq $0x0, 0x48(%rsp)
jge 0x4b05
leaq 0x9944(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x4af7
leaq 0x59b1(%rip), %rdi      # 0xa4a1
movb $0x0, %al
callq 0x84c0
leaq 0x59a3(%rip), %rdi      # 0xa4a1
callq 0x2360
jmp 0x4b09
jmp 0x4b07
jmp 0x4b09
movl 0x9851(%rip), %eax      # 0xe360
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq 0x2088(%rsp,%rax,8), %rax
movq %rax, 0x10(%rsp)
movl 0x9834(%rip), %eax      # 0xe360
movl $0x40, %ecx
cltd
idivl %ecx
movq 0x10(%rsp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x4d6c
movq 0x58(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x58(%rsp)
movl 0x97f9(%rip), %edi      # 0xe360
leaq 0x1078(%rsp), %rsi
movl $0x1010, %edx           # imm = 0x1010
callq 0x21d0
movq %rax, 0x40(%rsp)
cmpq $0x0, 0x40(%rsp)
jne 0x4ba9
leaq 0x9897(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x4ba4
leaq 0x58eb(%rip), %rdi      # 0xa488
movb $0x0, %al
callq 0x84c0
jmp 0x4d73
cmpq $0x0, 0x40(%rsp)
jge 0x4be0
leaq 0x986c(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x4bcf
leaq 0x5ad8(%rip), %rdi      # 0xa6a0
movb $0x0, %al
callq 0x84c0
leaq 0x5aca(%rip), %rdi      # 0xa6a0
callq 0x2360
jmp 0x4d6e
cmpl $0x2, 0x1078(%rsp)
jne 0x4d6a
jmp 0x4bf0
movq 0x40(%rsp), %rax
movzwl 0x107c(%rsp), %ecx
cmpq %rcx, %rax
jge 0x4c8a
leaq 0x9817(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
movl $0x3, %eax
cmpl %ecx, %eax
jg 0x4c34
movq 0x40(%rsp), %rsi
movzwl 0x107c(%rsp), %edx
leaq 0x5a8a(%rip), %rdi      # 0xa6b7
movb $0x0, %al
callq 0x84c0
movl 0x9726(%rip), %edi      # 0xe360
leaq 0x1078(%rsp), %rsi
addq 0x40(%rsp), %rsi
movzwl 0x107c(%rsp), %eax
movl %eax, %edx
subq 0x40(%rsp), %rdx
callq 0x21d0
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
jge 0x4c76
leaq 0x5a61(%rip), %rdi      # 0xa6d0
callq 0x2360
jmp 0x4c85
movq 0x28(%rsp), %rax
addq 0x40(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x4bf0
leaq 0x9793(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
movl $0x3, %eax
cmpl %ecx, %eax
jg 0x4ce4
movq 0x58(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq 0x58(%rsp), %rcx
movq 0x1080(%rsp), %r8
movq 0x58(%rsp), %rdi
movq 0x1080(%rsp), %r10
leaq 0x5845(%rip), %r9       # 0xa50d
leaq 0x5838(%rip), %rax      # 0xa507
cmpq %r10, %rdi
cmoveq %rax, %r9
leaq 0x5a04(%rip), %rdi      # 0xa6e1
movb $0x0, %al
callq 0x84c0
movl 0x967a(%rip), %edi      # 0xe364
leaq 0x1078(%rsp), %rsi
addq $0x10, %rsi
movq 0x40(%rsp), %rdx
xorl %eax, %eax
addq $0x10, %rax
subq %rax, %rdx
callq 0x20b0
movq %rax, 0x48(%rsp)
leaq 0x970f(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
movl $0x4, %eax
cmpl %ecx, %eax
jg 0x4d34
movq 0x48(%rsp), %rsi
leaq 0x5a07(%rip), %rdi      # 0xa734
movb $0x0, %al
callq 0x84c0
cmpq $0x0, 0x40(%rsp)
jge 0x4d68
leaq 0x96e1(%rip), %rax      # 0xe424
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x4d5a
leaq 0x5911(%rip), %rdi      # 0xa664
movb $0x0, %al
callq 0x84c0
leaq 0x5903(%rip), %rdi      # 0xa664
callq 0x2360
jmp 0x4d6e
jmp 0x4d6a
jmp 0x4d6c
jmp 0x4d6e
jmp 0x481a
movl 0x95eb(%rip), %edi      # 0xe364
callq 0x21b0
movl 0x95dc(%rip), %edi      # 0xe360
callq 0x21b0
movb $0x1, 0x6f(%rsp)
movb 0x6f(%rsp), %al
movb %al, 0xf(%rsp)
movq %fs:0x28, %rax
movq 0x2108(%rsp), %rcx
cmpq %rcx, %rax
jne 0x4db5
movb 0xf(%rsp), %al
movq %rbp, %rsp
popq %rbp
retq
callq 0x2100
nopw (%rax,%rax)