// File: /workspace/github_cpp_makefile_star2_O3/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 0x7f31(%rip), %r15      # 0x10479
movl $0x6, %edi
movq %r15, %rsi
callq 0x4330
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq -0x40(%rbp), %rdi
movq %r15, %rsi
movq %r15, %rdx
callq 0x891a
cmpl $0x2, %r14d
jl 0x85fd
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 0x45a0
leaq 0x7ef3(%rip), %rsi      # 0x10498
movq %rax, %rdi
callq 0x4110
testl %eax, %eax
je 0x86ff
leaq 0x7ee3(%rip), %rsi      # 0x1049f
leaq -0x40(%rbp), %rdi
callq 0x4110
testl %eax, %eax
je 0x86ff
leaq 0x7f68(%rip), %rsi      # 0x1053c
leaq -0x40(%rbp), %rdi
callq 0x4110
testl %eax, %eax
je 0x885d
leaq 0x7f53(%rip), %rsi      # 0x1053f
leaq -0x40(%rbp), %rdi
callq 0x4110
testl %eax, %eax
je 0x885d
leaq -0x40(%rbp), %rdi
callq 0xcccc
callq 0x62bc
movl $0x1, %ebx
testb %al, %al
je 0x88d1
callq 0x9b8e
leaq -0x40(%rbp), %rdi
callq 0xb3bc
testb %al, %al
je 0x87b3
leaq 0x7f2a(%rip), %rcx      # 0x1055f
leaq -0x40(%rbp), %rdi
movl $0x8, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x4400
cmpq $0x19, -0x38(%rbp)
jb 0x866e
leaq -0x40(%rbp), %rdi
movq $0x15, 0x8(%rdi)
movq (%rdi), %rax
movb $0x0, 0x15(%rax)
leaq 0xaa84(%rip), %rsi      # 0x130ed
callq 0x46e0
movq -0x40(%rbp), %rdi
movl $0x7, %esi
xorl %edx, %edx
movl $0x3, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x686d
callq 0xdfe4
leaq -0x40(%rbp), %rdi
movq %rax, %rsi
callq 0x4200
cmpq $0x19, -0x38(%rbp)
jb 0x86c0
leaq -0x40(%rbp), %rdi
movq $0x15, 0x8(%rdi)
movq (%rdi), %rax
movb $0x0, 0x15(%rax)
leaq 0xaa32(%rip), %rsi      # 0x130ed
callq 0x46e0
movq -0x40(%rbp), %rdi
movl $0x7, %esi
xorl %edx, %edx
movl $0x4, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x686d
callq 0xc4c7
movl %eax, %r14d
testb %al, %al
jne 0x87fb
callq 0x89b8
testb %al, %al
jne 0x87fb
callq 0xa318
jmp 0x86db
movq 0xe8c2(%rip), %rbx      # 0x16fc8
leaq 0x7d95(%rip), %rsi      # 0x104a2
movl $0x3f, %edx
movq %rbx, %rdi
callq 0x4410
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq 0xe890(%rip), %rdi      # 0x16fc8
callq 0x4040
movq %rax, %rdi
callq 0x4250
movq %rax, %rbx
leaq 0x7d93(%rip), %rsi      # 0x104e2
movl $0x3b, %edx
movq %rax, %rdi
callq 0x4410
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4250
movq %rax, %rbx
leaq 0x7d91(%rip), %rsi      # 0x1051e
movl $0x1d, %edx
movq %rax, %rdi
callq 0x4410
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4360
jmp 0x88bc
callq 0x67e7
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq 0xe829(%rip), %rdi      # 0x16ff0
callq 0x4410
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq %r14, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4250
jmp 0x88d1
callq 0xc44e
callq 0x67e7
callq 0xde08
xorl %ebx, %ebx
testb %r14b, %r14b
je 0x88d1
movq 0xe7ac(%rip), %r14      # 0x16fc8
leaq 0x7d45(%rip), %rsi      # 0x10568
movl $0x14, %edx
movq %r14, %rdi
callq 0x4410
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq 0xe77a(%rip), %rdi      # 0x16fc8
callq 0x4040
movq %rax, %rdi
callq 0x4250
jmp 0x88d1
movq 0xe764(%rip), %rdi      # 0x16fc8
leaq 0x7cde(%rip), %rsi      # 0x10549
movl $0x7, %edx
callq 0x4410
movq 0xe74c(%rip), %rdi      # 0x16fc8
leaq 0x7cce(%rip), %rsi      # 0x10551
movl $0xa, %edx
callq 0x4410
movq 0xe734(%rip), %rbx      # 0x16fc8
leaq 0x7cc1(%rip), %rsi      # 0x1055c
movl $0x2, %edx
movq %rbx, %rdi
callq 0x4410
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
xorl %ebx, %ebx
movq %rax, %rdi
callq 0x4250
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x88e6
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x4390
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x88f9
jmp 0x88f9
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x8911
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x4390
movq %rbx, %rdi
callq 0x4660
nop