// File: Doug0855[P]TigerZone/main.cpp
// Function: authenticationProtocol(Client&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
std::string authenticationProtocol(Client &client, std::string tournament_password, std::string username, std::string password)
{ //This protocol is called only to authenticate the client to the server.

	std::string message, message_to_send, player_id;
	std::string message_list = "";
	message = getMesssage(client, message_list);
	std::cout << GREEN << "Server sent: " << RESET << message << std::endl;

	if ( message == "THIS IS SPARTA!") //message to send tournament password
	{
		message_to_send = "JOIN " + tournament_password + "\r\n";
		std::cout << RED << "	We sent: " << RESET << message_to_send << std::endl;
		client.sendMessage(message_to_send);
	}
	else
	{
		std::cout << "ERROR: first message from server is: " << message;
		client.sendMessage("ILLEGAL MESSAGE SENT BY SERVER");
	}

	message = getMesssage(client, message_list);
	std::cout << GREEN << "Server sent: " << RESET << message << std::endl;
	if ( message == "HELLO!") //message to send team username and password
	{
		message_to_send = "I AM " + username + " " + password + "\r\n";
		std::cout << RED << "	We sent: " << RESET << message_to_send << std::endl;
		client.sendMessage(message_to_send);
	}
	else
	{
		std::cout << "ERROR: second message from server is: " << message;
		client.sendMessage("ILLEGAL MESSAGE SENT BY SERVER");
	}

	message = getMesssage(client, message_list); //last authentication message giving player id back
	std::cout << GREEN << "Server sent: " << RESET << message << std::endl;
	player_id = message.substr(8,message.find(" PLEASE")-8);
	std::cout << "	Player ID returned is: " << player_id << std::endl;
	return player_id;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3e0, %rsp            # imm = 0x3E0
movq %r8, -0x2a8(%rbp)
movq %rcx, -0x2a0(%rbp)
movq %rdx, -0x298(%rbp)
movq %rdi, -0x288(%rbp)
movq %rdi, %rax
movq %rax, -0x290(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x33c0
leaq -0x68(%rbp), %rdi
callq 0x33c0
movq -0x288(%rbp), %rdi
movb $0x0, -0x69(%rbp)
callq 0x33c0
leaq -0x91(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x3500
movq -0x280(%rbp), %rdx
leaq 0x22439(%rip), %rsi     # 0x29691
leaq -0x90(%rbp), %rdi
callq 0x33b0
jmp 0x7266
leaq -0x91(%rbp), %rdi
callq 0x32f0
movq -0x10(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
leaq -0x90(%rbp), %rdx
callq 0x4070
jmp 0x728b
leaq -0x48(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
movq %rsi, -0x2b8(%rbp)
callq 0x3360
movq -0x2b8(%rbp), %rdi
callq 0x3210
movq 0x2fd03(%rip), %rdi     # 0x36fb8
leaq 0x21d8a(%rip), %rsi     # 0x29046
callq 0x32b0
movq %rax, -0x2b0(%rbp)
jmp 0x72ca
movq -0x2b0(%rbp), %rdi
leaq 0x21d96(%rip), %rsi     # 0x2906e
callq 0x32b0
movq %rax, -0x2c0(%rbp)
jmp 0x72e6
movq -0x2c0(%rbp), %rdi
leaq 0x21d5e(%rip), %rsi     # 0x29052
callq 0x32b0
movq %rax, -0x2c8(%rbp)
jmp 0x7302
movq -0x2c8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3290
movq %rax, -0x2d0(%rbp)
jmp 0x731b
movq -0x2d0(%rbp), %rdi
movq 0x2fc7f(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x7330
leaq 0x21f6d(%rip), %rsi     # 0x292a4
leaq -0x48(%rbp), %rdi
callq 0x85b0
movb %al, -0x2d1(%rbp)
jmp 0x7348
movb -0x2d1(%rbp), %al
testb $0x1, %al
jne 0x7357
jmp 0x7503
movq -0x298(%rbp), %rdx
leaq 0x21f4f(%rip), %rsi     # 0x292b4
leaq -0x108(%rbp), %rdi
callq 0x8d10
jmp 0x7373
leaq 0x22315(%rip), %rdx     # 0x2968f
leaq -0xe8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x8ae0
jmp 0x738f
leaq -0x68(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
movq %rsi, -0x2e8(%rbp)
callq 0x3360
movq -0x2e8(%rbp), %rdi
callq 0x3210
leaq -0x108(%rbp), %rdi
callq 0x3210
movq 0x2fbf3(%rip), %rdi     # 0x36fb8
leaq 0x21ccc(%rip), %rsi     # 0x29098
callq 0x32b0
movq %rax, -0x2e0(%rbp)
jmp 0x73da
movq -0x2e0(%rbp), %rdi
leaq 0x21cb6(%rip), %rsi     # 0x2909e
callq 0x32b0
movq %rax, -0x2f0(%rbp)
jmp 0x73f6
movq -0x2f0(%rbp), %rdi
leaq 0x21c4e(%rip), %rsi     # 0x29052
callq 0x32b0
movq %rax, -0x2f8(%rbp)
jmp 0x7412
movq -0x2f8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x3290
movq %rax, -0x300(%rbp)
jmp 0x742b
movq -0x300(%rbp), %rdi
movq 0x2fb6f(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x7440
movq -0x10(%rbp), %rax
movq %rax, -0x308(%rbp)
leaq -0x128(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x3160
jmp 0x745d
movq -0x308(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x184b0
jmp 0x7472
leaq -0x128(%rbp), %rdi
callq 0x3210
jmp 0x75dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x91(%rbp), %rdi
callq 0x32f0
jmp 0x7b5f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x7b23
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x3210
jmp 0x7b23
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x3210
jmp 0x7b23
movq 0x2faae(%rip), %rdi     # 0x36fb8
leaq 0x21da9(%rip), %rsi     # 0x292ba
callq 0x32b0
movq %rax, -0x310(%rbp)
jmp 0x751f
movq -0x310(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3290
jmp 0x7531
movq -0x10(%rbp), %rax
movq %rax, -0x320(%rbp)
leaq -0x149(%rbp), %rdi
movq %rdi, -0x318(%rbp)
callq 0x3500
movq -0x318(%rbp), %rdx
leaq 0x21d83(%rip), %rsi     # 0x292e0
leaq -0x148(%rbp), %rdi
callq 0x33b0
jmp 0x756b
movq -0x320(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x184b0
jmp 0x7580
leaq -0x148(%rbp), %rdi
callq 0x3210
leaq -0x149(%rbp), %rdi
callq 0x32f0
jmp 0x75dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x75cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x3210
leaq -0x149(%rbp), %rdi
callq 0x32f0
jmp 0x7b23
movq -0x10(%rbp), %rsi
leaq -0x170(%rbp), %rdi
leaq -0x90(%rbp), %rdx
callq 0x4070
jmp 0x75f6
leaq -0x48(%rbp), %rdi
leaq -0x170(%rbp), %rsi
movq %rsi, -0x330(%rbp)
callq 0x3360
movq -0x330(%rbp), %rdi
callq 0x3210
movq 0x2f998(%rip), %rdi     # 0x36fb8
leaq 0x21a1f(%rip), %rsi     # 0x29046
callq 0x32b0
movq %rax, -0x328(%rbp)
jmp 0x7635
movq -0x328(%rbp), %rdi
leaq 0x21a2b(%rip), %rsi     # 0x2906e
callq 0x32b0
movq %rax, -0x338(%rbp)
jmp 0x7651
movq -0x338(%rbp), %rdi
leaq 0x219f3(%rip), %rsi     # 0x29052
callq 0x32b0
movq %rax, -0x340(%rbp)
jmp 0x766d
movq -0x340(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3290
movq %rax, -0x348(%rbp)
jmp 0x7686
movq -0x348(%rbp), %rdi
movq 0x2f914(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x769b
leaq 0x21c5d(%rip), %rsi     # 0x292ff
leaq -0x48(%rbp), %rdi
callq 0x85b0
movb %al, -0x349(%rbp)
jmp 0x76b3
movb -0x349(%rbp), %al
testb $0x1, %al
jne 0x76c2
jmp 0x78c4
movq -0x2a0(%rbp), %rdx
leaq 0x21c36(%rip), %rsi     # 0x29306
leaq -0x1f0(%rbp), %rdi
callq 0x8d10
jmp 0x76de
leaq 0x21ee6(%rip), %rdx     # 0x295cb
leaq -0x1d0(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x8ae0
jmp 0x76fa
movq -0x2a8(%rbp), %rdx
leaq -0x1b0(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x8e20
jmp 0x7716
leaq 0x21f72(%rip), %rdx     # 0x2968f
leaq -0x190(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x8ae0
jmp 0x7732
leaq -0x68(%rbp), %rdi
leaq -0x190(%rbp), %rsi
movq %rsi, -0x360(%rbp)
callq 0x3360
movq -0x360(%rbp), %rdi
callq 0x3210
leaq -0x1b0(%rbp), %rdi
callq 0x3210
leaq -0x1d0(%rbp), %rdi
callq 0x3210
leaq -0x1f0(%rbp), %rdi
callq 0x3210
movq 0x2f838(%rip), %rdi     # 0x36fb8
leaq 0x21911(%rip), %rsi     # 0x29098
callq 0x32b0
movq %rax, -0x358(%rbp)
jmp 0x7795
movq -0x358(%rbp), %rdi
leaq 0x218fb(%rip), %rsi     # 0x2909e
callq 0x32b0
movq %rax, -0x368(%rbp)
jmp 0x77b1
movq -0x368(%rbp), %rdi
leaq 0x21893(%rip), %rsi     # 0x29052
callq 0x32b0
movq %rax, -0x370(%rbp)
jmp 0x77cd
movq -0x370(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x3290
movq %rax, -0x378(%rbp)
jmp 0x77e6
movq -0x378(%rbp), %rdi
movq 0x2f7b4(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x77fb
movq -0x10(%rbp), %rax
movq %rax, -0x380(%rbp)
leaq -0x210(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x3160
jmp 0x7818
movq -0x380(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x184b0
jmp 0x782d
leaq -0x210(%rbp), %rdi
callq 0x3210
jmp 0x799e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x7890
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x7884
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x3210
leaq -0x1d0(%rbp), %rdi
callq 0x3210
leaq -0x1f0(%rbp), %rdi
callq 0x3210
jmp 0x7b23
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x3210
jmp 0x7b23
movq 0x2f6ed(%rip), %rdi     # 0x36fb8
leaq 0x21a3a(%rip), %rsi     # 0x2930c
callq 0x32b0
movq %rax, -0x388(%rbp)
jmp 0x78e0
movq -0x388(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3290
jmp 0x78f2
movq -0x10(%rbp), %rax
movq %rax, -0x398(%rbp)
leaq -0x231(%rbp), %rdi
movq %rdi, -0x390(%rbp)
callq 0x3500
movq -0x390(%rbp), %rdx
leaq 0x219c2(%rip), %rsi     # 0x292e0
leaq -0x230(%rbp), %rdi
callq 0x33b0
jmp 0x792c
movq -0x398(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0x184b0
jmp 0x7941
leaq -0x230(%rbp), %rdi
callq 0x3210
leaq -0x231(%rbp), %rdi
callq 0x32f0
jmp 0x799e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x798d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x3210
leaq -0x231(%rbp), %rdi
callq 0x32f0
jmp 0x7b23
movq -0x10(%rbp), %rsi
leaq -0x258(%rbp), %rdi
leaq -0x90(%rbp), %rdx
callq 0x4070
jmp 0x79b7
leaq -0x48(%rbp), %rdi
leaq -0x258(%rbp), %rsi
movq %rsi, -0x3a8(%rbp)
callq 0x3360
movq -0x3a8(%rbp), %rdi
callq 0x3210
movq 0x2f5d7(%rip), %rdi     # 0x36fb8
leaq 0x2165e(%rip), %rsi     # 0x29046
callq 0x32b0
movq %rax, -0x3a0(%rbp)
jmp 0x79f6
movq -0x3a0(%rbp), %rdi
leaq 0x2166a(%rip), %rsi     # 0x2906e
callq 0x32b0
movq %rax, -0x3b0(%rbp)
jmp 0x7a12
movq -0x3b0(%rbp), %rdi
leaq 0x21632(%rip), %rsi     # 0x29052
callq 0x32b0
movq %rax, -0x3b8(%rbp)
jmp 0x7a2e
movq -0x3b8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3290
movq %rax, -0x3c0(%rbp)
jmp 0x7a47
movq -0x3c0(%rbp), %rdi
movq 0x2f553(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x7a5c
leaq 0x218d0(%rip), %rsi     # 0x29333
xorl %eax, %eax
movl %eax, %edx
leaq -0x48(%rbp), %rdi
movq %rdi, -0x3c8(%rbp)
callq 0x3540
movq -0x3c8(%rbp), %rsi
movq %rax, %rcx
addq $-0x8, %rcx
leaq -0x278(%rbp), %rdi
movl $0x8, %edx
callq 0x32d0
jmp 0x7a98
movq -0x288(%rbp), %rdi
leaq -0x278(%rbp), %rsi
movq %rsi, -0x3d8(%rbp)
callq 0x3360
movq -0x3d8(%rbp), %rdi
callq 0x3210
movq 0x2f4f3(%rip), %rdi     # 0x36fb8
leaq 0x2186f(%rip), %rsi     # 0x2933b
callq 0x32b0
movq %rax, -0x3d0(%rbp)
jmp 0x7ada
movq -0x288(%rbp), %rsi
movq -0x3d0(%rbp), %rdi
callq 0x3290
movq %rax, -0x3e0(%rbp)
jmp 0x7af6
movq -0x3e0(%rbp), %rdi
movq 0x2f4a4(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x7b0b
movb $0x1, -0x69(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x3210
testb $0x1, -0x69(%rbp)
jne 0x7b3d
jmp 0x7b31
leaq -0x90(%rbp), %rdi
callq 0x3210
jmp 0x7b5f
movq -0x288(%rbp), %rdi
callq 0x3210
leaq -0x68(%rbp), %rdi
callq 0x3210
leaq -0x48(%rbp), %rdi
callq 0x3210
movq -0x290(%rbp), %rax
addq $0x3e0, %rsp            # imm = 0x3E0
popq %rbp
retq
movq -0x288(%rbp), %rdi
callq 0x3210
leaq -0x68(%rbp), %rdi
callq 0x3210
leaq -0x48(%rbp), %rdi
callq 0x3210
movq -0xa0(%rbp), %rdi
callq 0x34f0
nopl (%rax)