// File: /workspace/github_cpp_makefile_star2_O2/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)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0xd2e1(%rip), %rsi      # 0x12715
leaq -0x70(%rbp), %rdi
leaq -0x98(%rbp), %rdx
callq 0x30e0
leaq -0x98(%rbp), %rdi
leaq -0x70(%rbp), %rdx
movq %r15, %rsi
callq 0x3b80
leaq -0x48(%rbp), %rdi
leaq -0x98(%rbp), %r14
movq %r14, %rsi
callq 0x3280
movq %r14, %rdi
callq 0x3120
movq 0x13b47(%rip), %rdi     # 0x18fc0
leaq 0xcbc6(%rip), %rsi      # 0x12046
callq 0x3200
leaq 0xcbe2(%rip), %rsi      # 0x1206e
movq %rax, %rdi
callq 0x3200
leaq 0xcbb7(%rip), %rsi      # 0x12052
movq %rax, %rdi
callq 0x3200
leaq -0x48(%rbp), %rsi
movq %rax, %rdi
callq 0x31e0
movq %rax, %rdi
callq 0x3140
leaq -0x98(%rbp), %r12
pushq $0xa
popq %r13
leaq -0x48(%rbp), %r14
movq %r14, %rdi
leaq 0xcd64(%rip), %rsi      # 0x12234
callq 0x64ed
testb %al, %al
je 0x572b
movq %r14, %rdi
xorl %esi, %esi
pushq $0x1
popq %rdx
leaq 0xcbd3(%rip), %rcx      # 0x120bf
callq 0x32b0
testl %eax, %eax
je 0x5580
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
pushq $0x1
popq %rdx
leaq 0xcfae(%rip), %rcx      # 0x124b7
callq 0x32b0
testl %eax, %eax
je 0x56a3
movq 0x13aa3(%rip), %rdi     # 0x18fc0
leaq 0xcc5c(%rip), %rsi      # 0x12180
callq 0x3200
movq %rax, %rdi
callq 0x3140
movq 0x13a88(%rip), %rdi     # 0x18fc0
leaq 0xcc8d(%rip), %rsi      # 0x121cc
callq 0x3200
movq %rax, %rdi
leaq -0x48(%rbp), %rsi
callq 0x31e0
movq %rax, %rdi
callq 0x3140
movq %r12, %rdi
movq %r15, %rsi
leaq -0x70(%rbp), %rdx
callq 0x3b80
leaq -0x48(%rbp), %rdi
movq %r12, %rsi
callq 0x3280
movq %r12, %rdi
callq 0x3120
jmp 0x54c2
movq %r14, %rdi
leaq 0xccbc(%rip), %rsi      # 0x12246
xorl %edx, %edx
callq 0x3430
leaq -0xe(%rax), %rcx
movq %r12, %rdi
movq %r14, %rsi
pushq $0xe
popq %rdx
callq 0x3220
movq %r12, %rdi
xorl %esi, %esi
movl %r13d, %r14d
movl %r13d, %edx
callq 0x64cc
movl %eax, -0x4c(%rbp)
movq %r12, %rdi
callq 0x3120
leaq -0x48(%rbp), %r13
movq %r13, %rdi
leaq 0xcc7f(%rip), %rsi      # 0x1224b
xorl %edx, %edx
callq 0x3430
addq $0x5, %rax
movq %rax, -0x78(%rbp)
movq %r13, %rdi
leaq 0xcc48(%rip), %rsi      # 0x1222d
xorl %edx, %edx
callq 0x3430
movq %rax, %rbx
movq %r13, %rdi
leaq 0xcc52(%rip), %rsi      # 0x1224b
xorl %edx, %edx
callq 0x3430
subq %rax, %rbx
addq $-0x5, %rbx
movq %r12, %rdi
movq %r13, %rsi
movq -0x78(%rbp), %rdx
movq %rbx, %rcx
callq 0x3220
movq %r12, %rdi
xorl %esi, %esi
movl %r14d, %r13d
movl %r14d, %edx
callq 0x64cc
movl %eax, %r14d
movq %r12, %rdi
callq 0x3120
movq 0x13985(%rip), %rdi     # 0x18fc0
leaq 0xcc0e(%rip), %rsi      # 0x12250
callq 0x3200
movq %rax, %rdi
movl -0x4c(%rbp), %esi
callq 0x3390
movq %rax, %rdi
leaq 0xcc07(%rip), %rsi      # 0x12263
callq 0x3200
movq %rax, %rdi
movl %r14d, %esi
callq 0x3390
movq %rax, %rdi
leaq 0xcbfb(%rip), %rsi      # 0x12271
callq 0x3200
movq %rax, %rdi
callq 0x3140
movq %r15, %rdi
leaq -0x70(%rbp), %rsi
movl %r14d, %edx
callq 0x50af
movq %r12, %rdi
movq %r15, %rsi
leaq -0x70(%rbp), %rdx
callq 0x3b80
jmp 0x56cd
movq 0x13916(%rip), %rdi     # 0x18fc0
leaq 0xcbca(%rip), %rsi      # 0x1227b
callq 0x3200
movq %rax, %rdi
callq 0x3140
movq %r12, %rdi
movq %r15, %rsi
leaq -0x70(%rbp), %rdx
callq 0x3b80
leaq -0x48(%rbp), %rdi
movq %r12, %rsi
callq 0x3280
movq %r12, %rdi
callq 0x3120
movq 0x138d8(%rip), %rdi     # 0x18fc0
leaq 0xc957(%rip), %rsi      # 0x12046
callq 0x3200
movq %rax, %rdi
leaq 0xc970(%rip), %rsi      # 0x1206e
callq 0x3200
movq %rax, %rdi
leaq 0xc945(%rip), %rsi      # 0x12052
callq 0x3200
movq %rax, %rdi
leaq -0x48(%rbp), %rsi
callq 0x31e0
movq %rax, %rdi
callq 0x3140
jmp 0x54c2
leaq -0x98(%rbp), %rdi
leaq -0x70(%rbp), %rdx
movq %r15, %rsi
callq 0x3b80
leaq -0x48(%rbp), %rdi
leaq -0x98(%rbp), %rbx
movq %rbx, %rsi
callq 0x3280
movq %rbx, %rdi
callq 0x3120
movq 0x13860(%rip), %rdi     # 0x18fc0
leaq 0xc8df(%rip), %rsi      # 0x12046
callq 0x3200
leaq 0xc8fb(%rip), %rsi      # 0x1206e
movq %rax, %rdi
callq 0x3200
leaq 0xc8d0(%rip), %rsi      # 0x12052
movq %rax, %rdi
callq 0x3200
leaq -0x48(%rbp), %rsi
movq %rax, %rdi
callq 0x31e0
movq %rax, %rdi
callq 0x3140
leaq -0x70(%rbp), %rdi
callq 0x3120
leaq -0x48(%rbp), %rdi
callq 0x3120
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x57e7
jmp 0x57e7
movq %rax, %rbx
jmp 0x57f3
jmp 0x57e7
jmp 0x57e7
jmp 0x57ce
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x3120
jmp 0x57ea
jmp 0x57e7
jmp 0x57e7
jmp 0x57e7
jmp 0x57e7
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x3120
leaq -0x48(%rbp), %rdi
callq 0x3120
movq %rbx, %rdi
callq 0x33c0