// File: /workspace/github_c_makefile_star2_O1/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, 0x20(%rsp)
leaq 0x140(%rsp), %rax
movq %rax, (%rax)
movq %rax, 0x8(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x60(%rsp)
movw $0x2, %ax
movw %ax, 0x30(%rsp)
movq 0x8(%rdi), %rcx
movzwl 0x10(%rcx), %ecx
movw %cx, 0x32(%rsp)
movl (%rdi), %edx
movl %edx, 0x34(%rsp)
movw %ax, 0x60(%rsp)
movw %cx, 0x62(%rsp)
movq 0x10(%rdi), %rax
movl 0x34(%rax), %eax
movl %eax, 0x64(%rsp)
movl $0x2, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x24e0
testl %eax, %eax
js 0xc362
movl %eax, %ebx
leaq 0x2c(%rsp), %rcx
movl $0x1, (%rcx)
movl %eax, %edi
movl $0x1, %esi
movl $0x2, %edx
movl $0x4, %r8d
callq 0x20d0
testl %eax, %eax
js 0xc386
leaq 0x60(%rsp), %rsi
movl %ebx, %edi
movl $0x10, %edx
callq 0x2370
testl %eax, %eax
js 0xc39b
movq %r13, 0x8(%rsp)
movl %ebx, %edi
movl $0x3, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x20e0
movl %eax, 0x2c(%rsp)
orl $0x800, %eax            # imm = 0x800
movq %rbx, 0x10(%rsp)
movl %ebx, %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 0xb8e7
leaq 0xb10b(%rip), %rcx      # 0x172c0
movb $0xc, %r13b
testb %al, %al
jne 0xc3da
cmpq $0x0, (%rcx)
je 0xc3da
movl $0x1, %r12d
movq 0x10(%rsp), %rcx
shlq %cl, %r12
movl %ecx, %r14d
shrl $0x6, %r14d
leal 0x1(%rcx), %ebp
movb $0xc, %bl
leaq 0xc0(%rsp), %r15
movb $0x2, 0xc0(%rsp)
movl $0x64, %edx
movq 0x10(%rsp), %rdi
movq %r15, %rsi
xorl %ecx, %ecx
leaq 0x30(%rsp), %r8
movl $0x10, %r9d
callq 0x21e0
testq %rax, %rax
js 0xc2f9
movq $0x0, 0x40(%rsp)
movq $0x3d090, 0x48(%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)
orq %r12, 0x1d0(%rsp,%r14,8)
movl %ebp, %edi
leaq 0x1d0(%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
leaq 0x40(%rsp), %r8
callq 0x22c0
movl %eax, %r13d
testl %eax, %eax
jns 0xc2a8
callq 0x2070
movl (%rax), %edi
cmpl $0x4, %edi
jne 0xc3bf
testl %r13d, %r13d
jle 0xc318
testq %r12, 0x1d0(%rsp,%r14,8)
je 0xc318
movl $0x63, %edx
movq 0x10(%rsp), %rdi
movq %r15, %rsi
xorl %ecx, %ecx
leaq 0x150(%rsp), %r8
leaq 0x70(%rsp), %r9
callq 0x2320
testl %eax, %eax
js 0xc34b
cmpl $0x3, %eax
jg 0xc94f
xorl %edi, %edi
leaq 0x68cb(%rip), %rsi      # 0x12bb9
movl %eax, %edx
xorl %eax, %eax
callq 0xd5b0
jmp 0xc318
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x682d(%rip), %rsi      # 0x12b3b
movq %rax, %rdx
xorl %eax, %eax
callq 0xd5b0
leal -0x1(%rbx), %r13d
callq 0xb8e7
testb %al, %al
jne 0xc3da
leaq 0xaf90(%rip), %rax      # 0x172c0
cmpq $0x0, (%rax)
je 0xc3da
cmpb $0x1, %bl
movl %r13d, %ebx
ja 0xc1ec
jmp 0xc3da
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x6832(%rip), %rsi      # 0x12b92
jmp 0xc30e
callq 0x2070
movl (%rax), %edi
callq 0x2480
leaq 0x61cf(%rip), %rsi      # 0x12544
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0xd5b0
jmp 0xca74
callq 0x2070
movl (%rax), %edi
callq 0x2480
leaq 0x61d0(%rip), %rsi      # 0x12569
jmp 0xc3ae
callq 0x2070
movl (%rax), %edi
callq 0x2480
leaq 0x5c07(%rip), %rsi      # 0x11fb5
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0xd5b0
jmp 0xca6d
callq 0x2480
leaq 0x679f(%rip), %rsi      # 0x12b6a
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0xd5b0
movl %ebx, %r13d
movb $0x1, %bl
testb %r13b, %r13b
je 0xc3ea
movq 0x8(%rsp), %r13
xorl %ebp, %ebp
jmp 0xc401
leaq 0x6802(%rip), %rsi      # 0x12bf3
xorl %ebp, %ebp
xorl %edi, %edi
xorl %eax, %eax
callq 0xd5b0
movq 0x8(%rsp), %r13
callq 0xb0fc
movl %eax, %r12d
testb %bl, %bl
je 0xc423
movq 0x8(%r13), %rax
movl %r12d, 0x14(%rax)
incw 0x12(%rax)
movq 0x10(%rsp), %rbx
jmp 0xca6d
leaq 0x80(%rsp), %rbx
movl %ebp, %edi
movq %rbx, %rsi
movl $0x10, %edx
callq 0xb8b8
movl (%r13), %edi
leaq 0x50(%rsp), %r15
movq %r15, %rsi
movl $0x10, %edx
callq 0xb8b8
leaq 0x613f(%rip), %rsi      # 0x12596
xorl %r14d, %r14d
movl $0x3, %edi
movq %rbx, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0xd5b0
movq 0x10(%r13), %rdi
leaq 0xb0(%rsp), %rdx
leaq 0x4(%rsp), %r8
leaq 0x28(%rsp), %r9
movl $0x10, %ecx
movl %ebp, %esi
callq 0x8efb
testb %al, %al
movq 0x10(%rsp), %rbx
jle 0xca6d
movl %r12d, 0x24(%rsp)
leaq 0xb0(%rsp), %rbx
movq %rbx, %rdi
callq 0x8ce6
movl 0x28(%rsp), %r8d
subq $0x8, %rsp
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
movl %ebp, %ecx
movq %rbx, %r9
movq 0x18(%rsp), %rbx
pushq %r14
pushq %r14
pushq $0x44
callq 0x79b0
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)
movl $0x1, %eax
movl %ebx, %ecx
shlq %cl, %rax
movl %ebx, %ecx
shrl $0x6, %ecx
movq %rax, 0xa0(%rsp)
movq %rcx, 0x98(%rsp)
orq %rax, 0xc0(%rsp,%rcx,8)
movl $0x1, %eax
movl 0x4(%rsp), %ecx
leal 0x3f(%rcx), %edx
testl %ecx, %ecx
cmovnsl %ecx, %edx
movl %edx, %esi
andl $-0x40, %esi
movq %rcx, %r15
subl %esi, %ecx
shlq %cl, %rax
sarl $0x6, %edx
movslq %edx, %rcx
orq %rax, 0xc0(%rsp,%rcx,8)
callq 0xb8e7
testb %al, %al
movl %ebp, 0x18(%rsp)
leaq 0xad40(%rip), %rax      # 0x172c0
jne 0xca2a
cmpq $0x0, (%rax)
je 0xca2a
cmpl %r15d, %ebx
cmovgl %ebx, %r15d
incl %r15d
movq %r15, 0xa8(%rsp)
movb $0x1, %r15b
leaq 0xacf4(%rip), %rbp      # 0x172a0
movl $0x0, 0x1c(%rsp)
xorl %r14d, %r14d
xorl %r12d, %r12d
movq 0x8(%r13), %rax
cmpl $0x0, 0x18(%rax)
jne 0xca2a
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 0xb0fc
movl %eax, %r13d
testl %ebx, %ebx
jns 0xc62c
callq 0x2070
movl (%rax), %edi
cmpl $0x4, %edi
jne 0xc9bb
testl %ebx, %ebx
jle 0xc756
movq 0xa0(%rsp), %rax
movq 0x98(%rsp), %rcx
testq %rax, 0x150(%rsp,%rcx,8)
movq 0x10(%rsp), %rbx
je 0xc760
movl $0x5dc, %edx            # imm = 0x5DC
movl %ebx, %edi
leaq 0x1d0(%rsp), %rsi
xorl %ecx, %ecx
leaq 0x40(%rsp), %r8
leaq 0x20(%rsp), %r9
callq 0x2320
testl %eax, %eax
jle 0xc741
cmpl $0x1, %eax
jne 0xc6a3
xorl %edi, %edi
leaq 0x5f67(%rip), %rsi      # 0x125f4
leaq 0x80(%rsp), %rdx
movl $0x1, %ecx
xorl %eax, %eax
callq 0xd5b0
jmp 0xc657
movzbl 0x1d0(%rsp), %ecx
cmpl $0x1, %ecx
je 0xc6e9
cmpl $0x5, %ecx
je 0xc6bf
cmpl $0x3, %ecx
jne 0xc657
jmp 0xc9c9
movl $0x0, 0x1c(%rsp)
movl $0x3, %edi
leaq 0x5fca(%rip), %rsi      # 0x1269d
leaq 0x50(%rsp), %rdx
xorl %eax, %eax
callq 0xd5b0
movl %r13d, 0x24(%rsp)
jmp 0xc657
movl 0x4(%rsp), %edi
decl %eax
leaq 0x1d1(%rsp), %rsi
movq %rax, %rdx
callq 0x20f0
testq %rax, %rax
jns 0xc723
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x5f1b(%rip), %rsi      # 0x12634
movq %rax, %rdx
xorl %eax, %eax
callq 0xd5b0
cmpb $0x1, 0x1da(%rsp)
cmovnel %r13d, %r12d
movzbl %r15b, %r15d
movl $0x2, %eax
cmovnel %eax, %r15d
jmp 0xc657
callq 0x2070
movl (%rax), %edi
cmpl $0xb, %edi
je 0xc866
jmp 0xc966
movq 0x10(%rsp), %rbx
jmp 0xc866
movl 0x4(%rsp), %eax
leal 0x3f(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x6, %ecx
movslq %ecx, %rcx
movq 0x150(%rsp,%rcx,8), %rcx
btq %rax, %rcx
jae 0xc866
movl 0x4(%rsp), %edi
movl $0x5db, %edx            # imm = 0x5DB
leaq 0x1d1(%rsp), %rsi
callq 0x2230
testl %eax, %eax
jle 0xc856
movb $0x1, 0x1d0(%rsp)
incl %eax
movl %ebx, %edi
leaq 0x1d0(%rsp), %rsi
movq %rax, %rdx
xorl %ecx, %ecx
leaq 0x30(%rsp), %r8
movl $0x10, %r9d
callq 0x21e0
testq %rax, %rax
jns 0xc7ef
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x5f20(%rip), %rsi      # 0x12705
movq %rax, %rdx
xorl %eax, %eax
callq 0xd5b0
cmpb $0x1, %r15b
jne 0xc784
testl %r12d, %r12d
jne 0xc784
movb 0x1da(%rsp), %cl
cmpb $0x1, %cl
sete %al
cmpb $0x11, %cl
jne 0xc834
movl 0x1d1(%rsp), %ecx
andl $0xf, %ecx
movzwl 0x1d3(%rsp,%rcx,4), %ecx
xorl %edx, %edx
cmpw (%rdx,%rbp), %cx
je 0xc832
addq $0x2, %rdx
cmpq $0xc, %rdx
jne 0xc820
jmp 0xc834
movb $0x1, %al
movl 0x18(%rsp), %ecx
cmpl %ecx, 0x1dd(%rsp)
movl %r13d, %r12d
movl $0x0, %ecx
cmovnel %ecx, %r12d
testb %al, %al
cmovnel %ecx, %r12d
jmp 0xc784
callq 0x2070
movl (%rax), %edi
cmpl $0xb, %edi
jne 0xca0d
movl %r13d, %eax
subl 0x24(%rsp), %eax
addl $0xffedb080, %eax       # imm = 0xFFEDB080
testl %eax, %eax
jle 0xc8e4
movl %r13d, %eax
subl %r14d, %eax
addl $0xfffffc18, %eax       # imm = 0xFFFFFC18
testl %eax, %eax
jle 0xc8e4
cmpl $0xb, 0x1c(%rsp)
jg 0xc977
movb $0x4, 0x1d0(%rsp)
movl $0x64, %edx
movl %ebx, %edi
leaq 0x1d0(%rsp), %rsi
xorl %ecx, %ecx
leaq 0x30(%rsp), %r8
movl $0x10, %r9d
callq 0x21e0
testq %rax, %rax
jns 0xc8dd
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x5e8a(%rip), %rsi      # 0x1275d
movq %rax, %rdx
xorl %eax, %eax
callq 0xd5b0
incl 0x1c(%rsp)
movl %r13d, %r14d
cmpb $0x1, %r15b
jne 0xc8fe
testl %r12d, %r12d
je 0xc8fe
movl %r13d, %eax
subl %r12d, %eax
addl $0xffff15a0, %eax       # imm = 0xFFFF15A0
testl %eax, %eax
jg 0xc95d
cmpb $0x2, %r15b
jne 0xc927
subl %r12d, %r13d
addl $0xfffb6c20, %r13d      # imm = 0xFFFB6C20
testl %r13d, %r13d
movl $0x0, %eax
cmovgl %eax, %r12d
movzbl %r15b, %r15d
movl $0x1, %eax
cmovgl %eax, %r15d
movq 0x8(%rsp), %r13
callq 0xb8e7
testb %al, %al
leaq 0xa986(%rip), %rax      # 0x172c0
jne 0xca2a
cmpq $0x0, (%rax)
jne 0xc5ba
jmp 0xca2a
movl 0xc1(%rsp), %ebp
xorl %ebx, %ebx
jmp 0xc3fc
leaq 0x5e8c(%rip), %rsi      # 0x127f0
jmp 0xc994
callq 0x2480
leaq 0x5d62(%rip), %rsi      # 0x126d4
jmp 0xca19
leaq 0x80(%rsp), %rsi
movl 0x18(%rsp), %edi
movl $0x10, %edx
callq 0xb8b8
leaq 0x5e00(%rip), %rsi      # 0x12794
leaq 0x50(%rsp), %rdx
movl $0x3, %edi
xorl %eax, %eax
callq 0xd5b0
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %rax
movl %r13d, 0x14(%rax)
movq %rcx, %r13
incw 0x12(%rax)
jmp 0xca2a
callq 0x2480
leaq 0x5bff(%rip), %rsi      # 0x125c6
jmp 0xca19
leaq 0x80(%rsp), %rbx
movl 0x18(%rsp), %edi
movq %rbx, %rsi
movl $0x10, %edx
callq 0xb8b8
leaq 0x5c6b(%rip), %rsi      # 0x12654
leaq 0x50(%rsp), %rdx
movl $0x3, %edi
movq %rbx, %rcx
xorl %eax, %eax
callq 0xd5b0
leaq 0xa8bc(%rip), %rax      # 0x172c0
movq $0x0, (%rax)
jmp 0xca25
callq 0x2480
leaq 0x5d14(%rip), %rsi      # 0x1272d
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0xd5b0
movq 0x8(%rsp), %r13
movl 0x28(%rsp), %r8d
subq $0x8, %rsp
leaq 0xb8(%rsp), %rbx
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
movl 0x20(%rsp), %ecx
movq %rbx, %r9
pushq $0x1
pushq $0x0
pushq $0x44
callq 0x79b0
addq $0x20, %rsp
movq %rbx, %rdi
movq 0x10(%rsp), %rbx
callq 0x8da3
movl 0x4(%rsp), %edi
callq 0x8eb8
movl %ebx, %edi
callq 0x21f0
leaq 0xa845(%rip), %rax      # 0x172c0
movq $0x0, (%rax)
leaq 0xabff(%rip), %rax      # 0x17688
movb $0x0, (%rax)
movq %r13, %rdi
movl $0x4bc, %esi            # imm = 0x4BC
callq 0x5f5b
xorl %eax, %eax
addq $0x7b8, %rsp            # imm = 0x7B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq