// File: /workspace/github_cpp_makefile_star2_O3/Doug0855[P]TigerZone/main.cpp
// Function: challengeProtocol(Client&)
void challengeProtocol(Client &client) //This protocol is called once for each challenge
{
	int challenge_id, rounds;
	std::string message;
	std::string message_list = "";
	message = getMesssage(client, message_list);
	std::cout << GREEN << "Server sent: " << RESET << message << std::endl;
	while (message != TERMINATE_CHALLENGE)
	{
		if (message.compare(0,1,"N") == 0) //executing a new challenge
		{
			challenge_id = stoi(message.substr(14,message.find(" YOU")-14));
			rounds = stoi(message.substr(message.find("PLAY")+5,message.find(" MATCH")-message.find("PLAY")-5));
			//for (int i = 0; i < rounds; i++)
			//{
			std::cout << "	Challenge ID is: " << challenge_id << " and playing " << rounds << " round(s)" << std::endl;
			//std::cout << "	Current Round: " << i << std::endl;
			roundProtocol(client, message_list, rounds); //pass message reference
			//}
			message = getMesssage(client, message_list);
			std::cout << GREEN << "Server sent: " << RESET << message << std::endl;
		}
		else if (message.compare(0,1,"P") == 0)	//waiting for the next challenge to begin
		{
			std::cout << "	Waiting for the next challenge to begin" << std::endl;
			message = getMesssage(client, message_list);
			std::cout << GREEN << "Server sent: " << RESET << message << std::endl;
		}
		else //hopefully this is never reached
		{
			std::cout << "	ERROR: previous message could not be processed correctly. Message skipped!" << std::endl;
			std::cout << "		ERROR message: " << message << std::endl;
			message = getMesssage(client, message_list);
		}
	}
	message = getMesssage(client, message_list);
	std::cout << GREEN << "Server sent: " << RESET << message << std::endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %r15
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x80(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x11310(%rip), %rdx     # 0x18795
leaq -0x90(%rbp), %rdi
movq %rdx, %rsi
callq 0x9d62
leaq -0x68(%rbp), %rdi
leaq -0x90(%rbp), %rdx
movq %r15, %rsi
callq 0x40d1
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rbx
movq %rbx, %rsi
callq 0x32b0
movq (%rbx), %rdi
leaq -0x58(%rbp), %r14
cmpq %r14, %rdi
je 0x74c8
callq 0x3200
movq 0x17af9(%rip), %rdi     # 0x1efc8
leaq 0x10b8c(%rip), %rsi     # 0x18062
movl $0x5, %edx
callq 0x3280
movq 0x17ae1(%rip), %rdi     # 0x1efc8
leaq 0x10b9c(%rip), %rsi     # 0x1808a
movl $0xd, %edx
callq 0x3280
movq 0x17ac9(%rip), %rdi     # 0x1efc8
leaq 0x10b68(%rip), %rsi     # 0x1806e
movl $0x4, %edx
callq 0x3280
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq 0x17aa9(%rip), %r12     # 0x1efc8
movq %r12, %rdi
callq 0x3280
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
leaq 0x10cf8(%rip), %rsi     # 0x18250
leaq -0x48(%rbp), %rdi
callq 0x30b0
testl %eax, %eax
je 0x7a1c
leaq -0x48(%rbp), %rbx
movq %r15, -0x98(%rbp)
movl $0x1, %edx
movq %rbx, %rdi
xorl %esi, %esi
leaq 0x10b56(%rip), %rcx     # 0x180db
callq 0x32d0
testl %eax, %eax
je 0x7674
movl $0x1, %edx
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
leaq 0x10f63(%rip), %rcx     # 0x18507
callq 0x32d0
testl %eax, %eax
je 0x791f
movl $0x4b, %edx
movq %r12, %rdi
leaq 0x10bdc(%rip), %rsi     # 0x1819c
callq 0x3280
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
movl $0x11, %edx
movq %r12, %rdi
leaq 0x10bec(%rip), %rsi     # 0x181e8
callq 0x3280
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %r12, %rdi
callq 0x3280
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
leaq -0x68(%rbp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
leaq -0x90(%rbp), %rdx
callq 0x40d1
leaq -0x48(%rbp), %rdi
movq %rbx, %rsi
callq 0x32b0
movq -0x68(%rbp), %rdi
cmpq %r14, %rdi
je 0x7a01
callq 0x3200
jmp 0x7a01
movl $0x4, %ecx
leaq -0x48(%rbp), %rbx
movq %rbx, %rdi
leaq 0x10bdb(%rip), %rsi     # 0x18262
xorl %edx, %edx
callq 0x33e0
leaq -0xe(%rax), %rcx
movl $0xe, %edx
leaq -0x68(%rbp), %rdi
movq %rbx, %rsi
callq 0x3240
movq -0x68(%rbp), %r13
callq 0x3040
movq %rax, %r15
movl (%rax), %r12d
movl $0x0, (%rax)
movq %r13, %rdi
leaq -0x70(%rbp), %rsi
movl $0xa, %edx
callq 0x32e0
cmpq %r13, -0x70(%rbp)
je 0x7b20
leaq -0x80000000(%rax), %rdx
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
cmpq %rcx, %rdx
jb 0x7b14
movl (%r15), %ecx
cmpl $0x22, %ecx
je 0x7b14
movq %rax, -0xa0(%rbp)
testl %ecx, %ecx
jne 0x7707
movl %r12d, (%r15)
movq -0x68(%rbp), %rdi
cmpq %r14, %rdi
je 0x7715
callq 0x3200
movl $0x4, %ecx
leaq -0x48(%rbp), %r14
movq %r14, %rdi
leaq 0x10b3f(%rip), %rbx     # 0x18267
movq %rbx, %rsi
xorl %edx, %edx
callq 0x33e0
leaq 0x5(%rax), %r13
movl $0x6, %ecx
movq %r14, %rdi
leaq 0x10b04(%rip), %rsi     # 0x18249
xorl %edx, %edx
callq 0x33e0
movq %rax, %r12
movl $0x4, %ecx
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x33e0
subq %rax, %r12
addq $-0x5, %r12
leaq -0x68(%rbp), %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0x3240
movq -0x68(%rbp), %r12
movl (%r15), %r14d
movl $0x0, (%r15)
movq %r12, %rdi
leaq -0x70(%rbp), %rsi
movl $0xa, %edx
callq 0x32e0
cmpq %r12, -0x70(%rbp)
je 0x7b08
movq %rax, %r13
addq $-0x80000000, %rax      # imm = 0x80000000
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
cmpq %rcx, %rax
movq 0x17808(%rip), %r12     # 0x1efc8
jb 0x7b2c
movl (%r15), %eax
cmpl $0x22, %eax
je 0x7b2c
testl %eax, %eax
jne 0x77d9
movl %r14d, (%r15)
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %r14
cmpq %r14, %rdi
je 0x77eb
callq 0x3200
movl $0x12, %edx
movq %r12, %rdi
leaq 0x10a72(%rip), %rsi     # 0x1826c
callq 0x3280
movq -0x98(%rbp), %r15
movq %r12, %rdi
movq -0xa0(%rbp), %rsi
callq 0x33c0
movq %rax, %rbx
movl $0xd, %edx
movq %rax, %rdi
leaq 0x10a58(%rip), %rsi     # 0x1827f
callq 0x3280
movq %rbx, %rdi
movl %r13d, %esi
callq 0x33c0
movq %rax, %rbx
movl $0x9, %edx
movq %rax, %rdi
leaq 0x10a44(%rip), %rsi     # 0x1828d
callq 0x3280
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
movq %r15, %rdi
leaq -0x90(%rbp), %rsi
movl %r13d, %edx
callq 0x6b7c
leaq -0x68(%rbp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
leaq -0x90(%rbp), %rdx
callq 0x40d1
leaq -0x48(%rbp), %rdi
movq %rbx, %rsi
callq 0x32b0
movq -0x68(%rbp), %rdi
cmpq %r14, %rdi
je 0x78b7
callq 0x3200
movl $0x5, %edx
movq %r12, %rdi
leaq 0x1079c(%rip), %rsi     # 0x18062
callq 0x3280
movl $0xd, %edx
movq %r12, %rdi
leaq 0x107b0(%rip), %rsi     # 0x1808a
callq 0x3280
movl $0x4, %edx
movq %r12, %rdi
leaq 0x10780(%rip), %rsi     # 0x1806e
callq 0x3280
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %r12, %rdi
callq 0x3280
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3210
jmp 0x79ee
movl $0x28, %edx
movq %r12, %rdi
leaq 0x10969(%rip), %rsi     # 0x18297
callq 0x3280
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
leaq -0x68(%rbp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
leaq -0x90(%rbp), %rdx
callq 0x40d1
leaq -0x48(%rbp), %rdi
movq %rbx, %rsi
callq 0x32b0
movq -0x68(%rbp), %rdi
cmpq %r14, %rdi
je 0x798b
callq 0x3200
movl $0x5, %edx
movq %r12, %rdi
leaq 0x106c8(%rip), %rsi     # 0x18062
callq 0x3280
movl $0xd, %edx
movq %r12, %rdi
leaq 0x106dc(%rip), %rsi     # 0x1808a
callq 0x3280
movl $0x4, %edx
movq %r12, %rdi
leaq 0x106ac(%rip), %rsi     # 0x1806e
callq 0x3280
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %r12, %rdi
callq 0x3280
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
leaq -0x48(%rbp), %rbx
movq %rbx, %rdi
leaq 0x10841(%rip), %rsi     # 0x18250
callq 0x30b0
testl %eax, %eax
jne 0x7574
leaq -0x68(%rbp), %rdi
leaq -0x90(%rbp), %rdx
movq %r15, %rsi
callq 0x40d1
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rbx
movq %rbx, %rsi
callq 0x32b0
movq (%rbx), %rdi
cmpq %r14, %rdi
je 0x7a4c
callq 0x3200
movq 0x17575(%rip), %rdi     # 0x1efc8
leaq 0x10608(%rip), %rsi     # 0x18062
movl $0x5, %edx
callq 0x3280
movq 0x1755d(%rip), %rdi     # 0x1efc8
leaq 0x10618(%rip), %rsi     # 0x1808a
movl $0xd, %edx
callq 0x3280
movq 0x17545(%rip), %rdi     # 0x1efc8
leaq 0x105e4(%rip), %rsi     # 0x1806e
movl $0x4, %edx
callq 0x3280
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq 0x17525(%rip), %rdi     # 0x1efc8
callq 0x3280
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x7ae7
callq 0x3200
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x7af9
callq 0x3200
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10861(%rip), %rdi     # 0x18370
callq 0x3150
leaq 0x10855(%rip), %rdi     # 0x18370
callq 0x3320
leaq 0x10849(%rip), %rdi     # 0x18370
callq 0x3150
leaq 0x1083d(%rip), %rdi     # 0x18370
callq 0x3320
jmp 0x7b84
jmp 0x7b84
movq %rax, %rbx
jmp 0x7b9c
jmp 0x7b84
jmp 0x7b84
jmp 0x7b84
jmp 0x7b84
jmp 0x7b84
jmp 0x7b84
movq %rax, %rbx
cmpl $0x0, (%r15)
jne 0x7b59
movl %r12d, (%r15)
movq -0x68(%rbp), %rdi
cmpq %r14, %rdi
jne 0x7b7d
jmp 0x7b87
movq %rax, %rbx
cmpl $0x0, (%r15)
jne 0x7b70
movl %r14d, (%r15)
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x7b87
callq 0x3200
jmp 0x7b87
movq %rax, %rbx
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x7b9c
callq 0x3200
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x7bae
callq 0x3200
movq %rbx, %rdi
callq 0x33f0