// File: /workspace/github_cpp_makefile_star2_O1/m1c0l[P]TCP/server.cpp
// Function: main
int main(int argc, char **argv) {
	if (argc != 3) {
		cerr << "usage: " << argv[0] << " PORT-NUMBER FILENAME" << '\n';
		return 1;
	}

	string port = argv[1];
	string filename = argv[2];

	srand (time(NULL)); //Used to generate random ISN

	//Create UDP socket
	int sockfd = socket(AF_INET, SOCK_DGRAM, 0);
	if (sockfd == -1) {
		perror("socket");
		return 1;
	}

	//Timeout flags and stuff could be set here
	int yes = 1;
	if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) {
		perror("setsockopt");
		return 1;
	}


	sockaddr_in addr, other;
	addr.sin_family = AF_INET;
	addr.sin_port = htons(stoi(port));
	addr.sin_addr.s_addr = htonl(INADDR_ANY);//inet_addr("127.0.0.1");

	memset(addr.sin_zero, '\0', sizeof(addr.sin_zero));

	if (bind(sockfd, (sockaddr*) &addr, sizeof(addr)) == -1) {
		perror("bind");
		return 2;
	}

	socklen_t other_length = sizeof(other);
	TcpMessage received;
	TcpMessage toSend;
	bool hasReceivedSyn = false;
	bool sendFile = false;
	uint16_t seqToSend = rand() % MAX_SEQ_NUM; //The first sync
	uint16_t ackToSend;
	uint16_t ssThresh = MAX_SEQ_NUM;
	ifstream wantedFile;
	string flagsToSend = "";
	for (int packetsSent = 0; true; packetsSent++) {
	    // cerr << "Waiting for something" << endl;
		int r = received.recvfrom(sockfd, &other, other_length);
		if (r == RECV_TIMEOUT) {
			if (hasReceivedSyn) { // client ACK not received; resend SYN-ACK
				printSend("SYN", toSend.seqNum, DATA_SIZE, DATA_SIZE, true);
				toSend.sendto(sockfd, &other, other_length);
				// cerr << "Sending SYN-ACK (retransmit):" << endl;
				toSend.dump();
			}
			continue;
		}

		// cerr << "Packet arrived from" << inet_ntoa(addr.sin_addr)<< ": " << ntohs(other.sin_port) << endl;
		// cerr << "Received:" << endl;
		received.dump();

		clientRecvWindow = received.recvWindow;

		if (!packetsSent) {
			// Set receive timeout of 0.5s
			// Only want to run this code once
			timeval recvTimeval;
			recvTimeval.tv_sec = 0;
			recvTimeval.tv_usec = TIMEOUT * 1000;
			setSocketTimeout(sockfd, recvTimeval);
		}


		//Send SYN-ACK if client is trying to set up connection

		switch (received.flags) {
		case SYN_FLAG:
			printRecv(received.ackNum);
		    if (hasReceivedSyn) {
				// cerr << "Got another SYN, sending SYN-ACK\n";
			}
		    flagsToSend ="SA";
			printSend("SYN", seqToSend, DATA_SIZE, DATA_SIZE, hasReceivedSyn);
		    hasReceivedSyn = true;

		    break;

		case SYN_FLAG | ACK_FLAG:
		    // cerr << "Both SYN and ACK were set by client\n";
		    //exit(1);
		    break;

		case ACK_FLAG:
			printRecv(received.ackNum);
		    if (!hasReceivedSyn) {
				// cerr << "ACK before handshake\n";
				break;
			}
		    flagsToSend = "A";
		    //Time to start sending the file back
		    sendFile = true;

		    break;

		default:
		    // cerr << "Incorrect flags set\n";
		    break;
		}

		// if we're done handshake and are ready to send the file now
		if (sendFile) {
			break;
		}

		ackToSend = incSeqNum(received.seqNum, 1);
		toSend = TcpMessage(seqToSend, ackToSend, clientRecvWindow, flagsToSend);
		toSend.sendto(sockfd, &other, other_length);
		// cerr << "Handshake: sending packet\n";
		toSend.dump();
	}

	char filebuf[DATA_SIZE];
	wantedFile.open(filename);
	if (!wantedFile) {
		perror("fstream open");
		exit(1);
	}

	// if the client sent data, increment ack by that number
	size_t recvLength = received.data.length();
	ackToSend = incSeqNum(received.seqNum, recvLength);
	// increment our sequence number by 1
	seqToSend = incSeqNum(seqToSend, 1);

	double cwnd = DATA_SIZE;
	uint16_t cwndBot = seqToSend;
	uint16_t cwndTop = seqToSend + cwnd;
	bool useSlowStart = true;
	int filepkts = 0;

	uint16_t lastAckExpected = BAD_SEQ_NUM;
	lastAckRecvd = seqToSend;



	/* data */

	while(true) {

		// update receiver/congestion windows
		rwndBot = lastAckRecvd;
		rwndTop = incSeqNum(rwndBot, clientRecvWindow);
		cwndBot = lastAckRecvd;
		cwndTop = incSeqNum(cwndBot, cwnd);

		// remove old packets that are outside receiver window
		auto it = packetsInWindow.begin(); // iterator
		while (it != packetsInWindow.end()) {
			auto curr = it;
			it++;
			uint16_t currSeq = curr->second.seqNum;
			if (!inWindow(currSeq, rwndBot, rwndTop)) {
				packetsInWindow.erase(curr);
			}
		}

		// create new packets
		uint16_t seqToSendEnd = incSeqNum(seqToSend, DATA_SIZE);
		// stop if next packet will be outside rwnd or cwnd
		while (inWindow(seqToSendEnd, cwndBot, cwndTop) &&
			   lastAckExpected == BAD_SEQ_NUM) {

			memset(filebuf, 0, DATA_SIZE);
			wantedFile.read(filebuf, DATA_SIZE);
			streamsize dataSize = wantedFile.gcount();
			toSend = TcpMessage(seqToSend, ackToSend, clientRecvWindow, "A");
			toSend.data = string(filebuf, dataSize);

			// if already in map, we're retransmitting
			bool isRetransmit = packetsInWindow.count(toSend.seqNum);
			// store packet in case retransmission needed
			packetsInWindow[toSend.seqNum] = toSend;
			timestamps[toSend.seqNum] = now();

			seqToSend = incSeqNum(seqToSend, dataSize);
			seqToSendEnd = incSeqNum(seqToSend, DATA_SIZE);

			// send packet
			if (dataSize > 0) {
				printSend("data", toSend.seqNum, cwnd, ssThresh, isRetransmit);
				// cerr << "sending packet " << filepkts << " of file: " << endl;
				toSend.dump();
				toSend.sendto(sockfd, &other, other_length);
				filepkts++;
			}
			// no more data; this packet's seq should be the last ACK
			else {
				lastAckExpected = seqToSend;
				break;
			}

		}

	    int r = getAcks(sockfd, &other, other_length);

		// a old packet timed out; resend it
		if (r == RECV_TIMED_OUT_ALREADY) {
			// no packets in window
			if (timedOutSeq == BAD_SEQ_NUM) {
				// cerr << "!!!!!!!!!!!! no packets in window" << endl;
			}

			// cerr << "retransmit (timed out already)" << endl;
			packetsInWindow[timedOutSeq].dump();
			packetsInWindow[timedOutSeq].sendto(sockfd, &other, other_length);
			timestamps[timedOutSeq] = now();
		}

		// no ACK received
		else if (r == RECV_TIMEOUT) {
			// retransmit last ACKed packet
			if (packetsInWindow.count(lastAckRecvd) == 0) {
				// cerr << "!!!!! packet not in window: " << lastAckRecvd << endl;
				// cerr << "!!!!! should never reach this" << endl;
				for (auto i : packetsInWindow) {
					// cerr << i.first << " ";
				}
				// cerr << endl;
				if (packetsInWindow.size() == 0) {
					// cerr << "packetsInWindow is empty!" << endl;
				}
				continue;
			}
			// cerr << "retransmitting (timeout)" << endl;
			printSend("data", packetsInWindow[lastAckRecvd].seqNum, cwnd, ssThresh, true);
			packetsInWindow[lastAckRecvd].dump();
			packetsInWindow[lastAckRecvd].sendto(sockfd, &other, other_length);
			timestamps[lastAckRecvd] = now();

			// update congestion control
			ssThresh = cwnd / 2;
			if (ssThresh < DATA_SIZE) {
				ssThresh = DATA_SIZE;
			}
			cwnd = DATA_SIZE;
			useSlowStart = true;
		}
		// got an ACK
		else {
			// check if we are done
			// this can only be true after the last packet is sent; otherwise,
			// lastAckExpected has a impossible value
			if (lastAckRecvd == lastAckExpected) {
				break;
			}

			// fast retransmit
			if (lastAckRecvd == previousAck) {
				acksInARow++; 
				if (acksInARow == 4) {
					// cerr << "retransmitting (fast retransmit)" << lastAckRecvd << endl;
					if (packetsInWindow.count(lastAckRecvd) == 0) {
						// cerr << "!!!!! packet not in window: " << lastAckRecvd << endl;
						// cerr << "!!!!! should never reach this" << endl;
						for (auto i : packetsInWindow) {
							// cerr << i.first << " ";
						}
						// cerr << endl;
						if (packetsInWindow.size() == 0) {
							// cerr << "packetsInWindow is empty!" << endl;
						}
						continue;
					}
					printSend("data", packetsInWindow[lastAckRecvd].seqNum, cwnd, ssThresh, true);
					packetsInWindow[lastAckRecvd].dump();
					packetsInWindow[lastAckRecvd].sendto(sockfd, &other, other_length);
					timestamps[lastAckRecvd] = now();
					acksInARow = 0;
					//fast recovery
					//should actually be same logic as timeout retransmit, just without setting useSlowStart
					ssThresh = (cwnd/2 < DATA_SIZE) ? DATA_SIZE : cwnd/2;
					cwnd = ssThresh > clientRecvWindow ? clientRecvWindow : ssThresh;
					useSlowStart = false;
					previousAck = lastAckRecvd;
					continue;
					
				}
			}
			previousAck = lastAckRecvd;
			
			// check if all packets in window were cumulatively ACKed
			if (lastAckRecvd == seqToSend) {
				// cerr << "!!!!!!!!! all packets ACKed" << endl;
			}

			// update congestion control
			if (useSlowStart) {
				cwnd = cwnd + DATA_SIZE;
			}
			else {
				cwnd = cwnd + DATA_SIZE * DATA_SIZE /cwnd;
			}
			if (cwnd > clientRecvWindow) {
				cwnd = clientRecvWindow;
			}
			if (cwnd >= ssThresh) {
				useSlowStart = false;
			}
		}
	}


	// cerr << "out of loop\n";


	/* FIN */

	// reset to 0.5s timeout
	timeval recvTimeval;
	recvTimeval.tv_sec = 0;
	recvTimeval.tv_usec = TIMEOUT * 1000;
	setSocketTimeout(sockfd, recvTimeval);

	bool hasReceivedFin = false;
	bool hasReceivedFinAck = false;
	bool hasSentFin = false;
	bool hasSentAckFin = false;
	int timedWaitTimer = 2 * MAX_SEG_LIFETIME; // milliseconds to wait before closing

	while (timedWaitTimer > 0) {

		/* send FIN if no FIN-ACK received yet */
		if (!hasReceivedFinAck) {
			flagsToSend = "F";
			// Sequence number shouldn't change since we already increased by total data size
			ackToSend = 0; // ACK is invalid this packet
			toSend = TcpMessage(seqToSend, ackToSend, clientRecvWindow, flagsToSend);
			toSend.sendto(sockfd, &other, other_length);
			printSend("FIN", seqToSend, DATA_SIZE, ssThresh, hasSentFin);
			// cerr << "Sending FIN\n";
			toSend.dump();
			hasSentFin = true;
		}

		/* timed wait timer counts down after FIN received */
		if (hasReceivedFin) {
			timedWaitTimer -= TIMEOUT; // wait TIMEOUT msec each loop
		}

		int r = received.recvfrom(sockfd, &other, other_length);
		if (r == RECV_TIMEOUT) {
			// cerr << "Timeout while waiting for FIN-ACK/FIN\n";
			continue;
		}
		clientRecvWindow = received.recvWindow;

		switch(received.flags) {
			// FIN-ACK
			case FIN_FLAG | ACK_FLAG:
				printRecv(received.ackNum);
				// cerr << "Received FIN-ACK\n";
				hasReceivedFinAck = true;
				break;

			// FIN
			case FIN_FLAG:
				printRecv(received.ackNum);
				// cerr << "Received FIN\n";

				flagsToSend = "A";// this is "FIN-ACK" but without FIN flag
				seqToSend = incSeqNum(seqToSend, 1);// increase sequence number by 1
				ackToSend = incSeqNum(received.seqNum, 1); // increase ack by 1
				toSend = TcpMessage(seqToSend, ackToSend, clientRecvWindow, flagsToSend);
				toSend.sendto(sockfd, &other, other_length);
				printSend("data", seqToSend, DATA_SIZE, ssThresh, hasSentAckFin);
				// cerr << "Sending ACK of FIN\n";
				toSend.dump();
				// cerr << "Server received FIN; starting timed wait..." << endl;
				hasReceivedFinAck = true; // assume that client got a FIN
				hasReceivedFin = true;
				hasSentAckFin = true;
				break;

			default:
				// cerr << "Received packet wasn't FIN-ACK or FIN!\n";
				//exit(1);
				break;
		}
		received.dump();
	}

	// cerr << "Shouldn't receive anything else from client now\n";

	close(sockfd);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x8b8, %rsp            # imm = 0x8B8
movq %rsi, %rbx
cmpl $0x3, %edi
jne 0x33d8
movq 0x8(%rbx), %rsi
leaq 0x278(%rsp), %rdi
leaq 0x4b0(%rsp), %rdx
callq 0x450e
movq 0x10(%rbx), %rsi
leaq 0x258(%rsp), %rdi
leaq 0x4b0(%rsp), %rdx
callq 0x450e
xorl %edi, %edi
callq 0x21a0
movl %eax, %edi
callq 0x21b0
movl $0x2, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x2070
cmpl $-0x1, %eax
je 0x418b
leaq 0x254(%rsp), %rcx
movl $0x1, (%rcx)
movl $0x1, %ebx
movl %eax, 0xc(%rsp)
movl %eax, %edi
movl $0x1, %esi
movl $0x2, %edx
movl $0x4, %r8d
callq 0x22e0
cmpl $-0x1, %eax
je 0x41a1
movw $0x2, 0x298(%rsp)
movq 0x278(%rsp), %rbx
callq 0x2030
movq %rax, %r14
movl (%rax), %ebp
movl $0x0, (%rax)
leaq 0x4b0(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x2240
cmpq %rbx, (%r15)
je 0x41c8
movslq %eax, %rcx
cmpq %rax, %rcx
jne 0x41d4
movl (%r14), %ecx
cmpl $0x22, %ecx
je 0x41d4
testl %ecx, %ecx
jne 0x3012
movl %ebp, (%r14)
rolw $0x8, %ax
leaq 0x298(%rsp), %rsi
movw %ax, 0x2(%rsi)
movl $0x0, 0x4(%rsi)
movq $0x0, 0x8(%rsi)
movl 0xc(%rsp), %edi
movl $0x10, %edx
callq 0x2060
cmpl $-0x1, %eax
je 0x41b2
leaq 0xc8(%rsp), %rdi
callq 0x273c
leaq 0x38(%rsp), %rdi
callq 0x273c
callq 0x2090
movl %eax, %ebx
leaq 0x2a8(%rsp), %rdi
callq 0x21e0
leaq 0xa0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x2020(%rip), %rdx      # 0x50a6
leaq 0x90(%rsp), %rdi
movq %rdx, %rsi
callq 0x2990
movslq %ebx, %rdx
imulq $-0x77777777, %rdx, %rax # imm = 0x88888889
shrq $0x20, %rax
addl %edx, %eax
movl %eax, %ecx
shrl $0x1f, %ecx
shrl $0xe, %eax
addl %ecx, %eax
imull $0x7800, %eax, %eax     # imm = 0x7800
subl %eax, %edx
movq %rdx, 0x10(%rsp)
xorl %r13d, %r13d
xorl %ebx, %ebx
xorl %r14d, %r14d
leaq 0xc8(%rsp), %rdi
movl 0xc(%rsp), %esi
leaq 0xb0(%rsp), %rdx
movl $0x10, %ecx
callq 0x2898
cmpl $0x2, %eax
jne 0x3195
movl $0x4, %ebp
testb $0x1, %r14b
je 0x33ca
leaq 0x240(%rsp), %rax
movq %rax, 0x230(%rsp)
leaq 0x230(%rsp), %r15
movq %r15, %rdi
leaq 0x1fac(%rip), %rsi      # 0x50c9
leaq 0x1fa8(%rip), %rdx      # 0x50cc
callq 0x2990
movzwl 0x38(%rsp), %esi
movq %r15, %rdi
movl $0x400, %edx            # imm = 0x400
movl $0x400, %ecx            # imm = 0x400
movl $0x1, %r8d
callq 0x2c18
movq 0x230(%rsp), %rdi
leaq 0x240(%rsp), %rax
cmpq %rax, %rdi
je 0x316b
movq 0x240(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x38(%rsp), %rdi
movl 0xc(%rsp), %esi
leaq 0xb0(%rsp), %rdx
movl $0x10, %ecx
callq 0x284a
leaq 0x38(%rsp), %rdi
callq 0x28fe
jmp 0x33ca
leaq 0xc8(%rsp), %rdi
callq 0x28fe
movzwl 0xcc(%rsp), %eax
movw %ax, 0x5003(%rip)       # 0x81b4
testl %r13d, %r13d
jne 0x31c6
movl $0x7a120, %edx          # imm = 0x7A120
movl 0xc(%rsp), %edi
xorl %esi, %esi
callq 0x2af5
movzwl 0xce(%rsp), %eax
cmpl $0x4, %eax
je 0x3288
cmpl $0x2, %eax
jne 0x32c1
movzwl 0xca(%rsp), %edi
callq 0x2bd0
movq 0x98(%rsp), %rdx
movl $0x2, %r8d
leaq 0x90(%rsp), %rdi
xorl %esi, %esi
leaq 0x1ec1(%rip), %rcx      # 0x50cd
callq 0x2280
leaq 0x220(%rsp), %rax
movq %rax, 0x210(%rsp)
leaq 0x210(%rsp), %r15
movq %r15, %rdi
leaq 0x1e96(%rip), %rsi      # 0x50c9
leaq 0x1e92(%rip), %rdx      # 0x50cc
callq 0x2990
movzwl 0x10(%rsp), %esi
movzbl %r14b, %r8d
andl $0x1, %r8d
movq %r15, %rdi
movl $0x400, %edx            # imm = 0x400
movl $0x400, %ecx            # imm = 0x400
callq 0x2c18
movq 0x210(%rsp), %rdi
movb $0x1, %r14b
leaq 0x220(%rsp), %rax
cmpq %rax, %rdi
je 0x32c1
movq 0x220(%rsp), %rsi
incq %rsi
callq 0x21d0
jmp 0x32c1
movzwl 0xca(%rsp), %edi
callq 0x2bd0
testb $0x1, %r14b
je 0x32c1
movb $0x1, %bl
movq 0x98(%rsp), %rdx
movl $0x1, %r8d
leaq 0x90(%rsp), %rdi
xorl %esi, %esi
leaq 0x1e12(%rip), %rcx      # 0x50ce
callq 0x2280
movl $0x2, %ebp
testb $0x1, %bl
jne 0x33ca
movzwl 0xc8(%rsp), %edi
movl $0x1, %esi
callq 0x2a20
movl %eax, %ebp
movzwl 0x4ec9(%rip), %r15d     # 0x81b4
leaq 0x200(%rsp), %rax
movq %rax, 0x1f0(%rsp)
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
addq %rsi, %rdx
leaq 0x1f0(%rsp), %r12
movq %r12, %rdi
callq 0x2900
movzwl 0x10(%rsp), %esi
movzwl %bp, %edx
movzwl %r15w, %ecx
leaq 0x4b0(%rsp), %rdi
movq %r12, %r8
callq 0x255c
movq 0x4b0(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x4b8(%rsp), %rsi
callq 0x2210
movq 0x4b8(%rsp), %rdi
leaq 0x4c8(%rsp), %rax
cmpq %rax, %rdi
je 0x337e
movq 0x4c8(%rsp), %rsi
incq %rsi
callq 0x21d0
movq 0x1f0(%rsp), %rdi
leaq 0x200(%rsp), %rax
cmpq %rax, %rdi
je 0x33a3
movq 0x200(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x38(%rsp), %rdi
movl 0xc(%rsp), %esi
leaq 0xb0(%rsp), %rdx
movl $0x10, %ecx
callq 0x284a
xorl %ebp, %ebp
leaq 0x38(%rsp), %rdi
callq 0x28fe
testb $0x3, %bpl
jne 0x341e
decl %r13d
jmp 0x30c5
movq 0x4c11(%rip), %r14      # 0x7ff0
leaq 0x1cb9(%rip), %rsi      # 0x509f
movl $0x7, %edx
movq %r14, %rdi
callq 0x21f0
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x4127
movq %rbx, %rdi
callq 0x20e0
movq 0x4be2(%rip), %rdi      # 0x7ff0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x21f0
jmp 0x413f
leaq 0x2a8(%rsp), %rdi
leaq 0x258(%rsp), %rsi
movl $0x8, %edx
callq 0x2180
movq 0x2a8(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x2c8(%rsp,%rax)
jne 0x41e0
movzwl 0xd8(%rsp), %esi
movzwl 0xc8(%rsp), %edi
callq 0x2a20
movl %eax, %r14d
movzwl 0x10(%rsp), %edi
movl $0x1, %esi
callq 0x2a20
movl %eax, %ebp
movw %ax, 0x4d30(%rip)       # 0x81b2
movw $0x7800, %ax            # imm = 0x7800
movl %eax, 0x1c(%rsp)
movsd 0x1bbe(%rip), %xmm0     # 0x5050
movb $0x1, %al
movl %eax, 0x18(%rsp)
movw $0xd903, %r15w          # imm = 0xD903
movzwl %r14w, %eax
movl %eax, 0x24(%rsp)
movsd %xmm0, 0x28(%rsp)
movzwl 0x4d00(%rip), %edi      # 0x81b2
movw %di, 0x4cfd(%rip)       # 0x81b6
movzwl 0x4cf4(%rip), %esi      # 0x81b4
callq 0x2a20
movw %ax, 0x4cec(%rip)       # 0x81b8
cvttsd2si 0x28(%rsp), %eax
movzwl 0x4cd9(%rip), %edi      # 0x81b2
movl %eax, 0x34(%rsp)
movzwl %ax, %esi
movl %edi, 0x10(%rsp)
callq 0x2a20
movl %eax, %ebx
movq 0x4cde(%rip), %r14      # 0x81d0
testq %r14, %r14
je 0x352d
movq (%r14), %r12
movzwl 0x10(%r14), %edi
movzwl 0x4cb0(%rip), %esi      # 0x81b6
movzwl 0x4cab(%rip), %edx      # 0x81b8
callq 0x2a37
testb %al, %al
jne 0x3525
leaq 0x4ca3(%rip), %rdi      # 0x81c0
movq %r14, %rsi
callq 0x4952
movq %r12, %r14
testq %r12, %r12
jne 0x34f7
movzwl %bp, %edi
movl $0x400, %esi            # imm = 0x400
callq 0x2a20
movl %eax, %r14d
movzwl 0x1c(%rsp), %eax
movl %eax, 0x20(%rsp)
movzwl %bx, %eax
movl %eax, 0xc0(%rsp)
movl %r15d, %r12d
movzwl %r14w, %edi
movl 0x10(%rsp), %esi
movl 0xc0(%rsp), %edx
callq 0x2a37
movzwl %r12w, %ecx
cmpl $0xd903, %ecx           # imm = 0xD903
sete %cl
andb %cl, %al
cmpb $0x1, %al
jne 0x37db
movl $0x400, %edx            # imm = 0x400
leaq 0x4b0(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2100
movl $0x400, %edx            # imm = 0x400
leaq 0x2a8(%rsp), %rdi
movq %rbx, %rsi
callq 0x2220
movq 0x2b0(%rsp), %rbx
movzwl 0x4bfa(%rip), %r14d     # 0x81b4
leaq 0x1e0(%rsp), %rax
movq %rax, 0x1d0(%rsp)
leaq 0x1d0(%rsp), %r15
movq %r15, %rdi
leaq 0x1af2(%rip), %rsi      # 0x50ce
leaq 0x1aec(%rip), %rdx      # 0x50cf
callq 0x2990
movzwl %bp, %ebp
movzwl %r14w, %ecx
leaq 0x60(%rsp), %rdi
movl %ebp, %esi
movl 0x24(%rsp), %edx
movq %r15, %r8
callq 0x255c
movq 0x60(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x2210
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x3637
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x21d0
movq 0x1d0(%rsp), %rdi
leaq 0x1e0(%rsp), %rax
cmpq %rax, %rdi
je 0x365c
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x70(%rsp), %r14
movq %r14, 0x60(%rsp)
leaq (%rsp,%rbx), %rdx
addq $0x4b0, %rdx            # imm = 0x4B0
leaq 0x60(%rsp), %r15
movq %r15, %rdi
leaq 0x4b0(%rsp), %rsi
callq 0x2990
leaq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x2210
movq 0x60(%rsp), %rdi
cmpq %r14, %rdi
je 0x36aa
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x4b0f(%rip), %rdi      # 0x81c0
leaq 0x38(%rsp), %rsi
callq 0x4a14
movq %rax, %r13
leaq 0x4afb(%rip), %rdi      # 0x81c0
leaq 0x38(%rsp), %rsi
callq 0x4a92
movq 0x38(%rsp), %rcx
movq %rcx, (%rax)
addq $0x8, %rax
movq %rax, %rdi
leaq 0x40(%rsp), %rsi
callq 0x20f0
callq 0x2b29
movq %rax, %r14
movq %rdx, %r15
leaq 0x4afe(%rip), %rdi      # 0x81f8
leaq 0x38(%rsp), %rsi
callq 0x4664
movq %r14, (%rax)
movq %r15, 0x8(%rax)
movzwl %bx, %esi
movl %ebp, %edi
callq 0x2a20
movl %eax, %ebp
movzwl %ax, %edi
movl $0x400, %esi            # imm = 0x400
callq 0x2a20
movl %eax, %r14d
movl %ebp, %r15d
testq %rbx, %rbx
jle 0x37cd
leaq 0x1c0(%rsp), %rax
movq %rax, 0x1b0(%rsp)
leaq 0x1b0(%rsp), %r15
movq %r15, %rdi
leaq 0x1945(%rip), %rsi      # 0x509a
leaq 0x1942(%rip), %rdx      # 0x509e
callq 0x2990
xorl %r8d, %r8d
testq %r13, %r13
setne %r8b
movzwl 0x38(%rsp), %esi
movq %r15, %rdi
movl 0x34(%rsp), %edx
movl 0x20(%rsp), %ecx
callq 0x2c18
movq 0x1b0(%rsp), %rdi
leaq 0x1c0(%rsp), %rax
cmpq %rax, %rdi
je 0x37a5
movq 0x1c0(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x38(%rsp), %rdi
callq 0x28fe
leaq 0x38(%rsp), %rdi
movl 0xc(%rsp), %esi
leaq 0xb0(%rsp), %rdx
movl $0x10, %ecx
callq 0x284a
movl %r12d, %r15d
movl %r15d, %r12d
testq %rbx, %rbx
jg 0x3553
jmp 0x37de
movl %r12d, %r15d
movl 0xc(%rsp), %edi
leaq 0xb0(%rsp), %rsi
movl $0x10, %edx
callq 0x2d1c
leaq 0x70(%rsp), %r14
leaq 0x80(%rsp), %r12
cmpl $0x2, %eax
je 0x3880
cmpl $0x3, %eax
jne 0x39cb
leaq 0x49aa(%rip), %rdi      # 0x81c0
leaq 0x4a13(%rip), %rsi      # 0x8230
callq 0x4a92
movq %rax, %rdi
callq 0x28fe
leaq 0x498f(%rip), %rdi      # 0x81c0
leaq 0x49f8(%rip), %rsi      # 0x8230
callq 0x4a92
movq %rax, %rdi
movl 0xc(%rsp), %esi
leaq 0xb0(%rsp), %rdx
movl $0x10, %ecx
callq 0x284a
callq 0x2b29
movq %rax, %rbx
movq %rdx, %r14
leaq 0x4990(%rip), %rdi      # 0x81f8
leaq 0x49c1(%rip), %rsi      # 0x8230
callq 0x4664
movq %rbx, (%rax)
movq %r14, 0x8(%rax)
jmp 0x3bc0
leaq 0x4939(%rip), %rdi      # 0x81c0
leaq 0x4924(%rip), %rsi      # 0x81b2
callq 0x4a14
testq %rax, %rax
je 0x3bcf
leaq 0x120(%rsp), %rax
movq %rax, 0x110(%rsp)
leaq 0x110(%rsp), %rdi
leaq 0x17df(%rip), %rsi      # 0x509a
leaq 0x17dc(%rip), %rdx      # 0x509e
callq 0x2990
leaq 0x48f2(%rip), %rdi      # 0x81c0
leaq 0x48dd(%rip), %rsi      # 0x81b2
callq 0x4a92
movzwl (%rax), %esi
leaq 0x110(%rsp), %rdi
movl 0x34(%rsp), %edx
movl 0x20(%rsp), %ecx
movl $0x1, %r8d
callq 0x2c18
movq 0x110(%rsp), %rdi
leaq 0x120(%rsp), %rax
cmpq %rax, %rdi
je 0x391d
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x489c(%rip), %rdi      # 0x81c0
leaq 0x4887(%rip), %rsi      # 0x81b2
callq 0x4a92
movq %rax, %rdi
callq 0x28fe
leaq 0x4881(%rip), %rdi      # 0x81c0
leaq 0x486c(%rip), %rsi      # 0x81b2
callq 0x4a92
movq %rax, %rdi
movl 0xc(%rsp), %esi
leaq 0xb0(%rsp), %rdx
movl $0x10, %ecx
callq 0x284a
callq 0x2b29
movq %rax, %r14
movq %rdx, %rbx
leaq 0x4882(%rip), %rdi      # 0x81f8
leaq 0x4835(%rip), %rsi      # 0x81b2
callq 0x4664
movq %r14, (%rax)
movsd 0x28(%rsp), %xmm0
mulsd 0x16c5(%rip), %xmm0     # 0x5058
cvttsd2si %xmm0, %edx
movzwl %dx, %ecx
cmpl $0x401, %ecx            # imm = 0x401
movl $0x400, %ecx            # imm = 0x400
cmovbl %ecx, %edx
movl %edx, 0x1c(%rsp)
movq %rbx, 0x8(%rax)
movb $0x1, %al
movl %eax, 0x18(%rsp)
xorl %eax, %eax
movsd 0x1690(%rip), %xmm0     # 0x5050
movsd %xmm0, 0x28(%rsp)
jmp 0x3bc2
movzwl 0x47e0(%rip), %ecx      # 0x81b2
movb $0x1, %al
cmpw %r15w, %cx
je 0x3bc2
cmpw 0x47bd(%rip), %cx       # 0x81a2
jne 0x3b66
movzwl 0x4840(%rip), %eax      # 0x8232
incl %eax
movw %ax, 0x4837(%rip)       # 0x8232
cmpw $0x4, %ax
jne 0x3b66
leaq 0x47b4(%rip), %rdi      # 0x81c0
leaq 0x479f(%rip), %rsi      # 0x81b2
callq 0x4a14
testq %rax, %rax
je 0x3c24
leaq 0x100(%rsp), %rax
movq %rax, 0xf0(%rsp)
leaq 0xf0(%rsp), %rdi
leaq 0x165a(%rip), %rsi      # 0x509a
leaq 0x1657(%rip), %rdx      # 0x509e
callq 0x2990
leaq 0x476d(%rip), %rdi      # 0x81c0
leaq 0x4758(%rip), %rsi      # 0x81b2
callq 0x4a92
movzwl (%rax), %esi
leaq 0xf0(%rsp), %rdi
movl 0x34(%rsp), %edx
movl 0x20(%rsp), %ecx
movl $0x1, %r8d
callq 0x2c18
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x3aa2
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x4717(%rip), %rdi      # 0x81c0
leaq 0x4702(%rip), %rsi      # 0x81b2
callq 0x4a92
movq %rax, %rdi
callq 0x28fe
leaq 0x46fc(%rip), %rdi      # 0x81c0
leaq 0x46e7(%rip), %rsi      # 0x81b2
callq 0x4a92
movq %rax, %rdi
movl 0xc(%rsp), %esi
leaq 0xb0(%rsp), %rdx
movl $0x10, %ecx
callq 0x284a
callq 0x2b29
movq %rax, %rbx
movq %rdx, %r14
leaq 0x46fd(%rip), %rdi      # 0x81f8
leaq 0x46b0(%rip), %rsi      # 0x81b2
callq 0x4664
movq %rbx, (%rax)
movq %r14, 0x8(%rax)
movsd 0x28(%rsp), %xmm1
mulsd 0x153c(%rip), %xmm1     # 0x5058
movsd 0x152c(%rip), %xmm0     # 0x5050
maxsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movzwl 0x4681(%rip), %eax      # 0x81b4
cmpw %cx, %ax
movl %ecx, 0x1c(%rsp)
cmovbl %eax, %ecx
movw $0x0, 0x46ec(%rip)      # 0x8232
movzwl %cx, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x28(%rsp)
movzwl 0x4655(%rip), %eax      # 0x81b2
movw %ax, 0x463e(%rip)       # 0x81a2
jmp 0x3bb8
movw %cx, 0x4635(%rip)       # 0x81a2
movsd 0x14db(%rip), %xmm0     # 0x5050
testb $0x1, 0x18(%rsp)
jne 0x3b8a
movsd 0x14dc(%rip), %xmm0     # 0x5060
divsd 0x28(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
addsd %xmm0, %xmm1
movzwl 0x4619(%rip), %eax      # 0x81b4
cvtsi2sd %eax, %xmm2
minsd %xmm1, %xmm2
xorps %xmm0, %xmm0
cvtsi2sdl 0x20(%rsp), %xmm0
movsd %xmm2, 0x28(%rsp)
ucomisd %xmm0, %xmm2
jb 0x3bc0
movl $0x0, 0x18(%rsp)
xorl %eax, %eax
testb %al, %al
je 0x34ab
jmp 0x3c85
movq 0x45fa(%rip), %rbx      # 0x81d0
testq %rbx, %rbx
je 0x3bc0
movzwl 0x8(%rbx), %eax
movw %ax, 0x60(%rsp)
movq 0x10(%rbx), %rax
movq %rax, 0x68(%rsp)
movq %r12, 0x70(%rsp)
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x2900
movq 0x70(%rsp), %rdi
cmpq %r12, %rdi
je 0x3c1f
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x21d0
movq (%rbx), %rbx
jmp 0x3bd6
movq 0x45a5(%rip), %rbx      # 0x81d0
testq %rbx, %rbx
je 0x3bc0
movzwl 0x8(%rbx), %eax
movw %ax, 0x60(%rsp)
movq 0x10(%rbx), %rax
movq %rax, 0x68(%rsp)
movq %r12, 0x70(%rsp)
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
addq %rsi, %rdx
leaq 0x70(%rsp), %rdi
callq 0x2900
movq 0x70(%rsp), %rdi
cmpq %r12, %rdi
je 0x3c76
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x21d0
movq (%rbx), %rbx
xorl %eax, %eax
testq %rbx, %rbx
jne 0x3c30
jmp 0x3bc2
movl $0x7a120, %edx          # imm = 0x7A120
movl 0xc(%rsp), %edi
xorl %esi, %esi
callq 0x2af5
movzwl 0x1c(%rsp), %eax
movl %eax, 0x24(%rsp)
movl $0x1d4c0, %r14d         # imm = 0x1D4C0
movq $0x0, 0x10(%rsp)
movq $0x0, 0xc0(%rsp)
xorl %r15d, %r15d
testb $0x1, %r15b
jne 0x3e39
movq 0x98(%rsp), %rdx
movl $0x1, %r8d
leaq 0x90(%rsp), %rdi
xorl %esi, %esi
leaq 0x13f8(%rip), %rcx      # 0x50dd
callq 0x2280
movzwl 0x44c2(%rip), %r13d     # 0x81b4
leaq 0x1a0(%rsp), %rax
movq %rax, 0x190(%rsp)
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
addq %rsi, %rdx
leaq 0x190(%rsp), %r12
movq %r12, %rdi
callq 0x2900
movzwl %bp, %ebx
movzwl %r13w, %ecx
leaq 0x60(%rsp), %rdi
movl %ebx, %esi
xorl %edx, %edx
movq %r12, %r8
callq 0x255c
movq 0x60(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x2210
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x3d72
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x21d0
movq 0x190(%rsp), %rdi
leaq 0x1a0(%rsp), %rax
cmpq %rax, %rdi
je 0x3d97
movq 0x1a0(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x38(%rsp), %rdi
movl 0xc(%rsp), %esi
leaq 0xb0(%rsp), %rdx
movl $0x10, %ecx
callq 0x284a
leaq 0x180(%rsp), %rax
movq %rax, 0x170(%rsp)
leaq 0x170(%rsp), %r12
movq %r12, %rdi
leaq 0x130b(%rip), %rsi      # 0x50df
leaq 0x1307(%rip), %rdx      # 0x50e2
callq 0x2990
movzbl 0xc0(%rsp), %r8d
andl $0x1, %r8d
movq %r12, %rdi
movl %ebx, %esi
movl $0x400, %edx            # imm = 0x400
movl 0x24(%rsp), %ecx
callq 0x2c18
movq 0x170(%rsp), %rdi
leaq 0x180(%rsp), %rax
cmpq %rax, %rdi
je 0x3e25
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x21d0
movb $0x1, %al
movq %rax, 0xc0(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x28fe
leal -0x1f4(%r14), %eax
testb $0x1, 0x10(%rsp)
cmovnel %eax, %r14d
leaq 0xc8(%rsp), %rdi
movl 0xc(%rsp), %esi
leaq 0xb0(%rsp), %rdx
movl $0x10, %ecx
callq 0x2898
cmpl $0x2, %eax
je 0x4061
movzwl 0xcc(%rsp), %eax
movw %ax, 0x4335(%rip)       # 0x81b4
movzwl 0xce(%rsp), %eax
cmpl $0x1, %eax
je 0x3eaa
cmpl $0x5, %eax
jne 0x4054
movb $0x1, %r15b
movzwl 0xca(%rsp), %edi
callq 0x2bd0
jmp 0x4054
movzwl 0xca(%rsp), %edi
callq 0x2bd0
movq 0x98(%rsp), %rdx
movl $0x1, %r8d
leaq 0x90(%rsp), %rdi
xorl %esi, %esi
leaq 0x11f8(%rip), %rcx      # 0x50ce
callq 0x2280
movzwl %bp, %edi
movl $0x1, %esi
callq 0x2a20
movl %eax, %ebp
movzwl 0xc8(%rsp), %edi
movl $0x1, %esi
callq 0x2a20
movl %eax, %r15d
leaq 0x60(%rsp), %rbx
movzwl 0x42a8(%rip), %r13d     # 0x81b4
leaq 0x160(%rsp), %rax
movq %rax, 0x150(%rsp)
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
addq %rsi, %rdx
leaq 0x150(%rsp), %r12
movq %r12, %rdi
callq 0x2900
movzwl %bp, %eax
movzwl %r15w, %edx
movl %eax, %r15d
movzwl %r13w, %ecx
movq %rbx, %rdi
movl %eax, %esi
movq %r12, %r8
callq 0x255c
movq 0x60(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x2210
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x3f8f
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x21d0
movq 0x150(%rsp), %rdi
leaq 0x160(%rsp), %rax
cmpq %rax, %rdi
je 0x3fb4
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x38(%rsp), %rdi
movl 0xc(%rsp), %esi
leaq 0xb0(%rsp), %rdx
movl $0x10, %ecx
callq 0x284a
leaq 0x140(%rsp), %rax
movq %rax, 0x130(%rsp)
leaq 0x130(%rsp), %rbx
movq %rbx, %rdi
leaq 0x10a9(%rip), %rsi      # 0x509a
leaq 0x10a6(%rip), %rdx      # 0x509e
callq 0x2990
movzbl 0x10(%rsp), %r8d
andl $0x1, %r8d
movq %rbx, %rdi
movl %r15d, %esi
movl $0x400, %edx            # imm = 0x400
movl 0x24(%rsp), %ecx
callq 0x2c18
movq 0x130(%rsp), %rdi
leaq 0x140(%rsp), %rax
cmpq %rax, %rdi
je 0x4040
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x38(%rsp), %rdi
callq 0x28fe
movb $0x1, %al
movq %rax, 0x10(%rsp)
movb $0x1, %r15b
leaq 0xc8(%rsp), %rdi
callq 0x28fe
testl %r14d, %r14d
jg 0x3cbc
movl 0xc(%rsp), %edi
callq 0x2300
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x4098
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x2a8(%rsp), %rdi
callq 0x2080
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x40c0
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0xe0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x40e1
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x21d0
xorl %ebx, %ebx
leaq 0x268(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4104
movq 0x268(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x288(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4177
movq 0x288(%rsp), %rsi
incq %rsi
callq 0x21d0
jmp 0x4177
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x22b0
movq 0x3eaa(%rip), %rbx      # 0x7ff0
leaq 0xf5a(%rip), %rsi       # 0x50a7
movl $0x15, %edx
movq %rbx, %rdi
callq 0x21f0
leaq 0x4b0(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rbx, %rdi
callq 0x21f0
movl $0x1, %ebx
movl %ebx, %eax
addq $0x8b8, %rsp            # imm = 0x8B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xf2b(%rip), %rdi       # 0x50bd
callq 0x2170
movl $0x1, %ebx
jmp 0x40e3
leaq 0xe96(%rip), %rdi       # 0x503e
callq 0x2170
jmp 0x40e3
leaq 0xf0b(%rip), %rdi       # 0x50c4
callq 0x2170
movl $0x2, %ebx
jmp 0x40e3
leaq 0xf14(%rip), %rdi       # 0x50e3
callq 0x2110
leaq 0xf08(%rip), %rdi       # 0x50e3
callq 0x2250
callq 0x235f
jmp 0x4446
jmp 0x4446
jmp 0x4446
jmp 0x4446
movq %rax, %rbx
jmp 0x446e
movq %rax, %rbx
jmp 0x447b
movq %rax, %rbx
jmp 0x4496
movq %rax, %rbx
jmp 0x44b7
movq %rax, %rbx
jmp 0x44d8
jmp 0x4446
movq %rax, %rbx
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x4449
movq 0x100(%rsp), %rsi
jmp 0x4434
jmp 0x4446
movq %rax, %rbx
cmpl $0x0, (%r14)
jne 0x44b7
movl %ebp, (%r14)
jmp 0x44b7
movq %rax, %rbx
movq 0x130(%rsp), %rdi
leaq 0x140(%rsp), %rax
cmpq %rax, %rdi
je 0x4449
movq 0x140(%rsp), %rsi
jmp 0x4434
jmp 0x4446
movq %rax, %rbx
movq 0x150(%rsp), %rdi
leaq 0x160(%rsp), %rax
cmpq %rax, %rdi
je 0x4449
movq 0x160(%rsp), %rsi
jmp 0x4434
jmp 0x4446
jmp 0x4446
jmp 0x4446
movq %rax, %rbx
movq 0x210(%rsp), %rdi
leaq 0x220(%rsp), %rax
cmpq %rax, %rdi
je 0x4449
movq 0x220(%rsp), %rsi
jmp 0x4434
jmp 0x4446
jmp 0x4446
movq %rax, %rbx
movq 0x110(%rsp), %rdi
leaq 0x120(%rsp), %rax
cmpq %rax, %rdi
je 0x4449
movq 0x120(%rsp), %rsi
jmp 0x4434
jmp 0x4446
movq %rax, %rbx
movq 0x1f0(%rsp), %rdi
leaq 0x200(%rsp), %rax
cmpq %rax, %rdi
je 0x4449
movq 0x200(%rsp), %rsi
jmp 0x4434
movq %rax, %rbx
movq 0x230(%rsp), %rdi
leaq 0x240(%rsp), %rax
cmpq %rax, %rdi
je 0x4449
movq 0x240(%rsp), %rsi
jmp 0x4434
jmp 0x4446
jmp 0x4446
jmp 0x4446
jmp 0x4446
movq %rax, %rbx
movq 0x190(%rsp), %rdi
leaq 0x1a0(%rsp), %rax
cmpq %rax, %rdi
je 0x4449
movq 0x1a0(%rsp), %rsi
jmp 0x4434
movq %rax, %rbx
movq 0x170(%rsp), %rdi
leaq 0x180(%rsp), %rax
cmpq %rax, %rdi
je 0x4449
movq 0x180(%rsp), %rsi
jmp 0x4434
jmp 0x4446
jmp 0x4446
jmp 0x4446
jmp 0x4446
jmp 0x4446
jmp 0x4446
jmp 0x4446
jmp 0x4446
jmp 0x4446
movq %rax, %rbx
movq 0x1b0(%rsp), %rdi
leaq 0x1c0(%rsp), %rax
cmpq %rax, %rdi
je 0x4449
movq 0x1c0(%rsp), %rsi
jmp 0x4434
jmp 0x4446
movq %rax, %rbx
movq 0x1d0(%rsp), %rdi
leaq 0x1e0(%rsp), %rax
cmpq %rax, %rdi
je 0x4449
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x21d0
jmp 0x4449
jmp 0x4446
jmp 0x4446
jmp 0x4446
jmp 0x4446
movq %rax, %rbx
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x446e
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x2a8(%rsp), %rdi
callq 0x2080
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4496
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0xe0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x44b7
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x268(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x44d8
movq 0x268(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x288(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x44f9
movq 0x288(%rsp), %rsi
incq %rsi
callq 0x21d0
movq %rbx, %rdi
callq 0x22d0
nop