// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
subq $0x90, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0x80(%rbp)
leaq 0x34446(%rip), %rax     # 0x3f890
movl 0x20(%rax), %ecx
cmpl $0x4, %ecx
je 0xb45b
cmpl $0x6, %ecx
jne 0xb464
pushq $0xa
jmp 0xb45d
pushq $0x2
popq %rcx
movl %ecx, -0x9c(%rbp)
leaq -0xa0(%rbp), %r14
movl $0x2, 0x8(%r14)
movl $0x1, (%r14)
movl 0x1c(%rax), %esi
leaq -0x48(%rbp), %rbx
movq %rbx, %rdi
callq 0x24fde
movq (%rbx), %rsi
leaq -0x28(%rbp), %rbx
xorl %edi, %edi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x4500
movl %eax, %r14d
leaq -0x48(%rbp), %rdi
callq 0x47e8
testl %r14d, %r14d
je 0xb50f
movq 0x31b3b(%rip), %rdi     # 0x3cff0
leaq 0x1add0(%rip), %rsi     # 0x2628c
callq 0x43e0
movq %rax, %rbx
movl %r14d, %edi
callq 0x45a0
movq %rbx, %rdi
movq %rax, %rsi
jmp 0xb525
movl 0x4(%rbx), %edi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
callq 0x40f0
movl %eax, 0x33c50(%rip)     # 0x3f138
cmpl $-0x1, %eax
je 0xb50b
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
movl %eax, %edi
callq 0x4080
movl 0x33c37(%rip), %edi     # 0x3f138
cmpl $-0x1, %eax
jne 0xb540
callq 0x47a0
addq $0x28, %rbx
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0xb4d4
movq 0x31ad2(%rip), %rdi     # 0x3cff0
leaq 0x1ad7e(%rip), %rsi     # 0x262a3
callq 0x43e0
movq %rax, %rdi
callq 0x41c0
xorl %eax, %eax
addq $0x90, %rsp
popq %rbx
popq %r14
popq %rbp
retq
pushq $0x4
popq %rsi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x4210
movq -0x28(%rbp), %rdi
callq 0x4550
leaq -0x20(%rbp), %rdi
callq 0x43c0
leaq 0x1ad52(%rip), %rsi     # 0x262ba
leaq -0x68(%rbp), %rdi
leaq -0x11(%rbp), %rdx
callq 0xb292
leaq -0x20(%rbp), %rdi
callq 0x4170
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
movq %rax, %rdx
callq 0xb309
leaq -0x48(%rbp), %rdi
callq 0x10b68
leaq -0x48(%rbp), %rdi
callq 0x47e8
leaq -0x68(%rbp), %rdi
callq 0x47e8
movb $0x1, %al
jmp 0xb534
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x47e8
jmp 0xb5be
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
jmp 0xb5d0
movq %rax, %rbx
jmp 0xb5d5
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x47e8
movq %rbx, %rdi
callq 0x4710