// File: /workspace/github_cpp_makefile_star2_O1/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 0x111d8(%rip), %rdx     # 0x18795
leaq -0x90(%rbp), %rdi
movq %rdx, %rsi
callq 0x9e42
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 0x7600
callq 0x3200
movq 0x179c1(%rip), %rdi     # 0x1efc8
leaq 0x10a54(%rip), %rsi     # 0x18062
movl $0x5, %edx
callq 0x3280
movq 0x179a9(%rip), %rdi     # 0x1efc8
leaq 0x10a64(%rip), %rsi     # 0x1808a
movl $0xd, %edx
callq 0x3280
movq 0x17991(%rip), %rdi     # 0x1efc8
leaq 0x10a30(%rip), %rsi     # 0x1806e
movl $0x4, %edx
callq 0x3280
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq 0x17971(%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 0x10bc0(%rip), %rsi     # 0x18250
leaq -0x48(%rbp), %rdi
callq 0x30b0
testl %eax, %eax
je 0x7b54
leaq -0x48(%rbp), %rbx
movq %r15, -0x98(%rbp)
movl $0x1, %edx
movq %rbx, %rdi
xorl %esi, %esi
leaq 0x10a1e(%rip), %rcx     # 0x180db
callq 0x32d0
testl %eax, %eax
je 0x77ac
movl $0x1, %edx
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
leaq 0x10e2b(%rip), %rcx     # 0x18507
callq 0x32d0
testl %eax, %eax
je 0x7a57
movl $0x4b, %edx
movq %r12, %rdi
leaq 0x10aa4(%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 0x10ab4(%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 0x7b39
callq 0x3200
jmp 0x7b39
movl $0x4, %ecx
leaq -0x48(%rbp), %rbx
movq %rbx, %rdi
leaq 0x10aa3(%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 0x7c58
leaq -0x80000000(%rax), %rdx
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
cmpq %rcx, %rdx
jb 0x7c4c
movl (%r15), %ecx
cmpl $0x22, %ecx
je 0x7c4c
movq %rax, -0xa0(%rbp)
testl %ecx, %ecx
jne 0x783f
movl %r12d, (%r15)
movq -0x68(%rbp), %rdi
cmpq %r14, %rdi
je 0x784d
callq 0x3200
movl $0x4, %ecx
leaq -0x48(%rbp), %r14
movq %r14, %rdi
leaq 0x10a07(%rip), %rbx     # 0x18267
movq %rbx, %rsi
xorl %edx, %edx
callq 0x33e0
leaq 0x5(%rax), %r13
movl $0x6, %ecx
movq %r14, %rdi
leaq 0x109cc(%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 0x7c40
movq %rax, %r13
addq $-0x80000000, %rax      # imm = 0x80000000
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
cmpq %rcx, %rax
movq 0x176d0(%rip), %r12     # 0x1efc8
jb 0x7c64
movl (%r15), %eax
cmpl $0x22, %eax
je 0x7c64
testl %eax, %eax
jne 0x7911
movl %r14d, (%r15)
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %r14
cmpq %r14, %rdi
je 0x7923
callq 0x3200
movl $0x12, %edx
movq %r12, %rdi
leaq 0x1093a(%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 0x10920(%rip), %rsi     # 0x1827f
callq 0x3280
movq %rbx, %rdi
movl %r13d, %esi
callq 0x33c0
movq %rax, %rbx
movl $0x9, %edx
movq %rax, %rdi
leaq 0x1090c(%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 0x6cb2
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 0x79ef
callq 0x3200
movl $0x5, %edx
movq %r12, %rdi
leaq 0x10664(%rip), %rsi     # 0x18062
callq 0x3280
movl $0xd, %edx
movq %r12, %rdi
leaq 0x10678(%rip), %rsi     # 0x1808a
callq 0x3280
movl $0x4, %edx
movq %r12, %rdi
leaq 0x10648(%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 0x7b26
movl $0x28, %edx
movq %r12, %rdi
leaq 0x10831(%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 0x7ac3
callq 0x3200
movl $0x5, %edx
movq %r12, %rdi
leaq 0x10590(%rip), %rsi     # 0x18062
callq 0x3280
movl $0xd, %edx
movq %r12, %rdi
leaq 0x105a4(%rip), %rsi     # 0x1808a
callq 0x3280
movl $0x4, %edx
movq %r12, %rdi
leaq 0x10574(%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 0x10709(%rip), %rsi     # 0x18250
callq 0x30b0
testl %eax, %eax
jne 0x76ac
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 0x7b84
callq 0x3200
movq 0x1743d(%rip), %rdi     # 0x1efc8
leaq 0x104d0(%rip), %rsi     # 0x18062
movl $0x5, %edx
callq 0x3280
movq 0x17425(%rip), %rdi     # 0x1efc8
leaq 0x104e0(%rip), %rsi     # 0x1808a
movl $0xd, %edx
callq 0x3280
movq 0x1740d(%rip), %rdi     # 0x1efc8
leaq 0x104ac(%rip), %rsi     # 0x1806e
movl $0x4, %edx
callq 0x3280
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq 0x173ed(%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 0x7c1f
callq 0x3200
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x7c31
callq 0x3200
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10729(%rip), %rdi     # 0x18370
callq 0x3150
leaq 0x1071d(%rip), %rdi     # 0x18370
callq 0x3320
leaq 0x10711(%rip), %rdi     # 0x18370
callq 0x3150
leaq 0x10705(%rip), %rdi     # 0x18370
callq 0x3320
jmp 0x7cbc
jmp 0x7cbc
movq %rax, %rbx
jmp 0x7cd4
jmp 0x7cbc
jmp 0x7cbc
jmp 0x7cbc
jmp 0x7cbc
jmp 0x7cbc
jmp 0x7cbc
movq %rax, %rbx
cmpl $0x0, (%r15)
jne 0x7c91
movl %r12d, (%r15)
movq -0x68(%rbp), %rdi
cmpq %r14, %rdi
jne 0x7cb5
jmp 0x7cbf
movq %rax, %rbx
cmpl $0x0, (%r15)
jne 0x7ca8
movl %r14d, (%r15)
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x7cbf
callq 0x3200
jmp 0x7cbf
movq %rax, %rbx
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x7cd4
callq 0x3200
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x7ce6
callq 0x3200
movq %rbx, %rdi
callq 0x33f0