// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7a8, %rsp            # imm = 0x7A8
leaq 0xb1d4(%rip), %rax      # 0x17310
movq (%rax), %rbx
movl $0x100fea9, 0x30(%rsp)  # imm = 0x100FEA9
movl $0x10, 0x4c(%rsp)
callq 0xa9e4
movl %eax, %ebp
movl $0xd2100002, 0x70(%rsp) # imm = 0xD2100002
leaq 0x58(%rsp), %rax
movq %rax, (%rax)
movq %rax, 0x8(%rax)
leaq 0x80(%rsp), %rdx
pushq $0x10
popq %rcx
leaq 0x1c(%rsp), %r8
leaq 0x34(%rsp), %r9
movq %rbx, %rdi
movl $0xfea9, %esi           # imm = 0xFEA9
callq 0x8925
testb %al, %al
js 0xc86b
leaq 0x7d8(%rip), %rsi       # 0xc973
leaq 0x7db(%rip), %rdx       # 0xc97d
movl $0x80, %edi
callq 0x6095
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0xc86b
movq %rax, %r14
leaq 0x7f2(%rip), %rsi       # 0xc9b6
leaq 0x7f7(%rip), %rdx       # 0xc9c2
movl $0x80, %edi
callq 0x6095
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0xc863
movl 0x34(%rsp), %r8d
andl $0x0, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
movl $0xfe, (%rsp)
pushq $0x10
popq %rsi
xorl %r14d, %r14d
leaq 0x80(%rsp), %r9
movl $0xfea9, %edi           # imm = 0xFEA9
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x745c
cmpq $0x10, %r14
je 0xc229
andq $0x0, 0xc0(%rsp,%r14,8)
incq %r14
jmp 0xc215
movl 0x18(%rbx), %esi
pushq $0x40
popq %r15
movl %esi, %eax
cltd
idivl %r15d
movslq %eax, %rdx
shll $0x6, %eax
movl %esi, %ecx
subl %eax, %ecx
pushq $0x1
popq %rdi
movq %rdi, %rax
shlq %cl, %rax
orq %rax, 0xc0(%rsp,%rdx,8)
movl 0x1c(%rsp), %r8d
movl %r8d, %eax
cltd
idivl %r15d
movslq %eax, %rdx
shll $0x6, %eax
movl %r8d, %ecx
subl %eax, %ecx
movq %rdi, %rax
shlq %cl, %rax
orq %rax, 0xc0(%rsp,%rdx,8)
cmpl %r8d, %esi
cmovgl %esi, %r8d
incl %r8d
movl %r8d, 0x48(%rsp)
leaq 0x1c0(%rsp), %rax
orq %rax, %rdi
movq %rdi, 0x50(%rsp)
leaq 0x58(%rsp), %r13
leaq 0xb0(%rsp), %r12
callq 0xb07c
testb %al, %al
jne 0xc8ac
leaq 0xb003(%rip), %rax      # 0x172b9
cmpb $0x0, (%rax)
je 0xc8ac
andq $0x0, 0xa0(%rsp)
movq $0xfa, 0xa8(%rsp)
pushq $0x10
popq %rcx
leaq 0x140(%rsp), %rax
movq %rax, %rdi
leaq 0xc0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movl 0x48(%rsp), %edi
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
leaq 0xa0(%rsp), %r8
callq 0x22c0
movl %eax, %r14d
callq 0xa9e4
movl %eax, %ecx
testl %r14d, %r14d
js 0xc674
je 0xc7b3
movl 0x18(%rbx), %edi
movl %edi, %eax
cltd
idivl %r15d
cltq
movq 0x140(%rsp,%rax,8), %rax
btq %rdx, %rax
jae 0xc6ac
movl %ecx, 0x18(%rsp)
movl $0x5dc, %edx            # imm = 0x5DC
leaq 0x1c0(%rsp), %rsi
xorl %ecx, %ecx
leaq 0x38(%rsp), %r8
leaq 0x4c(%rsp), %r9
callq 0x2320
movq %rax, %r15
testl %r15d, %r15d
jle 0xc68f
cmpl $0x1, %r15d
jne 0xc399
movl 0x3c(%rsp), %edi
movq %r12, %rsi
pushq $0x10
popq %rdx
callq 0xb04f
xorl %edi, %edi
leaq 0x5575(%rip), %rsi      # 0x118fc
movq %r12, %rdx
pushq $0x1
popq %rcx
xorl %eax, %eax
callq 0xcb1c
jmp 0xc645
movzbl 0x1c0(%rsp), %eax
cmpl $0x4, %eax
je 0xc588
cmpl $0x2, %eax
je 0xc4f9
cmpl $0x1, %eax
jne 0xc645
movq 0x20(%rsp), %rdi
leaq 0x1c9(%rsp), %rsi
callq 0x61eb
movq %rax, %r14
movl 0x3c(%rsp), %edi
testq %rax, %rax
je 0xc3ee
cmpl %edi, (%r14)
je 0xc4b8
cmpb $0x0, 0x10(%r14)
jne 0xc4b8
movb $0x3, 0x1c0(%rsp)
movq %r12, %rsi
pushq $0x10
popq %rdx
callq 0xb04f
movzbl 0x1cd(%rsp), %ecx
movzbl 0x1ce(%rsp), %r8d
movzbl 0x1cf(%rsp), %r9d
movzbl 0x1d0(%rsp), %eax
movl %eax, (%rsp)
xorl %edi, %edi
leaq 0x550c(%rip), %rsi      # 0x1193b
movq %r12, %rdx
xorl %eax, %eax
callq 0xcb1c
testq %r14, %r14
jne 0xc4a4
leaq 0x38(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movq %r13, %rcx
leaq 0x30(%rsp), %r8
callq 0xc9fc
movq %rax, %r14
movl 0x4(%rax), %edi
movq %r12, %rsi
pushq $0x10
popq %rdx
callq 0xb04f
movl 0x3c(%rsp), %edi
movl %ebp, %r13d
leaq 0x90(%rsp), %rbp
movq %rbp, %rsi
pushq $0x10
popq %rdx
callq 0xb04f
pushq $0x3
popq %rdi
leaq 0x54fb(%rip), %rsi      # 0x1198a
movq %r12, %rdx
movq %rbp, %rcx
movl %r13d, %ebp
leaq 0x58(%rsp), %r13
xorl %eax, %eax
callq 0xcb1c
xorl %edi, %edi
leaq 0x5510(%rip), %rsi      # 0x119bd
xorl %eax, %eax
callq 0xcb1c
incb 0x10(%r14)
movl 0x1c(%rsp), %edi
decl %r15d
movq 0x50(%rsp), %rsi
movq %r15, %rdx
callq 0x20f0
testq %rax, %rax
jns 0xc645
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x5533(%rip), %rsi      # 0x11a1d
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
jmp 0xc645
leaq 0x38(%rsp), %r15
movq %r15, %rdi
leaq 0x28(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movq %r13, %rcx
leaq 0x30(%rsp), %r8
callq 0xc9fc
movq %rax, %r14
movl 0x4(%rax), %eax
movl %eax, 0x1c1(%rsp)
movl 0x18(%rbx), %edi
leaq 0x1c0(%rsp), %rsi
pushq $0x64
popq %rdx
xorl %ecx, %ecx
movq %r15, %r8
pushq $0x10
popq %r15
movl %r15d, %r9d
callq 0x21e0
testq %rax, %rax
js 0xc614
movl 0x4(%r14), %edi
movq %r12, %rsi
movl %r15d, %edx
callq 0xb04f
movl 0x3c(%rsp), %edi
leaq 0x90(%rsp), %r14
movq %r14, %rsi
movl %r15d, %edx
callq 0xb04f
pushq $0x3
popq %rdi
leaq 0x5573(%rip), %rsi      # 0x11af0
movq %r12, %rdx
movq %r14, %rcx
jmp 0xc63e
movq 0x28(%rsp), %rdi
leaq 0x3c(%rsp), %rsi
callq 0x61eb
movb $0x3, 0x1c0(%rsp)
testq %rax, %rax
je 0xc5b3
movl 0x18(%rsp), %ecx
movl %ecx, 0xc(%rax)
movb $0x5, 0x1c0(%rsp)
movl 0x3c(%rsp), %edi
movq %r12, %rsi
pushq $0x10
popq %r14
movl %r14d, %edx
callq 0xb04f
movl 0x18(%rbx), %edi
leaq 0x1c0(%rsp), %rsi
pushq $0x64
popq %rdx
xorl %ecx, %ecx
leaq 0x38(%rsp), %r8
movl %r14d, %r9d
callq 0x21e0
cmpb $0x5, 0x1c0(%rsp)
leaq 0x5490(%rip), %r14      # 0x11a82
leaq 0x5478(%rip), %rcx      # 0x11a71
cmoveq %rcx, %r14
testq %rax, %rax
js 0xc64d
pushq $0x3
popq %rdi
leaq 0x548d(%rip), %rsi      # 0x11a99
movq %r14, %rdx
movq %r12, %rcx
jmp 0xc63e
movl 0x3c(%rsp), %edi
movq %r12, %rsi
movl %r15d, %edx
callq 0xb04f
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x5483(%rip), %rsi      # 0x11abb
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xcb1c
movl 0x18(%rbx), %edi
jmp 0xc33f
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x53e4(%rip), %rsi      # 0x11a46
movq %r14, %rdx
movq %r12, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0xcb1c
jmp 0xc645
movl %ecx, %r14d
callq 0x2070
movl %r14d, %ecx
movl (%rax), %edi
cmpl $0x4, %edi
je 0xc7b3
jmp 0xc87f
callq 0x2070
movl (%rax), %edi
cmpl $0xb, %edi
pushq $0x40
popq %r15
movl 0x18(%rsp), %ecx
je 0xc7b3
jmp 0xc888
movl 0x1c(%rsp), %edi
movl %edi, %eax
cltd
idivl %r15d
cltq
movq 0x140(%rsp,%rax,8), %rax
btq %rdx, %rax
jae 0xc7b3
movl %ecx, 0x18(%rsp)
movq 0x20(%rsp), %r15
movl $0x5db, %edx            # imm = 0x5DB
movq 0x50(%rsp), %rsi
callq 0x2230
movq %rax, %r14
testl %r14d, %r14d
jle 0xc79b
movq %r15, %rdi
leaq 0x1cd(%rsp), %rsi
callq 0x61eb
testq %rax, %rax
je 0xc764
movl (%rax), %ecx
movl %ecx, 0x74(%rsp)
movzwl 0x8(%rax), %eax
movw %ax, 0x72(%rsp)
movb $0x1, 0x1c0(%rsp)
movl 0x18(%rbx), %edi
incl %r14d
leaq 0x1c0(%rsp), %rsi
movq %r14, %rdx
xorl %ecx, %ecx
leaq 0x70(%rsp), %r8
pushq $0x10
popq %r9
callq 0x21e0
testq %rax, %rax
jns 0xc792
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x53eb(%rip), %rsi      # 0x11b40
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xcb1c
jmp 0xc792
movl 0x1d1(%rsp), %edi
leaq 0x90(%rsp), %r14
movq %r14, %rsi
pushq $0x10
popq %rdx
callq 0xb04f
pushq $0x3
popq %rdi
leaq 0x53e5(%rip), %rsi      # 0x11b6d
movq %r14, %rdx
xorl %eax, %eax
callq 0xcb1c
movl 0x1c(%rsp), %edi
jmp 0xc6d3
callq 0x2070
movl (%rax), %edi
cmpl $0xb, %edi
pushq $0x40
popq %r15
movl 0x18(%rsp), %ecx
jne 0xc891
movl %ecx, %eax
subl %ebp, %eax
addl $0xffff15a0, %eax       # imm = 0xFFFF15A0
testl %eax, %eax
jle 0xc2a2
movq 0x28(%rsp), %r14
movl %ecx, 0x18(%rsp)
movl %ecx, %ebp
addl $0xffecc620, %ebp       # imm = 0xFFECC620
movq 0x20(%rsp), %rax
movq %rax, 0x68(%rsp)
xorl %r15d, %r15d
movq %r14, %rdi
movq %r15, %rsi
callq 0x5f8c
testq %rax, %rax
je 0xc851
movq %rax, %r15
movq 0x8(%rax), %rax
movq (%rax), %r13
movl %ebp, %eax
subl 0xc(%r13), %eax
testl %eax, %eax
jle 0xc7e2
movq %r14, %rdi
movq %r15, %rsi
callq 0x6241
movq 0x68(%rsp), %rdi
movq %r13, %rsi
callq 0x628e
pushq $0x38
popq %rdi
movl $0xd2, %esi
callq 0x58c9
movq %rax, (%rax)
movl 0x4(%r13), %ecx
movl %ecx, 0x8(%rax)
movq %rax, %rdi
leaq 0x58(%rsp), %rsi
callq 0x574d
movq %r13, %rdi
movl $0x4c0, %esi            # imm = 0x4C0
callq 0x5b1a
jmp 0xc7e2
movl 0x18(%rsp), %ebp
leaq 0x58(%rsp), %r13
pushq $0x40
popq %r15
jmp 0xc2a2
movq %r14, %rdi
callq 0x5f63
xorl %eax, %eax
addq $0x7a8, %rsp            # imm = 0x7A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x504f(%rip), %rbx      # 0x118d5
jmp 0xc898
leaq 0x5287(%rip), %rbx      # 0x11b16
jmp 0xc898
leaq 0x52fe(%rip), %rbx      # 0x11b96
callq 0x2480
xorl %edi, %edi
movq %rbx, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
movl 0x34(%rsp), %r8d
andl $0x0, 0x8(%rsp)
movl $0x1, 0x10(%rsp)
movl $0xfe, (%rsp)
pushq $0x10
popq %rsi
xorl %ebx, %ebx
leaq 0x80(%rsp), %r9
movl $0xfea9, %edi           # imm = 0xFEA9
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x745c
movl 0x1c(%rsp), %edi
callq 0x88e2
movq 0x28(%rsp), %r15
movq 0x20(%rsp), %r14
movq %r15, %rdi
movq %rbx, %rsi
callq 0x5f8c
testq %rax, %rax
je 0xc932
movq %rax, %rbx
movq 0x8(%rax), %rax
movq (%rax), %r12
movq %r15, %rdi
movq %rbx, %rsi
callq 0x6241
movq %r14, %rdi
movq %r12, %rsi
callq 0x628e
movq %r12, %rdi
movl $0x4c1, %esi            # imm = 0x4C1
callq 0x5b1a
jmp 0xc8f3
movq %r15, %rdi
callq 0x5f63
movq %r14, %rdi
callq 0x5f63
movq 0x58(%rsp), %rbx
cmpq %r13, %rbx
je 0xc86b
movq (%rbx), %r14
movq %r13, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x5763
movq %rbx, %rdi
movl $0x4c2, %esi            # imm = 0x4C2
callq 0x5b1a
movq %r14, %rbx
jmp 0xc947