// File: /workspace/github_c_makefile_star2_O1/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 0x994b(%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 0xb8e7
testb %al, %al
je 0xdc7b
movq 0x80(%r12), %rbp
cmpq %rbx, %rbp
je 0xdc67
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
leaq 0x97da(%rip), %r15      # 0x17348
movq %rbp, %r12
movq (%rbp), %rbp
movzbl 0xc(%r12), %eax
testq %rax, %rax
je 0xdc43
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 0xdbbe
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x568a(%rip), %rsi      # 0x1323e
movq %rax, %rdx
xorl %eax, %eax
callq 0xd5b0
movq (%r15), %rax
movzbl 0xc(%r12), %ecx
movq -0x8(%rax,%rcx,8), %rdx
movq %rdx, %rax
movq %r13, %rdi
movq (%rax), %r13
cmpq %rdx, %r13
je 0xdc0c
movl 0x8(%r13), %ecx
movq %r13, %rax
cmpl 0x8(%r12), %ecx
jne 0xdbcf
movq %r13, %rsi
callq 0x5bcf
movq 0x8(%r15), %rax
movzbl 0xc(%r12), %ecx
decw -0x2(%rax,%rcx,2)
movq %r13, %rdi
movl $0x4b4, %esi            # imm = 0x4B4
callq 0x5f5b
movq 0x10(%r15), %rax
movzbl 0xc(%r12), %ecx
movq -0x8(%rax,%rcx,8), %rdi
callq 0x22d0
testl %eax, %eax
je 0xdc43
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x563b(%rip), %rsi      # 0x13274
movq %rax, %rdx
xorl %eax, %eax
callq 0xd5b0
movq %rbx, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x5bcf
movq %r12, %rdi
movl $0x4b5, %esi            # imm = 0x4B5
callq 0x5f5b
cmpq %rbx, %rbp
jne 0xdb6e
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 0xdd56
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 0xdd64
movl $0x10, %edi
movl $0xc9, %esi
callq 0x5d3e
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 0xe6ed
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x51b9(%rip), %rsi      # 0x12ef3
movq %rax, %rdx
xorl %eax, %eax
callq 0xd5b0
callq 0xb8e7
testb %al, %al
je 0xdc87
jmp 0xdb50
js 0xe76d
movq %r15, %r13
jmp 0xe77c
movq 0x80(%r12), %r15
movl %eax, %r13d
cmpq %rbx, %r15
je 0xe77c
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 0xddf4
movl $0x64, %edx
leaq 0x40(%rsp), %rsi
callq 0x2230
testl %eax, %eax
jle 0xde03
movl 0x8(%r14), %edi
cmpl %r13d, %edi
cmovgl %edi, %r13d
movzbl 0x40(%rsp), %ecx
leal -0x61(%rcx), %edx
cmpl $0x11, %edx
ja 0xdf8c
leaq 0x4e6a(%rip), %rsi      # 0x12c40
movslq (%rsi,%rdx,4), %rcx
addq %rsi, %rcx
jmpq *%rcx
cmpl $0x3, %eax
jl 0xe5c0
leaq 0x42(%rsp), %rdi
xorl %esi, %esi
jmp 0xe5a4
cmpl %r13d, %edi
cmovgl %edi, %r13d
movq %rbp, %r14
jmp 0xe5c0
movq %r15, 0x8(%rsp)
jns 0xde29
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x5341(%rip), %rsi      # 0x13160
movq %rax, %rdx
xorl %eax, %eax
callq 0xd5b0
movzbl 0xc(%r14), %eax
testq %rax, %rax
je 0xdf21
movq %r13, (%rsp)
movq %r12, %r15
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
addl %ecx, %eax
leaq 0x94fc(%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 0xde83
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x530c(%rip), %rsi      # 0x13185
movq %rax, %rdx
xorl %eax, %eax
callq 0xd5b0
leaq 0x94be(%rip), %rax      # 0x17348
movq (%rax), %rax
movzbl 0xc(%r14), %ecx
movq -0x8(%rax,%rcx,8), %rdx
movq %rdx, %rax
movq %r12, %rdi
movq (%rax), %r12
cmpq %rdx, %r12
je 0xdedd
movl 0x8(%r12), %ecx
movq %r12, %rax
cmpl 0x8(%r14), %ecx
jne 0xde9a
movq %r12, %rsi
callq 0x5bcf
leaq 0x9486(%rip), %rax      # 0x17348
movq 0x8(%rax), %rax
movzbl 0xc(%r14), %ecx
decw -0x2(%rax,%rcx,2)
movq %r12, %rdi
movl $0x4b2, %esi            # imm = 0x4B2
callq 0x5f5b
leaq 0x9464(%rip), %rax      # 0x17348
movq 0x10(%rax), %rax
movzbl 0xc(%r14), %ecx
movq -0x8(%rax,%rcx,8), %rdi
callq 0x22d0
testl %eax, %eax
movq %r15, %r12
movq (%rsp), %r13
je 0xdf21
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x52a4(%rip), %rsi      # 0x131bb
movq %rax, %rdx
xorl %eax, %eax
callq 0xd5b0
movl $0x3, %edi
leaq 0x52c6(%rip), %rsi      # 0x131f3
xorl %eax, %eax
callq 0xd5b0
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 0x5bcf
movq %r14, %rdi
movl $0x4b3, %esi            # imm = 0x4B3
callq 0x5f5b
movq %rbp, %r14
movq 0x8(%rsp), %r15
jmp 0xe5c0
cmpl $0x41, %ecx
leaq 0x42(%rsp), %rdx
je 0xe597
cmpl $0x79, %ecx
jne 0xe5c0
leaq 0x93ce(%rip), %rax      # 0x17378
movq (%rax), %rdx
leaq 0x511d(%rip), %rsi      # 0x130d1
xorl %eax, %eax
callq 0x2200
leaq 0x92f8(%rip), %rax      # 0x172ba
movzbl (%rax), %edx
testl %edx, %edx
je 0xdfdb
movl 0x8(%r14), %edi
leaq 0x50f2(%rip), %rsi      # 0x130c6
xorl %eax, %eax
callq 0x2200
leaq 0x92ee(%rip), %rax      # 0x172d0
movl (%rax), %edi
testl %edi, %edi
leaq 0x20(%rsp), %r12
je 0xe00f
movq %r12, %rsi
movl $0x10, %edx
callq 0xb8b8
movl 0x8(%r14), %edi
leaq 0x50c8(%rip), %rsi      # 0x130cd
movq %r12, %rdx
xorl %eax, %eax
callq 0x2200
movq %r15, 0x8(%rsp)
movq %r13, (%rsp)
leaq 0x929a(%rip), %rax      # 0x172b9
movb (%rax), %al
testb %al, %al
je 0xe086
movzbl %al, %edi
leaq 0x18(%rsp), %rsi
leaq 0x14(%rsp), %rdx
callq 0x2ffe
movl 0x18(%rsp), %eax
movl %eax, %edx
shrl $0xa, %edx
movl $0x801, %esi            # imm = 0x801
cmpl %esi, %eax
cmovll %eax, %edx
leaq 0x1b32(%rip), %r9       # 0xfb83
movq %r9, %rcx
leaq 0x1b23(%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 0x5055(%rip), %rsi      # 0x130d4
xorl %eax, %eax
callq 0x2200
leaq 0x95a3(%rip), %rbp      # 0x17630
movq (%rbp), %r12
cmpq %rbp, %r12
leaq 0x20(%rsp), %r13
leaq 0x5042(%rip), %r15      # 0x130e2
je 0xe0d4
movl 0x8(%r12), %edi
movq %r13, %rsi
movl $0x10, %edx
callq 0xb8b8
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 0xe0a2
leaq 0x91dd(%rip), %rax      # 0x172b8
movzbl (%rax), %edx
testl %edx, %edx
je 0xe0f4
movl 0x8(%r14), %edi
leaq 0x4fff(%rip), %rsi      # 0x130ec
xorl %eax, %eax
callq 0x2200
leaq 0x918f(%rip), %rax      # 0x1728a
movswl (%rax), %edx
cmpl $0x3e8, %edx            # imm = 0x3E8
leaq 0x9255(%rip), %r12      # 0x17360
leaq 0x91fe(%rip), %rbp      # 0x17310
je 0xe126
movl 0x8(%r14), %edi
leaq 0x4fd4(%rip), %rsi      # 0x130f3
xorl %eax, %eax
callq 0x2200
cmpl $0x0, (%r12)
movq 0x8(%rsp), %r15
je 0xe15e
movl 0x8(%r12), %edi
leaq 0x20(%rsp), %r12
movq %r12, %rsi
movl $0x10, %edx
callq 0xb8b8
movl 0x8(%r14), %edi
leaq 0x4fa6(%rip), %rsi      # 0x130fa
movq %r12, %rdx
xorl %eax, %eax
callq 0x2200
leaq 0x9173(%rip), %rax      # 0x172d8
movq (%rax), %rdx
testq %rdx, %rdx
je 0xe17f
movl 0x8(%r14), %edi
leaq 0x4f89(%rip), %rsi      # 0x13101
xorl %eax, %eax
callq 0x2200
leaq 0x9106(%rip), %rax      # 0x1728c
movzbl (%rax), %edx
cmpl $0xa, %edx
je 0xe1a0
movl 0x8(%r14), %edi
leaq 0x4f84(%rip), %rsi      # 0x1311d
xorl %eax, %eax
callq 0x2200
leaq 0x90f2(%rip), %rax      # 0x17299
cmpb $0x0, (%rax)
jne 0xe1be
movl 0x8(%r14), %edi
leaq 0x4f78(%rip), %rsi      # 0x1312f
xorl %eax, %eax
callq 0x2200
leaq 0x90cb(%rip), %rax      # 0x17290
movl (%rax), %edx
cmpl $0x30d40, %edx          # imm = 0x30D40
je 0xe1e1
movl 0x8(%r14), %edi
leaq 0x4f6c(%rip), %rsi      # 0x13146
xorl %eax, %eax
callq 0x2200
movq (%rbp), %r12
cmpq %rbp, %r12
movq %rbp, %r13
leaq 0x4ede(%rip), %rbp      # 0x130d0
je 0xe210
movl 0x8(%r14), %edi
movq 0x8(%r12), %rdx
movq %rbp, %rsi
xorl %eax, %eax
callq 0x2200
movq (%r12), %r12
cmpq %r13, %r12
jne 0xe1f4
movl 0x8(%r14), %edi
leaq 0x4f3f(%rip), %rsi      # 0x1315a
xorl %eax, %eax
callq 0x2200
leaq 0x91df(%rip), %r12      # 0x17408
movq (%rsp), %r13
jmp 0xe5c0
cmpl $0x3, %eax
jl 0xe5ae
movl $0x2, %edi
leaq 0x42(%rsp), %rbp
movq %rbp, %rsi
leaq 0x1c(%rsp), %rdx
callq 0x22a0
testl %eax, %eax
jle 0xe6a7
movl 0x1c(%rsp), %eax
leaq 0x906b(%rip), %rcx      # 0x172d0
movl %eax, (%rcx)
leaq 0x9052(%rip), %rax      # 0x172c0
cmpq $0x0, (%rax)
je 0xe5ae
callq 0xb900
jmp 0xe5ae
cmpl $0x3, %eax
jl 0xe5ae
leaq 0x8ffe(%rip), %rax      # 0x17290
movl (%rax), %ebp
leaq 0x42(%rsp), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x2280
movl $0x3, %edi
leaq 0x4d9b(%rip), %rsi      # 0x1304c
movl %ebp, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0xd5b0
leaq 0x42(%rsp), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x2280
leaq 0x8fbb(%rip), %rcx      # 0x17290
movl %eax, (%rcx)
jmp 0xe5ae
cmpl $0x3, %eax
jl 0xe5ae
cmpb $0x0, 0x42(%rsp)
je 0xe2fb
xorl %edi, %edi
callq 0x8e70
testb %al, %al
je 0xe5ae
movb 0x42(%rsp), %bpl
cmpb $0x3, %bpl
ja 0xe5ae
leaq 0x8fa9(%rip), %rax      # 0x172ba
movb (%rax), %al
cmpb %al, %bpl
je 0xe5ae
testb %al, %al
je 0xe332
leaq 0x8f99(%rip), %rax      # 0x172c0
cmpq $0x0, (%rax)
je 0xe332
callq 0xb900
testb %bpl, %bpl
je 0xe360
leaq 0x8f7b(%rip), %rax      # 0x172b9
cmpb $0x0, (%rax)
je 0xe360
xorl %ecx, %ecx
leaq 0x8f6d(%rip), %rax      # 0x172b9
movb %cl, (%rax)
leaq 0x8fbb(%rip), %rax      # 0x17310
movq (%rax), %rax
movb %cl, 0x59(%rax)
callq 0xbbf2
testb %bpl, %bpl
setne %cl
leaq 0x8f4d(%rip), %rax      # 0x172ba
movb (%rax), %al
testb %al, %al
sete %dl
testb %dl, %cl
je 0xe6c2
xorl %eax, %eax
jmp 0xe6d6
cmpl $0x3, %eax
jl 0xe5c0
movb 0x42(%rsp), %al
testb %al, %al
jle 0xe5c0
movsbl %al, %eax
leaq 0x8ee6(%rip), %rcx      # 0x17288
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jg 0xe5c0
movzbl 0xc(%r14), %eax
testq %rax, %rax
je 0xe495
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
addl %ecx, %eax
leaq 0x8f7f(%rip), %rdx      # 0x17348
movq (%rdx), %rcx
movq 0x10(%rdx), %rdx
movq (%rcx,%rax,8), %rbp
movq (%rdx,%rax,8), %rdi
callq 0x24c0
testl %eax, %eax
je 0xe400
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x4b40(%rip), %rsi      # 0x12f36
movq %rax, %rdx
xorl %eax, %eax
callq 0xd5b0
leaq 0x8f41(%rip), %rax      # 0x17348
movq (%rax), %rax
movzbl 0xc(%r14), %ecx
movq -0x8(%rax,%rcx,8), %rdx
movq %rdx, %rax
movq %rbp, %rdi
movq (%rax), %rbp
cmpq %rdx, %rbp
je 0xe458
movl 0x8(%rbp), %ecx
movq %rbp, %rax
cmpl 0x8(%r14), %ecx
jne 0xe417
movq %rbp, %rsi
callq 0x5bcf
leaq 0x8f0b(%rip), %rax      # 0x17348
movq 0x8(%rax), %rax
movzbl 0xc(%r14), %ecx
decw -0x2(%rax,%rcx,2)
movq %rbp, %rdi
movl $0x4b1, %esi            # imm = 0x4B1
callq 0x5f5b
leaq 0x8ee9(%rip), %rax      # 0x17348
movq 0x10(%rax), %rax
movzbl 0xc(%r14), %ecx
movq -0x8(%rax,%rcx,8), %rdi
callq 0x22d0
testl %eax, %eax
je 0xe495
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x4ae1(%rip), %rsi      # 0x12f6c
movq %rax, %rdx
xorl %eax, %eax
callq 0xd5b0
movzbl 0xc(%r14), %ecx
movsbl 0x42(%rsp), %eax
cmpl %eax, %ecx
jne 0xe5d1
movb $0x0, 0xc(%r14)
jmp 0xe5c0
cmpl $0x3, %eax
jl 0xe5ae
leaq 0x8dcb(%rip), %rbp      # 0x1728c
movzbl (%rbp), %edx
movsbl 0x42(%rsp), %ecx
movl $0x3, %edi
leaq 0x4b3c(%rip), %rsi      # 0x13012
xorl %eax, %eax
callq 0xd5b0
movb 0x42(%rsp), %al
movb %al, (%rbp)
jmp 0xe5ae
cmpl $0x3, %eax
jl 0xe5ae
cmpb $0x0, 0x42(%rsp)
je 0xe508
xorl %edi, %edi
callq 0x8e70
testb %al, %al
je 0xe5ae
leaq 0x8daa(%rip), %rcx      # 0x172b9
movb (%rcx), %bpl
movb 0x42(%rsp), %al
movb %al, (%rcx)
leaq 0x8df1(%rip), %rcx      # 0x17310
movq (%rcx), %rcx
movb %al, 0x59(%rcx)
testb %al, %al
je 0xe55b
leaq 0x8d8a(%rip), %rax      # 0x172ba
cmpb $0x0, (%rax)
je 0xe55b
leaq 0x8d84(%rip), %rax      # 0x172c0
cmpq $0x0, (%rax)
je 0xe547
callq 0xb900
movl $0x1, %edi
callq 0x8352
leaq 0x8d62(%rip), %rax      # 0x172ba
movb $0x0, (%rax)
testb %bpl, %bpl
setne %cl
leaq 0x8d51(%rip), %rax      # 0x172b9
movb (%rax), %al
testb %al, %al
sete %dl
orb %cl, %dl
je 0xe69d
testb %al, %al
sete %al
testb %bpl, %bpl
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xe5ae
callq 0xbbf2
jmp 0xe5ae
callq 0xd88c
jmp 0xe5ae
cmpl $0x3, %eax
jl 0xe5c0
movq %rdx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x6b5e
movl 0x8(%r14), %edi
leaq 0x4ba2(%rip), %rsi      # 0x1315b
xorl %eax, %eax
callq 0x2200
movq %r14, %rbp
cmpq %rbx, %r15
jne 0xdd7b
jmp 0xe77c
movq %r15, %rbp
movq %r13, %r15
cltq
leaq 0x8d68(%rip), %rcx      # 0x17348
movq 0x10(%rcx), %rcx
movq -0x8(%rcx,%rax,8), %rdi
callq 0x24c0
testl %eax, %eax
je 0xe611
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x499d(%rip), %rsi      # 0x12fa4
movq %rax, %rdx
xorl %eax, %eax
callq 0xd5b0
movl $0x10, %edi
movl $0xca, %esi
callq 0x5d3e
movq %rax, (%rax)
movl 0x8(%r14), %ecx
movl %ecx, 0x8(%rax)
leaq 0x8d17(%rip), %r13      # 0x17348
movq (%r13), %rcx
movsbq 0x42(%rsp), %rdx
movq -0x8(%rcx,%rdx,8), %rsi
movq %rax, %rdi
callq 0x5ba4
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 0xe692
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x4952(%rip), %rsi      # 0x12fda
movq %rax, %rdx
xorl %eax, %eax
callq 0xd5b0
movq %r15, %r13
movq %rbp, %r15
jmp 0xe5c0
callq 0xa9a8
jmp 0xe5ae
movl $0x3, %edi
leaq 0x49cf(%rip), %rsi      # 0x13082
movq %rbp, %rdx
xorl %eax, %eax
callq 0xd5b0
jmp 0xe5ae
testb %bpl, %bpl
sete %cl
testb %al, %al
setne %dl
andb %cl, %dl
movb $0x1, %al
cmpb $0x1, %dl
jne 0xe6de
movzbl %al, %edi
callq 0x8352
leaq 0x8bd5(%rip), %rax      # 0x172ba
movb %bpl, (%rax)
jmp 0xe5ae
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 0x5bb9
movl $0x3, %edi
leaq 0x47b5(%rip), %rsi      # 0x12f19
xorl %eax, %eax
callq 0xd5b0
jmp 0xe77c
callq 0x2070
movl (%rax), %edi
cmpl $0x4, %edi
movq %r15, %r13
jne 0xe799
movq %r13, %r15
callq 0xb8e7
testb %al, %al
leaq 0x138(%rsp), %r13
je 0xdc83
jmp 0xdb50
callq 0x2480
leaq 0x4a71(%rip), %rsi      # 0x13216
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0xd5b0
jmp 0xdb50