// File: 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
movq %rsp, %rbp
subq $0x6c0, %rsp            # imm = 0x6C0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x86a0
movw $0x0, -0x32(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x86a0
cmpl $0x1, -0x8(%rbp)
jle 0x26a46
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x680(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0x678(%rbp)
callq 0x8860
movq -0x680(%rbp), %rsi
movq -0x678(%rbp), %rdx
leaq -0x78(%rbp), %rdi
callq 0xe770
jmp 0x269e3
leaq -0x30(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x85b0
leaq -0x78(%rbp), %rdi
callq 0x82a0
leaq -0x79(%rbp), %rdi
callq 0x84e0
cmpl $0x2, -0x8(%rbp)
jle 0x26a44
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x8160
movw %ax, -0x32(%rbp)
jmp 0x26a44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x79(%rbp), %rdi
callq 0x84e0
jmp 0x26d1f
jmp 0x26a46
jmp 0x26a48
leaq -0x30(%rbp), %rdi
callq 0x87d0
testb $0x1, %al
jne 0x26a57
jmp 0x26ab3
movq 0x18562(%rip), %rdi     # 0x3efc0
leaq 0x3a27(%rip), %rsi      # 0x2a48c
callq 0x8460
movq %rax, -0x688(%rbp)
jmp 0x26a73
movq -0x688(%rbp), %rdi
movq 0x184ff(%rip), %rsi     # 0x3ef80
callq 0x84c0
jmp 0x26a88
movq 0x18541(%rip), %rdi     # 0x3efd0
leaq -0x30(%rbp), %rsi
callq 0x80d0
jmp 0x26a9a
jmp 0x26a48
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x26d1f
jmp 0x26ab5
movzwl -0x32(%rbp), %eax
cmpl $0x0, %eax
jne 0x26b70
movq 0x184f7(%rip), %rdi     # 0x3efc0
leaq 0x39ee(%rip), %rsi      # 0x2a4be
callq 0x8460
movq %rax, -0x690(%rbp)
jmp 0x26ade
movq -0x690(%rbp), %rdi
movq 0x18494(%rip), %rsi     # 0x3ef80
callq 0x84c0
jmp 0x26af3
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x698(%rbp)
callq 0x86a0
movq -0x698(%rbp), %rsi
movq 0x184bc(%rip), %rdi     # 0x3efd0
callq 0x80d0
jmp 0x26b1b
leaq -0xb0(%rbp), %rdi
callq 0x81d0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x8160
movw %ax, -0x32(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x82a0
jmp 0x26ab5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x82a0
jmp 0x26d1f
jmp 0x26b72
leaq -0x58(%rbp), %rdi
callq 0x87d0
testb $0x1, %al
jne 0x26b81
jmp 0x26bc6
movq 0x18438(%rip), %rdi     # 0x3efc0
leaq 0x3954(%rip), %rsi      # 0x2a4e3
callq 0x8460
movq %rax, -0x6a0(%rbp)
jmp 0x26b9d
movq -0x6a0(%rbp), %rdi
movq 0x183d5(%rip), %rsi     # 0x3ef80
callq 0x84c0
jmp 0x26bb2
movq 0x18417(%rip), %rdi     # 0x3efd0
leaq -0x58(%rbp), %rsi
callq 0x80d0
jmp 0x26bc4
jmp 0x26b72
leaq -0xc0(%rbp), %rdi
callq 0x27690
jmp 0x26bd4
movzwl -0x32(%rbp), %eax
movl %eax, -0x6b4(%rbp)
leaq -0x640(%rbp), %rdi
movq %rdi, -0x6b0(%rbp)
leaq -0x641(%rbp), %rsi
callq 0x26d40
leaq -0x620(%rbp), %rax
movq %rax, -0x6c0(%rbp)
movq %rax, -0x670(%rbp)
leaq -0x668(%rbp), %rdi
movq %rdi, -0x6a8(%rbp)
leaq -0x670(%rbp), %rsi
callq 0x26dd0
movq -0x6c0(%rbp), %rdi
movl -0x6b4(%rbp), %edx
movq -0x6b0(%rbp), %r8
movq -0x6a8(%rbp), %r9
leaq -0xc0(%rbp), %rsi
leaq -0x30(%rbp), %rcx
callq 0x8e10
jmp 0x26c54
leaq -0x668(%rbp), %rdi
callq 0xdc00
leaq -0x640(%rbp), %rdi
callq 0xdc20
leaq -0x620(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x9280
jmp 0x26c7e
leaq -0xc0(%rbp), %rdi
callq 0x27740
jmp 0x26c8c
movl $0x0, -0x4(%rbp)
leaq -0x620(%rbp), %rdi
callq 0x9200
leaq -0xc0(%rbp), %rdi
callq 0x27790
leaq -0x58(%rbp), %rdi
callq 0x82a0
leaq -0x30(%rbp), %rdi
callq 0x82a0
movl -0x4(%rbp), %eax
addq $0x6c0, %rsp            # imm = 0x6C0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x668(%rbp), %rdi
callq 0xdc00
leaq -0x640(%rbp), %rdi
callq 0xdc20
jmp 0x26d13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x620(%rbp), %rdi
callq 0x9200
leaq -0xc0(%rbp), %rdi
callq 0x27790
leaq -0x58(%rbp), %rdi
callq 0x82a0
leaq -0x30(%rbp), %rdi
callq 0x82a0
movq -0x88(%rbp), %rdi
callq 0x8830
nopl (%rax)