// File: 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
subq $0x290, %rsp            # imm = 0x290
movq %rdi, -0x8(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x33c0
leaq -0x51(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x3500
movq -0x150(%rbp), %rdx
leaq 0x22bbb(%rip), %rsi     # 0x29691
leaq -0x50(%rbp), %rdi
callq 0x33b0
jmp 0x6ae1
leaq -0x51(%rbp), %rdi
callq 0x32f0
movq -0x8(%rbp), %rsi
leaq -0x88(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x4070
jmp 0x6b00
leaq -0x30(%rbp), %rdi
leaq -0x88(%rbp), %rsi
movq %rsi, -0x160(%rbp)
callq 0x3360
movq -0x160(%rbp), %rdi
callq 0x3210
movq 0x3048e(%rip), %rdi     # 0x36fb8
leaq 0x22515(%rip), %rsi     # 0x29046
callq 0x32b0
movq %rax, -0x158(%rbp)
jmp 0x6b3f
movq -0x158(%rbp), %rdi
leaq 0x22521(%rip), %rsi     # 0x2906e
callq 0x32b0
movq %rax, -0x168(%rbp)
jmp 0x6b5b
movq -0x168(%rbp), %rdi
leaq 0x224e9(%rip), %rsi     # 0x29052
callq 0x32b0
movq %rax, -0x170(%rbp)
jmp 0x6b77
movq -0x170(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3290
movq %rax, -0x178(%rbp)
jmp 0x6b90
movq -0x178(%rbp), %rdi
movq 0x3040a(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x6ba5
jmp 0x6ba7
leaq 0x22686(%rip), %rsi     # 0x29234
leaq -0x30(%rbp), %rdi
callq 0x8ce0
movb %al, -0x179(%rbp)
jmp 0x6bbf
movb -0x179(%rbp), %al
testb $0x1, %al
jne 0x6bce
jmp 0x70dc
leaq 0x224ea(%rip), %rcx     # 0x290bf
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
movl $0x1, %edx
callq 0x3390
movl %eax, -0x180(%rbp)
jmp 0x6bef
movl -0x180(%rbp), %eax
cmpl $0x0, %eax
jne 0x6f07
leaq 0x22641(%rip), %rsi     # 0x29246
xorl %eax, %eax
movl %eax, %edx
leaq -0x30(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0x3540
movq -0x188(%rbp), %rsi
movq %rax, %rcx
addq $-0xe, %rcx
leaq -0xa8(%rbp), %rdi
movl $0xe, %edx
callq 0x32d0
jmp 0x6c3a
xorl %eax, %eax
movl %eax, %esi
leaq -0xa8(%rbp), %rdi
movl $0xa, %edx
callq 0x8ca0
movl %eax, -0x18c(%rbp)
jmp 0x6c57
movl -0x18c(%rbp), %eax
movl %eax, -0xc(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x3210
leaq 0x225d8(%rip), %rsi     # 0x2924b
movq %rsi, -0x1b8(%rbp)
xorl %eax, %eax
movl %eax, %edx
movq %rdx, -0x1b0(%rbp)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x3540
movq -0x1b0(%rbp), %rdx
movq -0x1a0(%rbp), %rdi
addq $0x5, %rax
movq %rax, -0x198(%rbp)
leaq 0x22578(%rip), %rsi     # 0x2922d
callq 0x3540
movq -0x1b8(%rbp), %rsi
movq -0x1b0(%rbp), %rdx
movq -0x1a0(%rbp), %rdi
movq %rax, -0x1a8(%rbp)
callq 0x3540
movq -0x1a8(%rbp), %rcx
movq -0x1a0(%rbp), %rsi
movq -0x198(%rbp), %rdx
subq %rax, %rcx
addq $-0x5, %rcx
leaq -0xc8(%rbp), %rdi
callq 0x32d0
jmp 0x6d05
xorl %eax, %eax
movl %eax, %esi
leaq -0xc8(%rbp), %rdi
movl $0xa, %edx
callq 0x8ca0
movl %eax, -0x1bc(%rbp)
jmp 0x6d22
movl -0x1bc(%rbp), %eax
movl %eax, -0x10(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x3210
movq 0x3027a(%rip), %rdi     # 0x36fb8
leaq 0x2250b(%rip), %rsi     # 0x29250
callq 0x32b0
movq %rax, -0x1c8(%rbp)
jmp 0x6d53
movq -0x1c8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x34c0
movq %rax, -0x1d0(%rbp)
jmp 0x6d6b
movq -0x1d0(%rbp), %rdi
leaq 0x224ea(%rip), %rsi     # 0x29263
callq 0x32b0
movq %rax, -0x1d8(%rbp)
jmp 0x6d87
movq -0x1d8(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x34c0
movq %rax, -0x1e0(%rbp)
jmp 0x6d9f
movq -0x1e0(%rbp), %rdi
leaq 0x224c4(%rip), %rsi     # 0x29271
callq 0x32b0
movq %rax, -0x1e8(%rbp)
jmp 0x6dbb
movq -0x1e8(%rbp), %rdi
movq 0x301df(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x6dd0
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %edx
leaq -0x50(%rbp), %rsi
callq 0x6400
jmp 0x6de2
movq -0x8(%rbp), %rsi
leaq -0xe8(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x4070
jmp 0x6df8
leaq -0x30(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
movq %rsi, -0x1f8(%rbp)
callq 0x3360
movq -0x1f8(%rbp), %rdi
callq 0x3210
movq 0x30196(%rip), %rdi     # 0x36fb8
leaq 0x2221d(%rip), %rsi     # 0x29046
callq 0x32b0
movq %rax, -0x1f0(%rbp)
jmp 0x6e37
movq -0x1f0(%rbp), %rdi
leaq 0x22229(%rip), %rsi     # 0x2906e
callq 0x32b0
movq %rax, -0x200(%rbp)
jmp 0x6e53
movq -0x200(%rbp), %rdi
leaq 0x221f1(%rip), %rsi     # 0x29052
callq 0x32b0
movq %rax, -0x208(%rbp)
jmp 0x6e6f
movq -0x208(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3290
movq %rax, -0x210(%rbp)
jmp 0x6e88
movq -0x210(%rbp), %rdi
movq 0x30112(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x6e9d
jmp 0x70d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x51(%rbp), %rdi
callq 0x32f0
jmp 0x71bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x71b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x3210
jmp 0x71b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x3210
jmp 0x71b2
leaq 0x225b9(%rip), %rcx     # 0x294c7
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
movl $0x1, %edx
callq 0x3390
movl %eax, -0x214(%rbp)
jmp 0x6f28
movl -0x214(%rbp), %eax
cmpl $0x0, %eax
jne 0x7028
movq 0x3007a(%rip), %rdi     # 0x36fb8
leaq 0x22336(%rip), %rsi     # 0x2927b
callq 0x32b0
movq %rax, -0x220(%rbp)
jmp 0x6f53
movq -0x220(%rbp), %rdi
movq 0x30047(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x6f68
movq -0x8(%rbp), %rsi
leaq -0x108(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x4070
jmp 0x6f7e
leaq -0x30(%rbp), %rdi
leaq -0x108(%rbp), %rsi
movq %rsi, -0x230(%rbp)
callq 0x3360
movq -0x230(%rbp), %rdi
callq 0x3210
movq 0x30010(%rip), %rdi     # 0x36fb8
leaq 0x22097(%rip), %rsi     # 0x29046
callq 0x32b0
movq %rax, -0x228(%rbp)
jmp 0x6fbd
movq -0x228(%rbp), %rdi
leaq 0x220a3(%rip), %rsi     # 0x2906e
callq 0x32b0
movq %rax, -0x238(%rbp)
jmp 0x6fd9
movq -0x238(%rbp), %rdi
leaq 0x2206b(%rip), %rsi     # 0x29052
callq 0x32b0
movq %rax, -0x240(%rbp)
jmp 0x6ff5
movq -0x240(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3290
movq %rax, -0x248(%rbp)
jmp 0x700e
movq -0x248(%rbp), %rdi
movq 0x2ff8c(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x7023
jmp 0x70d5
movq 0x2ff89(%rip), %rdi     # 0x36fb8
leaq 0x2214a(%rip), %rsi     # 0x29180
callq 0x32b0
movq %rax, -0x250(%rbp)
jmp 0x7044
movq -0x250(%rbp), %rdi
movq 0x2ff56(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x7059
movq 0x2ff58(%rip), %rdi     # 0x36fb8
leaq 0x22165(%rip), %rsi     # 0x291cc
callq 0x32b0
movq %rax, -0x258(%rbp)
jmp 0x7075
movq -0x258(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3290
movq %rax, -0x260(%rbp)
jmp 0x708e
movq -0x260(%rbp), %rdi
movq 0x2ff0c(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x70a3
movq -0x8(%rbp), %rsi
leaq -0x128(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x4070
jmp 0x70b9
leaq -0x30(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x3360
leaq -0x128(%rbp), %rdi
callq 0x3210
jmp 0x70d7
jmp 0x6ba7
movq -0x8(%rbp), %rsi
leaq -0x148(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x4070
jmp 0x70f2
leaq -0x30(%rbp), %rdi
leaq -0x148(%rbp), %rsi
movq %rsi, -0x270(%rbp)
callq 0x3360
movq -0x270(%rbp), %rdi
callq 0x3210
movq 0x2fe9c(%rip), %rdi     # 0x36fb8
leaq 0x21f23(%rip), %rsi     # 0x29046
callq 0x32b0
movq %rax, -0x268(%rbp)
jmp 0x7131
movq -0x268(%rbp), %rdi
leaq 0x21f2f(%rip), %rsi     # 0x2906e
callq 0x32b0
movq %rax, -0x278(%rbp)
jmp 0x714d
movq -0x278(%rbp), %rdi
leaq 0x21ef7(%rip), %rsi     # 0x29052
callq 0x32b0
movq %rax, -0x280(%rbp)
jmp 0x7169
movq -0x280(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3290
movq %rax, -0x288(%rbp)
jmp 0x7182
movq -0x288(%rbp), %rdi
movq 0x2fe18(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x7197
leaq -0x50(%rbp), %rdi
callq 0x3210
leaq -0x30(%rbp), %rdi
callq 0x3210
addq $0x290, %rsp            # imm = 0x290
popq %rbp
retq
leaq -0x50(%rbp), %rdi
callq 0x3210
leaq -0x30(%rbp), %rdi
callq 0x3210
movq -0x60(%rbp), %rdi
callq 0x34f0
nopl (%rax)