// File: /workspace/github_cpp_makefile_star2_O1/lotuskip[P]yuxtapa/client/client.cpp
// Function: main
int main(int argc, char *argv[])
{
	setlocale(LC_ALL, "");

	string server = "";
	if(argc >= 2) // command line argument should be a server name
	{
		if((server = argv[1]) == "--help" || server == "-h")
		{
			cout << "Flag \'-v\' prints the version. Other than that, any command line"
				<< endl << "argument should be either a server address or a server name"
				<< endl << "defined in the configuration." << endl;
			return 0;
		}
		if(server == "-v" || server == "--version")
		{
			cout << PACKAGE << " client v." << VERSION << endl;
			return 0;
		}
	}
	Config::read_config(server);
	if(!Base::init_ncurses())
		return 1;
	init_msgs();
	// reuse server-string for connection errors:
	if(!Network::connect(server))
	{
		Base::deinit_ncurses();
		cerr << server << endl;
		return 1;
	}
	// If here, we are connected, and 'server' string is unmodified.
	// Print server info, which is constant for the whole session:
	server.insert(0, "Server: ");
	fix_str_to_fit(server);
	Base::print_str(server.c_str(), 7, 0, 3, STAT_WIN, false);
	// an IPv6 address might be too long to fit on one line:
	fix_str_to_fit((server = Config::get_server_ip()));
	Base::print_str(server.c_str(), 7, 0, 4, STAT_WIN, false);
	
	bool server_disconnect = false;
	while(!(server_disconnect = Network::receive_n_handle())
		&& !Input::inputhandle())
		upd_msgs();

	Network::disconnect();
	Base::deinit_ncurses();
	Config::save_msg_memory();
	if(server_disconnect)
		cout << "Server disconnected." << endl;
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rsi, %rbx
movl %edi, %r14d
leaq 0x7f39(%rip), %r15      # 0x10479
movl $0x6, %edi
movq %r15, %rsi
callq 0x4340
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq -0x40(%rbp), %rdi
movq %r15, %rsi
movq %r15, %rdx
callq 0x8912
cmpl $0x2, %r14d
jl 0x85f5
movq 0x8(%rbx), %rbx
leaq -0x40(%rbp), %r14
movq 0x8(%r14), %r15
movq %rbx, %rdi
callq 0x41b0
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rdx
movq %rbx, %rcx
movq %rax, %r8
callq 0x45b0
leaq 0x7efb(%rip), %rsi      # 0x10498
movq %rax, %rdi
callq 0x4110
testl %eax, %eax
je 0x86f7
leaq 0x7eeb(%rip), %rsi      # 0x1049f
leaq -0x40(%rbp), %rdi
callq 0x4110
testl %eax, %eax
je 0x86f7
leaq 0x7f70(%rip), %rsi      # 0x1053c
leaq -0x40(%rbp), %rdi
callq 0x4110
testl %eax, %eax
je 0x8855
leaq 0x7f5b(%rip), %rsi      # 0x1053f
leaq -0x40(%rbp), %rdi
callq 0x4110
testl %eax, %eax
je 0x8855
leaq -0x40(%rbp), %rdi
callq 0xcd98
callq 0x62fc
movl $0x1, %ebx
testb %al, %al
je 0x88c9
callq 0x9bee
leaq -0x40(%rbp), %rdi
callq 0xb40c
testb %al, %al
je 0x87ab
leaq 0x7f32(%rip), %rcx      # 0x1055f
leaq -0x40(%rbp), %rdi
movl $0x8, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x4410
cmpq $0x19, -0x38(%rbp)
jb 0x8666
leaq -0x40(%rbp), %rdi
movq $0x15, 0x8(%rdi)
movq (%rdi), %rax
movb $0x0, 0x15(%rax)
leaq 0xaa9c(%rip), %rsi      # 0x130fd
callq 0x46f0
movq -0x40(%rbp), %rdi
movl $0x7, %esi
xorl %edx, %edx
movl $0x3, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x68af
callq 0xe063
leaq -0x40(%rbp), %rdi
movq %rax, %rsi
callq 0x4200
cmpq $0x19, -0x38(%rbp)
jb 0x86b8
leaq -0x40(%rbp), %rdi
movq $0x15, 0x8(%rdi)
movq (%rdi), %rax
movb $0x0, 0x15(%rax)
leaq 0xaa4a(%rip), %rsi      # 0x130fd
callq 0x46f0
movq -0x40(%rbp), %rdi
movl $0x7, %esi
xorl %edx, %edx
movl $0x4, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x68af
callq 0xc591
movl %eax, %r14d
testb %al, %al
jne 0x87f3
callq 0x89ac
testb %al, %al
jne 0x87f3
callq 0xa367
jmp 0x86d3
movq 0xe8ca(%rip), %rbx      # 0x16fc8
leaq 0x7d9d(%rip), %rsi      # 0x104a2
movl $0x3f, %edx
movq %rbx, %rdi
callq 0x4420
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4370
movsbl %al, %esi
movq 0xe898(%rip), %rdi      # 0x16fc8
callq 0x4040
movq %rax, %rdi
callq 0x4250
movq %rax, %rbx
leaq 0x7d9b(%rip), %rsi      # 0x104e2
movl $0x3b, %edx
movq %rax, %rdi
callq 0x4420
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4370
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4250
movq %rax, %rbx
leaq 0x7d99(%rip), %rsi      # 0x1051e
movl $0x1d, %edx
movq %rax, %rdi
callq 0x4420
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4370
jmp 0x88b4
callq 0x6829
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq 0xe831(%rip), %rdi      # 0x16ff0
callq 0x4420
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4370
movsbl %al, %esi
movq %r14, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4250
jmp 0x88c9
callq 0xc518
callq 0x6829
callq 0xde87
xorl %ebx, %ebx
testb %r14b, %r14b
je 0x88c9
movq 0xe7b4(%rip), %r14      # 0x16fc8
leaq 0x7d4d(%rip), %rsi      # 0x10568
movl $0x14, %edx
movq %r14, %rdi
callq 0x4420
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x4370
movsbl %al, %esi
movq 0xe782(%rip), %rdi      # 0x16fc8
callq 0x4040
movq %rax, %rdi
callq 0x4250
jmp 0x88c9
movq 0xe76c(%rip), %rdi      # 0x16fc8
leaq 0x7ce6(%rip), %rsi      # 0x10549
movl $0x7, %edx
callq 0x4420
movq 0xe754(%rip), %rdi      # 0x16fc8
leaq 0x7cd6(%rip), %rsi      # 0x10551
movl $0xa, %edx
callq 0x4420
movq 0xe73c(%rip), %rbx      # 0x16fc8
leaq 0x7cc9(%rip), %rsi      # 0x1055c
movl $0x2, %edx
movq %rbx, %rdi
callq 0x4420
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4370
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
xorl %ebx, %ebx
movq %rax, %rdi
callq 0x4250
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x88de
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x43a0
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x88f1
jmp 0x88f1
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x8909
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x43a0
movq %rbx, %rdi
callq 0x4670
nop