// File: /workspace/github_c_makefile_star2_O0/open-mesh-mirror[P]batmand/posix/tunnel.c
// Function: gw_listen
void *gw_listen(void *BATMANUNUSED(arg)) {

	struct batman_if *batman_if = (struct batman_if *)if_list.next;
	struct timeval tv;
	struct sockaddr_in addr, client_addr;
	struct gw_client *gw_client;
	char gw_addr[16], str[16], tun_dev[IFNAMSIZ];
	unsigned char buff[1501];
	int32_t res, max_sock, buff_len, tun_fd, tun_ifi;
	uint32_t addr_len, client_timeout, current_time;
	uint8_t my_tun_ip[4] ALIGN_WORD, next_free_ip[4] ALIGN_WORD;
	struct hashtable_t *wip_hash, *vip_hash;
	struct list_head_first free_ip_list;
	fd_set wait_sockets, tmp_wait_sockets;
	struct hash_it_t *hashit;
	struct free_ip *free_ip;
	struct list_head *list_pos, *list_pos_tmp;


	my_tun_ip[0] = next_free_ip[0] = 169;
	my_tun_ip[1] = next_free_ip[1] = 254;
	my_tun_ip[2] = next_free_ip[2] = 0;
	my_tun_ip[3] = 0;
	next_free_ip[3] = 1;

	addr_len = sizeof (struct sockaddr_in);
	client_timeout = get_time_msec();

	client_addr.sin_family = AF_INET;
	client_addr.sin_port = htons(PORT + 1);

	INIT_LIST_HEAD_FIRST(free_ip_list);

	if (add_dev_tun(batman_if, *(uint32_t *)my_tun_ip, tun_dev, sizeof(tun_dev), &tun_fd, &tun_ifi) < 0)
		return NULL;

	if (NULL == ( wip_hash = hash_new(128, compare_wip, choose_wip)))
		return NULL;

	if (NULL == (vip_hash = hash_new(128, compare_vip, choose_vip))) {
		hash_destroy(wip_hash);
		return NULL;
	}

	add_del_route(*(uint32_t *)my_tun_ip, 16, 0, 0, tun_ifi, tun_dev, 254, ROUTE_TYPE_UNICAST, ROUTE_ADD);


	FD_ZERO(&wait_sockets);
	FD_SET(batman_if->udp_tunnel_sock, &wait_sockets);
	FD_SET(tun_fd, &wait_sockets);

	max_sock = (batman_if->udp_tunnel_sock > tun_fd ? batman_if->udp_tunnel_sock : tun_fd);

	while ((!is_aborted()) && (gateway_class > 0)) {

		tv.tv_sec = 0;
		tv.tv_usec = 250;
		memcpy(&tmp_wait_sockets, &wait_sockets, sizeof(fd_set));

		res = select(max_sock + 1, &tmp_wait_sockets, NULL, NULL, &tv);

		current_time = get_time_msec();

		if ((res < 0) && (errno != EINTR)) {
			debug_output(0, "Error - can't select (gw_listen): %s \n", strerror(errno));
			break;
		}

		if (res <= 0)
			goto after_incoming_packet;

		/* traffic coming from the tunnel client via UDP */
		if (FD_ISSET(batman_if->udp_tunnel_sock, &tmp_wait_sockets)) {

			while ((buff_len = recvfrom(batman_if->udp_tunnel_sock, buff, sizeof(buff) - 1, 0, (struct sockaddr *)&addr, &addr_len)) > 0) {

				if (buff_len < 2) {
					addr_to_string(addr.sin_addr.s_addr, str, sizeof(str));
					debug_output(0, "Error - ignoring client packet from %s: packet too small (%i)\n", str, buff_len);
					continue;
				}

				switch(buff[0]) {
				/* client sends us data that should to the internet */
				case TUNNEL_DATA:
					/* compare_vip() adds 4 bytes, hence buff + 9 */
					gw_client = ((struct gw_client *)hash_find(vip_hash, buff + 9));

					/* check whether client IP is known */
					if ((gw_client == NULL) || ((gw_client->wip_addr != addr.sin_addr.s_addr) && (gw_client->nat_warn == 0))) {

						buff[0] = TUNNEL_IP_INVALID;
						addr_to_string(addr.sin_addr.s_addr, str, sizeof(str));

						debug_output(0, "Error - got packet from unknown client: %s (tunnelled sender ip %i.%i.%i.%i) \n", str, (uint8_t)buff[13], (uint8_t)buff[14], (uint8_t)buff[15], (uint8_t)buff[16]);

						if (gw_client == NULL) {

							/* TODO: only send refresh if the IP comes from 169.254.x.y ?? */
							/*if (sendto(batman_if->udp_tunnel_sock, buff, buff_len, 0, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0)
								debug_output(0, "Error - can't send invalid ip information to client (%s): %s \n", str, strerror(errno));*/

							/* auto assign a dummy address to output the NAT warning only once */
							gw_client = get_ip_addr(&addr, &wip_hash, &vip_hash, &free_ip_list, next_free_ip);

							addr_to_string(gw_client->vip_addr, str, sizeof(str));
							addr_to_string(addr.sin_addr.s_addr, gw_addr, sizeof(gw_addr));
							debug_output(3, "Gateway - assigned %s to unregistered client: %s \n", str, gw_addr);

						}

						debug_output(0, "Either enable NAT on the client or make sure this host has a route back to the sender address.\n");
						gw_client->nat_warn++;
					}

					if (write(tun_fd, buff + 1, buff_len - 1) < 0)
						debug_output(0, "Error - can't write packet into tun: %s\n", strerror(errno));

					break;
				/* client asks us to refresh the IP lease */
				case TUNNEL_KEEPALIVE_REQUEST:
					gw_client = ((struct gw_client *)hash_find(wip_hash, &addr.sin_addr.s_addr));

					buff[0] = TUNNEL_IP_INVALID;

					if (gw_client != NULL) {
						gw_client->last_keep_alive = current_time;
						buff[0] = TUNNEL_KEEPALIVE_REPLY;
					}

					addr_to_string(addr.sin_addr.s_addr, str, sizeof(str));

					if (sendto(batman_if->udp_tunnel_sock, buff, 100, 0, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) {
						debug_output(0, "Error - can't send %s to client (%s): %s \n", (buff[0] == TUNNEL_KEEPALIVE_REPLY ? "keep alive reply" : "invalid ip information"), str, strerror(errno));
						continue;
					}

					debug_output(3, "Gateway - send %s to client: %s \n", (buff[0] == TUNNEL_KEEPALIVE_REPLY ? "keep alive reply" : "invalid ip information"), str);
					break;
				/* client requests a fresh IP */
				case TUNNEL_IP_REQUEST:
					gw_client = get_ip_addr(&addr, &wip_hash, &vip_hash, &free_ip_list, next_free_ip);

					memcpy(buff + 1, (char *)&gw_client->vip_addr, 4);

					if (sendto(batman_if->udp_tunnel_sock, buff, 100, 0, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) {
						addr_to_string(addr.sin_addr.s_addr, str, sizeof (str));
						debug_output(0, "Error - can't send requested ip to client (%s): %s \n", str, strerror(errno));
						continue;
					}

					addr_to_string(gw_client->vip_addr, str, sizeof(str));
					addr_to_string(addr.sin_addr.s_addr, gw_addr, sizeof(gw_addr));
					debug_output(3, "Gateway - assigned %s to client: %s \n", str, gw_addr);
					break;
				}

			}

			if (errno != EWOULDBLOCK) {
				debug_output(0, "Error - gateway can't receive packet: %s\n", strerror(errno));
				break;
			}

		/* traffic coming from the internet that needs to be sent back to the client */
		} else if (FD_ISSET(tun_fd, &tmp_wait_sockets)) {

			while ((buff_len = read(tun_fd, buff + 1, sizeof(buff) - 2 )) > 0) {

				gw_client = ((struct gw_client *)hash_find(vip_hash, buff + 13));

				if (gw_client != NULL) {

					client_addr.sin_addr.s_addr = gw_client->wip_addr;
					client_addr.sin_port = gw_client->client_port;

					buff[0] = TUNNEL_DATA;

					if (sendto(batman_if->udp_tunnel_sock, buff, buff_len + 1, 0, (struct sockaddr *)&client_addr, sizeof(struct sockaddr_in)) < 0)
						debug_output(0, "Error - can't send data to client (%s): %s \n", str, strerror(errno));

				} else {

					addr_to_string( *(uint32_t *)(buff + 17), gw_addr, sizeof(gw_addr));
					debug_output(3, "Gateway - could not resolve packet: %s \n", gw_addr);

				}

			}

			if (errno != EWOULDBLOCK) {
				debug_output(0, "Error - gateway can't read tun data: %s\n", strerror(errno));
				break;
			}

		}

after_incoming_packet:

		/* close unresponsive client connections (free unused IPs) */
		if ((int)(current_time - (client_timeout + 60000)) > 0) {

			client_timeout = current_time;

			hashit = NULL;

			while (NULL != (hashit = hash_iterate(wip_hash, hashit))) {

				gw_client = hashit->bucket->data;

				if ((int)(current_time - (gw_client->last_keep_alive + IP_LEASE_TIMEOUT + GW_STATE_UNKNOWN_TIMEOUT)) > 0) {

					hash_remove_bucket(wip_hash, hashit);
					hash_remove(vip_hash, gw_client);

					free_ip = debugMalloc(sizeof(struct neigh_node), 210);

					INIT_LIST_HEAD(&free_ip->list);
					free_ip->addr = gw_client->vip_addr;

					list_add_tail( &free_ip->list, &free_ip_list );

					debugFree(gw_client, 1216);

				}

			}

		}

	}

	/* delete tun device and routes on exit */
	my_tun_ip[3] = 0;
	add_del_route( *(uint32_t *)my_tun_ip, 16, 0, 0, tun_ifi, tun_dev, 254, ROUTE_TYPE_UNICAST, ROUTE_DEL );

	del_dev_tun( tun_fd );

	hashit = NULL;

	while (NULL != (hashit = hash_iterate(wip_hash, hashit))) {

		gw_client = hashit->bucket->data;

		hash_remove_bucket(wip_hash, hashit);
		hash_remove(vip_hash, gw_client);

		debugFree(gw_client, 1217);

	}

	hash_destroy(wip_hash);
	hash_destroy(vip_hash);

	list_for_each_safe(list_pos, list_pos_tmp, &free_ip_list) {

		free_ip = list_entry(list_pos, struct free_ip, list);

		list_del((struct list_head *)&free_ip_list, list_pos, &free_ip_list);

		debugFree(free_ip, 1218);

	}

	return NULL;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x860, %rsp            # imm = 0x860
movq %rdi, -0x10(%rbp)
leaq 0x9f9a(%rip), %rax      # 0x1b3b0
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movb $-0x57, -0x690(%rbp)
movb $-0x57, -0x688(%rbp)
movb $-0x2, -0x68f(%rbp)
movb $-0x2, -0x687(%rbp)
movb $0x0, -0x68e(%rbp)
movb $0x0, -0x686(%rbp)
movb $0x0, -0x685(%rbp)
movb $0x1, -0x68d(%rbp)
movl $0x10, -0x678(%rbp)
callq 0xf260
movl %eax, -0x67c(%rbp)
movw $0x2, -0x48(%rbp)
movl $0x10d2, %edi           # imm = 0x10D2
callq 0x2170
movw %ax, -0x46(%rbp)
leaq -0x6b0(%rbp), %rax
movq %rax, -0x6b0(%rbp)
leaq -0x6b0(%rbp), %rax
movq %rax, -0x6a8(%rbp)
movq -0x18(%rbp), %rdi
movl -0x688(%rbp), %esi
leaq -0x80(%rbp), %rdx
movl $0x10, %ecx
leaq -0x670(%rbp), %r8
leaq -0x674(%rbp), %r9
callq 0xc220
movsbl %al, %eax
cmpl $0x0, %eax
jge 0x114d5
movq $0x0, -0x8(%rbp)
jmp 0x12016
movl $0x80, %edi
leaq 0xb4f(%rip), %rsi       # 0x12030
leaq 0xb78(%rip), %rdx       # 0x12060
callq 0x81d0
movq %rax, %rcx
movq %rcx, -0x698(%rbp)
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x1150b
movq $0x0, -0x8(%rbp)
jmp 0x12016
movl $0x80, %edi
leaq 0xbe9(%rip), %rsi       # 0x12100
leaq 0xc22(%rip), %rdx       # 0x12140
callq 0x81d0
movq %rax, %rcx
movq %rcx, -0x6a0(%rbp)
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x1154d
movq -0x698(%rbp), %rdi
callq 0x7f50
movq $0x0, -0x8(%rbp)
jmp 0x12016
movl -0x688(%rbp), %edi
movl -0x674(%rbp), %r8d
leaq -0x80(%rbp), %r9
movl $0x10, %esi
xorl %ecx, %ecx
movl %ecx, %edx
movl $0xfe, (%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0xa420
leaq -0x730(%rbp), %rax
movq %rax, -0x7e0(%rbp)
movl $0x0, -0x7d4(%rbp)
movl -0x7d4(%rbp), %eax
cmpq $0x10, %rax
jae 0x115cd
movq -0x7e0(%rbp), %rax
movl -0x7d4(%rbp), %ecx
movq $0x0, (%rax,%rcx,8)
movl -0x7d4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7d4(%rbp)
jmp 0x1159b
jmp 0x115cf
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
movl $0x40, %esi
cltd
idivl %esi
cltq
orq -0x730(%rbp,%rax,8), %rcx
movq %rcx, -0x730(%rbp,%rax,8)
movl -0x670(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
movl -0x670(%rbp), %eax
movl $0x40, %esi
cltd
idivl %esi
cltq
orq -0x730(%rbp,%rax,8), %rcx
movq %rcx, -0x730(%rbp,%rax,8)
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
cmpl -0x670(%rbp), %eax
jle 0x11669
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x804(%rbp)
jmp 0x11675
movl -0x670(%rbp), %eax
movl %eax, -0x804(%rbp)
movl -0x804(%rbp), %eax
movl %eax, -0x668(%rbp)
callq 0xfaf0
movb %al, %cl
xorl %eax, %eax
cmpb $0x0, %cl
movb %al, -0x805(%rbp)
jne 0x116ab
leaq 0x9cbd(%rip), %rax      # 0x1b359
movzbl (%rax), %eax
cmpl $0x0, %eax
setg %al
movb %al, -0x805(%rbp)
movb -0x805(%rbp), %al
testb $0x1, %al
jne 0x116ba
jmp 0x11eb5
movq $0x0, -0x28(%rbp)
movq $0xfa, -0x20(%rbp)
leaq -0x7b0(%rbp), %rdi
leaq -0x730(%rbp), %rsi
movl $0x80, %edx
callq 0x22c0
movl -0x668(%rbp), %edi
addl $0x1, %edi
leaq -0x7b0(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
leaq -0x28(%rbp), %r8
movq %rcx, %rdx
callq 0x22f0
movl %eax, -0x664(%rbp)
callq 0xf260
movl %eax, -0x680(%rbp)
cmpl $0x0, -0x664(%rbp)
jge 0x1174a
callq 0x2070
cmpl $0x4, (%rax)
je 0x1174a
callq 0x2070
movl (%rax), %edi
callq 0x24a0
movq %rax, %rdx
xorl %edi, %edi
leaq 0x619f(%rip), %rsi      # 0x178dd
movb $0x0, %al
callq 0x123f0
jmp 0x11eb5
cmpl $0x0, -0x664(%rbp)
jg 0x11758
jmp 0x11d9f
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq -0x7b0(%rbp,%rax,8), %rax
movq %rax, -0x810(%rbp)
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x810(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x11c0d
jmp 0x117aa
movq -0x18(%rbp), %rax
movl 0x18(%rax), %edi
leaq -0x660(%rbp), %rsi
leaq -0x38(%rbp), %rax
movq %rax, -0x7e8(%rbp)
movq -0x7e8(%rbp), %r8
movl $0x5dc, %edx            # imm = 0x5DC
xorl %ecx, %ecx
leaq -0x678(%rbp), %r9
callq 0x2350
movl %eax, -0x66c(%rbp)
cmpl $0x0, %eax
jle 0x11bda
cmpl $0x2, -0x66c(%rbp)
jge 0x11822
movl -0x34(%rbp), %edi
leaq -0x70(%rbp), %rsi
movl $0x10, %edx
callq 0xfa90
leaq -0x70(%rbp), %rdx
movl -0x66c(%rbp), %ecx
xorl %edi, %edi
leaq 0x60eb(%rip), %rsi      # 0x17904
movb $0x0, %al
callq 0x123f0
jmp 0x117aa
movzbl -0x660(%rbp), %eax
movl %eax, -0x814(%rbp)
subl $0x1, %eax
je 0x1185b
jmp 0x11836
movl -0x814(%rbp), %eax
subl $0x2, %eax
je 0x11adf
jmp 0x11847
movl -0x814(%rbp), %eax
subl $0x4, %eax
je 0x119c4
jmp 0x11bd5
movq -0x6a0(%rbp), %rdi
leaq -0x660(%rbp), %rsi
addq $0x9, %rsi
callq 0x83f0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x1189d
movq -0x50(%rbp), %rax
movl (%rax), %eax
cmpl -0x34(%rbp), %eax
je 0x11978
movq -0x50(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x0, %eax
jne 0x11978
movb $0x3, -0x660(%rbp)
movl -0x34(%rbp), %edi
leaq -0x70(%rbp), %rsi
movl $0x10, %edx
callq 0xfa90
leaq -0x70(%rbp), %rdx
movzbl -0x653(%rbp), %ecx
movzbl -0x652(%rbp), %r8d
movzbl -0x651(%rbp), %r9d
movzbl -0x650(%rbp), %eax
xorl %edi, %edi
leaq 0x6063(%rip), %rsi      # 0x17943
movl %eax, (%rsp)
movb $0x0, %al
callq 0x123f0
cmpq $0x0, -0x50(%rbp)
jne 0x1195b
leaq -0x690(%rbp), %r8
leaq -0x38(%rbp), %rdi
leaq -0x698(%rbp), %rsi
leaq -0x6a0(%rbp), %rdx
leaq -0x6b0(%rbp), %rcx
callq 0x121e0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl 0x4(%rax), %edi
leaq -0x70(%rbp), %rsi
movl $0x10, %edx
callq 0xfa90
movl -0x34(%rbp), %edi
leaq -0x60(%rbp), %rsi
movl $0x10, %edx
callq 0xfa90
leaq -0x70(%rbp), %rdx
leaq -0x60(%rbp), %rcx
movl $0x3, %edi
leaq 0x603e(%rip), %rsi      # 0x17992
movb $0x0, %al
callq 0x123f0
xorl %edi, %edi
leaq 0x6061(%rip), %rsi      # 0x179c5
movb $0x0, %al
callq 0x123f0
movq -0x50(%rbp), %rax
movb 0x10(%rax), %cl
addb $0x1, %cl
movb %cl, 0x10(%rax)
movl -0x670(%rbp), %edi
leaq -0x660(%rbp), %rsi
addq $0x1, %rsi
movl -0x66c(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rdx
callq 0x20f0
cmpq $0x0, %rax
jge 0x119bf
callq 0x2070
movl (%rax), %edi
callq 0x24a0
movq %rax, %rdx
xorl %edi, %edi
leaq 0x606d(%rip), %rsi      # 0x17a25
movb $0x0, %al
callq 0x123f0
jmp 0x11bd5
movq -0x698(%rbp), %rdi
leaq -0x38(%rbp), %rsi
addq $0x4, %rsi
callq 0x83f0
movq %rax, -0x50(%rbp)
movb $0x3, -0x660(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x119fe
movl -0x680(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0xc(%rax)
movb $0x5, -0x660(%rbp)
movl -0x34(%rbp), %edi
leaq -0x70(%rbp), %rsi
movl $0x10, %edx
callq 0xfa90
movq -0x18(%rbp), %rax
movl 0x18(%rax), %edi
leaq -0x660(%rbp), %rsi
leaq -0x38(%rbp), %rax
movq %rax, -0x7f0(%rbp)
movq -0x7f0(%rbp), %r8
movl $0x64, %edx
xorl %ecx, %ecx
movl $0x10, %r9d
callq 0x2200
cmpq $0x0, %rax
jge 0x11aa7
movzbl -0x660(%rbp), %edx
leaq 0x6035(%rip), %rax      # 0x17a8a
leaq 0x601d(%rip), %rcx      # 0x17a79
cmpl $0x5, %edx
cmoveq %rcx, %rax
movq %rax, -0x828(%rbp)
leaq -0x70(%rbp), %rax
movq %rax, -0x820(%rbp)
callq 0x2070
movl (%rax), %edi
callq 0x24a0
movq -0x828(%rbp), %rdx
movq -0x820(%rbp), %rcx
movq %rax, %r8
xorl %edi, %edi
leaq 0x5fb3(%rip), %rsi      # 0x17a4e
movb $0x0, %al
callq 0x123f0
jmp 0x117aa
movzbl -0x660(%rbp), %ecx
leaq 0x5fd5(%rip), %rdx      # 0x17a8a
leaq 0x5fbd(%rip), %rax      # 0x17a79
cmpl $0x5, %ecx
cmoveq %rax, %rdx
leaq -0x70(%rbp), %rcx
movl $0x3, %edi
leaq 0x5fce(%rip), %rsi      # 0x17aa1
movb $0x0, %al
callq 0x123f0
jmp 0x11bd5
leaq -0x690(%rbp), %r8
leaq -0x38(%rbp), %rdi
leaq -0x698(%rbp), %rsi
leaq -0x6a0(%rbp), %rdx
leaq -0x6b0(%rbp), %rcx
callq 0x121e0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x65f(%rbp)
movq -0x18(%rbp), %rax
movl 0x18(%rax), %edi
leaq -0x660(%rbp), %rsi
leaq -0x38(%rbp), %rax
movq %rax, -0x7f8(%rbp)
movq -0x7f8(%rbp), %r8
movl $0x64, %edx
xorl %ecx, %ecx
movl $0x10, %r9d
callq 0x2200
cmpq $0x0, %rax
jge 0x11b94
movl -0x34(%rbp), %edi
leaq -0x70(%rbp), %rsi
movl $0x10, %edx
callq 0xfa90
leaq -0x70(%rbp), %rax
movq %rax, -0x830(%rbp)
callq 0x2070
movl (%rax), %edi
callq 0x24a0
movq -0x830(%rbp), %rdx
movq %rax, %rcx
xorl %edi, %edi
leaq 0x5f3b(%rip), %rsi      # 0x17ac3
movb $0x0, %al
callq 0x123f0
jmp 0x117aa
movq -0x50(%rbp), %rax
movl 0x4(%rax), %edi
leaq -0x70(%rbp), %rsi
movl $0x10, %edx
callq 0xfa90
movl -0x34(%rbp), %edi
leaq -0x60(%rbp), %rsi
movl $0x10, %edx
callq 0xfa90
leaq -0x70(%rbp), %rdx
leaq -0x60(%rbp), %rcx
movl $0x3, %edi
leaq 0x5f2a(%rip), %rsi      # 0x17af8
movb $0x0, %al
callq 0x123f0
jmp 0x117aa
callq 0x2070
cmpl $0xb, (%rax)
je 0x11c08
callq 0x2070
movl (%rax), %edi
callq 0x24a0
movq %rax, %rdx
xorl %edi, %edi
leaq 0x5f22(%rip), %rsi      # 0x17b1e
movb $0x0, %al
callq 0x123f0
jmp 0x11eb5
jmp 0x11d9d
movl -0x670(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq -0x7b0(%rbp,%rax,8), %rax
movq %rax, -0x838(%rbp)
movl -0x670(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x838(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x11d9b
jmp 0x11c5d
movl -0x670(%rbp), %edi
leaq -0x660(%rbp), %rsi
addq $0x1, %rsi
movl $0x5db, %edx            # imm = 0x5DB
callq 0x2250
movl %eax, -0x66c(%rbp)
cmpl $0x0, %eax
jle 0x11d6b
movq -0x6a0(%rbp), %rdi
leaq -0x660(%rbp), %rsi
addq $0xd, %rsi
callq 0x83f0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x11d3b
movq -0x50(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x50(%rbp), %rax
movw 0x8(%rax), %ax
movw %ax, -0x46(%rbp)
movb $0x1, -0x660(%rbp)
movq -0x18(%rbp), %rax
movl 0x18(%rax), %edi
leaq -0x660(%rbp), %rsi
movl -0x66c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdx
leaq -0x48(%rbp), %rax
movq %rax, -0x800(%rbp)
movq -0x800(%rbp), %r8
xorl %ecx, %ecx
movl $0x10, %r9d
callq 0x2200
cmpq $0x0, %rax
jge 0x11d39
leaq -0x70(%rbp), %rax
movq %rax, -0x840(%rbp)
callq 0x2070
movl (%rax), %edi
callq 0x24a0
movq -0x840(%rbp), %rdx
movq %rax, %rcx
xorl %edi, %edi
leaq 0x5e16(%rip), %rsi      # 0x17b48
movb $0x0, %al
callq 0x123f0
jmp 0x11d66
movl -0x64f(%rbp), %edi
leaq -0x60(%rbp), %rsi
movl $0x10, %edx
callq 0xfa90
leaq -0x60(%rbp), %rdx
movl $0x3, %edi
leaq 0x5e16(%rip), %rsi      # 0x17b75
movb $0x0, %al
callq 0x123f0
jmp 0x11c5d
callq 0x2070
cmpl $0xb, (%rax)
je 0x11d99
callq 0x2070
movl (%rax), %edi
callq 0x24a0
movq %rax, %rdx
xorl %edi, %edi
leaq 0x5e11(%rip), %rsi      # 0x17b9e
movb $0x0, %al
callq 0x123f0
jmp 0x11eb5
jmp 0x11d9b
jmp 0x11d9d
jmp 0x11d9f
movl -0x680(%rbp), %eax
movl -0x67c(%rbp), %ecx
addl $0xea60, %ecx           # imm = 0xEA60
subl %ecx, %eax
cmpl $0x0, %eax
jle 0x11eb0
movl -0x680(%rbp), %eax
movl %eax, -0x67c(%rbp)
movq $0x0, -0x7b8(%rbp)
movq -0x698(%rbp), %rdi
movq -0x7b8(%rbp), %rsi
callq 0x7fb0
movq %rax, %rcx
movq %rcx, -0x7b8(%rbp)
xorl %eax, %eax
cmpq %rcx, %rax
je 0x11eae
movq -0x7b8(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movl -0x680(%rbp), %eax
movq -0x50(%rbp), %rcx
movl 0xc(%rcx), %ecx
addl $0x124f80, %ecx         # imm = 0x124F80
addl $0xea60, %ecx           # imm = 0xEA60
subl %ecx, %eax
cmpl $0x0, %eax
jle 0x11ea9
movq -0x698(%rbp), %rdi
movq -0x7b8(%rbp), %rsi
callq 0x8480
movq -0x6a0(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x8520
movl $0x38, %edi
movl $0xd2, %esi
callq 0x7220
movq %rax, -0x7c0(%rbp)
movq -0x7c0(%rbp), %rcx
movq -0x7c0(%rbp), %rax
movq %rcx, (%rax)
movq -0x50(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x7c0(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x7c0(%rbp), %rdi
leaq -0x6b0(%rbp), %rsi
callq 0x6e60
movq -0x50(%rbp), %rdi
movl $0x4c0, %esi            # imm = 0x4C0
callq 0x7720
jmp 0x11dd3
jmp 0x11eb0
jmp 0x11681
movb $0x0, -0x685(%rbp)
movl -0x688(%rbp), %edi
movl -0x674(%rbp), %r8d
leaq -0x80(%rbp), %r9
movl $0x10, %esi
xorl %ecx, %ecx
movl %ecx, %edx
movl $0xfe, (%rsp)
movl $0x0, 0x8(%rsp)
movl $0x1, 0x10(%rsp)
callq 0xa420
movl -0x670(%rbp), %edi
callq 0xc1c0
movq $0x0, -0x7b8(%rbp)
movq -0x698(%rbp), %rdi
movq -0x7b8(%rbp), %rsi
callq 0x7fb0
movq %rax, %rcx
movq %rcx, -0x7b8(%rbp)
xorl %eax, %eax
cmpq %rcx, %rax
je 0x11f71
movq -0x7b8(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x698(%rbp), %rdi
movq -0x7b8(%rbp), %rsi
callq 0x8480
movq -0x6a0(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x8520
movq -0x50(%rbp), %rdi
movl $0x4c1, %esi            # imm = 0x4C1
callq 0x7720
jmp 0x11f08
movq -0x698(%rbp), %rdi
callq 0x7f50
movq -0x6a0(%rbp), %rdi
callq 0x7f50
movq -0x6b0(%rbp), %rax
movq %rax, -0x7c8(%rbp)
movq -0x7c8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x7d0(%rbp)
leaq -0x6b0(%rbp), %rax
cmpq %rax, -0x7c8(%rbp)
je 0x1200e
movq -0x7c8(%rbp), %rax
movq %rax, -0x7c0(%rbp)
movq -0x7c8(%rbp), %rsi
leaq -0x6b0(%rbp), %rdx
movq %rdx, %rdi
callq 0x6ed0
movq -0x7c0(%rbp), %rdi
movl $0x4c2, %esi            # imm = 0x4C2
callq 0x7720
movq -0x7d0(%rbp), %rax
movq %rax, -0x7c8(%rbp)
movq -0x7c8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x7d0(%rbp)
jmp 0x11fa8
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x860, %rsp            # imm = 0x860
popq %rbp
retq
nopw %cs:(%rax,%rax)