// File: /workspace/github_c_makefile_star2_O2/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 $0x7d8, %rsp            # imm = 0x7D8
movq %rdi, %r14
movl $0x10, 0x68(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, (%rax)
andq $0x0, 0x78(%rsp)
movq %rax, 0x8(%rax)
andq $0x0, 0xa8(%rsp)
movw $0x2, %ax
movw %ax, 0x70(%rsp)
movq 0x8(%rdi), %rcx
movzwl 0x10(%rcx), %ecx
movw %cx, 0x72(%rsp)
movl (%rdi), %edx
movl %edx, 0x74(%rsp)
movw %ax, 0xa0(%rsp)
movw %cx, 0xa2(%rsp)
movq 0x10(%rdi), %rax
movl 0x34(%rax), %eax
movl %eax, 0xa4(%rsp)
pushq $0x2
popq %rdi
movl %edi, %esi
xorl %edx, %edx
callq 0x24e0
testl %eax, %eax
js 0xba65
movl %eax, %ebx
leaq 0x6c(%rsp), %rcx
movl $0x1, (%rcx)
pushq $0x1
popq %rsi
pushq $0x2
popq %rdx
pushq $0x4
popq %r8
movl %eax, %edi
callq 0x20d0
testl %eax, %eax
js 0xba89
leaq 0xa0(%rsp), %rsi
pushq $0x10
popq %rdx
movl %ebx, %edi
callq 0x2370
testl %eax, %eax
js 0xba9e
movq %r14, 0x58(%rsp)
pushq $0x3
popq %rsi
movl %ebx, %edi
xorl %edx, %edx
xorl %eax, %eax
callq 0x20e0
movl %eax, 0x6c(%rsp)
orl $0x800, %eax            # imm = 0x800
pushq $0x4
popq %rsi
movl %ebx, %edi
movl %eax, %edx
xorl %eax, %eax
callq 0x20e0
leaq 0x90(%rsp), %rax
movl $0x10, (%rax)
xorps %xmm0, %xmm0
leaq 0xf0(%rsp), %r12
movaps %xmm0, (%r12)
movaps %xmm0, 0x10(%r12)
movaps %xmm0, 0x20(%r12)
andl $0x0, 0x60(%r12)
movaps %xmm0, 0x30(%r12)
movaps %xmm0, 0x40(%r12)
pushq $0x1
popq %rax
movl %ebx, %ecx
shlq %cl, %rax
movq %rax, 0x50(%rsp)
movaps %xmm0, 0x50(%r12)
movl %ebx, %eax
shrl $0x6, %eax
movq %rax, 0x48(%rsp)
movq %rbx, 0x28(%rsp)
leal 0x1(%rbx), %r13d
movb $0xc, %r14b
leaq 0x70(%rsp), %r15
pushq $0x10
popq %rbx
movl %r14d, %ebp
callq 0xb07c
addb $-0x1, %r14b
setb %cl
testb %al, %al
jne 0xbad7
leaq 0xb9a8(%rip), %rax      # 0x172c0
cmpq $0x0, (%rax)
je 0xbad7
testb %cl, %cl
je 0xbad7
movb $0x2, 0xf0(%rsp)
movq 0x28(%rsp), %rdi
movq %r12, %rsi
pushq $0x64
popq %rdx
xorl %ecx, %ecx
movq %r15, %r8
movl %ebx, %r9d
callq 0x21e0
testq %rax, %rax
js 0xba18
andq $0x0, 0xc0(%rsp)
movq $0x3d090, 0xc8(%rsp) # imm = 0x3D090
xorl %eax, %eax
cmpq $0x10, %rax
je 0xb97e
andq $0x0, 0x1f0(%rsp,%rax,8)
incq %rax
jmp 0xb96a
movq 0x50(%rsp), %rax
movq 0x48(%rsp), %rcx
orq %rax, 0x1f0(%rsp,%rcx,8)
movl %r13d, %edi
leaq 0x1f0(%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
leaq 0xc0(%rsp), %r8
callq 0x22c0
testl %eax, %eax
js 0xba3c
je 0xb8fa
movq 0x50(%rsp), %rax
movq 0x48(%rsp), %rcx
testq %rax, 0x1f0(%rsp,%rcx,8)
je 0xb8fa
movq 0x28(%rsp), %rdi
movq %r12, %rsi
pushq $0x63
popq %rdx
xorl %ecx, %ecx
leaq 0x170(%rsp), %r8
leaq 0x90(%rsp), %r9
callq 0x2320
testl %eax, %eax
js 0xba4e
cmpl $0x3, %eax
ja 0xbb43
xorl %edi, %edi
leaq 0x6233(%rip), %rsi      # 0x11c3d
movl %eax, %edx
xorl %eax, %eax
callq 0xcb1c
jmp 0xb8fa
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x6192(%rip), %rsi      # 0x11bbf
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
jmp 0xb8fa
callq 0x2070
movl (%rax), %edi
cmpl $0x4, %edi
je 0xb8fa
jmp 0xbabf
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x61b3(%rip), %rsi      # 0x11c16
jmp 0xba2d
callq 0x2070
movl (%rax), %edi
callq 0x2480
leaq 0x5b50(%rip), %rsi      # 0x115c8
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
jmp 0xbb0d
callq 0x2070
movl (%rax), %edi
callq 0x2480
leaq 0x5b51(%rip), %rsi      # 0x115ed
jmp 0xbab1
callq 0x2070
movl (%rax), %edi
callq 0x2480
leaq 0x5588(%rip), %rsi      # 0x11039
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
jmp 0xbb06
callq 0x2480
leaq 0x6123(%rip), %rsi      # 0x11bee
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
testb %bpl, %bpl
jne 0xbaec
leaq 0x6194(%rip), %rsi      # 0x11c77
xorl %edi, %edi
xorl %eax, %eax
callq 0xcb1c
callq 0xa9e4
movq 0x58(%rsp), %r14
movq 0x8(%r14), %rcx
movl %eax, 0x14(%rcx)
incw 0x12(%rcx)
movq 0x28(%rsp), %rbx
movl %ebx, %edi
callq 0x21f0
leaq 0xb7ac(%rip), %rax      # 0x172c0
andq $0x0, (%rax)
leaq 0xbb69(%rip), %rax      # 0x17688
movb $0x0, (%rax)
movq %r14, %rdi
movl $0x4bc, %esi            # imm = 0x4BC
callq 0x5b1a
xorl %eax, %eax
addq $0x7d8, %rsp            # imm = 0x7D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0xf1(%rsp), %r12d
callq 0xa9e4
movl %eax, 0x3c(%rsp)
leaq 0xb0(%rsp), %rbx
pushq $0x10
popq %rbp
movl %r12d, %edi
movq %rbx, %rsi
movl %ebp, %edx
callq 0xb04f
movq 0x58(%rsp), %r14
movl (%r14), %edi
leaq 0x80(%rsp), %r15
movq %r15, %rsi
movl %ebp, %edx
callq 0xb04f
leaq 0x5a8d(%rip), %rsi      # 0x1161a
pushq $0x3
popq %rdi
movq %rbx, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0xcb1c
movq 0x10(%r14), %rdi
leaq 0xd0(%rsp), %rdx
pushq $0x10
popq %rcx
leaq 0x24(%rsp), %r8
leaq 0x44(%rsp), %r9
movl %r12d, %esi
callq 0x8925
testb %al, %al
movq 0x28(%rsp), %rbx
jle 0xbb06
leaq 0xd0(%rsp), %rbx
movq %rbx, %rdi
callq 0x86f2
movl 0x44(%rsp), %r8d
andl $0x0, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
movl $0x44, (%rsp)
xorl %r14d, %r14d
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
movl %r12d, %ecx
movq %rbx, %r9
movq 0x28(%rsp), %rbx
callq 0x745c
cmpq $0x10, %r14
je 0xbc1e
andq $0x0, 0xf0(%rsp,%r14,8)
incq %r14
jmp 0xbc0a
movl %r12d, 0x34(%rsp)
movq 0x50(%rsp), %rax
movq 0x48(%rsp), %rcx
orq %rax, 0xf0(%rsp,%rcx,8)
movl 0x24(%rsp), %esi
pushq $0x40
popq %rcx
movl %esi, %eax
cltd
idivl %ecx
movslq %eax, %rdx
shll $0x6, %eax
movl %esi, %ecx
subl %eax, %ecx
pushq $0x1
popq %rax
shlq %cl, %rax
orq %rax, 0xf0(%rsp,%rdx,8)
cmpl %esi, %ebx
cmovgl %ebx, %esi
incl %esi
movl %esi, 0x64(%rsp)
movb $0x1, %r13b
leaq 0xb632(%rip), %rbp      # 0x172a0
xorl %r15d, %r15d
xorl %edx, %edx
movl $0x0, 0x38(%rsp)
movq 0x58(%rsp), %r14
movl %edx, 0x40(%rsp)
callq 0xb07c
testb %al, %al
jne 0xc0db
leaq 0xb628(%rip), %rax      # 0x172c0
cmpq $0x0, (%rax)
je 0xc0db
movq 0x8(%r14), %rax
cmpl $0x0, 0x18(%rax)
jne 0xc0db
andq $0x0, 0x90(%rsp)
movq $0xfa, 0x98(%rsp)
pushq $0x10
popq %rcx
leaq 0x170(%rsp), %rax
movq %rax, %rdi
leaq 0xf0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movl 0x64(%rsp), %edi
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
leaq 0x90(%rsp), %r8
callq 0x22c0
movl %eax, %ebx
callq 0xa9e4
movl %eax, %r12d
testl %ebx, %ebx
js 0xbe14
je 0xbe43
movq 0x50(%rsp), %rax
movq 0x48(%rsp), %rcx
testq %rax, 0x170(%rsp,%rcx,8)
movq 0x28(%rsp), %rbx
je 0xbe4d
movl $0x5dc, %edx            # imm = 0x5DC
movl %ebx, %edi
leaq 0x1f0(%rsp), %rsi
xorl %ecx, %ecx
leaq 0xc0(%rsp), %r8
leaq 0x68(%rsp), %r9
callq 0x2320
testl %eax, %eax
jle 0xbe2e
cmpl $0x1, %eax
jne 0xbd78
xorl %edi, %edi
leaq 0x5914(%rip), %rsi      # 0x11678
leaq 0xb0(%rsp), %rdx
pushq $0x1
popq %rcx
xorl %eax, %eax
callq 0xcb1c
jmp 0xbd2b
movzbl 0x1f0(%rsp), %ecx
cmpl $0x5, %ecx
je 0xbde9
cmpl $0x3, %ecx
je 0xc083
cmpl $0x1, %ecx
jne 0xbd2b
movl 0x24(%rsp), %edi
decl %eax
leaq 0x1f1(%rsp), %rsi
movq %rax, %rdx
callq 0x20f0
testq %rax, %rax
jns 0xbdcd
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x58f5(%rip), %rsi      # 0x116b8
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
cmpb $0x1, 0x1fa(%rsp)
cmovnel %r12d, %r15d
movzbl %r13b, %r13d
pushq $0x2
popq %rax
cmovnel %eax, %r13d
jmp 0xbd2b
movl $0x0, 0x38(%rsp)
pushq $0x3
popq %rdi
leaq 0x5926(%rip), %rsi      # 0x11721
leaq 0x80(%rsp), %rdx
xorl %eax, %eax
callq 0xcb1c
movl %r12d, 0x3c(%rsp)
jmp 0xbd2b
callq 0x2070
movl (%rax), %edi
cmpl $0x4, %edi
movq 0x28(%rsp), %rbx
je 0xbf4f
jmp 0xc067
callq 0x2070
movl (%rax), %edi
cmpl $0xb, %edi
je 0xbf4f
jmp 0xc075
movq 0x28(%rsp), %rbx
jmp 0xbf4f
movl 0x24(%rsp), %edi
movl %edi, %eax
cltd
pushq $0x40
popq %rcx
idivl %ecx
cltq
movq 0x170(%rsp,%rax,8), %rax
btq %rdx, %rax
jae 0xbf4f
movl $0x5db, %edx            # imm = 0x5DB
leaq 0x1f1(%rsp), %rsi
callq 0x2230
testl %eax, %eax
jle 0xbf3f
movb $0x1, 0x1f0(%rsp)
incl %eax
movl %ebx, %edi
leaq 0x1f0(%rsp), %rsi
movq %rax, %rdx
xorl %ecx, %ecx
leaq 0x70(%rsp), %r8
pushq $0x10
popq %r9
callq 0x21e0
testq %rax, %rax
jns 0xbed2
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x58c1(%rip), %rsi      # 0x11789
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
cmpb $0x1, %r13b
jne 0xbf36
testl %r15d, %r15d
jne 0xbf36
movb 0x1fa(%rsp), %cl
cmpb $0x1, %cl
sete %al
cmpb $0x11, %cl
jne 0xbf19
xorl %ecx, %ecx
cmpq $0xc, %rcx
setne %al
je 0xbf19
movl 0x1f1(%rsp), %edx
andl $0xf, %edx
movzwl 0x1f3(%rsp,%rdx,4), %edx
leaq 0x2(%rcx), %rsi
cmpw (%rcx,%rbp), %dx
movq %rsi, %rcx
jne 0xbef1
movl 0x34(%rsp), %ecx
cmpl %ecx, 0x1fd(%rsp)
movl %r12d, %r15d
movl $0x0, %ecx
cmovnel %ecx, %r15d
testb %al, %al
cmovnel %ecx, %r15d
movl 0x24(%rsp), %edi
jmp 0xbe6d
callq 0x2070
movl (%rax), %edi
cmpl $0xb, %edi
jne 0xc0c3
movl %r12d, %eax
subl 0x3c(%rsp), %eax
addl $0xffedb080, %eax       # imm = 0xFFEDB080
testl %eax, %eax
jle 0xbfce
movl %r12d, %eax
movl 0x40(%rsp), %edx
subl %edx, %eax
addl $0xfffffc18, %eax       # imm = 0xFFFFFC18
testl %eax, %eax
jle 0xbfd2
cmpl $0xb, 0x38(%rsp)
jg 0xc02c
movb $0x4, 0x1f0(%rsp)
movl %ebx, %edi
leaq 0x1f0(%rsp), %rsi
pushq $0x64
popq %rdx
xorl %ecx, %ecx
leaq 0x70(%rsp), %r8
pushq $0x10
popq %r9
callq 0x21e0
testq %rax, %rax
jns 0xbfc5
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x5826(%rip), %rsi      # 0x117e1
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
incl 0x38(%rsp)
movl %r12d, %edx
jmp 0xbfd2
movl 0x40(%rsp), %edx
cmpb $0x1, %r13b
jne 0xbff5
testl %r15d, %r15d
je 0xbff5
movl %r12d, %eax
subl %r15d, %eax
addl $0xffff15a0, %eax       # imm = 0xFFFF15A0
movb $0x1, %r13b
testl %eax, %eax
jle 0xbc80
jmp 0xc023
cmpb $0x2, %r13b
jne 0xbc80
subl %r15d, %r12d
addl $0xfffb6c20, %r12d      # imm = 0xFFFB6C20
testl %r12d, %r12d
setg %al
movl $0x0, %ecx
cmovgl %ecx, %r15d
movb $0x2, %r13b
subb %al, %r13b
jmp 0xbc80
leaq 0x584a(%rip), %rsi      # 0x11874
jmp 0xc047
leaq 0xb0(%rsp), %rsi
pushq $0x10
popq %rdx
movl 0x34(%rsp), %edi
callq 0xb04f
leaq 0x57d1(%rip), %rsi      # 0x11818
pushq $0x3
popq %rdi
leaq 0x80(%rsp), %rdx
xorl %eax, %eax
callq 0xcb1c
movq 0x8(%r14), %rax
movl %r12d, 0x14(%rax)
incw 0x12(%rax)
jmp 0xc0db
callq 0x2480
leaq 0x55d7(%rip), %rsi      # 0x1164a
jmp 0xc0cf
callq 0x2480
leaq 0x56d7(%rip), %rsi      # 0x11758
jmp 0xc0cf
leaq 0xb0(%rsp), %rbx
pushq $0x10
popq %rdx
movl 0x34(%rsp), %edi
movq %rbx, %rsi
callq 0xb04f
leaq 0x5637(%rip), %rsi      # 0x116d8
pushq $0x3
popq %rdi
leaq 0x80(%rsp), %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0xcb1c
leaq 0xb203(%rip), %rax      # 0x172c0
andq $0x0, (%rax)
jmp 0xc0db
callq 0x2480
leaq 0x56e2(%rip), %rsi      # 0x117b1
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
movl 0x44(%rsp), %r8d
movl $0x1, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
movl $0x44, (%rsp)
leaq 0xd0(%rsp), %rbx
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
movl 0x34(%rsp), %ecx
movq %rbx, %r9
callq 0x745c
movq %rbx, %rdi
callq 0x87bd
movl 0x24(%rsp), %edi
callq 0x88e2
jmp 0xbb01