// File: /workspace/github_c_makefile_star2_O2/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 $0x218, %rsp            # imm = 0x218
movl $0x6e, 0x8(%rsp)
leaq 0xa43b(%rip), %rbx      # 0x17408
leaq 0x80(%rbx), %rcx
movq %rcx, 0x80(%rbx)
movq %rcx, 0x88(%rbx)
xorl %eax, %eax
cmpq $0x10, %rax
je 0xcff8
andq $0x0, 0xa8(%rsp,%rax,8)
incq %rax
jmp 0xcfe4
movq %rcx, (%rsp)
movl (%rbx), %r14d
pushq $0x40
popq %rcx
movl %r14d, %eax
cltd
idivl %ecx
movslq %eax, %rdx
shll $0x6, %eax
movl %r14d, %ecx
subl %eax, %ecx
pushq $0x1
popq %r12
movq %r12, %rax
shlq %cl, %rax
orq %rax, 0xa8(%rsp,%rdx,8)
leal 0x1(%r14), %ebp
callq 0xb07c
testb %al, %al
jne 0xdad7
movq $0x1, 0x30(%rsp)
andq $0x0, 0x38(%rsp)
pushq $0x10
popq %rcx
leaq 0x128(%rsp), %rax
movq %rax, %rdi
leaq 0xa8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movl %ebp, %edi
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
leaq 0x30(%rsp), %r8
callq 0x22c0
movsbl %al, %eax
testl %eax, %eax
jle 0xd0ef
movl (%rbx), %r13d
movl %r13d, %eax
cltd
pushq $0x40
popq %rcx
idivl %ecx
cltq
movq 0x128(%rsp,%rax,8), %rax
btq %rdx, %rax
jae 0xd10a
pushq $0x10
popq %rdi
movl $0xc9, %esi
callq 0x58c9
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl (%rbx), %edi
leaq 0x1aa(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x2400
movl %eax, 0x8(%r15)
cmpl $-0x1, %eax
jne 0xda4e
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x4eb3(%rip), %rsi      # 0x11f93
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
jmp 0xd029
jns 0xd029
callq 0x2070
movl (%rax), %edi
cmpl $0x4, %edi
je 0xd029
jmp 0xdabf
movq 0x80(%rbx), %r12
movq (%rsp), %r14
movq %r14, %r15
movq %r12, %rbp
movq (%r12), %r12
cmpq %r14, %rbp
je 0xda42
movl 0x8(%rbp), %edi
movl %edi, %eax
cltd
pushq $0x40
popq %rcx
idivl %ecx
cltq
movq 0x128(%rsp,%rax,8), %rax
btq %rdx, %rax
jae 0xd199
leaq 0x40(%rsp), %rsi
pushq $0x64
popq %rdx
callq 0x2230
testl %eax, %eax
jle 0xd1a5
movl 0x8(%rbp), %edi
cmpl %r13d, %edi
cmovgl %edi, %r13d
movzbl 0x40(%rsp), %ecx
leal -0x61(%rcx), %edx
cmpl $0x11, %edx
ja 0xd280
leaq 0x4b6a(%rip), %rsi      # 0x11ce0
movslq (%rsi,%rdx,4), %rcx
addq %rsi, %rcx
movq %rbp, %r15
jmpq *%rcx
movq %rbp, %r15
cmpl $0x3, %eax
jb 0xd118
leaq 0x42(%rsp), %rdi
xorl %esi, %esi
pushq $0x1
popq %rdx
jmp 0xd686
cmpl %r13d, %edi
cmovgl %edi, %r13d
jmp 0xd118
jns 0xd1c6
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x5044(%rip), %rsi      # 0x12200
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
movzbl 0xc(%rbp), %eax
testq %rax, %rax
je 0xd3f1
movq %r15, 0x18(%rsp)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
addl %ecx, %eax
leaq 0xa162(%rip), %rdx      # 0x17348
movq (%rdx), %rcx
movq 0x10(%rdx), %rdx
movq (%rcx,%rax,8), %r15
movq (%rdx,%rax,8), %rdi
callq 0x24c0
testl %eax, %eax
je 0xd21d
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x5012(%rip), %rsi      # 0x12225
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
leaq 0xa124(%rip), %rax      # 0x17348
movq (%rax), %rcx
movzbl 0xc(%rbp), %eax
movq -0x8(%rcx,%rax,8), %rdx
movq %rdx, %rcx
movq %r15, %rdi
movq (%rcx), %r15
cmpq %rdx, %r15
je 0xd3b0
movl 0x8(%r15), %esi
movq %r15, %rcx
cmpl 0x8(%rbp), %esi
jne 0xd233
movq %r15, %rsi
callq 0x5763
leaq 0xa0eb(%rip), %r14      # 0x17348
movq 0x8(%r14), %rax
movzbl 0xc(%rbp), %ecx
decw -0x2(%rax,%rcx,2)
movq %r15, %rdi
movl $0x4b2, %esi            # imm = 0x4B2
callq 0x5b1a
movzbl 0xc(%rbp), %eax
jmp 0xd3b7
movq %rbp, %r15
cmpl $0x41, %ecx
je 0xd673
cmpl $0x79, %ecx
jne 0xd118
leaq 0xa0dc(%rip), %rax      # 0x17378
movq (%rax), %rdx
leaq 0x4ecb(%rip), %rsi      # 0x12171
xorl %eax, %eax
callq 0x2200
leaq 0xa006(%rip), %rax      # 0x172ba
movzbl (%rax), %edx
testl %edx, %edx
je 0xd2cc
movl 0x8(%rbp), %edi
leaq 0x4ea1(%rip), %rsi      # 0x12166
xorl %eax, %eax
callq 0x2200
leaq 0x9ffd(%rip), %rax      # 0x172d0
movl (%rax), %edi
testl %edi, %edi
je 0xd2fd
leaq 0x20(%rsp), %r14
movq %r14, %rsi
pushq $0x10
popq %rdx
callq 0xb04f
movl 0x8(%rbp), %edi
leaq 0x4e7a(%rip), %rsi      # 0x1216d
movq %r14, %rdx
xorl %eax, %eax
callq 0x2200
leaq 0x9fb5(%rip), %rax      # 0x172b9
movb (%rax), %al
testb %al, %al
je 0xd36a
movzbl %al, %edi
leaq 0x10(%rsp), %rsi
leaq 0xc(%rsp), %rdx
callq 0x2ef8
movl 0x10(%rsp), %eax
movl %eax, %edx
shrl $0xa, %edx
movl $0x801, %esi            # imm = 0x801
cmpl %esi, %eax
cmovll %eax, %edx
leaq 0x184d(%rip), %r9       # 0xeb83
movq %r9, %rcx
leaq 0x183e(%rip), %r10      # 0xeb7e
cmovgeq %r10, %rcx
movl 0xc(%rsp), %eax
movl %eax, %r8d
shrl $0xa, %r8d
cmpl %esi, %eax
cmovll %eax, %r8d
movl 0x8(%rbp), %edi
cmovgeq %r10, %r9
leaq 0x4e11(%rip), %rsi      # 0x12174
xorl %eax, %eax
callq 0x2200
leaq 0xa2bf(%rip), %r14      # 0x17630
movq (%r14), %r14
cmpq 0x9c45(%rip), %r14      # 0x16fc0
je 0xd6a4
movl 0x8(%r14), %edi
leaq 0x20(%rsp), %r15
movq %r15, %rsi
pushq $0x10
popq %rdx
callq 0xb04f
movl 0x8(%rbp), %edi
movzbl 0xc(%r14), %ecx
leaq 0x4dde(%rip), %rsi      # 0x12182
movq %r15, %rdx
xorl %eax, %eax
callq 0x2200
jmp 0xd371
leaq 0x9f91(%rip), %r14      # 0x17348
movq 0x10(%r14), %rcx
movq -0x8(%rcx,%rax,8), %rdi
callq 0x22d0
testl %eax, %eax
movq (%rsp), %r14
movq 0x18(%rsp), %r15
je 0xd3f1
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x4e74(%rip), %rsi      # 0x1225b
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
pushq $0x3
popq %rdi
leaq 0x4e98(%rip), %rsi      # 0x12293
xorl %eax, %eax
callq 0xcb1c
movl 0x8(%rbp), %ecx
pushq $-0x2
popq %rsi
rolq %cl, %rsi
movl %ecx, %eax
cltd
pushq $0x40
popq %rdi
idivl %edi
cltq
andq %rsi, 0xa8(%rsp,%rax,8)
movl %ecx, %edi
callq 0x21f0
leaq 0x80(%rbx), %rdx
movq %r15, %rdi
movq %rbp, %rsi
callq 0x5763
movq %rbp, %rdi
movl $0x4b3, %esi            # imm = 0x4B3
callq 0x5b1a
jmp 0xd118
cmpl $0x3, %eax
jb 0xd68e
leaq 0x9e34(%rip), %r15      # 0x1728c
movzbl (%r15), %edx
movsbl 0x42(%rsp), %ecx
pushq $0x3
popq %rdi
leaq 0x4c47(%rip), %rsi      # 0x120b2
xorl %eax, %eax
callq 0xcb1c
movb 0x42(%rsp), %al
movb %al, (%r15)
jmp 0xd68b
cmpl $0x3, %eax
jb 0xd68b
cmpb $0x0, 0x42(%rsp)
je 0xd7d0
xorl %edi, %edi
callq 0x8885
testb %al, %al
je 0xd68b
movb 0x42(%rsp), %al
jmp 0xd7d2
callq 0xcdb0
jmp 0xd68b
cmpl $0x3, %eax
jb 0xda25
cmpb $0x0, 0x42(%rsp)
je 0xd85e
xorl %edi, %edi
callq 0x8885
testb %al, %al
setne %al
movb 0x42(%rsp), %r14b
cmpb $0x4, %r14b
setb %cl
andb %al, %cl
cmpb $0x1, %cl
je 0xd861
jmp 0xda25
movq %rbp, %r15
cmpl $0x3, %eax
jb 0xd118
movb 0x42(%rsp), %al
movq %rbp, %r15
testb %al, %al
jle 0xd118
movsbl %al, %eax
leaq 0x9d73(%rip), %rcx      # 0x17288
movzbl (%rcx), %ecx
movq %rbp, %r15
cmpl %ecx, %eax
jg 0xd118
movzbl 0xc(%rbp), %eax
testq %rax, %rax
leaq 0x9e17(%rip), %r14      # 0x17348
je 0xd92e
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
addl %ecx, %eax
movq (%r14), %rcx
movq 0x10(%r14), %rdx
movq (%rcx,%rax,8), %r14
movq (%rdx,%rax,8), %rdi
callq 0x24c0
testl %eax, %eax
je 0xd575
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x4a6b(%rip), %rsi      # 0x11fd6
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
leaq 0x9dcc(%rip), %rax      # 0x17348
movq (%rax), %rcx
movzbl 0xc(%rbp), %eax
movq -0x8(%rcx,%rax,8), %rdx
movq %rdx, %rcx
movq %r14, %rdi
movq (%rcx), %r14
cmpq %rdx, %r14
je 0xd8f3
movl 0x8(%r14), %esi
movq %r14, %rcx
cmpl 0x8(%rbp), %esi
jne 0xd58b
movq %r14, %rsi
callq 0x5763
leaq 0x9d93(%rip), %r15      # 0x17348
movq 0x8(%r15), %rax
movzbl 0xc(%rbp), %ecx
decw -0x2(%rax,%rcx,2)
movq %r14, %rdi
movl $0x4b1, %esi            # imm = 0x4B1
callq 0x5b1a
movzbl 0xc(%rbp), %eax
jmp 0xd8fa
cmpl $0x3, %eax
jb 0xd68b
pushq $0x2
popq %rdi
leaq 0x42(%rsp), %r15
movq %r15, %rsi
leaq 0x14(%rsp), %rdx
callq 0x22a0
testl %eax, %eax
jle 0xd8da
movl 0x14(%rsp), %eax
leaq 0x9cc7(%rip), %rcx      # 0x172d0
movl %eax, (%rcx)
leaq 0x9cae(%rip), %rax      # 0x172c0
cmpq $0x0, (%rax)
je 0xd68b
callq 0xb095
jmp 0xd68b
cmpl $0x3, %eax
jb 0xd68e
leaq 0x9c65(%rip), %rax      # 0x17290
movl (%rax), %r14d
leaq 0x42(%rsp), %r15
movq %r15, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2280
pushq $0x3
popq %rdi
leaq 0x4aa2(%rip), %rsi      # 0x120ec
movl %r14d, %edx
movq (%rsp), %r14
movq %rax, %rcx
xorl %eax, %eax
callq 0xcb1c
movq %r15, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2280
leaq 0x9c21(%rip), %rcx      # 0x17290
movl %eax, (%rcx)
jmp 0xd68b
cmpl $0x3, %eax
jb 0xd118
leaq 0x42(%rsp), %rdi
pushq $0x1
popq %rdx
movl %edx, %esi
callq 0x666f
movl 0x8(%rbp), %edi
leaq 0x4b66(%rip), %rsi      # 0x121fb
xorl %eax, %eax
callq 0x2200
movq %rbp, %r15
jmp 0xd118
leaq 0x9c0d(%rip), %rax      # 0x172b8
movzbl (%rax), %edx
testl %edx, %edx
je 0xd6c3
movl 0x8(%rbp), %edi
leaq 0x4ad0(%rip), %rsi      # 0x1218c
xorl %eax, %eax
callq 0x2200
leaq 0x9bc0(%rip), %rax      # 0x1728a
movswl (%rax), %edx
cmpl $0x3e8, %edx            # imm = 0x3E8
leaq 0x9c86(%rip), %r14      # 0x17360
je 0xd6ed
movl 0x8(%rbp), %edi
leaq 0x4aad(%rip), %rsi      # 0x12193
xorl %eax, %eax
callq 0x2200
cmpl $0x0, (%r14)
je 0xd71b
movl 0x8(%r14), %edi
leaq 0x20(%rsp), %r14
movq %r14, %rsi
pushq $0x10
popq %rdx
callq 0xb04f
movl 0x8(%rbp), %edi
leaq 0x4a89(%rip), %rsi      # 0x1219a
movq %r14, %rdx
xorl %eax, %eax
callq 0x2200
leaq 0x9bb6(%rip), %rax      # 0x172d8
movq (%rax), %rdx
testq %rdx, %rdx
je 0xd73b
movl 0x8(%rbp), %edi
leaq 0x4a6d(%rip), %rsi      # 0x121a1
xorl %eax, %eax
callq 0x2200
leaq 0x9b4a(%rip), %rax      # 0x1728c
movzbl (%rax), %edx
cmpl $0xa, %edx
je 0xd75b
movl 0x8(%rbp), %edi
leaq 0x4a69(%rip), %rsi      # 0x121bd
xorl %eax, %eax
callq 0x2200
leaq 0x9b37(%rip), %rax      # 0x17299
cmpb $0x0, (%rax)
jne 0xd778
movl 0x8(%rbp), %edi
leaq 0x4a5e(%rip), %rsi      # 0x121cf
xorl %eax, %eax
callq 0x2200
leaq 0x9b11(%rip), %rax      # 0x17290
movl (%rax), %edx
cmpl $0x30d40, %edx          # imm = 0x30D40
je 0xd79a
movl 0x8(%rbp), %edi
leaq 0x4a53(%rip), %rsi      # 0x121e6
xorl %eax, %eax
callq 0x2200
leaq 0x9b6f(%rip), %r14      # 0x17310
movq (%r14), %r14
movl 0x8(%rbp), %edi
cmpq 0x982a(%rip), %r14      # 0x16fd8
je 0xd7c4
movq 0x8(%r14), %rdx
leaq 0x49b5(%rip), %rsi      # 0x12170
xorl %eax, %eax
callq 0x2200
jmp 0xd7a1
leaq 0x4a2f(%rip), %rsi      # 0x121fa
jmp 0xda2f
xorl %eax, %eax
leaq 0x9ae0(%rip), %rcx      # 0x172b9
movb (%rcx), %r14b
movb %al, (%rcx)
leaq 0x9b2b(%rip), %rcx      # 0x17310
movq (%rcx), %rcx
movb %al, 0x59(%rcx)
testb %al, %al
je 0xd828
leaq 0x9ac4(%rip), %rcx      # 0x172ba
cmpb $0x0, (%rcx)
je 0xd828
leaq 0x9abe(%rip), %rax      # 0x172c0
cmpq $0x0, (%rax)
je 0xd80d
callq 0xb095
pushq $0x1
popq %rdi
callq 0x7df2
leaq 0x9a9e(%rip), %rax      # 0x172ba
movb $0x0, (%rax)
leaq 0x9a93(%rip), %rax      # 0x172b9
movb (%rax), %al
testb %r14b, %r14b
jne 0xd83f
testb %al, %al
je 0xd83f
callq 0xa31c
movq (%rsp), %r14
jmp 0xd68b
testb %r14b, %r14b
movq (%rsp), %r14
je 0xd68b
testb %al, %al
jne 0xd68b
callq 0xb36b
jmp 0xd68b
xorl %r14d, %r14d
leaq 0x9a52(%rip), %rax      # 0x172ba
movb (%rax), %al
cmpb %al, %r14b
je 0xda25
testb %al, %al
je 0xd889
leaq 0x9a42(%rip), %rax      # 0x172c0
cmpq $0x0, (%rax)
je 0xd889
callq 0xb095
testb %r14b, %r14b
je 0xd8b7
leaq 0x9a24(%rip), %rax      # 0x172b9
cmpb $0x0, (%rax)
je 0xd8b7
xorl %ecx, %ecx
leaq 0x9a16(%rip), %rax      # 0x172b9
movb %cl, (%rax)
leaq 0x9a64(%rip), %rax      # 0x17310
movq (%rax), %rax
movb %cl, 0x59(%rax)
callq 0xb36b
testb %r14b, %r14b
setne %cl
leaq 0x99f6(%rip), %rax      # 0x172ba
movb (%rax), %al
testb %al, %al
sete %dl
testb %dl, %cl
je 0xd9ff
xorl %eax, %eax
jmp 0xda13
pushq $0x3
popq %rdi
leaq 0x483e(%rip), %rsi      # 0x12122
movq %r15, %rdx
xorl %eax, %eax
callq 0xcb1c
jmp 0xd68b
leaq 0x9a4e(%rip), %r15      # 0x17348
movq 0x10(%r15), %rcx
movq -0x8(%rcx,%rax,8), %rdi
callq 0x22d0
testl %eax, %eax
movq %r15, %r14
je 0xd92e
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x46e8(%rip), %rsi      # 0x1200c
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
movzbl 0xc(%rbp), %ecx
movsbl 0x42(%rsp), %eax
cmpl %eax, %ecx
jne 0xd944
movb $0x0, 0xc(%rbp)
jmp 0xda36
cltq
movq 0x10(%r14), %rcx
movq -0x8(%rcx,%rax,8), %rdi
callq 0x24c0
testl %eax, %eax
je 0xd977
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x46d7(%rip), %rsi      # 0x12044
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
pushq $0x10
popq %rdi
movl $0xca, %esi
callq 0x58c9
movq %rax, (%rax)
movl 0x8(%rbp), %ecx
movl %ecx, 0x8(%rax)
movq (%r14), %rcx
movsbq 0x42(%rsp), %rdx
movq -0x8(%rcx,%rdx,8), %rsi
movq %rax, %rdi
callq 0x5738
movq 0x8(%r14), %rax
movsbq 0x42(%rsp), %rcx
incw -0x2(%rax,%rcx,2)
movsbq 0x42(%rsp), %rax
movb %al, 0xc(%rbp)
movq 0x10(%r14), %rcx
movq -0x8(%rcx,%rax,8), %rdi
callq 0x22d0
movq %rbp, %r15
testl %eax, %eax
movq (%rsp), %r14
je 0xd118
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x468d(%rip), %rsi      # 0x1207a
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
movq %rbp, %r15
jmp 0xd118
testb %r14b, %r14b
sete %cl
testb %al, %al
setne %dl
andb %cl, %dl
movb $0x1, %al
cmpb $0x1, %dl
jne 0xda1b
movzbl %al, %edi
callq 0x7df2
leaq 0x9898(%rip), %rax      # 0x172ba
movb %r14b, (%rax)
movl 0x8(%rbp), %edi
leaq 0x47cc(%rip), %rsi      # 0x121fb
xorl %eax, %eax
callq 0x2200
movq %rbp, %r15
movq (%rsp), %r14
jmp 0xd118
movl %r13d, %r14d
pushq $0x1
popq %r12
jmp 0xd025
movl %eax, %edi
movq %r15, (%r15)
cltd
pushq $0x40
popq %rcx
idivl %ecx
movslq %eax, %rdx
shll $0x6, %eax
movl %edi, %ecx
subl %eax, %ecx
movq %r12, %rax
shlq %cl, %rax
orq %rax, 0xa8(%rsp,%rdx,8)
cmpl %r14d, %edi
cmovgl %edi, %r14d
pushq $0x3
popq %rbp
movl %ebp, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x20e0
movl 0x8(%r15), %edi
orl $0x800, %eax            # imm = 0x800
pushq $0x4
popq %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x20e0
leaq 0x80(%rbx), %rsi
movq %r15, %rdi
callq 0x574d
movl %ebp, %edi
leaq 0x4506(%rip), %rsi      # 0x11fb9
xorl %eax, %eax
callq 0xcb1c
jmp 0xd025
callq 0x2480
leaq 0x47eb(%rip), %rsi      # 0x122b6
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
movq 0x80(%rbx), %r15
subq $-0x80, %rbx
leaq 0x47f5(%rip), %r12      # 0x122de
cmpq %rbx, %r15
je 0xdbff
movq (%r15), %rbp
movzbl 0xc(%r15), %eax
testq %rax, %rax
je 0xdbdc
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
addl %ecx, %eax
leaq 0x9837(%rip), %rdx      # 0x17348
movq (%rdx), %rcx
movq 0x10(%rdx), %rdx
movq (%rcx,%rax,8), %r13
movq (%rdx,%rax,8), %rdi
callq 0x24c0
testl %eax, %eax
je 0xdb44
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
movq %r12, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
leaq 0x97fd(%rip), %rax      # 0x17348
movq (%rax), %rcx
movzbl 0xc(%r15), %eax
movq -0x8(%rcx,%rax,8), %rdx
movq %rdx, %rcx
movq %r13, %rdi
movq (%rcx), %r13
cmpq %rdx, %r13
je 0xdba4
movl 0x8(%r13), %esi
movq %r13, %rcx
cmpl 0x8(%r15), %esi
jne 0xdb5b
movq %r13, %rsi
callq 0x5763
leaq 0x97c6(%rip), %r14      # 0x17348
movq 0x8(%r14), %rax
movzbl 0xc(%r15), %ecx
decw -0x2(%rax,%rcx,2)
movq %r13, %rdi
movl $0x4b4, %esi            # imm = 0x4B4
callq 0x5b1a
movzbl 0xc(%r15), %eax
jmp 0xdbab
leaq 0x979d(%rip), %r14      # 0x17348
movq 0x10(%r14), %rcx
movq -0x8(%rcx,%rax,8), %rdi
callq 0x22d0
testl %eax, %eax
je 0xdbdc
callq 0x2070
movl (%rax), %edi
callq 0x2480
xorl %edi, %edi
leaq 0x4742(%rip), %rsi      # 0x12314
movq %rax, %rdx
xorl %eax, %eax
callq 0xcb1c
movq %rbx, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x5763
movq %r15, %rdi
movl $0x4b5, %esi            # imm = 0x4B5
callq 0x5b1a
movq %rbp, %r15
jmp 0xdae9
xorl %eax, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq