// File: /workspace/github_cpp_makefile_star2_O1/lotuskip[P]yuxtapa/server/network.cpp
// Function: Network::startup()
bool Network::startup()
{
	struct addrinfo hints, *servinfo, *p;
	bzero(&hints, sizeof(hints));
	switch(Config::int_settings[Config::IS_IPV])
	{
	case 0: hints.ai_family = AF_UNSPEC; break;
	case 4: hints.ai_family = AF_INET; break;
	case 6: hints.ai_family = AF_INET6;
	}
	hints.ai_socktype = SOCK_DGRAM;
	hints.ai_flags = AI_PASSIVE; // use my IP
	int rv;
	if((rv = getaddrinfo(NULL,
		lex_cast(Config::int_settings[Config::IS_PORT]).c_str(),
		&hints, &servinfo)) != 0)
	{
		cerr << "Error in getaddrinfo: " <<  gai_strerror(rv) << endl;
		return false;
	}
	for(p = servinfo; p; p = p->ai_next)
	{
		if((s_me = socket(p->ai_family, p->ai_socktype,	p->ai_protocol)) == -1)
			continue;
		if(bind(s_me, p->ai_addr, p->ai_addrlen) == -1)
		{
			close(s_me);
			continue;
		}
		break; // created socket and bound
	}
	if(!p)
	{
		cerr << "Failed to bind socket!" << endl;
		return false;
	}
	// set socket to nonblock mode
	fcntl(s_me, F_SETFL, O_NONBLOCK);
	
	freeaddrinfo(servinfo);
	
	time_t rawtime;
	time(&rawtime);
	to_log(string("Startup on ") + ctime(&rawtime));
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x88, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0x80(%rbp)
leaq 0x347ec(%rip), %rax     # 0x428a0
movl 0x20(%rax), %ecx
testl %ecx, %ecx
je 0xe0d1
cmpl $0x6, %ecx
je 0xe0cc
cmpl $0x4, %ecx
jne 0xe0d7
movl $0x2, %ecx
jmp 0xe0d1
movl $0xa, %ecx
movl %ecx, -0x9c(%rbp)
leaq -0xa0(%rbp), %rbx
movl $0x2, 0x8(%rbx)
movl $0x1, (%rbx)
movl 0x1c(%rax), %esi
leaq -0x38(%rbp), %r14
movq %r14, %rdi
callq 0x2be77
movq (%r14), %rsi
leaq -0x40(%rbp), %rcx
xorl %edi, %edi
movq %rbx, %rdx
callq 0x4500
movl %eax, %r14d
leaq -0x28(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0xe127
movq -0x28(%rbp), %rsi
incq %rsi
callq 0x43f0
testl %r14d, %r14d
je 0xe16e
movq 0x31ebd(%rip), %rbx     # 0x3fff0
leaq 0x1e0f6(%rip), %rsi     # 0x2c230
movl $0x16, %edx
movq %rbx, %rdi
callq 0x4460
movl %r14d, %edi
callq 0x4590
testq %rax, %rax
je 0xe1d1
movq %rax, %r14
movq %rax, %rdi
callq 0x41a0
movq 0x31e8a(%rip), %rdi     # 0x3fff0
movq %r14, %rsi
movq %rax, %rdx
jmp 0xe1ca
movq -0x40(%rbp), %rbx
testq %rbx, %rbx
je 0xe1b4
movl 0x4(%rbx), %edi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
callq 0x40e0
movl %eax, 0x33fbd(%rip)     # 0x42148
cmpl $-0x1, %eax
je 0xe1ae
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
movl %eax, %edi
callq 0x4090
movl 0x33fa4(%rip), %edi     # 0x42148
cmpl $-0x1, %eax
jne 0xe21f
callq 0x47d0
movq 0x28(%rbx), %rbx
jmp 0xe172
movq 0x31e35(%rip), %rbx     # 0x3fff0
leaq 0x1e085(%rip), %rsi     # 0x2c247
movl $0x16, %edx
movq %rbx, %rdi
callq 0x4460
jmp 0xe1e8
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x43d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4250
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x4210
movq -0x40(%rbp), %rdi
callq 0x4540
leaq -0x48(%rbp), %rdi
callq 0x43b0
leaq -0x58(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x1e00d(%rip), %rsi     # 0x2c25e
leaq 0x1e011(%rip), %rdx     # 0x2c269
leaq -0x68(%rbp), %rdi
callq 0xdfec
leaq -0x48(%rbp), %rdi
callq 0x4170
leaq -0x68(%rbp), %rdi
movq %rax, %rsi
callq 0x47c0
movq %r15, -0x38(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xe296
movq %rdx, -0x38(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x28(%rbp)
jmp 0xe29d
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
leaq -0x38(%rbp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
callq 0x15050
movq -0x38(%rbp), %rdi
cmpq %r15, %rdi
je 0xe2d2
movq -0x28(%rbp), %rsi
incq %rsi
callq 0x43f0
movq -0x68(%rbp), %rdi
cmpq %r14, %rdi
je 0xe2e7
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x43f0
movb $0x1, %al
jmp 0xe211
movq %rax, %rbx
movq -0x38(%rbp), %rdi
cmpq %r15, %rdi
je 0xe30b
movq -0x28(%rbp), %rsi
incq %rsi
callq 0x43f0
jmp 0xe30b
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r14, %rdi
je 0xe33b
movq -0x58(%rbp), %rsi
jmp 0xe333
movq %rax, %rbx
jmp 0xe33b
movq %rax, %rbx
leaq -0x28(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xe33b
movq -0x28(%rbp), %rsi
incq %rsi
callq 0x43f0
movq %rbx, %rdi
callq 0x4750