// File: /workspace/github_cpp_makefile_star2_O2/tonymuu[P]distributed-kv-store/Application.cpp
// Function: Application::readTest()
void Application::readTest() {

	// Step 0. Key to be read
	// This key is used for all read tests
	map<string, string>::iterator it = testKVPairs.begin();
	int number;
	vector<Node> replicas;
	int replicaIdToFail = TERTIARY;
	int nodeToFail;
	bool failedOneNode = false;

	/**
 	 * Test 1: Test if value of a single read operation is read correctly in quorum number of nodes
 	 */
	if ( par->getcurrtime() == TEST_TIME ) {
		// Step 1.a. Find a node that is alive
		number = findARandomNodeThatIsAlive();

		// Step 1.b Do a read operation
		cout<<endl<<"Reading a valid key.... ... .. . ."<<endl;
		log->LOG(&mp2[number]->getMemberNode()->addr, "READ OPERATION KEY: %s VALUE: %s at time: %d", it->first.c_str(), it->second.c_str(), par->getcurrtime());
		mp2[number]->clientRead(it->first);
	}

	/** end of test1 **/

	/**
	 * Test 2: FAIL ONE REPLICA. Test if value is read correctly in quorum number of nodes after ONE OF THE REPLICAS IS FAILED
	 */
	if ( par->getcurrtime() == (TEST_TIME + FIRST_FAIL_TIME) ) {
		// Step 2.a Find a node that is alive and assign it as number
		number = findARandomNodeThatIsAlive();

		// Step 2.b Find the replicas of this key
		replicas.clear();
		replicas = mp2[number]->findNodes(it->first);
		// if less than quorum replicas are found then exit
		if ( replicas.size() < (RF-1) ) {
			cout<<endl<<"Could not find at least quorum replicas for this key. Exiting!!! size of replicas vector: "<<replicas.size()<<endl;
			log->LOG(&mp2[number]->getMemberNode()->addr, "Could not find at least quorum replicas for this key. Exiting!!! size of replicas vector: %d", replicas.size());
			exit(1);
		}

		// Step 2.c Fail a replica
		for ( int i = 0; i < par->EN_GPSZ; i++ ) {
			if ( mp2[i]->getMemberNode()->addr.getAddress() == replicas.at(replicaIdToFail).getAddress()->getAddress() ) {
				if ( !mp2[i]->getMemberNode()->bFailed ) {
					nodeToFail = i;
					failedOneNode = true;
					break;
				}
				else {
					// Since we fail at most two nodes, one of the replicas must be alive
					if ( replicaIdToFail > 0 ) {
						replicaIdToFail--;
					}
					else {
						failedOneNode = false;
					}
				}
			}
		}
		if ( failedOneNode ) {
			log->LOG(&mp2[nodeToFail]->getMemberNode()->addr, "Node failed at time=%d", par->getcurrtime());
			mp2[nodeToFail]->getMemberNode()->bFailed = true;
			mp1[nodeToFail]->getMemberNode()->bFailed = true;
			cout<<endl<<"Failed a replica node"<<endl;
		}
		else {
			// The code can never reach here
			log->LOG(&mp2[number]->getMemberNode()->addr, "Could not fail a node");
			cout<<"Could not fail a node. Exiting!!!";
			exit(1);
		}

		number = findARandomNodeThatIsAlive();

		// Step 2.d Issue a read
		cout<<endl<<"Reading a valid key.... ... .. . ."<<endl;
		log->LOG(&mp2[number]->getMemberNode()->addr, "READ OPERATION KEY: %s VALUE: %s at time: %d", it->first.c_str(), it->second.c_str(), par->getcurrtime());
		mp2[number]->clientRead(it->first);

		failedOneNode = false;
	}

	/** end of test 2 **/

	/**
	 * Test 3 part 1: Fail two replicas. Test if value is read correctly in quorum number of nodes after TWO OF THE REPLICAS ARE FAILED
	 */
	// Wait for STABILIZE_TIME and fail two replicas
	if ( par->getcurrtime() >= (TEST_TIME + FIRST_FAIL_TIME + STABILIZE_TIME) ) {
		vector<int> nodesToFail;
		nodesToFail.clear();
		int count = 0;

		if ( par->getcurrtime() == (TEST_TIME + FIRST_FAIL_TIME + STABILIZE_TIME) ) {
			// Step 3.a. Find a node that is alive
			number = findARandomNodeThatIsAlive();

			// Get the keys replicas
			replicas.clear();
			replicas = mp2[number]->findNodes(it->first);

			// Step 3.b. Fail two replicas
			//cout<<"REPLICAS SIZE: "<<replicas.size();
			if ( replicas.size() > 2 ) {
				replicaIdToFail = TERTIARY;
				while ( count != 2 ) {
					int i = 0;
					while ( i != par->EN_GPSZ ) {
						if ( mp2[i]->getMemberNode()->addr.getAddress() == replicas.at(replicaIdToFail).getAddress()->getAddress() ) {
							if ( !mp2[i]->getMemberNode()->bFailed ) {
								nodesToFail.emplace_back(i);
								replicaIdToFail--;
								count++;
								break;
							}
							else {
								// Since we fail at most two nodes, one of the replicas must be alive
								if ( replicaIdToFail > 0 ) {
									replicaIdToFail--;
								}
							}
						}
						i++;
					}
				}
			}
			else {
				// If the code reaches here. Test your stabilization protocol
				cout<<endl<<"Not enough replicas to fail two nodes. Number of replicas of this key: " <<replicas.size() <<". Exiting test case !! "<<endl;
				exit(1);
			}
			if ( count == 2 ) {
				for ( int i = 0; i < (int)nodesToFail.size(); i++ ) {
					// Fail a node
					log->LOG(&mp2[nodesToFail.at(i)]->getMemberNode()->addr, "Node failed at time=%d", par->getcurrtime());
					mp2[nodesToFail.at(i)]->getMemberNode()->bFailed = true;
					mp1[nodesToFail.at(i)]->getMemberNode()->bFailed = true;
					cout<<endl<<"Failed a replica node"<<endl;
				}
			}
			else {
				// The code can never reach here
				log->LOG(&mp2[number]->getMemberNode()->addr, "Could not fail two nodes");
				//cout<<"COUNT: " <<count;
				cout<<"Could not fail two nodes. Exiting!!!";
				exit(1);
			}

			number = findARandomNodeThatIsAlive();

			// Step 3.c Issue a read
			cout<<endl<<"Reading a valid key.... ... .. . ."<<endl;
			log->LOG(&mp2[number]->getMemberNode()->addr, "READ OPERATION KEY: %s VALUE: %s at time: %d", it->first.c_str(), it->second.c_str(), par->getcurrtime());
			// This read should fail since at least quorum nodes are not alive
			mp2[number]->clientRead(it->first);
		}

		/**
		 * TEST 3 part 2: After failing two replicas and waiting for STABILIZE_TIME, issue a read
		 */
		// Step 3.d Wait for stabilization protocol to kick in
		if ( par->getcurrtime() == (TEST_TIME + FIRST_FAIL_TIME + STABILIZE_TIME + STABILIZE_TIME) ) {
			number = findARandomNodeThatIsAlive();
			// Step 3.e Issue a read
			cout<<endl<<"Reading a valid key.... ... .. . ."<<endl;
			log->LOG(&mp2[number]->getMemberNode()->addr, "READ OPERATION KEY: %s VALUE: %s at time: %d", it->first.c_str(), it->second.c_str(), par->getcurrtime());
			// This read should be successful
			mp2[number]->clientRead(it->first);
		}
	}

	/** end of test 3 **/

	/**
	 * Test 4: FAIL A NON-REPLICA. Test if value is read correctly in quorum number of nodes after a NON-REPLICA IS FAILED
	 */
	if ( par->getcurrtime() == (TEST_TIME + FIRST_FAIL_TIME + STABILIZE_TIME + STABILIZE_TIME + LAST_FAIL_TIME ) ) {
		// Step 4.a. Find a node that is alive
		number = findARandomNodeThatIsAlive();

		// Step 4.b Find a non - replica for this key
		replicas.clear();
		replicas = mp2[number]->findNodes(it->first);
		for ( int i = 0; i < par->EN_GPSZ; i++ ) {
			if ( !mp2[i]->getMemberNode()->bFailed ) {
				if ( mp2[i]->getMemberNode()->addr.getAddress() != replicas.at(PRIMARY).getAddress()->getAddress() &&
					 mp2[i]->getMemberNode()->addr.getAddress() != replicas.at(SECONDARY).getAddress()->getAddress() &&
					 mp2[i]->getMemberNode()->addr.getAddress() != replicas.at(TERTIARY).getAddress()->getAddress() ) {
					// Step 4.c Fail a non-replica node
					log->LOG(&mp2[i]->getMemberNode()->addr, "Node failed at time=%d", par->getcurrtime());
					mp2[i]->getMemberNode()->bFailed = true;
					mp1[i]->getMemberNode()->bFailed = true;
					failedOneNode = true;
					cout<<endl<<"Failed a non-replica node"<<endl;
					break;
				}
			}
		}
		if ( !failedOneNode ) {
			// The code can never reach here
			log->LOG(&mp2[number]->getMemberNode()->addr, "Could not fail a node(non-replica)");
			cout<<"Could not fail a node(non-replica). Exiting!!!";
			exit(1);
		}

		number = findARandomNodeThatIsAlive();

		// Step 4.d Issue a read operation
		cout<<endl<<"Reading a valid key.... ... .. . ."<<endl;
		log->LOG(&mp2[number]->getMemberNode()->addr, "READ OPERATION KEY: %s VALUE: %s at time: %d", it->first.c_str(), it->second.c_str(), par->getcurrtime());
		// This read should fail since at least quorum nodes are not alive
		mp2[number]->clientRead(it->first);
	}

	/** end of test 4 **/

	/**
	 * Test 5: Read a non-existent key.
	 */
	if ( par->getcurrtime() == (TEST_TIME + FIRST_FAIL_TIME + STABILIZE_TIME + STABILIZE_TIME + LAST_FAIL_TIME ) ) {
		string invalidKey = "invalidKey";

		// Step 5.a Find a node that is alive
		number = findARandomNodeThatIsAlive();

		// Step 5.b Issue a read operation
		cout<<endl<<"Reading an invalid key.... ... .. . ."<<endl;
		log->LOG(&mp2[number]->getMemberNode()->addr, "READ OPERATION KEY: %s at time: %d", invalidKey.c_str(), par->getcurrtime());
		// This read should fail since at least quorum nodes are not alive
		mp2[number]->clientRead(invalidKey);
	}

	/** end of test 5 **/

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movq %rdi, %rbx
movq 0x78(%rdi), %rax
movq %rax, 0x8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movq 0x58(%rdi), %rdi
callq 0xabe4
cmpl $0x96, %eax
jne 0x7691
movq %rbx, %rdi
callq 0x94fc
movl %eax, %ebp
movq 0x159d0(%rip), %rdi     # 0x1cfc0
callq 0x3140
leaq 0xbe43(%rip), %rsi      # 0x1343f
movq %rax, %rdi
callq 0x3290
movq %rax, %rdi
callq 0x3140
movq 0x38(%rbx), %r14
movq 0x48(%rbx), %rax
movslq %ebp, %rbp
movq (%rax,%rbp,8), %rax
movq 0x50(%rax), %r13
movq 0x8(%rsp), %rax
movq 0x20(%rax), %r15
movq 0x40(%rax), %r12
movq 0x58(%rbx), %rdi
callq 0xabe4
addq $0x8, %r13
leaq 0xbe22(%rip), %rdx      # 0x13462
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rcx
movq %r12, %r8
movl %eax, %r9d
xorl %eax, %eax
callq 0xa106
movq 0x8(%rsp), %rax
leaq 0x20(%rax), %rsi
movq 0x48(%rbx), %rax
movq (%rax,%rbp,8), %r14
leaq 0x1e8(%rsp), %rdi
callq 0x33a0
leaq 0x1e8(%rsp), %rsi
movq %r14, %rdi
callq 0xdbae
leaq 0x1e8(%rsp), %rdi
callq 0x3120
movq 0x58(%rbx), %rdi
callq 0xabe4
cmpl $0xaf, %eax
jne 0x78f3
movq %rbx, %rdi
callq 0x94fc
movl %eax, %ebp
leaq 0x10(%rsp), %rdi
callq 0x97f0
movq 0x48(%rbx), %rax
movslq %ebp, %r12
movq (%rax,%r12,8), %r15
movq 0x8(%rsp), %rax
leaq 0x20(%rax), %r14
leaq 0x1c8(%rsp), %rdi
movq %r14, %rsi
callq 0x33a0
leaq 0x40(%rsp), %rdi
leaq 0x1c8(%rsp), %rdx
movq %r15, %rsi
callq 0xd97e
movq %r12, 0x30(%rsp)
movq %r14, 0x38(%rsp)
leaq 0x10(%rsp), %r15
leaq 0x40(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x9eb4
movq %r12, %rdi
callq 0x97f8
leaq 0x1c8(%rsp), %rdi
callq 0x3120
movq 0x8(%r15), %rax
subq (%r15), %rax
cmpq $0x21, %rax
jb 0x81cf
pushq $0x2
popq %r12
xorl %r14d, %r14d
leaq 0x40(%rsp), %r15
leaq 0xa8(%rsp), %r13
movq 0x58(%rbx), %rax
movslq 0x18(%rax), %rax
cmpq %rax, %r14
jge 0x818d
movq 0x48(%rbx), %rax
movq (%rax,%r14,8), %rax
movq 0x50(%rax), %rsi
addq $0x8, %rsi
movq %r15, %rdi
callq 0x9666
movslq %r12d, %rsi
leaq 0x10(%rsp), %rdi
callq 0x981a
movq %rax, %rdi
callq 0x10686
movq %r13, %rdi
movq %rax, %rsi
callq 0x9666
movq %r15, %rdi
movq %r13, %rsi
callq 0x56e4
movl %eax, %ebp
movq %r13, %rdi
callq 0x3120
movq %r15, %rdi
callq 0x3120
testb %bpl, %bpl
je 0x77d3
movq 0x48(%rbx), %rax
movq (%rax,%r14,8), %rax
movq 0x50(%rax), %rbp
cmpb $0x0, 0x10(%rbp)
je 0x77db
xorl %eax, %eax
testl %r12d, %r12d
setg %al
subl %eax, %r12d
incq %r14
jmp 0x774b
movq 0x38(%rbx), %r15
movq 0x58(%rbx), %rdi
callq 0xabe4
addq $0x8, %rbp
leaq 0xbb19(%rip), %rdx      # 0x1330c
movq %r15, %rdi
movq %rbp, %rsi
movl %eax, %ecx
xorl %eax, %eax
callq 0xa106
movq 0x48(%rbx), %rax
movq (%rax,%r14,8), %rax
movq 0x50(%rax), %rax
movb $0x1, %cl
movb %cl, 0x10(%rax)
movq 0x40(%rbx), %rax
movq (%rax,%r14,8), %rax
movq 0x20(%rax), %rax
movb %cl, 0x10(%rax)
movq 0x15797(%rip), %rdi     # 0x1cfc0
callq 0x3140
leaq 0xbd12(%rip), %rsi      # 0x13547
movq %rax, %rdi
callq 0x3290
movq %rax, %rdi
callq 0x3140
movq %rbx, %rdi
callq 0x94fc
movl %eax, %ebp
movq 0x1576a(%rip), %rdi     # 0x1cfc0
callq 0x3140
leaq 0xbbdd(%rip), %rsi      # 0x1343f
movq %rax, %rdi
callq 0x3290
movq %rax, %rdi
callq 0x3140
movq 0x38(%rbx), %r15
movq 0x48(%rbx), %rax
movslq %ebp, %r14
movq (%rax,%r14,8), %rax
movq 0x50(%rax), %rbp
movq 0x8(%rsp), %rax
movq 0x20(%rax), %r12
movq 0x40(%rax), %r13
movq 0x58(%rbx), %rdi
callq 0xabe4
addq $0x8, %rbp
leaq 0xbbbc(%rip), %rdx      # 0x13462
movq %r15, %rdi
movq %rbp, %rsi
movq %r12, %rcx
movq %r13, %r8
movl %eax, %r9d
xorl %eax, %eax
callq 0xa106
movq 0x48(%rbx), %rax
movq (%rax,%r14,8), %r15
leaq 0x1a8(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x33a0
leaq 0x1a8(%rsp), %rsi
movq %r15, %rdi
callq 0xdbae
leaq 0x1a8(%rsp), %rdi
callq 0x3120
movq 0x58(%rbx), %rdi
callq 0xabe4
cmpl $0xe1, %eax
jl 0x7cde
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
andq $0x0, 0x70(%rsp)
movq 0x58(%rbx), %rdi
callq 0xabe4
cmpl $0xe1, %eax
jne 0x7c0e
movq %rbx, %rdi
callq 0x94fc
movl %eax, %ebp
leaq 0x10(%rsp), %rdi
callq 0x97f0
movq 0x48(%rbx), %rax
movslq %ebp, %rcx
movq (%rax,%rcx,8), %r14
movq 0x8(%rsp), %rax
leaq 0x20(%rax), %r15
leaq 0x188(%rsp), %rdi
movq %r15, %rsi
callq 0x33a0
leaq 0x40(%rsp), %rdi
leaq 0x188(%rsp), %rdx
movq %r14, %rsi
callq 0xd97e
movq %r15, 0x30(%rsp)
leaq 0x10(%rsp), %r14
leaq 0x40(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x9eb4
movq %r15, %rdi
callq 0x97f8
leaq 0x188(%rsp), %rdi
callq 0x3120
movq 0x8(%r14), %rax
subq (%r14), %rax
cmpq $0x41, %rax
jb 0x823f
pushq $0x2
popq %r14
movl $0x0, 0x38(%rsp)
leaq 0x40(%rsp), %r15
leaq 0x10(%rsp), %r12
leaq 0xa8(%rsp), %r13
cmpl $0x2, 0x38(%rsp)
je 0x7a95
xorl %eax, %eax
movl %eax, 0x88(%rsp)
movq 0x58(%rbx), %rcx
cmpl 0x18(%rcx), %eax
je 0x79d4
movq 0x48(%rbx), %rcx
cltq
movq (%rcx,%rax,8), %rax
movq 0x50(%rax), %rsi
addq $0x8, %rsi
movq %r15, %rdi
callq 0x9666
movslq %r14d, %rsi
movq %r12, %rdi
callq 0x981a
movq %rax, %rdi
callq 0x10686
movq %r13, %rdi
movq %rax, %rsi
callq 0x9666
movq %r15, %rdi
movq %r13, %rsi
callq 0x56e4
movl %eax, %ebp
movq %r13, %rdi
callq 0x3120
movq %r15, %rdi
callq 0x3120
movslq 0x88(%rsp), %rax
testb %bpl, %bpl
je 0x7a70
movq 0x48(%rbx), %rcx
movq (%rcx,%rax,8), %rcx
movq 0x50(%rcx), %rcx
cmpb $0x0, 0x10(%rcx)
je 0x7a77
xorl %ecx, %ecx
testl %r14d, %r14d
setg %cl
subl %ecx, %r14d
incl %eax
jmp 0x79e1
leaq 0x60(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x983c
decl %r14d
incl 0x38(%rsp)
jmp 0x79d4
leaq 0x60(%rsp), %r14
leaq 0xbaa6(%rip), %r13      # 0x13547
xorl %ebp, %ebp
movq 0x68(%rsp), %rax
subq 0x60(%rsp), %rax
shrq $0x2, %rax
cltq
cmpq %rax, %rbp
jge 0x7b60
movq 0x38(%rbx), %r15
movq 0x48(%rbx), %r12
movq %r14, %rdi
movq %rbp, %rsi
callq 0x9870
movslq (%rax), %rax
movq (%r12,%rax,8), %rax
movq 0x50(%rax), %r12
movq 0x58(%rbx), %rdi
callq 0xabe4
addq $0x8, %r12
movq %r15, %rdi
movq %r12, %rsi
leaq 0xb818(%rip), %rdx      # 0x1330c
movl %eax, %ecx
xorl %eax, %eax
callq 0xa106
movq 0x48(%rbx), %r15
movq %r14, %rdi
movq %rbp, %rsi
callq 0x9870
movslq (%rax), %rax
movq (%r15,%rax,8), %rax
movq 0x50(%rax), %rax
movb $0x1, 0x10(%rax)
movq 0x40(%rbx), %r15
movq %r14, %rdi
movq %rbp, %rsi
callq 0x9870
movslq (%rax), %rax
movq (%r15,%rax,8), %rax
movq 0x20(%rax), %rax
movb $0x1, 0x10(%rax)
movq 0x15480(%rip), %rdi     # 0x1cfc0
callq 0x3140
movq %rax, %rdi
movq %r13, %rsi
callq 0x3290
movq %rax, %rdi
callq 0x3140
incq %rbp
jmp 0x7aa3
movq %rbx, %rdi
callq 0x94fc
movl %eax, %ebp
movq 0x1544f(%rip), %rdi     # 0x1cfc0
callq 0x3140
leaq 0xb8c2(%rip), %rsi      # 0x1343f
movq %rax, %rdi
callq 0x3290
movq %rax, %rdi
callq 0x3140
movq 0x38(%rbx), %r14
movq 0x48(%rbx), %rax
movslq %ebp, %rbp
movq (%rax,%rbp,8), %rax
movq 0x50(%rax), %r13
movq 0x8(%rsp), %rax
movq 0x20(%rax), %r15
movq 0x40(%rax), %r12
movq 0x58(%rbx), %rdi
callq 0xabe4
addq $0x8, %r13
leaq 0xb8a1(%rip), %rdx      # 0x13462
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rcx
movq %r12, %r8
movl %eax, %r9d
xorl %eax, %eax
callq 0xa106
movq 0x48(%rbx), %rax
movq (%rax,%rbp,8), %r14
leaq 0x168(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x33a0
leaq 0x168(%rsp), %rsi
movq %r14, %rdi
callq 0xdbae
leaq 0x168(%rsp), %rdi
callq 0x3120
movq 0x58(%rbx), %rdi
callq 0xabe4
cmpl $0x113, %eax            # imm = 0x113
jne 0x7cd4
movq %rbx, %rdi
callq 0x94fc
movl %eax, %ebp
movq 0x1538d(%rip), %rdi     # 0x1cfc0
callq 0x3140
leaq 0xb800(%rip), %rsi      # 0x1343f
movq %rax, %rdi
callq 0x3290
movq %rax, %rdi
callq 0x3140
movq 0x38(%rbx), %r14
movq 0x48(%rbx), %rax
movslq %ebp, %rbp
movq (%rax,%rbp,8), %rax
movq 0x50(%rax), %r13
movq 0x8(%rsp), %rax
movq 0x20(%rax), %r15
movq 0x40(%rax), %r12
movq 0x58(%rbx), %rdi
callq 0xabe4
addq $0x8, %r13
leaq 0xb7df(%rip), %rdx      # 0x13462
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rcx
movq %r12, %r8
movl %eax, %r9d
xorl %eax, %eax
callq 0xa106
movq 0x8(%rsp), %rax
leaq 0x20(%rax), %rsi
movq 0x48(%rbx), %rax
movq (%rax,%rbp,8), %r14
leaq 0x148(%rsp), %rdi
callq 0x33a0
leaq 0x148(%rsp), %rsi
movq %r14, %rdi
callq 0xdbae
leaq 0x148(%rsp), %rdi
callq 0x3120
leaq 0x60(%rsp), %rdi
callq 0x9f26
movq 0x58(%rbx), %rdi
callq 0xabe4
cmpl $0x11d, %eax            # imm = 0x11D
jne 0x8058
movq %rbx, %rdi
callq 0x94fc
movl %eax, %ebp
leaq 0x10(%rsp), %rdi
callq 0x97f0
movq 0x48(%rbx), %rax
movslq %ebp, %r12
movq (%rax,%r12,8), %r14
movq 0x8(%rsp), %rax
leaq 0x20(%rax), %r15
leaq 0x128(%rsp), %rdi
movq %r15, %rsi
callq 0x33a0
movq %r12, 0x80(%rsp)
movq %r15, 0x30(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x128(%rsp), %rdx
movq %r14, %rsi
callq 0xd97e
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %r14
movq %r14, %rsi
callq 0x9eb4
movq %r14, %rdi
callq 0x97f8
leaq 0x128(%rsp), %rdi
callq 0x3120
xorl %r14d, %r14d
leaq 0xa8(%rsp), %r12
leaq 0x60(%rsp), %rbp
leaq 0x88(%rsp), %r13
movq 0x58(%rbx), %rax
movslq 0x18(%rax), %rax
cmpq %rax, %r14
jge 0x814e
movq 0x48(%rbx), %rax
movq (%rax,%r14,8), %rax
movq 0x50(%rax), %rsi
cmpb $0x0, 0x10(%rsi)
jne 0x7f2c
addq $0x8, %rsi
leaq 0x40(%rsp), %rdi
callq 0x9666
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x981a
movq %rax, %rdi
callq 0x10686
movq %r12, %rdi
movq %rax, %rsi
callq 0x9666
movq %rbx, %r15
movq %r12, %rbx
leaq 0x40(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x9891
testb %al, %al
je 0x7eef
movq 0x48(%r15), %rax
movq (%rax,%r14,8), %rax
movq 0x50(%rax), %rsi
addq $0x8, %rsi
movq %rbp, %rdi
callq 0x9666
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x981a
movq %rax, %rdi
callq 0x10686
movq %r13, %rdi
movq %rax, %rsi
callq 0x9666
movq %rbp, %rdi
movq %r13, %r12
movq %r13, %rsi
callq 0x9891
testb %al, %al
je 0x7f01
movq 0x48(%r15), %rax
movq (%rax,%r14,8), %rax
movq 0x50(%rax), %rsi
addq $0x8, %rsi
leaq 0x108(%rsp), %rdi
callq 0x9666
leaq 0x10(%rsp), %rdi
pushq $0x2
popq %rsi
callq 0x981a
movq %rax, %rdi
callq 0x10686
leaq 0x208(%rsp), %rdi
movq %rax, %rsi
callq 0x9666
leaq 0x108(%rsp), %rdi
leaq 0x208(%rsp), %r12
movq %r12, %rsi
callq 0x9891
movb %al, 0x38(%rsp)
movq %r12, %rdi
callq 0x3120
leaq 0x108(%rsp), %rdi
callq 0x3120
movq %r13, %rdi
callq 0x3120
movq %rbp, %rdi
callq 0x3120
movq %rbx, %rdi
callq 0x3120
leaq 0x40(%rsp), %rdi
callq 0x3120
cmpb $0x0, 0x38(%rsp)
movq %rbx, %r12
movq %r15, %rbx
je 0x7f2c
jmp 0x7f34
movq %rbx, %rdi
callq 0x3120
movq %r12, %rdi
callq 0x3120
jmp 0x7f26
movq %r12, %rdi
callq 0x3120
movq %rbp, %rdi
callq 0x3120
movq %rbx, %rdi
callq 0x3120
leaq 0x40(%rsp), %rdi
callq 0x3120
movq %r12, %r13
movq %rbx, %r12
movq %r15, %rbx
incq %r14
jmp 0x7d8b
movq 0x38(%rbx), %r12
movq 0x48(%rbx), %rax
movq (%rax,%r14,8), %rax
movq 0x50(%rax), %r15
movq 0x58(%rbx), %rdi
callq 0xabe4
addq $0x8, %r15
leaq 0xb3b4(%rip), %rdx      # 0x1330c
movq %r12, %rdi
movq %r15, %rsi
movl %eax, %ecx
xorl %eax, %eax
callq 0xa106
movq 0x48(%rbx), %rax
movq (%rax,%r14,8), %rax
movq 0x50(%rax), %rax
movb $0x1, %cl
movb %cl, 0x10(%rax)
movq 0x40(%rbx), %rax
movq (%rax,%r14,8), %rax
movq 0x20(%rax), %rax
movb %cl, 0x10(%rax)
movq 0x15032(%rip), %rdi     # 0x1cfc0
callq 0x3140
leaq 0xb681(%rip), %rsi      # 0x1361b
movq %rax, %rdi
callq 0x3290
movq %rax, %rdi
callq 0x3140
movq %rbx, %rdi
callq 0x94fc
movl %eax, %ebp
movq 0x15005(%rip), %rdi     # 0x1cfc0
callq 0x3140
leaq 0xb478(%rip), %rsi      # 0x1343f
movq %rax, %rdi
callq 0x3290
movq %rax, %rdi
callq 0x3140
movq 0x38(%rbx), %r14
movq 0x48(%rbx), %rax
movslq %ebp, %rbp
movq (%rax,%rbp,8), %rax
movq 0x50(%rax), %r13
movq 0x8(%rsp), %rax
movq 0x20(%rax), %r15
movq 0x40(%rax), %r12
movq 0x58(%rbx), %rdi
callq 0xabe4
addq $0x8, %r13
leaq 0xb457(%rip), %rdx      # 0x13462
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rcx
movq %r12, %r8
movl %eax, %r9d
xorl %eax, %eax
callq 0xa106
movq 0x48(%rbx), %rax
movq (%rax,%rbp,8), %r14
leaq 0xe8(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x33a0
leaq 0xe8(%rsp), %rsi
movq %r14, %rdi
callq 0xdbae
leaq 0xe8(%rsp), %rdi
callq 0x3120
movq 0x58(%rbx), %rdi
callq 0xabe4
cmpl $0x11d, %eax            # imm = 0x11D
jne 0x8132
leaq 0xb39c(%rip), %rsi      # 0x1340f
leaq 0x40(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
callq 0x4bc2
movq %rbx, %rdi
callq 0x94fc
movl %eax, %ebp
movq 0x14f2a(%rip), %rdi     # 0x1cfc0
callq 0x3140
leaq 0xb5e5(%rip), %rsi      # 0x13687
movq %rax, %rdi
callq 0x3290
movq %rax, %rdi
callq 0x3140
movq 0x38(%rbx), %r14
movq 0x48(%rbx), %rax
movslq %ebp, %r13
movq (%rax,%r13,8), %rax
movq 0x50(%rax), %r12
movq 0x40(%rsp), %r15
movq 0x58(%rbx), %rdi
callq 0xabe4
addq $0x8, %r12
leaq 0xb5cf(%rip), %rdx      # 0x136ad
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rcx
movl %eax, %r8d
xorl %eax, %eax
callq 0xa106
movq 0x48(%rbx), %rax
movq (%rax,%r13,8), %rbx
leaq 0xc8(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x33a0
leaq 0xc8(%rsp), %rsi
movq %rbx, %rdi
callq 0xdbae
leaq 0xc8(%rsp), %rdi
callq 0x3120
leaq 0x40(%rsp), %rdi
callq 0x3120
leaq 0x10(%rsp), %rdi
callq 0x97f8
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x38(%rbx), %rdi
movq 0x48(%rbx), %rax
movq 0x80(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %rsi
addq $0x8, %rsi
leaq 0xb4c4(%rip), %rdx      # 0x13635
xorl %eax, %eax
callq 0xa106
movq 0x14e41(%rip), %rdi     # 0x1cfc0
leaq 0xb4d2(%rip), %rsi      # 0x13658
callq 0x3290
jmp 0x81c7
movq 0x38(%rbx), %rdi
movq 0x48(%rbx), %rax
movq 0x30(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %rsi
addq $0x8, %rsi
leaq 0xb3b0(%rip), %rdx      # 0x1355d
xorl %eax, %eax
callq 0xa106
movq 0x14e05(%rip), %rdi     # 0x1cfc0
leaq 0xb3b1(%rip), %rsi      # 0x13573
callq 0x3290
pushq $0x1
popq %rdi
callq 0x3350
movq 0x14dea(%rip), %rdi     # 0x1cfc0
callq 0x3140
leaq 0xb2ad(%rip), %rsi      # 0x1348f
movq %rax, %rdi
callq 0x3290
movq 0x18(%rsp), %rsi
subq 0x10(%rsp), %rsi
sarq $0x5, %rsi
movq %rax, %rdi
callq 0x31c0
movq %rax, %rdi
callq 0x3140
movq 0x38(%rbx), %rdi
movq 0x48(%rbx), %rax
movq 0x30(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %rsi
addq $0x8, %rsi
movq 0x18(%rsp), %rcx
subq 0x10(%rsp), %rcx
sarq $0x5, %rcx
leaq 0xb2b4(%rip), %rdx      # 0x134ea
xorl %eax, %eax
callq 0xa106
jmp 0x81c7
movq 0x14d7a(%rip), %rdi     # 0x1cfc0
callq 0x3140
leaq 0xb343(%rip), %rsi      # 0x13595
movq %rax, %rdi
callq 0x3290
movq 0x18(%rsp), %rsi
subq 0x10(%rsp), %rsi
sarq $0x5, %rsi
movq %rax, %rdi
callq 0x31c0
leaq 0xb4da(%rip), %rsi      # 0x13751
movq %rax, %rdi
callq 0x3290
movq %rax, %rdi
callq 0x3140
jmp 0x81c7
movq %rax, %rbx
leaq 0x168(%rsp), %rdi
jmp 0x839d
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
jmp 0x839d
movq %rax, %rbx
leaq 0x188(%rsp), %rdi
jmp 0x839d
jmp 0x8381
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
jmp 0x838e
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
jmp 0x8373
jmp 0x837c
movq %rax, %rbx
leaq 0x128(%rsp), %rdi
jmp 0x838e
jmp 0x837c
movq %rax, %rbx
leaq 0x1a8(%rsp), %rdi
jmp 0x838e
movq %rax, %rbx
leaq 0x1e8(%rsp), %rdi
jmp 0x838e
movq %rax, %rbx
leaq 0x1c8(%rsp), %rdi
jmp 0x838e
jmp 0x837c
jmp 0x837c
jmp 0x8381
jmp 0x8386
jmp 0x8381
movq %rax, %rbx
jmp 0x834b
movq %rax, %rbx
jmp 0x836b
jmp 0x837c
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x3120
leaq 0x88(%rsp), %rdi
callq 0x3120
jmp 0x8361
jmp 0x8381
jmp 0x837c
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x3120
leaq 0xa8(%rsp), %rdi
callq 0x3120
jmp 0x8389
jmp 0x8386
movq %rax, %rbx
jmp 0x83ac
movq %rax, %rbx
jmp 0x83a2
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x3120
jmp 0x83ac
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x3120
leaq 0x60(%rsp), %rdi
callq 0x9f26
leaq 0x10(%rsp), %rdi
callq 0x97f8
movq %rbx, %rdi
callq 0x3490