// File: /workspace/github_cpp_makefile_star2_O2/muzuka[P]Cards-Against-Humanity-Online/Client.cpp
// Function: main
int main(int argc, char* argv[]) {
	
	if (argc != 3) {
		printf("Usage: %s <server IP> <Server Port>\n", argv[0]);
		exit(EXIT_FAILURE);
	}
	
	printf("Welcome to Cards Against Humanity Online!\n");
	printf("Experience all of the hilarious and bad humour of the real thing.\n");
	printf("What do you want as a username(Must be unique and have no spaces):\n");
	cin >> name;
	self.setName(name);
	printf("Please wait until you have connected.\n");
	
	if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
		printf("socket() failed\n");
		exit(EXIT_FAILURE);
	}
	self.setSocket(sock);
	
	int yes = 1;
	if (setsockopt(self.getSocket(), SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) < 0) {
		printf("setsockopt() failed\n");
		exit(EXIT_FAILURE);
	}
	
	memset(&serverAddr, 0, sizeof(serverAddr));
	serverAddr.sin_family = AF_INET;
	serverAddr.sin_port = htons(atoi(argv[2]));
	serverAddr.sin_addr.s_addr = inet_addr(argv[1]);
	
	printf("Connecting to server.\n");
	if (connect(self.getSocket(), (struct sockaddr*) &serverAddr, sizeof(serverAddr)) < 0) {
		printf("connect() failed\n");
		exit(EXIT_FAILURE);
	}
	printf("Connected to Server successfully.\n");

	bytesSent = send(self.getSocket(), self.getName().c_str(), self.getName().length(), 0);
	if (bytesSent <= 0) {
		printf("Couldn't send name.\n");
		exit(EXIT_FAILURE);
	}
	
	// while sent name isn't available
	while(!isReady) {
		memset(&inBuffer, 0, sizeof(inBuffer));
		bytesRecv = 0;
		while(bytesRecv <= 0) {
			// receive confirmation
			bytesRecv = recv(self.getSocket(), (char*)&inBuffer, 1, 0);
		}
		printf("Received answer from Server: %s\n", (char*)inBuffer);
		if (inBuffer[0] == 'y') {
			break;
		}
		else if(inBuffer[0] == 'n'){
			printf("The name was already taken, please enter another:\n");
			cin >> name;
			self.setName(name);
			bytesSent = send(self.getSocket(), self.getName().c_str(), self.getName().length(), 0);
			if (bytesSent <= 0) {
				printf("Couldn't send name.\n");
				exit(EXIT_FAILURE);
			}
		}
		
	}
	printf("The name was accepted!\n");
	// Receive cards
	for(int i = 0; i < 10; i++) {
		memset(&inBuffer, 0, sizeof(inBuffer));
		bytesRecv = 0;
		while(bytesRecv <= 0) {
			bytesRecv = recv(self.getSocket(), (char*)&inBuffer, 100, 0);
		}
		parseMessage(string(inBuffer));
	}
	
	if(self.getHand().empty()) {
		printf("Hand is empty.\n");
	}
	else {
		printf("This is your current hand.\nPlease enter the number to choose one when prompted.\n");
		printHand(self.getHand());
	}
	// Start main loop
	while(running) {
		
		printf("A new round has begun!\n");
		
		// receive NOTIFY for new judge
		while (true) {
			memset(&inBuffer, 0, sizeof(inBuffer));
			bytesRecv = 0;
			while(bytesRecv <= 0) {
				bytesRecv = recv(self.getSocket(), (char*)&inBuffer, 100, 0);
			}
			if (string(inBuffer).length() != 0) {
				printf("The new judge is %s.\n", string(inBuffer).c_str());
				parseMessage(string(inBuffer));
				break;
			}
		}
		
		// receive POST for new black card
		while (true) {
			memset(&inBuffer, 0, sizeof(inBuffer));
			bytesRecv = 0;
			while(bytesRecv <= 0) {
				bytesRecv = recv(self.getSocket(), (char*)&inBuffer, 300, 0);
			}
			if (string(inBuffer).length() != 0) {
				printf("The black card is %s.\n", string(inBuffer).c_str());
				parseMessage(string(inBuffer));
				break;
			}
		}
		
		// Judge Code --------------------------------------
		if(isJudge) {
			printf("Please wait for the others' answers.\n");
			int playerNum = 0;
			// Get number of answers to expect.
			while (playerNum <= 0) {
				memset(&inBuffer, 0, sizeof(inBuffer));
				bytesRecv = 0;
				while (bytesRecv <= 0) {
					bytesRecv = recv(self.getSocket(), (char*)&inBuffer, 100, 0);
				}
				if (string(inBuffer).length() != 0) {
					printf("About to parse notify.\n%s\n", string(inBuffer).c_str());
					playerNum = parseMessage(string(inBuffer));
				}
				else {
					printf("Nothing received yet.\n");
				}
				
				
			}
			printf("PlayerNum is equal to %d.\n", playerNum);
			// receive answers
			for (int i = 0; i < playerNum; i++) {
				memset(&inBuffer, 0, sizeof(inBuffer));
				bytesRecv = 0;
				while (bytesRecv <= 0) {
					bytesRecv = recv(self.getSocket(), (char*)&inBuffer, 100, 0);
				}
				printf("new answer(before parsing):\n%s\n", (char*)inBuffer);
				parseMessage(string(inBuffer));
			}
			
			printf("Got all %d of the answers.\n", playerNum);
			
			printf("All of the answers are ready.\n");
			printAnswers(answers, blackCard.numOfAnswers);
			printf("Please select the best answer:\nCommands:\n");
			printf("a # to send answer.\nt # to test answer.\nh to see choices.\ns to see score.\nq to quit.\n");
			
			cin >> answer;
			if (answer == 'q') {
				note = composeNOTIFYMessage('q', self.getName());
				bytesSent = send(self.getSocket(), (char*)note.c_str(), 100, 0);
				if (bytesSent <= 0) {
					printf("Couldn't send quit.\n");
					exit(EXIT_FAILURE);
				}
				exit(EXIT_FAILURE);
			}
			else if (answer == 'h') {
				printAnswers(answers, blackCard.numOfAnswers);
			}
			else if (answer == 's') {
				printf("You have won %d rounds.\n", self.getScore());
			}
			else {
				cin >> num[0];
			}
			while (!ready) {
				switch (answer) {
					case 'a':
						if(num[0] > blackCard.numOfAnswers || num[0] < 1) {
							printf("Choice is out of range. Try again.");
							break;
						}
						chosen = composeNOTIFYMessage('w', answers[blackCard.numOfAnswers*(num[0] - 1)].owner);
						bytesSent = send(self.getSocket(), (char*)chosen.c_str(), 100, 0);
						if (bytesSent <= 0) {
							printf("Couldn't send NOTIFY.\n");
							exit(EXIT_FAILURE);
						}
						printf("Sent winner to server.\n");
						ready = !ready;
						break;
					case 't':
						int place;
						switch (blackCard.numOfAnswers) {
							case 1:
								ans[0] = answers[num[0]-1].content;
								testAnswer = substitute(blackCard.content, ans, '_');
								printf("%s\n", testAnswer.c_str());
								break;
							case 2:
								place = blackCard.numOfAnswers*(num[0]-1);
								ans[0] = answers[place].content;
								ans[1] = answers[place + 1].content;
								testAnswer = substitute(blackCard.content, ans, '_');
								printf("%s\n", testAnswer.c_str());
								break;
							case 3:
								place = blackCard.numOfAnswers*(num[0]-1);
								ans[0] = answers[place].content;
								ans[1] = answers[place + 1].content;
								ans[2] = answers[place + 2].content;
								testAnswer = substitute(blackCard.content, ans, '_');
								printf("%s\n", testAnswer.c_str());
								break;
							default:
								break;
						}
						break;
					default:
						break;
				}
				if (!ready) {
					printf("Please select the best answer:\nCommands:\n");
					printf("a # to send answer.\nt # to test answer.\nh to see hand\ns to see score\nq to quit.\n");
					
					cin >> answer;
					if (answer == 'q') {
						note = composeNOTIFYMessage('q', self.getName());
						bytesSent = send(self.getSocket(), (char*)note.c_str(), 100, 0);
						if (bytesSent <= 0) {
							printf("Couldn't send quit.\n");
							exit(EXIT_FAILURE);
						}
						exit(EXIT_FAILURE);
					}
					else if (answer == 'h') {
						printAnswers(answers, blackCard.numOfAnswers);
					}
					else if (answer == 's') {
						printf("You have won %d rounds.\n", self.getScore());
					}
					else {
						cin >> num[0];
					}
				}
			}
		}
		// Non-Judge Code---------------------------------------------------
		else {
			
			// Make a choice
			while (!inputValid) {
				getInput();
				processInput();
			}
			
			for (int i = 0; i < blackCard.numOfAnswers; i++) {
				bytesSent = send(self.getSocket(), (char*)composeREQUESTMessage().c_str(), 100, 0);
				if (bytesSent <= 0) {
					printf("Couldn't send request.\n");
					exit(EXIT_FAILURE);
				}
			}
			
			for (int i = 0; i < blackCard.numOfAnswers; i++) {
				bytesRecv = 0;
				memset(&inBuffer, 0, sizeof(inBuffer));
				while (bytesRecv <= 0) {
					bytesRecv = recv(self.getSocket(), (char*)&inBuffer, 100, 0);
				}
				if (string(inBuffer).length() != 0) {
					printf("Received new white card on request.\n");
					parseMessage(string(inBuffer));
				}
				else {
					i--;
				}
				
			}
			printf("Received all new cards as needed.\n");
			
			while (true) {
				memset(&inBuffer, 0, sizeof(inBuffer));
				bytesRecv = 0;
				while (bytesRecv <= 0) {
					bytesRecv = recv(self.getSocket(), (char*)&inBuffer, 100, 0);
				}
				if (string(inBuffer).length() != 0) {
					parseMessage(string(inBuffer));
					break;
				}
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movq %rsi, %rbx
cmpl $0x3, %edi
jne 0x3f27
leaq 0x3175(%rip), %rdi      # 0x62c8
callq 0x2230
leaq 0x3193(%rip), %rdi      # 0x62f2
callq 0x2230
leaq 0x31c9(%rip), %rdi      # 0x6334
callq 0x2230
movq 0x5e69(%rip), %rdi      # 0x8fe0
leaq 0x62e2(%rip), %r14      # 0x9460
movq %r14, %rsi
callq 0x21c0
leaq -0x100(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x21f0
leaq 0x6211(%rip), %rdi      # 0x93b0
movq %r15, %rsi
callq 0x2946
leaq -0x100(%rbp), %rdi
callq 0x22e8
leaq 0x31bd(%rip), %rdi      # 0x6377
callq 0x2230
pushq $0x2
popq %rdi
pushq $0x1
popq %rsi
pushq $0x6
popq %rdx
callq 0x2050
movl %eax, 0x5fd5(%rip)      # 0x91a8
testl %eax, %eax
js 0x3f3d
leaq 0x61ce(%rip), %r14      # 0x93b0
movq %r14, %rdi
movl %eax, %esi
callq 0x295a
leaq -0x9c(%rbp), %r15
movl $0x1, (%r15)
movq %r14, %rdi
callq 0x2950
pushq $0x1
popq %rsi
pushq $0x2
popq %rdx
pushq $0x4
popq %r8
movl %eax, %edi
movq %r15, %rcx
callq 0x2290
testl %eax, %eax
js 0x3f49
xorps %xmm0, %xmm0
movups %xmm0, 0x6130(%rip)     # 0x9358
leaq 0x6129(%rip), %r14      # 0x9358
movw $0x2, 0x6120(%rip)      # 0x9358
movq 0x10(%rbx), %rdi
callq 0x2240
rolw $0x8, %ax
movw %ax, 0x610e(%rip)       # 0x935a
movq 0x8(%rbx), %rdi
callq 0x2170
movl %eax, 0x6101(%rip)      # 0x935c
leaq 0x313b(%rip), %rdi      # 0x639d
callq 0x2230
leaq 0x6142(%rip), %rdi      # 0x93b0
callq 0x2950
pushq $0x10
popq %rdx
movl %eax, %edi
movq %r14, %rsi
callq 0x2140
testl %eax, %eax
js 0x3f55
leaq 0x3124(%rip), %rdi      # 0x63b3
callq 0x2230
leaq 0x6115(%rip), %r15      # 0x93b0
movq %r15, %rdi
callq 0x2950
movl %eax, %ebx
leaq -0x50(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x292e
movq (%r14), %r14
leaq -0x70(%rbp), %rdi
movq %r15, %rsi
callq 0x292e
movq -0x68(%rbp), %rdx
movl %ebx, %edi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x20c0
movl %eax, 0x5ed7(%rip)      # 0x91b0
leaq -0x70(%rbp), %rdi
callq 0x22e8
leaq -0x50(%rbp), %rdi
callq 0x22e8
cmpl $0x0, 0x5ebe(%rip)      # 0x91b0
jle 0x3426
leaq 0x5ec1(%rip), %rbx      # 0x91c0
leaq 0x60aa(%rip), %r14      # 0x93b0
pushq $0x1
popq %r15
leaq 0x2d32(%rip), %r12      # 0x6043
cmpb $0x0, 0x5e8b(%rip)      # 0x91a3
jne 0x3432
xorl %r13d, %r13d
movl $0xc8, %edx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x20f0
movl %r13d, 0x5e75(%rip)     # 0x91ac
testl %r13d, %r13d
jg 0x3358
movq %r14, %rdi
callq 0x2950
movl %eax, %edi
movq %rbx, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x2080
movq %rax, %r13
jmp 0x3330
movq %r12, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2040
movzbl 0x5e54(%rip), %eax      # 0x91c0
cmpl $0x6e, %eax
je 0x337b
cmpl $0x79, %eax
jne 0x3311
jmp 0x3432
leaq 0x3053(%rip), %rdi      # 0x63d5
callq 0x2230
movq 0x5c52(%rip), %rdi      # 0x8fe0
leaq 0x60cb(%rip), %r12      # 0x9460
movq %r12, %rsi
callq 0x21c0
leaq -0x260(%rbp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x21f0
movq %r14, %rdi
movq %r13, %rsi
callq 0x2946
movq %r13, %rdi
callq 0x22e8
movq %r14, %rdi
callq 0x2950
movl %eax, %r13d
leaq -0x50(%rbp), %rdi
movq %r14, %rsi
callq 0x292e
movq -0x50(%rbp), %r12
leaq -0x70(%rbp), %rdi
movq %r14, %rsi
callq 0x292e
movq -0x68(%rbp), %rdx
movl %r13d, %edi
movq %r12, %rsi
xorl %ecx, %ecx
callq 0x20c0
movl %eax, 0x5db0(%rip)      # 0x91b0
leaq -0x70(%rbp), %rdi
callq 0x22e8
leaq -0x50(%rbp), %rdi
callq 0x22e8
cmpl $0x0, 0x5d97(%rip)      # 0x91b0
leaq 0x2c23(%rip), %r12      # 0x6043
jg 0x3311
leaq 0x3218(%rip), %rdi      # 0x6645
jmp 0x3e40
leaq 0x2fce(%rip), %rdi      # 0x6407
callq 0x2230
xorl %eax, %eax
leaq 0x5d79(%rip), %rbx      # 0x91c0
leaq 0x5f62(%rip), %r14      # 0x93b0
pushq $0x64
popq %r15
leaq -0x240(%rbp), %r12
cmpl $0xa, %eax
je 0x34c1
movl %eax, -0x2c(%rbp)
xorl %r13d, %r13d
movl $0xc8, %edx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x20f0
movl %r13d, 0x5d32(%rip)     # 0x91ac
testl %r13d, %r13d
jg 0x349b
movq %r14, %rdi
callq 0x2950
movl %eax, %edi
movq %rbx, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x2080
movq %rax, %r13
jmp 0x3473
movq %r12, %rdi
movq %rbx, %rsi
leaq -0x50(%rbp), %rdx
callq 0x52fa
movq %r12, %rdi
callq 0x4088
movq %r12, %rdi
callq 0x22e8
movl -0x2c(%rbp), %eax
incl %eax
jmp 0x3459
leaq 0x5ee8(%rip), %rsi      # 0x93b0
leaq -0x50(%rbp), %rbx
movq %rbx, %rdi
callq 0x2c0a
movq (%rbx), %r14
movq 0x8(%rbx), %r15
movq %rbx, %rdi
callq 0x2c42
cmpq %r15, %r14
je 0x351c
leaq 0x2f2f(%rip), %rdi      # 0x641e
callq 0x2230
leaq 0x5eb5(%rip), %rsi      # 0x93b0
leaq -0x2c0(%rbp), %rbx
movq %rbx, %rdi
callq 0x2c0a
movq %rbx, %rdi
callq 0x4371
movq %rbx, %rdi
callq 0x2c42
jmp 0x3528
leaq 0x2f4b(%rip), %rdi      # 0x646e
callq 0x2230
leaq 0x5c91(%rip), %r14      # 0x91c0
leaq 0x5e7a(%rip), %r15      # 0x93b0
pushq $0x64
popq %r12
leaq -0x50(%rbp), %r13
cmpb $0x1, 0x5c43(%rip)      # 0x9188
jne 0x3e25
leaq 0x2f2b(%rip), %rdi      # 0x647d
callq 0x2230
xorl %ebx, %ebx
movl $0xc8, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x20f0
movl %ebx, 0x5c3e(%rip)      # 0x91ac
testl %ebx, %ebx
jg 0x358e
movq %r15, %rdi
callq 0x2950
movl %eax, %edi
movq %r14, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x2080
movq %rax, %rbx
jmp 0x3568
movq %r13, %rdi
movq %r14, %rsi
leaq -0x70(%rbp), %rdx
callq 0x52fa
movq -0x48(%rbp), %rbx
movq %r13, %rdi
callq 0x22e8
testq %rbx, %rbx
je 0x3557
movq %r13, %rdi
movq %r14, %rsi
leaq -0x70(%rbp), %rdx
callq 0x52fa
movq -0x50(%rbp), %rsi
leaq 0x2a9c(%rip), %rdi      # 0x6064
xorl %eax, %eax
callq 0x2040
movq %r13, %rdi
callq 0x22e8
leaq -0x220(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x52fa
movq %rbx, %rdi
callq 0x4088
movq %rbx, %rdi
callq 0x22e8
xorl %ebx, %ebx
movl $0xc8, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x20f0
movl %ebx, 0x5b99(%rip)      # 0x91ac
testl %ebx, %ebx
jg 0x3635
movq %r15, %rdi
callq 0x2950
movl $0x12c, %edx            # imm = 0x12C
movl %eax, %edi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x2080
movq %rax, %rbx
jmp 0x360d
movq %r13, %rdi
movq %r14, %rsi
leaq -0x70(%rbp), %rdx
callq 0x52fa
movq -0x48(%rbp), %rbx
movq %r13, %rdi
callq 0x22e8
testq %rbx, %rbx
je 0x35fc
movq %r13, %rdi
movq %r14, %rsi
leaq -0x70(%rbp), %rdx
callq 0x52fa
movq -0x50(%rbp), %rsi
leaq 0x2a0b(%rip), %rdi      # 0x607a
xorl %eax, %eax
callq 0x2040
movq %r13, %rdi
callq 0x22e8
leaq -0x200(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x52fa
movq %rbx, %rdi
callq 0x4088
movq %rbx, %rdi
callq 0x22e8
cmpb $0x0, 0x5afa(%rip)      # 0x91a4
je 0x378f
leaq 0x2e3a(%rip), %rdi      # 0x64f1
callq 0x2230
movl $0x0, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jg 0x37fa
xorl %r13d, %r13d
movl $0xc8, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x20f0
movl %r13d, 0x5ac6(%rip)     # 0x91ac
testl %r13d, %r13d
jg 0x3707
movq %r15, %rdi
callq 0x2950
movl %eax, %edi
movq %r14, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x2080
movq %rax, %r13
jmp 0x36df
leaq -0x50(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
leaq -0x70(%rbp), %rdx
callq 0x52fa
movq -0x48(%rbp), %rbx
movq %r13, %rdi
callq 0x22e8
testq %rbx, %rbx
jne 0x3739
leaq 0x2efd(%rip), %rdi      # 0x662f
callq 0x2230
jmp 0x36c3
movq %r13, %rdi
movq %r14, %rsi
leaq -0x70(%rbp), %rdx
callq 0x52fa
movq -0x50(%rbp), %rsi
leaq 0x293e(%rip), %rdi      # 0x6091
xorl %eax, %eax
callq 0x2040
movq %r13, %rdi
callq 0x22e8
leaq -0x1e0(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x52fa
movq %rbx, %rdi
callq 0x4088
movl %eax, -0x2c(%rbp)
movq %rbx, %rdi
callq 0x22e8
jmp 0x36c3
cmpb $0x1, 0x5a0b(%rip)      # 0x91a1
je 0x37a4
callq 0x4724
callq 0x4aa6
jmp 0x378f
pushq $-0x1
popq %r13
movl 0x5bde(%rip), %eax      # 0x938c
incl %r13d
cmpl %eax, %r13d
jge 0x3897
movq %r15, %rdi
callq 0x2950
movl %eax, %ebx
leaq -0x50(%rbp), %rdi
callq 0x4e76
movq -0x50(%rbp), %rsi
movl %ebx, %edi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x20c0
movl %eax, 0x59cd(%rip)      # 0x91b0
leaq -0x50(%rbp), %rdi
callq 0x22e8
cmpl $0x0, 0x59bd(%rip)      # 0x91b0
jg 0x37a8
jmp 0x3e39
xorl %ebx, %ebx
leaq 0x28a9(%rip), %rdi      # 0x60ac
movl -0x2c(%rbp), %esi
xorl %eax, %eax
callq 0x2040
cmpl -0x2c(%rbp), %ebx
je 0x394c
xorl %r13d, %r13d
movl $0xc8, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x20f0
movl %r13d, 0x597d(%rip)     # 0x91ac
testl %r13d, %r13d
jg 0x3850
movq %r15, %rdi
callq 0x2950
movl %eax, %edi
movq %r14, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x2080
movq %rax, %r13
jmp 0x3828
movl %ebx, -0x74(%rbp)
leaq 0x286d(%rip), %rdi      # 0x60c7
movq %r14, %rsi
xorl %eax, %eax
callq 0x2040
leaq -0x1c0(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
leaq -0x50(%rbp), %r13
movq %r13, %rdx
callq 0x52fa
movq %rbx, %rdi
callq 0x4088
movq %rbx, %rdi
callq 0x22e8
movl -0x74(%rbp), %ebx
incl %ebx
jmp 0x380d
xorl %ecx, %ecx
cmpl %eax, %ecx
jge 0x39ee
movl %ecx, -0x2c(%rbp)
andl $0x0, 0x5901(%rip)      # 0x91ac
xorl %ebx, %ebx
movl $0xc8, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x20f0
testl %ebx, %ebx
jg 0x38e2
movq %r15, %rdi
callq 0x2950
movl %eax, %edi
movq %r14, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x2080
movq %rax, %rbx
movl %ebx, 0x58cc(%rip)      # 0x91ac
jmp 0x38bc
leaq -0x50(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
leaq -0x70(%rbp), %rdx
callq 0x52fa
movq -0x48(%rbp), %rbx
movq %r13, %rdi
callq 0x22e8
testq %rbx, %rbx
je 0x393e
leaq 0x2ba9(%rip), %rdi      # 0x64b6
callq 0x2230
leaq -0x140(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x52fa
movq %rbx, %rdi
callq 0x4088
movq %rbx, %rdi
callq 0x22e8
movl -0x2c(%rbp), %ecx
incl %ecx
jmp 0x3941
movl -0x2c(%rbp), %ecx
movl 0x5a45(%rip), %eax      # 0x938c
jmp 0x3899
leaq 0x2794(%rip), %rdi      # 0x60e7
movl -0x2c(%rbp), %esi
xorl %eax, %eax
callq 0x2040
leaq 0x2bb2(%rip), %rdi      # 0x6516
callq 0x2230
leaq -0x2a8(%rbp), %rbx
movq %rbx, %rdi
leaq 0x5b06(%rip), %rsi      # 0x9480
callq 0x2cec
movl 0x5a07(%rip), %esi      # 0x938c
movq %rbx, %rdi
callq 0x43d0
movq %rbx, %rdi
callq 0x2c42
leaq 0x2c1a(%rip), %rdi      # 0x65b6
callq 0x2230
leaq 0x2b8c(%rip), %rdi      # 0x6534
callq 0x2230
movq 0x562c(%rip), %rdi      # 0x8fe0
leaq 0x5b51(%rip), %rsi      # 0x950c
callq 0x21e0
movzbl 0x5b45(%rip), %eax      # 0x950c
cmpl $0x68, %eax
je 0x3aa3
cmpl $0x73, %eax
je 0x3a7f
cmpl $0x71, %eax
leaq -0x98(%rbp), %rbx
jne 0x3e0d
jmp 0x3edb
leaq 0x2a9f(%rip), %rdi      # 0x6494
callq 0x2230
leaq -0x50(%rbp), %r13
xorl %ebx, %ebx
movl $0xc8, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x20f0
movl %ebx, 0x5797(%rip)      # 0x91ac
testl %ebx, %ebx
jg 0x3a35
movq %r15, %rdi
callq 0x2950
movl %eax, %edi
movq %r14, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x2080
movq %rax, %rbx
jmp 0x3a0f
movq %r13, %rdi
movq %r14, %rsi
leaq -0x70(%rbp), %rdx
callq 0x52fa
movq -0x48(%rbp), %rbx
movq %r13, %rdi
callq 0x22e8
testq %rbx, %rbx
je 0x39fe
leaq -0x120(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x52fa
movq %rbx, %rdi
callq 0x4088
movq %rbx, %rdi
callq 0x22e8
jmp 0x353e
movq %r15, %rdi
callq 0x2964
leaq 0x2675(%rip), %rdi      # 0x6103
movl %eax, %esi
xorl %eax, %eax
callq 0x2040
leaq -0x98(%rbp), %rbx
jmp 0x3b25
leaq -0x290(%rbp), %rbx
movq %rbx, %rdi
leaq 0x59cc(%rip), %rsi      # 0x9480
callq 0x2cec
movl 0x58cd(%rip), %esi      # 0x938c
movq %rbx, %rdi
callq 0x43d0
movq %rbx, %rdi
callq 0x2c42
leaq -0x98(%rbp), %rbx
jmp 0x3b25
movq %r15, %rdi
callq 0x2964
leaq 0x261c(%rip), %rdi      # 0x6103
movl %eax, %esi
xorl %eax, %eax
callq 0x2040
jmp 0x3b25
leaq -0x278(%rbp), %rbx
movq %rbx, %rdi
leaq 0x597d(%rip), %rsi      # 0x9480
callq 0x2cec
movl 0x587e(%rip), %esi      # 0x938c
movq %rbx, %rdi
callq 0x43d0
movq %rbx, %rdi
leaq -0x98(%rbp), %rbx
callq 0x2c42
cmpb $0x0, 0x5676(%rip)      # 0x91a2
jne 0x353e
movzbl 0x59d3(%rip), %eax      # 0x950c
cmpl $0x74, %eax
je 0x3b7a
cmpl $0x61, %eax
jne 0x3db7
movl 0x59b3(%rip), %eax      # 0x9500
movl 0x5839(%rip), %ecx      # 0x938c
cmpl %ecx, %eax
setle %dl
testl %eax, %eax
setg %sil
testb %dl, %sil
jne 0x3bf1
leaq 0x25ae(%rip), %rdi      # 0x611c
xorl %eax, %eax
callq 0x2040
jmp 0x3db7
movl 0x580c(%rip), %eax      # 0x938c
cmpl $0x3, %eax
je 0x3cf8
cmpl $0x2, %eax
je 0x3c82
cmpl $0x1, %eax
jne 0x3db7
movslq 0x595e(%rip), %rax      # 0x9500
movq 0x58d7(%rip), %rcx      # 0x9480
imulq $0x48, %rax, %rax
leaq (%rcx,%rax), %rsi
addq $-0x48, %rsi
leaq 0x58e4(%rip), %rdi      # 0x94a0
callq 0x20e0
leaq -0x1a0(%rbp), %rbx
movq %rbx, %rdi
leaq 0x5796(%rip), %rsi      # 0x9368
callq 0x21f0
movq %r13, %rdi
movq %rbx, %rsi
leaq 0x58bc(%rip), %rdx      # 0x94a0
pushq $0x5f
popq %rcx
callq 0x45e1
jmp 0x3d85
decl %eax
imull %eax, %ecx
movslq %ecx, %rax
movq 0x5880(%rip), %rcx      # 0x9480
imulq $0x48, %rax, %rax
leaq (%rcx,%rax), %rsi
addq $0x28, %rsi
movq %rbx, %rdi
callq 0x21f0
movq %r13, %rdi
pushq $0x77
popq %rsi
movq %rbx, %rdx
callq 0x445b
leaq 0x5907(%rip), %rdi      # 0x9530
movq %r13, %rsi
callq 0x21b0
movq %r13, %rdi
callq 0x22e8
movq %rbx, %rdi
callq 0x22e8
movq %r15, %rdi
callq 0x2950
movq 0x58e0(%rip), %rsi      # 0x9530
movl %eax, %edi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x20c0
movl %eax, 0x554e(%rip)      # 0x91b0
testl %eax, %eax
jle 0x3e4d
leaq 0x2918(%rip), %rdi      # 0x6589
callq 0x2230
xorb $0x1, 0x5525(%rip)      # 0x91a2
jmp 0x3db7
movl 0x5878(%rip), %ebx      # 0x9500
leal -0x2(,%rbx,2), %eax
cltq
imulq $0x48, %rax, %rsi
addq 0x57e4(%rip), %rsi      # 0x9480
leaq 0x57fd(%rip), %rdi      # 0x94a0
callq 0x20e0
leal -0x1(,%rbx,2), %eax
leaq -0x180(%rbp), %rbx
cltq
imulq $0x48, %rax, %rsi
addq 0x57bd(%rip), %rsi      # 0x9480
leaq 0x57f6(%rip), %rdi      # 0x94c0
callq 0x20e0
movq %rbx, %rdi
leaq 0x568f(%rip), %rsi      # 0x9368
callq 0x21f0
movq %r13, %rdi
movq %rbx, %rsi
leaq 0x57b5(%rip), %rdx      # 0x94a0
pushq $0x5f
popq %rcx
callq 0x45e1
jmp 0x3d85
movl 0x5802(%rip), %ebx      # 0x9500
leal (%rbx,%rbx,2), %eax
addl $-0x3, %eax
cltq
imulq $0x48, %rax, %rsi
addq 0x576f(%rip), %rsi      # 0x9480
leaq 0x5788(%rip), %rdi      # 0x94a0
callq 0x20e0
leal (%rbx,%rbx,2), %eax
addl $-0x2, %eax
cltq
imulq $0x48, %rax, %rsi
addq 0x5750(%rip), %rsi      # 0x9480
leaq 0x5789(%rip), %rdi      # 0x94c0
callq 0x20e0
leal (%rbx,%rbx,2), %eax
decl %eax
leaq -0x160(%rbp), %rbx
cltq
imulq $0x48, %rax, %rsi
addq 0x572b(%rip), %rsi      # 0x9480
leaq 0x5784(%rip), %rdi      # 0x94e0
callq 0x20e0
movq %rbx, %rdi
leaq 0x55fd(%rip), %rsi      # 0x9368
callq 0x21f0
movq %r13, %rdi
movq %rbx, %rsi
leaq 0x5723(%rip), %rdx      # 0x94a0
pushq $0x5f
popq %rcx
callq 0x45e1
leaq 0x5784(%rip), %rdi      # 0x9510
movq %r13, %rsi
callq 0x21b0
movq %r13, %rdi
callq 0x22e8
movq %rbx, %rdi
callq 0x22e8
movq 0x5765(%rip), %rdi      # 0x9510
callq 0x2230
leaq -0x98(%rbp), %rbx
cmpb $0x0, 0x53e4(%rip)      # 0x91a2
jne 0x3b25
leaq 0x27eb(%rip), %rdi      # 0x65b6
callq 0x2230
leaq 0x2808(%rip), %rdi      # 0x65df
callq 0x2230
movq 0x51fd(%rip), %rdi      # 0x8fe0
leaq 0x5722(%rip), %rsi      # 0x950c
callq 0x21e0
movzbl 0x5716(%rip), %eax      # 0x950c
cmpl $0x68, %eax
je 0x3af2
cmpl $0x73, %eax
je 0x3ad8
cmpl $0x71, %eax
je 0x3e56
movq 0x51cc(%rip), %rdi      # 0x8fe0
leaq 0x56e5(%rip), %rsi      # 0x9500
callq 0x2100
jmp 0x3b25
xorl %eax, %eax
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x269a(%rip), %rdi      # 0x64da
callq 0x2230
pushq $0x1
popq %rdi
callq 0x21a0
leaq 0x274c(%rip), %rdi      # 0x65a0
jmp 0x3e40
leaq 0x5553(%rip), %rsi      # 0x93b0
leaq -0xc0(%rbp), %rbx
movq %rbx, %rdi
callq 0x292e
leaq -0x50(%rbp), %rdi
pushq $0x71
popq %rsi
movq %rbx, %rdx
callq 0x445b
leaq 0x56ce(%rip), %rdi      # 0x9550
leaq -0x50(%rbp), %rbx
movq %rbx, %rsi
callq 0x21b0
movq %rbx, %rdi
callq 0x22e8
leaq -0xc0(%rbp), %rdi
callq 0x22e8
leaq 0x5507(%rip), %rdi      # 0x93b0
callq 0x2950
movq 0x569b(%rip), %rsi      # 0x9550
pushq $0x64
popq %rdx
movl %eax, %edi
xorl %ecx, %ecx
callq 0x20c0
movl %eax, 0x52e9(%rip)      # 0x91b0
testl %eax, %eax
jg 0x3e45
leaq 0x28d5(%rip), %rdi      # 0x67ab
jmp 0x3e40
leaq 0x54ce(%rip), %rsi      # 0x93b0
leaq -0xe0(%rbp), %rbx
movq %rbx, %rdi
callq 0x292e
leaq -0x50(%rbp), %rdi
pushq $0x71
popq %rsi
movq %rbx, %rdx
callq 0x445b
leaq 0x5649(%rip), %rdi      # 0x9550
leaq -0x50(%rbp), %rbx
movq %rbx, %rsi
callq 0x21b0
movq %rbx, %rdi
callq 0x22e8
leaq -0xe0(%rbp), %rdi
jmp 0x3e9d
movq (%rbx), %rsi
leaq 0x20ed(%rip), %rdi      # 0x601e
xorl %eax, %eax
callq 0x2040
jmp 0x3e45
leaq 0x273a(%rip), %rdi      # 0x667e
jmp 0x3e40
leaq 0x271a(%rip), %rdi      # 0x666a
jmp 0x3e40
leaq 0x26fd(%rip), %rdi      # 0x6659
jmp 0x3e40
jmp 0x3f86
jmp 0x4069
movq %rax, %rbx
leaq -0x100(%rbp), %rdi
jmp 0x4070
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
jmp 0x4070
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x22e8
jmp 0x406c
jmp 0x4069
movq %rax, %rbx
leaq -0x260(%rbp), %rdi
jmp 0x4070
movq %rax, %rbx
leaq -0x1e0(%rbp), %rdi
jmp 0x4070
jmp 0x407d
jmp 0x407d
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
jmp 0x4070
jmp 0x407d
movq %rax, %rbx
leaq -0x200(%rbp), %rdi
jmp 0x4070
jmp 0x407d
jmp 0x407d
movq %rax, %rbx
leaq -0x220(%rbp), %rdi
jmp 0x4070
jmp 0x407d
jmp 0x407d
jmp 0x407d
movq %rax, %rbx
leaq -0x240(%rbp), %rdi
jmp 0x4070
movq %rax, %rbx
leaq -0x160(%rbp), %rdi
jmp 0x4070
movq %rax, %rbx
leaq -0x180(%rbp), %rdi
jmp 0x4070
movq %rax, %rbx
leaq -0x1a0(%rbp), %rdi
jmp 0x4070
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
jmp 0x4070
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
jmp 0x4070
movq %rax, %rbx
leaq -0x140(%rbp), %rdi
jmp 0x4070
jmp 0x407d
jmp 0x407d
jmp 0x407d
movq %rax, %rbx
leaq -0x1c0(%rbp), %rdi
jmp 0x4070
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x22e8
jmp 0x4080
jmp 0x407d
jmp 0x407d
jmp 0x407d
movq %rax, %rbx
movq %rbx, %rdi
callq 0x2280