// File: /workspace/github_c_makefile_star2_O3/open-mesh-mirror[P]batmand/posix/unix_socket.c
// Function: unix_listen
void *unix_listen(void * BATMANUNUSED(arg)) {

	struct unix_client *unix_client;
	struct debug_level_info *debug_level_info;
	struct list_head *list_pos, *unix_pos_tmp, *debug_pos, *debug_pos_tmp, *prev_list_head, *prev_list_head_unix;
	struct hna_local_entry *hna_local_entry;
	struct batman_if *batman_if;
	struct timeval tv;
	struct sockaddr_un sun_addr;
	struct in_addr tmp_ip_holder;
	int32_t status, max_sock, unix_opts, download_speed, upload_speed;
	int8_t res;
	char buff[100], str[16], was_gateway, tmp_unix_value;
	fd_set wait_sockets, tmp_wait_sockets;
	socklen_t sun_size = sizeof(struct sockaddr_un);


	INIT_LIST_HEAD_FIRST(unix_if.client_list);

	FD_ZERO(&wait_sockets);
	FD_SET(unix_if.unix_sock, &wait_sockets);

	max_sock = unix_if.unix_sock;

	while (!is_aborted()) {

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

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

		if ( res > 0 ) {

			/* new client */
			if ( FD_ISSET( unix_if.unix_sock, &tmp_wait_sockets ) ) {

				unix_client = debugMalloc( sizeof(struct unix_client), 201 );
				memset( unix_client, 0, sizeof(struct unix_client) );

				if ( ( unix_client->sock = accept( unix_if.unix_sock, (struct sockaddr *)&sun_addr, &sun_size) ) == -1 ) {
					debug_output( 0, "Error - can't accept unix client: %s\n", strerror(errno) );
					continue;
				}

				INIT_LIST_HEAD( &unix_client->list );

				FD_SET( unix_client->sock, &wait_sockets );
				if ( unix_client->sock > max_sock )
					max_sock = unix_client->sock;

				/* make unix socket non blocking */
				unix_opts = fcntl( unix_client->sock, F_GETFL, 0 );
				fcntl( unix_client->sock, F_SETFL, unix_opts | O_NONBLOCK );

				list_add_tail( &unix_client->list, &unix_if.client_list );

				debug_output( 3, "Unix socket: got connection\n" );

			/* client sent data */
			} else {

				max_sock = unix_if.unix_sock;

				prev_list_head_unix = (struct list_head *)&unix_if.client_list;

				list_for_each_safe( list_pos, unix_pos_tmp, &unix_if.client_list ) {

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

					if ( FD_ISSET( unix_client->sock, &tmp_wait_sockets ) ) {

						status = read( unix_client->sock, buff, sizeof( buff ) );

						if ( status > 0 ) {

							if ( unix_client->sock > max_sock )
								max_sock = unix_client->sock;

							/* debug_output( 3, "gateway: client sent data via unix socket: %s\n", buff ); */

							if (buff[0] == 'a') {

								if (status > 2) {
									hna_local_task_add_str(buff + 2, ROUTE_ADD, 1);
									dprintf(unix_client->sock, "EOD\n");
								}

							} else if (buff[0] == 'A') {

								if (status > 2) {
									hna_local_task_add_str(buff + 2, ROUTE_DEL, 1);
									dprintf(unix_client->sock, "EOD\n");
								}

							} else if ( buff[0] == 'd' ) {

								if ( ( status > 2 ) && ( ( buff[2] > 0 ) && ( buff[2] <= debug_level_max ) ) ) {

									if ( unix_client->debug_level != 0 ) {

										prev_list_head = (struct list_head *)debug_clients.fd_list[unix_client->debug_level - 1];

										if ( pthread_mutex_lock( (pthread_mutex_t *)debug_clients.mutex[unix_client->debug_level - 1] ) != 0 )
											debug_output( 0, "Error - could not lock mutex (unix_listen => 1): %s \n", strerror( errno ) );

										list_for_each_safe( debug_pos, debug_pos_tmp, (struct list_head *)debug_clients.fd_list[unix_client->debug_level - 1] ) {

											debug_level_info = list_entry( debug_pos, struct debug_level_info, list );

											if ( debug_level_info->fd == unix_client->sock ) {

												list_del( prev_list_head, debug_pos, debug_clients.fd_list[unix_client->debug_level - 1] );
												debug_clients.clients_num[unix_client->debug_level - 1]--;

												debugFree( debug_pos, 1201 );

												break;

											}

											prev_list_head = &debug_level_info->list;

										}

										if ( pthread_mutex_unlock( (pthread_mutex_t *)debug_clients.mutex[unix_client->debug_level - 1] ) != 0 )
											debug_output( 0, "Error - could not unlock mutex (unix_listen => 1): %s \n", strerror( errno ) );

									}

									if ( unix_client->debug_level != buff[2] ) {

										if ( pthread_mutex_lock( (pthread_mutex_t *)debug_clients.mutex[buff[2] - 1] ) != 0 )
											debug_output( 0, "Error - could not lock mutex (unix_listen => 2): %s \n", strerror( errno ) );

										debug_level_info = debugMalloc( sizeof(struct debug_level_info), 202 );
										INIT_LIST_HEAD( &debug_level_info->list );
										debug_level_info->fd = unix_client->sock;
										list_add( &debug_level_info->list, (struct list_head_first *)debug_clients.fd_list[buff[2] - 1] );
										debug_clients.clients_num[buff[2] - 1]++;

										unix_client->debug_level = buff[2];

										if ( pthread_mutex_unlock( (pthread_mutex_t *)debug_clients.mutex[buff[2] - 1] ) != 0 )
											debug_output( 0, "Error - could not unlock mutex (unix_listen => 2): %s \n", strerror( errno ) );

									} else {

										unix_client->debug_level = 0;

									}

								}

							} else if ( buff[0] == 'i' ) {

								internal_output(unix_client->sock);
								dprintf( unix_client->sock, "EOD\n" );

							} else if ( buff[0] == 'g' ) {

								if ( status > 2 ) {

									if ((buff[2] == 0) || (probe_tun(0))) {

										was_gateway = ( gateway_class > 0 ? 1 : 0 );

										gateway_class = buff[2];
										((struct batman_if *)if_list.next)->out.gwflags = gateway_class;

										if ( ( gateway_class > 0 ) && ( routing_class > 0 ) ) {

											if ((routing_class != 0) && (curr_gateway != NULL))
												del_default_route();

											add_del_interface_rules(RULE_DEL);
											routing_class = 0;

										}

										if ( ( !was_gateway ) && ( gateway_class > 0 ) )
											init_interface_gw();
										else if ((was_gateway) && (gateway_class == 0))
											del_gw_interface();
									}

								}

								dprintf( unix_client->sock, "EOD\n" );

							} else if ( buff[0] == 'm' ) {

								if ( status > 2 ) {
									debug_output(3, "Unix socket: changing hop penalty points from: %i to: %i\n", hop_penalty, buff[2]);
									hop_penalty = buff[2];
								}

								dprintf( unix_client->sock, "EOD\n" );

							} else if ( buff[0] == 'q' ) {

								if ( status > 2 ) {
									debug_output(3, "Unix socket: changing purge timeout from: %i to: %li\n", purge_timeout, strtol(buff + 2, NULL, 10));
									purge_timeout = strtol(buff + 2, NULL, 10);
								}

								dprintf( unix_client->sock, "EOD\n" );

							} else if ( buff[0] == 'r' ) {

								if ( status > 2 ) {

									if ((buff[2] == 0) || (probe_tun(0))) {

										tmp_unix_value = buff[2];

										if ( ( tmp_unix_value >= 0 ) && ( tmp_unix_value <= 3 ) && (tmp_unix_value != routing_class) ) {

											if ((routing_class != 0) && (curr_gateway != NULL))
												del_default_route();

											if ( ( tmp_unix_value > 0 ) && ( gateway_class > 0 ) ) {

												gateway_class = 0;
												((struct batman_if *)if_list.next)->out.gwflags = gateway_class;
												del_gw_interface();

											}

											if ((tmp_unix_value > 0) && (routing_class == 0))
												add_del_interface_rules(RULE_ADD);
											else if ((tmp_unix_value == 0) && (routing_class > 0))
												add_del_interface_rules(RULE_DEL);

											routing_class = tmp_unix_value;

										}

									}

								}

								dprintf( unix_client->sock, "EOD\n" );

							} else if ( buff[0] == 'p' ) {

								if ( status > 2 ) {

									if ( inet_pton( AF_INET, buff + 2, &tmp_ip_holder ) > 0 ) {

										pref_gateway = tmp_ip_holder.s_addr;

										if ( curr_gateway != NULL )
											del_default_route();

									} else {

										debug_output( 3, "Unix socket: rejected new preferred gw (%s) - invalid IP specified\n", buff + 2 );

									}

								}

								dprintf( unix_client->sock, "EOD\n" );

							} else if (buff[0] == 'y') {

								dprintf(unix_client->sock, "%s", prog_name);

								if (routing_class > 0)
									dprintf(unix_client->sock, " -r %i", routing_class);

								if (pref_gateway > 0) {

									addr_to_string( pref_gateway, str, sizeof (str) );

									dprintf(unix_client->sock, " -p %s", str);

								}

								if (gateway_class > 0) {

									get_gw_speeds(gateway_class, &download_speed, &upload_speed);

									dprintf(unix_client->sock, " -g %i%s/%i%s", (download_speed > 2048 ? download_speed / 1024 : download_speed), (download_speed > 2048 ? "MBit" : "KBit"), (upload_speed > 2048 ? upload_speed / 1024 : upload_speed), (upload_speed > 2048 ? "MBit" : "KBit"));

								}

								list_for_each(debug_pos, &hna_list) {

									hna_local_entry = list_entry(debug_pos, struct hna_local_entry, list);

									addr_to_string(hna_local_entry->addr, str, sizeof (str));
									dprintf(unix_client->sock, " -a %s/%i", str, hna_local_entry->netmask);
								}

								if (debug_level != 0)
									dprintf(unix_client->sock, " -d %i", debug_level);

								if (originator_interval != 1000)
									dprintf(unix_client->sock, " -o %i", originator_interval);

								if (vis_if.sock) {
									addr_to_string(vis_if.addr.sin_addr.s_addr, str, sizeof(str));
									dprintf(unix_client->sock, " -s %s", str);
								}

								if (policy_routing_script != NULL)
									dprintf(unix_client->sock, " --policy-routing-script %s", policy_routing_script);

								if (hop_penalty != TQ_HOP_PENALTY)
									dprintf(unix_client->sock, " --hop-penalty %i", hop_penalty);

								if (!aggregation_enabled)
									dprintf(unix_client->sock, " --disable-aggregation");

								if (purge_timeout != PURGE_TIMEOUT)
									dprintf(unix_client->sock, " --purge-timeout %u", purge_timeout);

								list_for_each(debug_pos, &if_list) {

									batman_if = list_entry(debug_pos, struct batman_if, list);

									dprintf(unix_client->sock, " %s", batman_if->dev);

								}

								dprintf(unix_client->sock, "\nEOD\n");

							}

							prev_list_head_unix = &unix_client->list;

						} else {

							if ( status < 0 )
								debug_output( 0, "Error - can't read unix message: %s\n", strerror(errno) );

							if ( unix_client->debug_level != 0 ) {

								prev_list_head = (struct list_head *)debug_clients.fd_list[unix_client->debug_level - 1];

								if ( pthread_mutex_lock( (pthread_mutex_t *)debug_clients.mutex[unix_client->debug_level - 1] ) != 0 )
									debug_output( 0, "Error - could not lock mutex (unix_listen => 3): %s \n", strerror( errno ) );

								list_for_each_safe( debug_pos, debug_pos_tmp, (struct list_head *)debug_clients.fd_list[unix_client->debug_level - 1] ) {

									debug_level_info = list_entry( debug_pos, struct debug_level_info, list );

									if ( debug_level_info->fd == unix_client->sock ) {

										list_del( prev_list_head, debug_pos, debug_clients.fd_list[unix_client->debug_level - 1] );
										debug_clients.clients_num[unix_client->debug_level - 1]--;

										debugFree( debug_pos, 1202 );

										break;

									}

									prev_list_head = &debug_level_info->list;

								}

								if ( pthread_mutex_unlock( (pthread_mutex_t *)debug_clients.mutex[unix_client->debug_level - 1] ) != 0 )
									debug_output( 0, "Error - could not unlock mutex (unix_listen => 3): %s \n", strerror( errno ) );

							}

							debug_output( 3, "Unix client closed connection ...\n" );

							FD_CLR(unix_client->sock, &wait_sockets);
							close( unix_client->sock );

							list_del( prev_list_head_unix, list_pos, &unix_if.client_list );
							debugFree( list_pos, 1203 );

						}

					} else {

						if ( unix_client->sock > max_sock )
							max_sock = unix_client->sock;

					}

				}

			}

		} else if ((res < 0) && (errno != EINTR)) {

			debug_output(0, "Error - can't select (unix_listen): %s\n", strerror(errno));
			break;

		}

	}

	list_for_each_safe( list_pos, unix_pos_tmp, &unix_if.client_list ) {

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

		if ( unix_client->debug_level != 0 ) {

			prev_list_head = (struct list_head *)debug_clients.fd_list[unix_client->debug_level - 1];

			if ( pthread_mutex_lock( (pthread_mutex_t *)debug_clients.mutex[unix_client->debug_level - 1] ) != 0 )
				debug_output( 0, "Error - could not lock mutex (unix_listen => 4): %s \n", strerror( errno ) );

			list_for_each_safe( debug_pos, debug_pos_tmp, (struct list_head *)debug_clients.fd_list[unix_client->debug_level - 1] ) {

				debug_level_info = list_entry(debug_pos, struct debug_level_info, list);

				if ( debug_level_info->fd == unix_client->sock ) {

					list_del( prev_list_head, debug_pos, debug_clients.fd_list[unix_client->debug_level - 1] );
					debug_clients.clients_num[unix_client->debug_level - 1]--;

					debugFree( debug_pos, 1204 );

					break;

				}

				prev_list_head = &debug_level_info->list;

			}

			if ( pthread_mutex_unlock( (pthread_mutex_t *)debug_clients.mutex[unix_client->debug_level - 1] ) != 0 )
				debug_output( 0, "Error - could not unlock mutex (unix_listen => 4): %s \n", strerror( errno ) );

		}

		list_del( (struct list_head *)&unix_if.client_list, list_pos, &unix_if.client_list );
		debugFree( list_pos, 1205 );

	}

	return NULL;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movl $0x6e, 0x10(%rsp)
leaq 0x9675(%rip), %r12      # 0x17408
leaq 0x80(%r12), %rbx
movq %rbx, 0x80(%r12)
movq %rbx, 0x88(%r12)
xorps %xmm0, %xmm0
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0xc0(%rsp)
movaps %xmm0, 0xd0(%rsp)
movaps %xmm0, 0xe0(%rsp)
movaps %xmm0, 0xf0(%rsp)
movaps %xmm0, 0x100(%rsp)
movaps %xmm0, 0x110(%rsp)
movaps %xmm0, 0x120(%rsp)
movl (%r12), %ecx
leal 0x3f(%rcx), %eax
testl %ecx, %ecx
cmovnsl %ecx, %eax
movl %eax, %edx
andl $-0x40, %edx
movq %rcx, %r15
subl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
sarl $0x6, %eax
cltq
orq %rdx, 0xb0(%rsp,%rax,8)
callq 0xbbdb
testb %al, %al
je 0xdf51
movq 0x80(%r12), %rbp
cmpq %rbx, %rbp
je 0xdf3d
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
leaq 0x9504(%rip), %r15      # 0x17348
movq %rbp, %r12
movq (%rbp), %rbp
movzbl 0xc(%r12), %eax
testq %rax, %rax
je 0xdf19
addl %r14d, %eax
movq (%r15), %rcx
movq 0x10(%r15), %rdx
movq (%rcx,%rax,8), %r13
movq (%rdx,%rax,8), %rdi
callq 0x24c0
testl %eax, %eax
je 0xde94
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x5474(%rip), %rsi      # 0x132fe
movq %rax, %rdx
xorl %eax, %eax
callq 0xd88c
movq (%r15), %rcx
movzbl 0xc(%r12), %eax
movq -0x8(%rcx,%rax,8), %rdx
movq %rdx, %rcx
movq %r13, %rdi
movq (%rcx), %r13
cmpq %rdx, %r13
je 0xdee8
movl 0x8(%r13), %esi
movq %r13, %rcx
cmpl 0x8(%r12), %esi
jne 0xdea5
movq %r13, %rsi
callq 0x5be3
movq 0x8(%r15), %rax
movzbl 0xc(%r12), %ecx
decw -0x2(%rax,%rcx,2)
movq %r13, %rdi
movl $0x4b4, %esi            # imm = 0x4B4
callq 0x628b
movzbl 0xc(%r12), %eax
movq 0x10(%r15), %rcx
movq -0x8(%rcx,%rax,8), %rdi
callq 0x22d0
testl %eax, %eax
je 0xdf19
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x5425(%rip), %rsi      # 0x13334
movq %rax, %rdx
xorl %eax, %eax
callq 0xd88c
movq %rbx, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x5be3
movq %r12, %rdi
movl $0x4b5, %esi            # imm = 0x4B5
callq 0x628b
cmpq %rbx, %rbp
jne 0xde44
xorl %eax, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x138(%rsp), %r13
leal 0x1(%r15), %ebp
movq $0x1, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
movl $0x10, %ecx
movq %r13, %rdi
leaq 0xb0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movl %ebp, %edi
movq %r13, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
leaq 0x30(%rsp), %r8
callq 0x22c0
movsbl %al, %eax
testl %eax, %eax
jle 0xe02c
movl (%r12), %eax
leal 0x3f(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x6, %ecx
movslq %ecx, %rcx
movq 0x138(%rsp,%rcx,8), %rcx
btq %rax, %rcx
jae 0xe03a
movl $0x10, %edi
movl $0xc9, %esi
callq 0x5d52
movq %rax, %r14
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl (%r12), %edi
leaq 0x1ba(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x2400
movl %eax, 0x8(%r14)
cmpl $-0x1, %eax
jne 0xe9bf
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x4fa3(%rip), %rsi      # 0x12fb3
movq %rax, %rdx
xorl %eax, %eax
callq 0xd88c
callq 0xbbdb
testb %al, %al
je 0xdf5d
jmp 0xde26
js 0xea3f
movq %r15, %r13
jmp 0xea4e
movq 0x80(%r12), %r15
movl %eax, %r13d
cmpq %rbx, %r15
je 0xea4e
movq %rbx, %rbp
movq %r15, %r14
movq (%r15), %r15
movl 0x8(%r14), %edi
leal 0x3f(%rdi), %eax
testl %edi, %edi
cmovnsl %edi, %eax
sarl $0x6, %eax
cltq
movq 0x138(%rsp,%rax,8), %rax
btq %rdi, %rax
jae 0xe0ca
movl $0x64, %edx
leaq 0x40(%rsp), %rsi
callq 0x2230
testl %eax, %eax
jle 0xe0d9
movl 0x8(%r14), %edi
cmpl %r13d, %edi
cmovgl %edi, %r13d
movzbl 0x40(%rsp), %ecx
leal -0x61(%rcx), %edx
cmpl $0x11, %edx
ja 0xe1c1
leaq 0x4c54(%rip), %rsi      # 0x12d00
movslq (%rsi,%rdx,4), %rcx
addq %rsi, %rcx
jmpq *%rcx
cmpl $0x3, %eax
jb 0xe767
leaq 0x42(%rsp), %rdi
xorl %esi, %esi
jmp 0xe74b
cmpl %r13d, %edi
cmovgl %edi, %r13d
movq %rbp, %r14
jmp 0xe767
movq %r15, (%rsp)
jns 0xe0fe
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x512c(%rip), %rsi      # 0x13220
movq %rax, %rdx
xorl %eax, %eax
callq 0xd88c
movzbl 0xc(%r14), %eax
testq %rax, %rax
je 0xe4a7
movq %r13, 0x8(%rsp)
movq %r12, %r15
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
addl %ecx, %eax
leaq 0x9226(%rip), %rdx      # 0x17348
movq (%rdx), %rcx
movq 0x10(%rdx), %rdx
movq (%rcx,%rax,8), %r12
movq (%rdx,%rax,8), %rdi
callq 0x24c0
testl %eax, %eax
je 0xe159
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x50f6(%rip), %rsi      # 0x13245
movq %rax, %rdx
xorl %eax, %eax
callq 0xd88c
leaq 0x91e8(%rip), %rax      # 0x17348
movq (%rax), %rcx
movzbl 0xc(%r14), %eax
movq -0x8(%rcx,%rax,8), %rdx
movq %rdx, %rcx
movq %r12, %rdi
movq (%rcx), %r12
cmpq %rdx, %r12
je 0xe467
movl 0x8(%r12), %esi
movq %r12, %rcx
cmpl 0x8(%r14), %esi
jne 0xe170
movq %r12, %rsi
callq 0x5be3
leaq 0x91ac(%rip), %r13      # 0x17348
movq 0x8(%r13), %rax
movzbl 0xc(%r14), %ecx
decw -0x2(%rax,%rcx,2)
movq %r12, %rdi
movl $0x4b2, %esi            # imm = 0x4B2
callq 0x628b
movzbl 0xc(%r14), %eax
jmp 0xe46e
cmpl $0x41, %ecx
leaq 0x42(%rsp), %rdx
je 0xe73e
cmpl $0x79, %ecx
jne 0xe767
leaq 0x9199(%rip), %rax      # 0x17378
movq (%rax), %rdx
leaq 0x4fa8(%rip), %rsi      # 0x13191
xorl %eax, %eax
callq 0x2200
leaq 0x90c3(%rip), %rax      # 0x172ba
movzbl (%rax), %edx
testl %edx, %edx
je 0xe210
movl 0x8(%r14), %edi
leaq 0x4f7d(%rip), %rsi      # 0x13186
xorl %eax, %eax
callq 0x2200
leaq 0x90b9(%rip), %rax      # 0x172d0
movl (%rax), %edi
testl %edi, %edi
leaq 0x20(%rsp), %r12
je 0xe244
movq %r12, %rsi
movl $0x10, %edx
callq 0xbbac
movl 0x8(%r14), %edi
leaq 0x4f53(%rip), %rsi      # 0x1318d
movq %r12, %rdx
xorl %eax, %eax
callq 0x2200
movq %r15, (%rsp)
movq %r13, 0x8(%rsp)
leaq 0x9065(%rip), %rax      # 0x172b9
movb (%rax), %al
testb %al, %al
je 0xe2bb
movzbl %al, %edi
leaq 0x18(%rsp), %rsi
leaq 0x14(%rsp), %rdx
callq 0x3006
movl 0x18(%rsp), %eax
movl %eax, %edx
shrl $0xa, %edx
movl $0x801, %esi            # imm = 0x801
cmpl %esi, %eax
cmovll %eax, %edx
leaq 0x18fd(%rip), %r9       # 0xfb83
movq %r9, %rcx
leaq 0x18ee(%rip), %r10      # 0xfb7e
cmovgeq %r10, %rcx
movl 0x14(%rsp), %eax
movl %eax, %r8d
shrl $0xa, %r8d
cmpl %esi, %eax
cmovll %eax, %r8d
movl 0x8(%r14), %edi
cmovgeq %r10, %r9
leaq 0x4ee0(%rip), %rsi      # 0x13194
xorl %eax, %eax
callq 0x2200
leaq 0x936e(%rip), %rbp      # 0x17630
movq (%rbp), %r12
cmpq %rbp, %r12
leaq 0x20(%rsp), %r13
leaq 0x4ecd(%rip), %r15      # 0x131a2
je 0xe309
movl 0x8(%r12), %edi
movq %r13, %rsi
movl $0x10, %edx
callq 0xbbac
movl 0x8(%r14), %edi
movzbl 0xc(%r12), %ecx
movq %r15, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x2200
movq (%r12), %r12
cmpq %rbp, %r12
jne 0xe2d7
leaq 0x8fa8(%rip), %rax      # 0x172b8
movzbl (%rax), %edx
testl %edx, %edx
je 0xe329
movl 0x8(%r14), %edi
leaq 0x4e8a(%rip), %rsi      # 0x131ac
xorl %eax, %eax
callq 0x2200
leaq 0x8f5a(%rip), %rax      # 0x1728a
movswl (%rax), %edx
cmpl $0x3e8, %edx            # imm = 0x3E8
leaq 0x9020(%rip), %r12      # 0x17360
leaq 0x8fc9(%rip), %rbp      # 0x17310
je 0xe35b
movl 0x8(%r14), %edi
leaq 0x4e5f(%rip), %rsi      # 0x131b3
xorl %eax, %eax
callq 0x2200
cmpl $0x0, (%r12)
movq (%rsp), %r15
je 0xe392
movl 0x8(%r12), %edi
leaq 0x20(%rsp), %r12
movq %r12, %rsi
movl $0x10, %edx
callq 0xbbac
movl 0x8(%r14), %edi
leaq 0x4e32(%rip), %rsi      # 0x131ba
movq %r12, %rdx
xorl %eax, %eax
callq 0x2200
leaq 0x8f3f(%rip), %rax      # 0x172d8
movq (%rax), %rdx
testq %rdx, %rdx
je 0xe3b3
movl 0x8(%r14), %edi
leaq 0x4e15(%rip), %rsi      # 0x131c1
xorl %eax, %eax
callq 0x2200
leaq 0x8ed2(%rip), %rax      # 0x1728c
movzbl (%rax), %edx
cmpl $0xa, %edx
je 0xe3d4
movl 0x8(%r14), %edi
leaq 0x4e10(%rip), %rsi      # 0x131dd
xorl %eax, %eax
callq 0x2200
leaq 0x8ebe(%rip), %rax      # 0x17299
cmpb $0x0, (%rax)
jne 0xe3f2
movl 0x8(%r14), %edi
leaq 0x4e04(%rip), %rsi      # 0x131ef
xorl %eax, %eax
callq 0x2200
leaq 0x8e97(%rip), %rax      # 0x17290
movl (%rax), %edx
cmpl $0x30d40, %edx          # imm = 0x30D40
je 0xe415
movl 0x8(%r14), %edi
leaq 0x4df8(%rip), %rsi      # 0x13206
xorl %eax, %eax
callq 0x2200
movq (%rbp), %r12
cmpq %rbp, %r12
movq %rbp, %r13
leaq 0x4d6a(%rip), %rbp      # 0x13190
je 0xe444
movl 0x8(%r14), %edi
movq 0x8(%r12), %rdx
movq %rbp, %rsi
xorl %eax, %eax
callq 0x2200
movq (%r12), %r12
cmpq %r13, %r12
jne 0xe428
movl 0x8(%r14), %edi
leaq 0x4dcb(%rip), %rsi      # 0x1321a
xorl %eax, %eax
callq 0x2200
leaq 0x8fab(%rip), %r12      # 0x17408
movq 0x8(%rsp), %r13
jmp 0xe767
leaq 0x8eda(%rip), %r13      # 0x17348
movq 0x10(%r13), %rcx
movq -0x8(%rcx,%rax,8), %rdi
callq 0x22d0
testl %eax, %eax
movq %r15, %r12
movq 0x8(%rsp), %r13
je 0xe4a7
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x4dde(%rip), %rsi      # 0x1327b
movq %rax, %rdx
xorl %eax, %eax
callq 0xd88c
movl $0x3, %edi
leaq 0x4e00(%rip), %rsi      # 0x132b3
xorl %eax, %eax
callq 0xd88c
movl 0x8(%r14), %ecx
movq $-0x2, %rax
rolq %cl, %rax
leal 0x3f(%rcx), %edx
testl %ecx, %ecx
cmovnsl %ecx, %edx
sarl $0x6, %edx
movslq %edx, %rdx
andq %rax, 0xb0(%rsp,%rdx,8)
movl %ecx, %edi
callq 0x21f0
leaq 0x80(%r12), %rdx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x5be3
movq %r14, %rdi
movl $0x4b3, %esi            # imm = 0x4B3
callq 0x628b
movq %rbp, %r14
movq (%rsp), %r15
jmp 0xe767
cmpl $0x3, %eax
jb 0xe755
movl $0x2, %edi
leaq 0x42(%rsp), %rbp
movq %rbp, %rsi
leaq 0x1c(%rsp), %rdx
callq 0x22a0
testl %eax, %eax
jle 0xe778
movl 0x1c(%rsp), %eax
leaq 0x8d8c(%rip), %rcx      # 0x172d0
movl %eax, (%rcx)
leaq 0x8d73(%rip), %rax      # 0x172c0
cmpq $0x0, (%rax)
je 0xe755
callq 0xbbf4
jmp 0xe755
cmpl $0x3, %eax
jb 0xe759
leaq 0x8d1f(%rip), %rax      # 0x17290
movl (%rax), %ebp
leaq 0x42(%rsp), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x2280
movl $0x3, %edi
leaq 0x4b7c(%rip), %rsi      # 0x1310c
movl %ebp, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0xd88c
leaq 0x42(%rsp), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x2280
leaq 0x8cdc(%rip), %rcx      # 0x17290
movl %eax, (%rcx)
jmp 0xe755
cmpl $0x3, %eax
jb 0xe755
cmpb $0x0, 0x42(%rsp)
je 0xe790
xorl %edi, %edi
callq 0x91d0
testb %al, %al
setne %al
movb 0x42(%rsp), %bpl
cmpb $0x4, %bpl
setb %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xe755
jmp 0xe792
cmpl $0x3, %eax
jb 0xe767
movb 0x42(%rsp), %al
testb %al, %al
jle 0xe767
movsbl %al, %eax
leaq 0x8c72(%rip), %rcx      # 0x17288
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jg 0xe767
movq %r15, (%rsp)
movq %r13, %r15
movzbl 0xc(%r14), %eax
testq %rax, %rax
leaq 0x8d11(%rip), %r13      # 0x17348
je 0xe8c7
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
addl %ecx, %eax
movq (%r13), %rcx
movq 0x10(%r13), %rdx
movq (%rcx,%rax,8), %rbp
movq (%rdx,%rax,8), %rdi
callq 0x24c0
testl %eax, %eax
je 0xe67c
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x4984(%rip), %rsi      # 0x12ff6
movq %rax, %rdx
xorl %eax, %eax
callq 0xd88c
leaq 0x8cc5(%rip), %rax      # 0x17348
movq (%rax), %rcx
movzbl 0xc(%r14), %eax
movq -0x8(%rcx,%rax,8), %rdx
movq %rdx, %rcx
movq %rbp, %rdi
movq (%rcx), %rbp
cmpq %rdx, %rbp
je 0xe88f
movl 0x8(%rbp), %esi
movq %rbp, %rcx
cmpl 0x8(%r14), %esi
jne 0xe693
movq %rbp, %rsi
callq 0x5be3
leaq 0x8c8b(%rip), %r13      # 0x17348
movq 0x8(%r13), %rax
movzbl 0xc(%r14), %ecx
decw -0x2(%rax,%rcx,2)
movq %rbp, %rdi
movl $0x4b1, %esi            # imm = 0x4B1
callq 0x628b
movzbl 0xc(%r14), %eax
jmp 0xe896
cmpl $0x3, %eax
jb 0xe759
leaq 0x8b9e(%rip), %rbp      # 0x1728c
movzbl (%rbp), %edx
movsbl 0x42(%rsp), %ecx
movl $0x3, %edi
leaq 0x49cf(%rip), %rsi      # 0x130d2
xorl %eax, %eax
callq 0xd88c
movb 0x42(%rsp), %al
movb %al, (%rbp)
jmp 0xe755
cmpl $0x3, %eax
jb 0xe755
cmpb $0x0, 0x42(%rsp)
je 0xe807
xorl %edi, %edi
callq 0x91d0
testb %al, %al
je 0xe755
movb 0x42(%rsp), %al
jmp 0xe809
callq 0xdb62
jmp 0xe755
cmpl $0x3, %eax
jb 0xe767
movq %rdx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x6e98
movl 0x8(%r14), %edi
leaq 0x4abb(%rip), %rsi      # 0x1321b
xorl %eax, %eax
callq 0x2200
movq %r14, %rbp
cmpq %rbx, %r15
jne 0xe051
jmp 0xea4e
movl $0x3, %edi
leaq 0x49be(%rip), %rsi      # 0x13142
movq %rbp, %rdx
xorl %eax, %eax
callq 0xd88c
jmp 0xe755
xorl %ebp, %ebp
leaq 0x8b21(%rip), %rax      # 0x172ba
movb (%rax), %al
cmpb %al, %bpl
je 0xe755
testb %al, %al
je 0xe7b6
leaq 0x8b15(%rip), %rax      # 0x172c0
cmpq $0x0, (%rax)
je 0xe7b6
callq 0xbbf4
testb %bpl, %bpl
je 0xe7e4
leaq 0x8af7(%rip), %rax      # 0x172b9
cmpb $0x0, (%rax)
je 0xe7e4
xorl %ecx, %ecx
leaq 0x8ae9(%rip), %rax      # 0x172b9
movb %cl, (%rax)
leaq 0x8b37(%rip), %rax      # 0x17310
movq (%rax), %rax
movb %cl, 0x59(%rax)
callq 0xbee6
testb %bpl, %bpl
setne %cl
leaq 0x8ac9(%rip), %rax      # 0x172ba
movb (%rax), %al
testb %al, %al
sete %dl
testb %dl, %cl
je 0xe994
xorl %eax, %eax
jmp 0xe9a8
xorl %eax, %eax
leaq 0x8aa9(%rip), %rcx      # 0x172b9
movb (%rcx), %bpl
movb %al, (%rcx)
leaq 0x8af4(%rip), %rcx      # 0x17310
movq (%rcx), %rcx
movb %al, 0x59(%rcx)
testb %al, %al
je 0xe861
leaq 0x8a8d(%rip), %rcx      # 0x172ba
cmpb $0x0, (%rcx)
je 0xe861
leaq 0x8a87(%rip), %rax      # 0x172c0
cmpq $0x0, (%rax)
je 0xe844
callq 0xbbf4
movl $0x1, %edi
callq 0x86b2
leaq 0x8a65(%rip), %rax      # 0x172ba
movb $0x0, (%rax)
leaq 0x8a5a(%rip), %rax      # 0x172b9
movb (%rax), %al
testb %bpl, %bpl
jne 0xe874
testb %al, %al
je 0xe874
callq 0xacaa
jmp 0xe755
testb %bpl, %bpl
je 0xe755
testb %al, %al
jne 0xe755
callq 0xbee6
jmp 0xe755
leaq 0x8ab2(%rip), %r13      # 0x17348
movq 0x10(%r13), %rcx
movq -0x8(%rcx,%rax,8), %rdi
callq 0x22d0
testl %eax, %eax
je 0xe8c7
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x476f(%rip), %rsi      # 0x1302c
movq %rax, %rdx
xorl %eax, %eax
callq 0xd88c
movzbl 0xc(%r14), %ecx
movsbl 0x42(%rsp), %eax
cmpl %eax, %ecx
jne 0xe8df
movb $0x0, 0xc(%r14)
jmp 0xe98c
cltq
movq 0x10(%r13), %rcx
movq -0x8(%rcx,%rax,8), %rdi
callq 0x24c0
testl %eax, %eax
je 0xe912
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x475c(%rip), %rsi      # 0x13064
movq %rax, %rdx
xorl %eax, %eax
callq 0xd88c
movl $0x10, %edi
movl $0xca, %esi
callq 0x5d52
movq %rax, (%rax)
movl 0x8(%r14), %ecx
movl %ecx, 0x8(%rax)
movq (%r13), %rcx
movsbq 0x42(%rsp), %rdx
movq -0x8(%rcx,%rdx,8), %rsi
movq %rax, %rdi
callq 0x5bb8
movq 0x8(%r13), %rax
movsbq 0x42(%rsp), %rcx
incw -0x2(%rax,%rcx,2)
movsbq 0x42(%rsp), %rax
movb %al, 0xc(%r14)
movq 0x10(%r13), %rcx
movq -0x8(%rcx,%rax,8), %rdi
callq 0x22d0
testl %eax, %eax
je 0xe98c
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x4718(%rip), %rsi      # 0x1309a
movq %rax, %rdx
xorl %eax, %eax
callq 0xd88c
movq %r15, %r13
jmp 0xe508
testb %bpl, %bpl
sete %cl
testb %al, %al
setne %dl
andb %cl, %dl
movb $0x1, %al
cmpb $0x1, %dl
jne 0xe9b0
movzbl %al, %edi
callq 0x86b2
leaq 0x8903(%rip), %rax      # 0x172ba
movb %bpl, (%rax)
jmp 0xe755
movq %r14, (%r14)
leal 0x3f(%rax), %edx
testl %eax, %eax
cmovnsl %eax, %edx
movl %edx, %esi
andl $-0x40, %esi
movl %eax, %ecx
subl %esi, %ecx
movl $0x1, %esi
shlq %cl, %rsi
sarl $0x6, %edx
movslq %edx, %rcx
orq %rsi, 0xb0(%rsp,%rcx,8)
movq %r15, %r13
cmpl %r13d, %eax
cmovgl %eax, %r13d
movl %eax, %edi
movl $0x3, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x20e0
movl 0x8(%r14), %edi
orl $0x800, %eax            # imm = 0x800
movl $0x4, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x20e0
leaq 0x80(%r12), %rsi
movq %r14, %rdi
callq 0x5bcd
movl $0x3, %edi
leaq 0x45a3(%rip), %rsi      # 0x12fd9
xorl %eax, %eax
callq 0xd88c
jmp 0xea4e
callq 0x2070
movl (%rax), %edi
cmpl $0x4, %edi
movq %r15, %r13
jne 0xea6b
movq %r13, %r15
callq 0xbbdb
testb %al, %al
leaq 0x138(%rsp), %r13
je 0xdf59
jmp 0xde26
callq 0x2480
leaq 0x485f(%rip), %rsi      # 0x132d6
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0xd88c
jmp 0xde26