// File: /workspace/github_cpp_makefile_star2_O3/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 0x347b8(%rip), %rax     # 0x428a0
movl 0x20(%rax), %ecx
cmpl $0x4, %ecx
je 0xe0fc
cmpl $0x6, %ecx
jne 0xe107
movl $0xa, %ecx
jmp 0xe101
movl $0x2, %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 0x2ba03
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 0xe157
movq -0x28(%rbp), %rsi
incq %rsi
callq 0x43f0
testl %r14d, %r14d
je 0xe19e
movq 0x31e85(%rip), %rbx     # 0x3ffe8
leaq 0x1e0c6(%rip), %rsi     # 0x2c230
movl $0x16, %edx
movq %rbx, %rdi
callq 0x4460
movl %r14d, %edi
callq 0x4590
testq %rax, %rax
je 0xe201
movq %rax, %r14
movq %rax, %rdi
callq 0x41a0
movq 0x31e52(%rip), %rdi     # 0x3ffe8
movq %r14, %rsi
movq %rax, %rdx
jmp 0xe1fa
movq -0x40(%rbp), %rbx
testq %rbx, %rbx
je 0xe1e4
movl 0x4(%rbx), %edi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
callq 0x40e0
movl %eax, 0x33f8d(%rip)     # 0x42148
cmpl $-0x1, %eax
je 0xe1de
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
movl %eax, %edi
callq 0x4090
movl 0x33f74(%rip), %edi     # 0x42148
cmpl $-0x1, %eax
jne 0xe24f
callq 0x47c0
movq 0x28(%rbx), %rbx
jmp 0xe1a2
movq 0x31dfd(%rip), %rbx     # 0x3ffe8
leaq 0x1e055(%rip), %rsi     # 0x2c247
movl $0x16, %edx
movq %rbx, %rdi
callq 0x4460
jmp 0xe218
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x4700
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 0x1dfdd(%rip), %rsi     # 0x2c25e
leaq 0x1dfe1(%rip), %rdx     # 0x2c269
leaq -0x68(%rbp), %rdi
callq 0xe01c
leaq -0x48(%rbp), %rdi
callq 0x4170
leaq -0x68(%rbp), %rdi
movq %rax, %rsi
callq 0x47b0
movq %r15, -0x38(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xe2c6
movq %rdx, -0x38(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x28(%rbp)
jmp 0xe2cd
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 0x14f24
movq -0x38(%rbp), %rdi
cmpq %r15, %rdi
je 0xe302
movq -0x28(%rbp), %rsi
incq %rsi
callq 0x43f0
movq -0x68(%rbp), %rdi
cmpq %r14, %rdi
je 0xe317
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x43f0
movb $0x1, %al
jmp 0xe241
movq %rax, %rbx
movq -0x38(%rbp), %rdi
cmpq %r15, %rdi
je 0xe33b
movq -0x28(%rbp), %rsi
incq %rsi
callq 0x43f0
jmp 0xe33b
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r14, %rdi
je 0xe36b
movq -0x58(%rbp), %rsi
jmp 0xe363
movq %rax, %rbx
jmp 0xe36b
movq %rax, %rbx
leaq -0x28(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xe36b
movq -0x28(%rbp), %rsi
incq %rsi
callq 0x43f0
movq %rbx, %rdi
callq 0x4740