// File: /workspace/github_c_makefile_star2_O3/open-mesh-mirror[P]batmand/posix/tunnel.c
// Function: client_to_gw_tun
void *client_to_gw_tun(void *arg)
{
	struct curr_gw_data *curr_gw_data = (struct curr_gw_data *)arg;
	struct sockaddr_in gw_addr, my_addr, sender_addr;
	struct timeval tv;
	struct list_head_first packet_list;
	int32_t res, max_sock, buff_len, udp_sock, tun_fd, tun_ifi, sock_opts, i, num_refresh_lease = 0, last_refresh_attempt = 0;
	uint32_t addr_len, current_time, ip_lease_time = 0, gw_state_time = 0, my_tun_addr = 0, ignore_packet;
	char tun_if[IFNAMSIZ], my_str[ADDR_STR_LEN], gw_str[ADDR_STR_LEN], gw_state = GW_STATE_UNKNOWN;
	unsigned char buff[1501];
	fd_set wait_sockets, tmp_wait_sockets;


	addr_len = sizeof(struct sockaddr_in);

	INIT_LIST_HEAD_FIRST(packet_list);

	memset(&gw_addr, 0, sizeof(struct sockaddr_in));
	memset(&my_addr, 0, sizeof(struct sockaddr_in));

	gw_addr.sin_family = AF_INET;
	gw_addr.sin_port = curr_gw_data->gw_node->gw_port;
	gw_addr.sin_addr.s_addr = curr_gw_data->orig;

	my_addr.sin_family = AF_INET;
	my_addr.sin_port = curr_gw_data->gw_node->gw_port;
	my_addr.sin_addr.s_addr = curr_gw_data->batman_if->addr.sin_addr.s_addr;


	/* connect to server (establish udp tunnel) */
	if ((udp_sock = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
		debug_output(0, "Error - can't create udp socket: %s\n", strerror(errno));
		goto out;
	}

	sock_opts = 1;
        if (setsockopt(udp_sock, SOL_SOCKET, SO_REUSEADDR, &sock_opts, sizeof(sock_opts)) < 0) {
               debug_output(0, "Error - can't set options on udp socket: %s\n", strerror(errno));
		goto udp_out;
        }

	if (bind(udp_sock, (struct sockaddr *)&my_addr, sizeof(struct sockaddr_in)) < 0) {
		debug_output(0, "Error - can't bind tunnel socket: %s\n", strerror(errno));
		goto udp_out;
	}


	/* make udp socket non blocking */
	sock_opts = fcntl(udp_sock, F_GETFL, 0);
	fcntl(udp_sock, F_SETFL, sock_opts | O_NONBLOCK);


	if (get_tun_ip(&gw_addr, udp_sock, &my_tun_addr) < 0) {
		curr_gw_data->gw_node->last_failure = get_time_msec();
		curr_gw_data->gw_node->gw_failure++;

		goto udp_out;
	}

	ip_lease_time = get_time_msec();

	addr_to_string(my_tun_addr, my_str, sizeof(my_str));
	addr_to_string(curr_gw_data->orig, gw_str, sizeof(gw_str));
	debug_output(3, "Gateway client - got IP (%s) from gateway: %s \n", my_str, gw_str);


	if (add_dev_tun(curr_gw_data->batman_if, my_tun_addr, tun_if, sizeof(tun_if), &tun_fd, &tun_ifi) <= 0)
		goto udp_out;

	add_nat_rule(tun_if);
	add_del_route(0, 0, 0, my_tun_addr, tun_ifi, tun_if, BATMAN_RT_TABLE_TUNNEL, ROUTE_TYPE_UNICAST, ROUTE_ADD);

	FD_ZERO(&wait_sockets);
	FD_SET(udp_sock, &wait_sockets);
	FD_SET(tun_fd, &wait_sockets);

	max_sock = (udp_sock > tun_fd ? udp_sock : tun_fd);

	while ((!is_aborted()) && (curr_gateway != NULL) && (!curr_gw_data->gw_node->deleted)) {

		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 (client_to_gw_tun): %s \n", strerror(errno));
			break;
		}

		if (res <= 0)
			goto after_incoming_packet;

		/* traffic that comes from the gateway via the tunnel */
		if (FD_ISSET(udp_sock, &tmp_wait_sockets)) {

			while ((buff_len = recvfrom(udp_sock, buff, sizeof(buff) - 1, 0, (struct sockaddr *)&sender_addr, &addr_len)) > 0) {

				if (buff_len < 2) {
					debug_output(0, "Error - ignoring gateway packet from %s: packet too small (%i)\n", my_str, buff_len);
					continue;
				}

				/* a gateway with multiple interfaces breaks here */
				/*if (sender_addr.sin_addr.s_addr != gw_addr.sin_addr.s_addr) {
					debug_output(0, "Error - can't receive ip request: sender IP is not gateway IP \n");
					continue;
				}*/

				switch(buff[0]) {
				/* got data from gateway */
				case TUNNEL_DATA:
					if (write(tun_fd, buff + 1, buff_len - 1) < 0)
						debug_output(0, "Error - can't write packet: %s\n", strerror(errno));

					if (get_tunneled_protocol(buff) != IPPROTO_ICMP) {
						gw_state = GW_STATE_VERIFIED;
						gw_state_time = current_time;
					}
					break;
				/* gateway told us that we have no valid ip */
				case TUNNEL_IP_INVALID:
					addr_to_string(my_tun_addr, my_str, sizeof(my_str));
					debug_output(3, "Gateway client - gateway (%s) says: IP (%s) is invalid (maybe expired) \n", gw_str, my_str);

					curr_gateway = NULL;
					goto cleanup;
				/* keep alive packet was confirmed */
				case TUNNEL_KEEPALIVE_REPLY:
					debug_output(3, "Gateway client - successfully refreshed IP lease: %s \n", gw_str);
					ip_lease_time = current_time;
					num_refresh_lease = 0;
					break;
				}

			}

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

		/* traffic that we should send to the gateway via the tunnel */
		} else if (FD_ISSET(tun_fd, &tmp_wait_sockets)) {

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

				buff[0] = TUNNEL_DATA;

				if (sendto(udp_sock, buff, buff_len + 1, 0, (struct sockaddr *)&gw_addr, sizeof(struct sockaddr_in)) < 0)
					debug_output(0, "Error - can't send data to gateway: %s\n", strerror(errno));

				if ((gw_state == GW_STATE_UNKNOWN) && (gw_state_time == 0)) {

					ignore_packet = 0;

					if (get_tunneled_protocol(buff) == IPPROTO_ICMP)
						ignore_packet = 1;

					if (get_tunneled_protocol(buff) == IPPROTO_UDP) {

						for (i = 0; i < (int)(sizeof(bh_udp_ports)/sizeof(short)); i++) {

							if (get_tunneled_udpdest(buff) == bh_udp_ports[i]) {

								ignore_packet = 1;
								break;

							}

						}

					}

					/* if the packet was not natted (half tunnel) don't active the blackhole detection */
					if (get_tunneled_sender_ip(buff) != my_tun_addr)
						ignore_packet = 1;

					if (!ignore_packet)
						gw_state_time = current_time;

				}
			}

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

		}

after_incoming_packet:

		/* refresh leased IP */
		if (((int)(current_time - (ip_lease_time + IP_LEASE_TIMEOUT)) > 0) &&
			((int)(current_time - (last_refresh_attempt + 1000)) > 0)) {

			if (num_refresh_lease < 12) {

				buff[0] = TUNNEL_KEEPALIVE_REQUEST;

				if (sendto(udp_sock, buff, 100, 0, (struct sockaddr *)&gw_addr, sizeof(struct sockaddr_in)) < 0)
					debug_output(0, "Error - can't send keep alive request to gateway: %s \n", strerror(errno));

				num_refresh_lease++;
				last_refresh_attempt = current_time;

			} else {

				addr_to_string(my_tun_addr, my_str, sizeof(my_str));
				debug_output(3, "Gateway client - disconnecting from unresponsive gateway (%s): could not refresh IP lease \n", gw_str);

				curr_gw_data->gw_node->last_failure = current_time;
				curr_gw_data->gw_node->gw_failure++;
				break;

			}

		}

		/* drop connection to gateway if the gateway does not respond */
		if ((gw_state == GW_STATE_UNKNOWN) && (gw_state_time != 0) &&
				   ((int)(current_time - (gw_state_time + GW_STATE_UNKNOWN_TIMEOUT)) > 0)) {

			debug_output(3, "Gateway client - disconnecting from unresponsive gateway (%s): gateway seems to be a blackhole \n", gw_str);

			curr_gw_data->gw_node->last_failure = current_time;
			curr_gw_data->gw_node->gw_failure++;

			break;
		}

		/* change back to unknown state if gateway did not respond in time */
		if ((gw_state == GW_STATE_VERIFIED) &&
				   ((int)(current_time - (gw_state_time + GW_STATE_VERIFIED_TIMEOUT)) > 0)) {
			gw_state = GW_STATE_UNKNOWN;
			gw_state_time = 0;
		}

	}

cleanup:
	add_del_route(0, 0, 0, my_tun_addr, tun_ifi, tun_if, BATMAN_RT_TABLE_TUNNEL, ROUTE_TYPE_UNICAST, ROUTE_DEL);
	del_nat_rule(tun_if);
	del_dev_tun(tun_fd);

udp_out:
	close(udp_sock);

out:
	curr_gateway = NULL;
	tunnel_running = 0;
	debugFree(arg, 1212);

	return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7b8, %rsp            # imm = 0x7B8
movq %rdi, %r13
movl $0x10, 0x18(%rsp)
leaq 0x140(%rsp), %rax
movq %rax, (%rax)
movq %rax, 0x8(%rax)
xorl %eax, %eax
movq %rax, 0x48(%rsp)
movq %rax, 0x88(%rsp)
movw $0x2, %ax
movw %ax, 0x40(%rsp)
movq 0x8(%rdi), %rcx
movzwl 0x10(%rcx), %ecx
movw %cx, 0x42(%rsp)
movl (%rdi), %edx
movl %edx, 0x44(%rsp)
movw %ax, 0x80(%rsp)
movw %cx, 0x82(%rsp)
movq 0x10(%rdi), %rax
movl 0x34(%rax), %eax
movl %eax, 0x84(%rsp)
movl $0x2, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x24e0
testl %eax, %eax
js 0xc675
movl %eax, %r14d
leaq 0x3c(%rsp), %rcx
movl $0x1, (%rcx)
movl %eax, %edi
movl $0x1, %esi
movl $0x2, %edx
movl $0x4, %r8d
callq 0x20d0
testl %eax, %eax
js 0xc699
leaq 0x80(%rsp), %rsi
movl %r14d, %edi
movl $0x10, %edx
callq 0x2370
testl %eax, %eax
js 0xc6ae
movl %r14d, %edi
movl $0x3, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x20e0
movl %eax, 0x3c(%rsp)
orl $0x800, %eax            # imm = 0x800
movl %r14d, %edi
movl $0x4, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x20e0
movl $0x10, 0x70(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0xc0(%rsp)
movaps %xmm0, 0xd0(%rsp)
movaps %xmm0, 0xe0(%rsp)
movaps %xmm0, 0xf0(%rsp)
movaps %xmm0, 0x100(%rsp)
movaps %xmm0, 0x110(%rsp)
movl $0x0, 0x120(%rsp)
callq 0xbbdb
testb %al, %al
jne 0xc707
leaq 0xae0b(%rip), %rax      # 0x172c0
cmpq $0x0, (%rax)
je 0xc707
movq %r13, 0x8(%rsp)
movl $0x1, %eax
movl %r14d, %ecx
shlq %cl, %rax
movq %rax, 0x30(%rsp)
movl %r14d, %eax
shrl $0x6, %eax
movq %rax, 0x28(%rsp)
leal 0x1(%r14), %ebp
movb $0xc, %r13b
leaq 0xc0(%rsp), %r15
leaq 0x40(%rsp), %r12
movb $0x2, 0xc0(%rsp)
movl $0x64, %edx
movl %r14d, %edi
movq %r15, %rsi
xorl %ecx, %ecx
movq %r12, %r8
movl $0x10, %r9d
callq 0x21e0
testq %rax, %rax
js 0xc5fc
movq $0x0, 0x50(%rsp)
movq $0x3d090, 0x58(%rsp)    # imm = 0x3D090
xorps %xmm0, %xmm0
movaps %xmm0, 0x1d0(%rsp)
movaps %xmm0, 0x1e0(%rsp)
movaps %xmm0, 0x1f0(%rsp)
movaps %xmm0, 0x200(%rsp)
movaps %xmm0, 0x210(%rsp)
movaps %xmm0, 0x220(%rsp)
movaps %xmm0, 0x230(%rsp)
movaps %xmm0, 0x240(%rsp)
movq 0x30(%rsp), %rax
movq 0x28(%rsp), %rcx
orq %rax, 0x1d0(%rsp,%rcx,8)
movl %ebp, %edi
leaq 0x1d0(%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
leaq 0x50(%rsp), %r8
callq 0x22c0
testl %eax, %eax
js 0xc61d
je 0xc62d
movq 0x30(%rsp), %rax
movq 0x28(%rsp), %rcx
testq %rax, 0x1d0(%rsp,%rcx,8)
je 0xc62d
movl $0x63, %edx
movl %r14d, %edi
movq %r15, %rsi
xorl %ecx, %ecx
leaq 0x150(%rsp), %r8
leaq 0x70(%rsp), %r9
callq 0x2320
testl %eax, %eax
js 0xc65e
cmpl $0x3, %eax
ja 0xc758
xorl %edi, %edi
leaq 0x666c(%rip), %rsi      # 0x12c5d
movl %eax, %edx
xorl %eax, %eax
callq 0xd88c
jmp 0xc62d
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x65ce(%rip), %rsi      # 0x12bdf
movq %rax, %rdx
xorl %eax, %eax
callq 0xd88c
jmp 0xc62d
callq 0x2070
movl (%rax), %edi
cmpl $0x4, %edi
jne 0xc6ea
leal -0x1(%r13), %ebx
callq 0xbbdb
testb %al, %al
jne 0xc6cf
leaq 0xac7b(%rip), %rax      # 0x172c0
cmpq $0x0, (%rax)
je 0xc6cf
cmpb $0x1, %r13b
movl %ebx, %r13d
ja 0xc4f3
jmp 0xc6cf
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x65c3(%rip), %rsi      # 0x12c36
jmp 0xc611
callq 0x2070
movl (%rax), %edi
callq 0x2480
leaq 0x5f60(%rip), %rsi      # 0x125e8
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0xd88c
jmp 0xc71f
callq 0x2070
movl (%rax), %edi
callq 0x2480
leaq 0x5f61(%rip), %rsi      # 0x1260d
jmp 0xc6c1
callq 0x2070
movl (%rax), %edi
callq 0x2480
leaq 0x5998(%rip), %rsi      # 0x12059
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0xd88c
jmp 0xc717
testb %bl, %bl
movq 0x8(%rsp), %r13
jne 0xc707
leaq 0x65b8(%rip), %rsi      # 0x12c97
xorl %edi, %edi
xorl %eax, %eax
callq 0xd88c
jmp 0xc707
callq 0x2480
leaq 0x6518(%rip), %rsi      # 0x12c0e
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0xd88c
movq 0x8(%rsp), %r13
callq 0xb3f0
movq 0x8(%r13), %rcx
movl %eax, 0x14(%rcx)
incw 0x12(%rcx)
movl %r14d, %edi
callq 0x21f0
leaq 0xab9a(%rip), %rax      # 0x172c0
movq $0x0, (%rax)
leaq 0xaf54(%rip), %rax      # 0x17688
movb $0x0, (%rax)
movq %r13, %rdi
movl $0x4bc, %esi            # imm = 0x4BC
callq 0x628b
xorl %eax, %eax
addq $0x7b8, %rsp            # imm = 0x7B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0xc1(%rsp), %ebp
callq 0xb3f0
movl %eax, 0x1c(%rsp)
leaq 0x90(%rsp), %rbx
movl %ebp, %edi
movq %rbx, %rsi
movl $0x10, %edx
callq 0xbbac
movq 0x8(%rsp), %r13
movl (%r13), %edi
leaq 0x60(%rsp), %r15
movq %r15, %rsi
movl $0x10, %edx
callq 0xbbac
leaq 0x5e99(%rip), %rsi      # 0x1263a
xorl %r12d, %r12d
movl $0x3, %edi
movq %rbx, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0xd88c
movq 0x10(%r13), %rdi
leaq 0xb0(%rsp), %rdx
leaq 0x4(%rsp), %r8
leaq 0x24(%rsp), %r9
movl $0x10, %ecx
movl %ebp, %esi
callq 0x925b
testb %al, %al
jle 0xc717
leaq 0xb0(%rsp), %rbx
movq %rbx, %rdi
callq 0x9046
movl 0x24(%rsp), %r8d
subq $0x8, %rsp
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
movl %ebp, 0x18(%rsp)
movl %ebp, %ecx
movq %rbx, %r9
pushq %r12
pushq %r12
pushq $0x44
callq 0x7cd4
addq $0x20, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, 0x130(%rsp)
movaps %xmm0, 0x120(%rsp)
movaps %xmm0, 0x110(%rsp)
movaps %xmm0, 0x100(%rsp)
movaps %xmm0, 0xf0(%rsp)
movaps %xmm0, 0xe0(%rsp)
movaps %xmm0, 0xd0(%rsp)
movaps %xmm0, 0xc0(%rsp)
movq 0x30(%rsp), %rax
movq 0x28(%rsp), %rcx
orq %rax, 0xc0(%rsp,%rcx,8)
movl 0x4(%rsp), %ecx
leal 0x3f(%rcx), %eax
testl %ecx, %ecx
cmovnsl %ecx, %eax
movl %eax, %edx
andl $-0x40, %edx
movq %rcx, %rbx
subl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
sarl $0x6, %eax
cltq
orq %rdx, 0xc0(%rsp,%rax,8)
callq 0xbbdb
testb %al, %al
jne 0xcd6d
leaq 0xaa15(%rip), %rax      # 0x172c0
cmpq $0x0, (%rax)
je 0xcd6d
cmpl %ebx, %r14d
cmovgl %r14d, %ebx
incl %ebx
movq %rbx, 0xa8(%rsp)
movb $0x1, %al
movl %eax, (%rsp)
leaq 0x1d1(%rsp), %rbx
leaq 0xa9c6(%rip), %rbp      # 0x172a0
movl $0x0, 0x14(%rsp)
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x8(%r13), %rax
cmpl $0x0, 0x18(%rax)
jne 0xcd6d
movl %r15d, 0x20(%rsp)
movq %rbx, %r15
movq $0x0, 0x70(%rsp)
movq $0xfa, 0x78(%rsp)
movl $0x10, %ecx
leaq 0x150(%rsp), %rax
movq %rax, %rdi
leaq 0xc0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0xa8(%rsp), %rdi
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
leaq 0x70(%rsp), %r8
callq 0x22c0
movl %eax, %ebx
callq 0xb3f0
movl %eax, %r13d
testl %ebx, %ebx
js 0xca69
je 0xca96
movq 0x30(%rsp), %rax
movq 0x28(%rsp), %rcx
testq %rax, 0x150(%rsp,%rcx,8)
movq %r15, %rbx
je 0xca9e
movl $0x5dc, %edx            # imm = 0x5DC
movl %r14d, %edi
leaq 0x1d0(%rsp), %r15
movq %r15, %rsi
xorl %ecx, %ecx
leaq 0x50(%rsp), %r8
leaq 0x18(%rsp), %r9
callq 0x2320
testl %eax, %eax
jle 0xca81
cmpl $0x1, %eax
jne 0xc9cf
xorl %edi, %edi
leaq 0x5ce7(%rip), %rsi      # 0x12698
leaq 0x90(%rsp), %rdx
movl $0x1, %ecx
xorl %eax, %eax
callq 0xd88c
movl $0x5dc, %edx            # imm = 0x5DC
movl %r14d, %edi
jmp 0xc987
movzbl 0x1d0(%rsp), %ecx
cmpl $0x1, %ecx
je 0xca12
cmpl $0x5, %ecx
je 0xc9eb
cmpl $0x3, %ecx
jne 0xc9c5
jmp 0xcd0c
movl $0x0, 0x14(%rsp)
movl $0x3, %edi
leaq 0x5d42(%rip), %rsi      # 0x12741
leaq 0x60(%rsp), %rdx
xorl %eax, %eax
callq 0xd88c
movl %r13d, 0x1c(%rsp)
jmp 0xc9c5
movl 0x4(%rsp), %edi
decl %eax
movq %rbx, %rsi
movq %rax, %rdx
callq 0x20f0
testq %rax, %rax
jns 0xca47
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x5c9b(%rip), %rsi      # 0x126d8
movq %rax, %rdx
xorl %eax, %eax
callq 0xd88c
cmpb $0x1, 0x1da(%rsp)
cmovnel %r13d, %r12d
movl (%rsp), %eax
movzbl %al, %eax
movl $0x2, %ecx
cmovnel %ecx, %eax
movl %eax, (%rsp)
jmp 0xc9c5
callq 0x2070
movl (%rax), %edi
cmpl $0x4, %edi
movq %r15, %rbx
je 0xcba9
jmp 0xccf0
callq 0x2070
movl (%rax), %edi
cmpl $0xb, %edi
je 0xcba9
jmp 0xccfe
movq %r15, %rbx
jmp 0xcba9
movl 0x4(%rsp), %edi
leal 0x3f(%rdi), %eax
testl %edi, %edi
cmovnsl %edi, %eax
sarl $0x6, %eax
cltq
movq 0x150(%rsp,%rax,8), %rax
btq %rdi, %rax
leaq 0x1d0(%rsp), %r15
jae 0xcba9
movl $0x5db, %edx            # imm = 0x5DB
movq %rbx, %rsi
callq 0x2230
testl %eax, %eax
jle 0xcb99
movb $0x1, 0x1d0(%rsp)
incl %eax
movl %r14d, %edi
movq %r15, %rsi
movq %rax, %rdx
xorl %ecx, %ecx
leaq 0x40(%rsp), %r8
movl $0x10, %r9d
callq 0x21e0
testq %rax, %rax
jns 0xcb27
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x5c8c(%rip), %rsi      # 0x127a9
movq %rax, %rdx
xorl %eax, %eax
callq 0xd88c
cmpb $0x1, (%rsp)
jne 0xcb8b
testl %r12d, %r12d
jne 0xcb8b
movb 0x1da(%rsp), %cl
cmpb $0x1, %cl
sete %al
cmpb $0x11, %cl
jne 0xcb6e
movl 0x1d1(%rsp), %eax
andl $0xf, %eax
movzwl 0x1d3(%rsp,%rax,4), %ecx
xorl %edx, %edx
cmpw (%rdx,%rbp), %cx
sete %al
je 0xcb6e
leaq 0x2(%rdx), %rsi
cmpq $0xa, %rdx
movq %rsi, %rdx
jne 0xcb58
movl 0x10(%rsp), %ecx
cmpl %ecx, 0x1dd(%rsp)
movl %r13d, %r12d
movl $0x0, %ecx
cmovnel %ecx, %r12d
testb %al, %al
cmovnel %ecx, %r12d
movl 0x4(%rsp), %edi
movl $0x5db, %edx            # imm = 0x5DB
jmp 0xcace
callq 0x2070
movl (%rax), %edi
cmpl $0xb, %edi
jne 0xcd50
movl %r13d, %eax
subl 0x1c(%rsp), %eax
addl $0xffedb080, %eax       # imm = 0xFFEDB080
testl %eax, %eax
jle 0xcc2f
movl %r13d, %eax
movl 0x20(%rsp), %r15d
subl %r15d, %eax
addl $0xfffffc18, %eax       # imm = 0xFFFFFC18
testl %eax, %eax
leaq 0x1d0(%rsp), %rsi
jle 0xcc34
cmpl $0xb, 0x14(%rsp)
jg 0xccac
movb $0x4, 0x1d0(%rsp)
movl $0x64, %edx
movl %r14d, %edi
xorl %ecx, %ecx
leaq 0x40(%rsp), %r8
movl $0x10, %r9d
callq 0x21e0
testq %rax, %rax
jns 0xcc26
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x5be5(%rip), %rsi      # 0x12801
movq %rax, %rdx
xorl %eax, %eax
callq 0xd88c
incl 0x14(%rsp)
movl %r13d, %r15d
jmp 0xcc34
movl 0x20(%rsp), %r15d
cmpb $0x1, (%rsp)
jne 0xcc55
testl %r12d, %r12d
je 0xcc55
movl %r13d, %eax
subl %r12d, %eax
addl $0xffff15a0, %eax       # imm = 0xFFFF15A0
movb $0x1, %cl
movl %ecx, (%rsp)
testl %eax, %eax
jle 0xcc7b
jmp 0xcca3
cmpb $0x2, (%rsp)
jne 0xcc7b
subl %r12d, %r13d
addl $0xfffb6c20, %r13d      # imm = 0xFFFB6C20
testl %r13d, %r13d
setg %al
movl $0x0, %ecx
cmovgl %ecx, %r12d
movb $0x2, %cl
subb %al, %cl
movl %ecx, (%rsp)
callq 0xbbdb
testb %al, %al
movq 0x8(%rsp), %r13
jne 0xcd6d
leaq 0xa62c(%rip), %rax      # 0x172c0
cmpq $0x0, (%rax)
jne 0xc8e8
jmp 0xcd6d
leaq 0x5bea(%rip), %rsi      # 0x12894
jmp 0xccc9
leaq 0x90(%rsp), %rsi
movl 0x10(%rsp), %edi
movl $0x10, %edx
callq 0xbbac
leaq 0x5b6f(%rip), %rsi      # 0x12838
leaq 0x60(%rsp), %rdx
movl $0x3, %edi
xorl %eax, %eax
callq 0xd88c
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %rax
movl %r13d, 0x14(%rax)
movq %rcx, %r13
incw 0x12(%rax)
jmp 0xcd6d
callq 0x2480
leaq 0x596e(%rip), %rsi      # 0x1266a
jmp 0xcd5c
callq 0x2480
leaq 0x5a6e(%rip), %rsi      # 0x12778
jmp 0xcd5c
leaq 0x90(%rsp), %rbx
movl 0x10(%rsp), %edi
movq %rbx, %rsi
movl $0x10, %edx
callq 0xbbac
leaq 0x59cc(%rip), %rsi      # 0x126f8
leaq 0x60(%rsp), %rdx
movl $0x3, %edi
movq %rbx, %rcx
xorl %eax, %eax
callq 0xd88c
leaq 0xa579(%rip), %rax      # 0x172c0
movq $0x0, (%rax)
jmp 0xcd68
callq 0x2480
leaq 0x5a75(%rip), %rsi      # 0x127d1
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0xd88c
movq 0x8(%rsp), %r13
movl 0x24(%rsp), %r8d
subq $0x8, %rsp
leaq 0xb8(%rsp), %rbx
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
movl 0x18(%rsp), %ecx
movq %rbx, %r9
pushq $0x1
pushq $0x0
pushq $0x44
callq 0x7cd4
addq $0x20, %rsp
movq %rbx, %rdi
callq 0x9103
movl 0x4(%rsp), %edi
callq 0x9218
jmp 0xc717