// File: /workspace/github_cpp_makefile_star2_O2/patxitron[P]BattleyeRconToolLinux/main.cpp
// Function: main
int main(int argc, char* argv[])
{
	string host;
	uint16_t port = 0;
	string passwd;
	if(argc > 1) {
		host = string(argv[1]);
		if(argc > 2) {
			port = static_cast<uint16_t>(strtoul(argv[2], nullptr, 10));
		}
	}
	while(host.empty()) {
		cout << "Please enter the name or IP addres of the server:" << endl;
		getline(cin, host);
	}
	while(port == 0) {
		cout << "Please enter the port of the server:" << endl;
		string p;
		getline(cin, p);
		port = static_cast<uint16_t>(strtoul(p.c_str(), nullptr, 10));
	}
	while(passwd.empty()) {
		cout << "Please enter the password:" << endl;
		getline(cin, passwd);
	}
	boost::asio::io_service io_service;
	patxi::a3s server(
		 io_service
		,port
		,host
		,[](char const* data, std::size_t length)
		{
			string msg(data, length);
			cout << msg << endl;
		}
		,[&server](bool logged)
		{
			if(logged) {
				cout << "Successfully logged in." << endl;
				server.consoleInput();
			} else {
				cout << "Failed to log in" << endl;
			}
		}
	);
	server.login(passwd);
	io_service.run();
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5f8, %rsp            # imm = 0x5F8
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq 0x40(%rsp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
xorl %ebx, %ebx
movb %bl, (%rax)
movb %bl, (%rcx)
cmpl $0x2, %edi
jl 0xf154
movq %rsi, %r14
movl %edi, %ebp
movq 0x8(%rsi), %rsi
leaq 0x98(%rsp), %rdi
movq %rsp, %rdx
callq 0x8268
leaq 0x10(%rsp), %rdi
leaq 0x98(%rsp), %rbx
movq %rbx, %rsi
callq 0x6410
movq %rbx, %rdi
callq 0x6180
cmpl $0x2, %ebp
jne 0xf143
xorl %ebx, %ebx
jmp 0xf154
movq 0x10(%r14), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x6110
movq %rax, %rbx
movq 0xbe6d(%rip), %r14      # 0x1afc8
leaq 0x2284(%rip), %r15      # 0x113e6
movq 0xbe6f(%rip), %r12      # 0x1afd8
leaq 0x10(%rsp), %r13
cmpq $0x0, 0x18(%rsp)
jne 0xf196
movq %r14, %rdi
movq %r15, %rsi
callq 0x6350
movq %rax, %rdi
callq 0x61a0
movq %r12, %rdi
movq %r13, %rsi
callq 0x60a0
jmp 0xf16e
movq 0xbe2b(%rip), %r15      # 0x1afc8
leaq 0x2274(%rip), %r12      # 0x11418
movq 0xbe2d(%rip), %r13      # 0x1afd8
leaq 0x98(%rsp), %r14
pushq $0xa
popq %rbp
testw %bx, %bx
jne 0xf218
movq %r15, %rdi
movq %r12, %rsi
callq 0x6350
movq %rax, %rdi
callq 0x61a0
leaq 0xa8(%rsp), %rax
movq %rax, 0x98(%rsp)
andq $0x0, 0xa0(%rsp)
movb $0x0, 0xa8(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0x60a0
movq 0x98(%rsp), %rdi
xorl %esi, %esi
movl %ebp, %edx
callq 0x6110
movq %rax, %rbx
movq %r14, %rdi
callq 0x6180
jmp 0xf1b6
movq 0xbda9(%rip), %r15      # 0x1afc8
leaq 0x2217(%rip), %r12      # 0x1143d
movq 0xbdab(%rip), %r13      # 0x1afd8
leaq 0x30(%rsp), %rbp
cmpq $0x0, 0x38(%rsp)
jne 0xf25a
movq %r15, %rdi
movq %r12, %rsi
callq 0x6350
movq %rax, %rdi
callq 0x61a0
movq %r13, %rdi
movq %rbp, %rsi
callq 0x60a0
jmp 0xf232
movq %rsp, %rdi
callq 0xf474
xorps %xmm0, %xmm0
leaq 0x50(%rsp), %r8
movaps %xmm0, (%r8)
leaq 0x11d(%rip), %rax       # 0xf392
movq %rax, 0x18(%r8)
leaq 0x16c(%rip), %rax       # 0xf3ec
movq %rax, 0x10(%r8)
leaq 0x78(%rsp), %r9
andq $0x0, 0x8(%r9)
movq %r14, (%r9)
leaq 0x16c(%rip), %rax       # 0xf404
movq %rax, 0x18(%r9)
leaq 0x1ab(%rip), %rax       # 0xf44e
movq %rax, 0x10(%r9)
movzwl %bx, %edx
movq %rsp, %rsi
leaq 0x10(%rsp), %rcx
movq %r14, %rdi
callq 0x68bc
leaq 0x78(%rsp), %rdi
callq 0x8088
leaq 0x50(%rsp), %rdi
callq 0x8088
leaq 0x98(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x6b72
movq %rsp, %rdi
callq 0xf4d8
leaq 0x98(%rsp), %rdi
callq 0x6b1a
movq %rsp, %rdi
callq 0xf518
leaq 0x30(%rsp), %rdi
callq 0x6180
leaq 0x10(%rsp), %rdi
callq 0x6180
xorl %eax, %eax
addq $0x5f8, %rsp            # imm = 0x5F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xf372
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x8088
leaq 0x50(%rsp), %rdi
callq 0x8088
jmp 0xf352
jmp 0xf372
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x6b1a
movq %rsp, %rdi
callq 0xf518
jmp 0xf375
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x6180
jmp 0xf375
jmp 0xf372
jmp 0xf372
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x6180
leaq 0x10(%rsp), %rdi
callq 0x6180
movq %rbx, %rdi
callq 0x65d0
nop