// File: /workspace/github_c_makefile_star2_O2/yakushstanislav[P]EagleMQ/src/eagle.c
// Function: init_server
void init_server(void)
{
	if (server->daemonize) {
		daemonize();
	}

	if (server->pidfile) {
		create_pid_file(server->pidfile);
	}

	if (server->logfile) {
		enable_log(server->logfile);
	}

	unblock_open_files_limit();

	server->loop = create_event_loop(server->max_clients + 1);

	if (server->port != 0)
	{
		server->fd = net_tcp_server(server->error, server->addr, server->port);
		if (server->fd == EG_NET_ERR) {
			fatal("Error create server: %s\n%s", server->addr, server->error);
		}
	}

	if (server->unix_socket != NULL)
	{
		unlink(server->unix_socket);

		server->sfd = net_unix_server(server->error, server->unix_socket, server->unix_perm);
		if (server->sfd == EG_NET_ERR) {
			fatal("Opening socket: %s\n", server->error);
		}
	}

	if (server->fd < 0 && server->sfd < 0) {
		fatal("Error configure server");
	}

	if (server->fd > 0 && create_file_event(server->loop, server->fd, EG_EVENT_READABLE, accept_tcp_handler, NULL) == EG_EVENT_ERR) {
		fatal("Error create file event");
	}

	if (server->sfd > 0 && create_file_event(server->loop, server->sfd, EG_EVENT_READABLE, accept_unix_handler, NULL) == EG_EVENT_ERR) {
		fatal("Error create file event");
	}

	server->ufd = create_time_event(server->loop, 1, server_updater, NULL, NULL);
}

// Assembly:
pushq %rax
movq 0xf52c(%rip), %rax      # 0x12290
cmpl $0x0, 0x1b8(%rax)
je 0x2d79
callq 0x2604
movq 0xf517(%rip), %rax      # 0x12290
movq 0x1c8(%rax), %rdi
testq %rdi, %rdi
je 0x2d91
callq 0x25cc
movq 0xf4ff(%rip), %rax      # 0x12290
movq 0x1d0(%rax), %rdi
testq %rdi, %rdi
je 0x2da2
callq 0x4514
callq 0x2660
movq 0xf4e2(%rip), %rax      # 0x12290
movl 0x48(%rax), %edi
incl %edi
callq 0x3508
movq 0xf4d1(%rip), %rcx      # 0x12290
movq %rax, (%rcx)
movq 0xf4c7(%rip), %rcx      # 0x12290
movl 0x20(%rcx), %edx
testl %edx, %edx
je 0x2e0f
movq 0x18(%rcx), %rsi
addq $0x60, %rcx
movq %rcx, %rdi
callq 0x3df1
movq 0xf4a9(%rip), %rcx      # 0x12290
movl %eax, 0x8(%rcx)
cmpl $-0x1, %eax
jne 0x2e0f
movq 0x18(%rcx), %rsi
addq $0x60, %rcx
leaq 0x93da(%rip), %rdi      # 0xc1d8
movq %rcx, %rdx
xorl %eax, %eax
callq 0x4741
movq 0xf481(%rip), %rcx      # 0x12290
movq 0x28(%rcx), %rdi
testq %rdi, %rdi
je 0x2e5f
callq 0x2060
movq 0xf46c(%rip), %rax      # 0x12290
leaq 0x60(%rax), %rdi
movq 0x28(%rax), %rsi
movl 0x30(%rax), %edx
callq 0x3f9e
movq 0xf455(%rip), %rcx      # 0x12290
movl %eax, 0xc(%rcx)
cmpl $-0x1, %eax
jne 0x2e5f
addq $0x60, %rcx
leaq 0x93a5(%rip), %rdi      # 0xc1f3
movq %rcx, %rsi
xorl %eax, %eax
callq 0x4741
movq 0xf431(%rip), %rcx      # 0x12290
movl 0x8(%rcx), %esi
testl %esi, %esi
js 0x2e94
testl %esi, %esi
jle 0x2e9a
movq (%rcx), %rdi
leaq 0x4e07(%rip), %rcx      # 0x7c7b
pushq $0x1
popq %rdx
xorl %r8d, %r8d
callq 0x362e
cmpl $-0x1, %eax
jne 0x2e9a
leaq 0x9393(%rip), %rdi      # 0xc21e
xorl %eax, %eax
callq 0x4741
jmp 0x2e9a
cmpl $0x0, 0xc(%rcx)
js 0x2efb
movq 0xf3ef(%rip), %rax      # 0x12290
movl 0xc(%rax), %esi
testl %esi, %esi
jle 0x2ed0
movq (%rax), %rdi
leaq 0x4e54(%rip), %rcx      # 0x7d06
pushq $0x1
popq %rdx
xorl %r8d, %r8d
callq 0x362e
cmpl $-0x1, %eax
jne 0x2ed0
leaq 0x9355(%rip), %rdi      # 0xc21e
xorl %eax, %eax
callq 0x4741
movq 0xf3b9(%rip), %rax      # 0x12290
movq (%rax), %rdi
leaq -0x299(%rip), %rdx      # 0x2c48
pushq $0x1
popq %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x37be
movq 0xf39b(%rip), %rcx      # 0x12290
movq %rax, 0x10(%rcx)
popq %rax
retq
leaq 0x9305(%rip), %rdi      # 0xc207
xorl %eax, %eax
callq 0x4741
movq 0xf380(%rip), %rcx      # 0x12290
movl 0x8(%rcx), %esi
jmp 0x2e66