// File: PrarabdhJoshi[P]DatabaseImplementation/Comparison.cc
// Function: CNF::GrowFromParseTree(AndList*, Schema*, Schema*, Record&)
void CNF :: GrowFromParseTree (struct AndList *parseTree, Schema *leftSchema, 
	Schema *rightSchema, Record &literal) {

	CNF &cnf = *this;

	// as kind of a hack, the literal record is built up insiide of a text file,
	// where it will be read in from subsequently
	FILE *outRecFile = fopen ("sdafdsfFFDSDA", "w");

	// also as kind of a hack, the schema for the literal record is built up
	// inside of a text file, where it will also be read from subsequently
	FILE *outSchemaFile = fopen ("hkljdfgkSDFSDF", "w");
	fprintf (outSchemaFile, "BEGIN\ntempSchema\nwherever\n");

	// this tells us the size of the literal record
	int numFieldsInLiteral = 0;

	// now we go through and build the comparison structure
	for (int whichAnd = 0; 1; whichAnd++, parseTree = parseTree->rightAnd) {
		
		// see if we have run off of the end of all of the ANDs
		if (parseTree == NULL) {
			cnf.numAnds = whichAnd;
			break;
		}	

		// we have not, so copy over all of the ORs hanging off of this AND
		struct OrList *myOr = parseTree->left;
		for (int whichOr = 0; 1; whichOr++, myOr = myOr->rightOr) {

			// see if we have run off of the end of the ORs
			if (myOr == NULL) {
				cnf.orLens[whichAnd] = whichOr;
				break;
			}

			// we have not run off the list, so add the current OR in!
			
			// these store the types of the two values that are found
			Type typeLeft;
			Type typeRight;


			// first thing is to deal with the left operand
			// so we check to see if it is an attribute name, and if so,
			// we look it up in the schema
			if (myOr->left->left->code == NAME) {
				
				// see if we can find this attribute in the left schema
				if (leftSchema->Find (myOr->left->left->value) != -1) {
					cnf.orList[whichAnd][whichOr].operand1 = Left;
					cnf.orList[whichAnd][whichOr].whichAtt1 =
						leftSchema->Find (myOr->left->left->value);	
					typeLeft = leftSchema->FindType (myOr->left->left->value);

				// see if we can find it in the right schema
				} else if (rightSchema->Find (myOr->left->left->value) != -1) {
                                        cnf.orList[whichAnd][whichOr].operand1 = Right;
                                        cnf.orList[whichAnd][whichOr].whichAtt1 =
                                                rightSchema->Find (myOr->left->left->value);
                                        typeLeft = rightSchema->FindType (myOr->left->left->value);

				// it is not there!  So there is an error in the query
                                } else {
					cout << "ERROR: Could not find attribute " <<
						myOr->left->left->value << "\n";
					exit (1);	
				}

			// the next thing is to see if we have a string; if so, add it to the 
			// literal record that stores all of the comparison values
			} else if (myOr->left->left->code == STRING) {

				cnf.orList[whichAnd][whichOr].operand1 = Literal;
				cnf.orList[whichAnd][whichOr].whichAtt1 = numFieldsInLiteral;
				AddLitToFile (numFieldsInLiteral, outRecFile, outSchemaFile, myOr->left->left->value, String);
				typeLeft = String;

			// see if it is an integer
			} else if (myOr->left->left->code == INT) {

				cnf.orList[whichAnd][whichOr].operand1 = Literal;
				cnf.orList[whichAnd][whichOr].whichAtt1 = numFieldsInLiteral;
				AddLitToFile (numFieldsInLiteral, outRecFile, outSchemaFile, myOr->left->left->value, Int);
				typeLeft = Int;

			// see if it is a double
			} else if (myOr->left->left->code == DOUBLE) {

				cnf.orList[whichAnd][whichOr].operand1 = Literal;
				cnf.orList[whichAnd][whichOr].whichAtt1 = numFieldsInLiteral;
				AddLitToFile (numFieldsInLiteral, outRecFile, outSchemaFile, myOr->left->left->value, Double);
				typeLeft = Double;
	
			// catch-all case
			} else {
				cerr << "You gave me some strange type for an operand that I do not recognize!!\n";
				exit (1);
			}

			// now that we have dealt with the left operand, we need to deal with the
			// right operand
			if (myOr->left->right->code == NAME) {
				
				// see if we can find this attribute in the left schema
				if (leftSchema->Find (myOr->left->right->value) != -1) {
					cnf.orList[whichAnd][whichOr].operand2 = Left;
					cnf.orList[whichAnd][whichOr].whichAtt2 =
						leftSchema->Find (myOr->left->right->value);	
					typeRight = leftSchema->FindType (myOr->left->right->value);

				// see if we can find it in the right schema
				} else if (rightSchema->Find (myOr->left->right->value) != -1) {
                                        cnf.orList[whichAnd][whichOr].operand2 = Right;
                                        cnf.orList[whichAnd][whichOr].whichAtt2 =
                                                rightSchema->Find (myOr->left->right->value);
					typeRight = rightSchema->FindType (myOr->left->right->value);

				// it is not there!  So there is an error in the query
                                } else {
					cout << "ERROR: Could not find attribute " << myOr->left->right->value << "\n";
					exit (1);	
				}

			// the next thing is to see if we have a string; if so, add it to the 
			// literal record that stores all of the comparison values
			} else if (myOr->left->right->code == STRING) {

				cnf.orList[whichAnd][whichOr].operand2 = Literal;
				cnf.orList[whichAnd][whichOr].whichAtt2 = numFieldsInLiteral;
				AddLitToFile (numFieldsInLiteral, outRecFile, outSchemaFile, myOr->left->right->value, String);
				typeRight = String;

			// see if it is an integer
			} else if (myOr->left->right->code == INT) {

				cnf.orList[whichAnd][whichOr].operand2 = Literal;
				cnf.orList[whichAnd][whichOr].whichAtt2 = numFieldsInLiteral;
				AddLitToFile (numFieldsInLiteral, outRecFile, outSchemaFile, myOr->left->right->value, Int);
				typeRight = Int;

			// see if it is a double
			} else if (myOr->left->right->code == DOUBLE) {

				cnf.orList[whichAnd][whichOr].operand2 = Literal;
				cnf.orList[whichAnd][whichOr].whichAtt2 = numFieldsInLiteral;
				AddLitToFile (numFieldsInLiteral, outRecFile, outSchemaFile, myOr->left->right->value, Double);
				typeRight = Double;
	
			// catch-all case
			} else {
				cerr << "You gave me some strange type for an operand that I do not recognize!!\n";
				exit (1);
			}

			

			// now we check to make sure that there was not a type mismatch
			if (typeLeft != typeRight) {
				cerr << "ERROR! Type mismatch in CNF.  " << myOr->left->left->value << " and "
					<< myOr->left->right->value << " were found to not match.\n";
				exit (1);
			}

			// set up the type info for this comparison
			cnf.orList[whichAnd][whichOr].attType = typeLeft;

			// and finally set up the comparison operator for this comparison
			if (myOr->left->code == LESS_THAN) {
				cnf.orList[whichAnd][whichOr].op = LessThan;	
			} else if (myOr->left->code == GREATER_THAN) {
				cnf.orList[whichAnd][whichOr].op = GreaterThan;	
			} else if (myOr->left->code == EQUALS) {
				cnf.orList[whichAnd][whichOr].op = Equals;
			} else {
				cerr << "BAD: found a comparison op I don't recognize.\n";
				exit (1);
			}
		
		}
	}

	// the very last thing is to set up the literal record; first close the
	// file where its information has been stored
	fclose (outRecFile);
	fprintf (outSchemaFile, "END\n");
	fclose (outSchemaFile);

	// and open up the record file
	outRecFile = fopen ("sdafdsfFFDSDA", "r");

	// read in the record's schema
	Schema mySchema("hkljdfgkSDFSDF", "tempSchema");

	// and get the record
	literal.SuckNextRecord (&mySchema, outRecFile);

	// close the record file
	fclose (outRecFile);

	remove("sdafdsfFFDSDA");
	remove("hkljdfgkSDFSDF");
}

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x90(%rsp)
movq %rsi, 0x88(%rsp)
movq %rdx, 0x80(%rsp)
movq %rcx, 0x78(%rsp)
movq %r8, 0x70(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x68(%rsp)
leaq 0x83c3(%rip), %rdi      # 0xc0f0
leaq 0x8d09(%rip), %rsi      # 0xca3d
callq 0x21a0
movq %rax, 0x60(%rsp)
leaq 0x83b9(%rip), %rdi      # 0xc0fe
leaq 0x8cf1(%rip), %rsi      # 0xca3d
callq 0x21a0
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rdi
leaq 0x83ab(%rip), %rsi      # 0xc10d
movb $0x0, %al
callq 0x2210
movl $0x0, 0x54(%rsp)
movl $0x0, 0x50(%rsp)
movb $0x1, %al
testb $0x1, %al
jne 0x3d84
jmp 0x46dd
cmpq $0x0, 0x88(%rsp)
jne 0x3da3
movl 0x50(%rsp), %ecx
movq 0x68(%rsp), %rax
movl %ecx, 0x25d0(%rax)
jmp 0x46dd
movq 0x88(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x48(%rsp)
movl $0x0, 0x44(%rsp)
movb $0x1, %al
testb $0x1, %al
jne 0x3dc6
jmp 0x46b7
cmpq $0x0, 0x48(%rsp)
jne 0x3de8
movl 0x44(%rsp), %edx
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rcx
movl %edx, 0x2580(%rax,%rcx,4)
jmp 0x46b7
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
cmpl $0x4, (%rax)
jne 0x3fa4
movq 0x80(%rsp), %rdi
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x5c20
cmpl $-0x1, %eax
je 0x3eb1
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rcx
imulq $0x1e0, %rcx, %rcx      # imm = 0x1E0
addq %rcx, %rax
movslq 0x44(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x0, (%rax)
movq 0x80(%rsp), %rdi
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x5c20
movl %eax, %ecx
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rdx
imulq $0x1e0, %rdx, %rdx      # imm = 0x1E0
addq %rdx, %rax
movslq 0x44(%rsp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movq 0x80(%rsp), %rdi
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x5ca0
movl %eax, 0x40(%rsp)
jmp 0x3f9f
movq 0x78(%rsp), %rdi
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x5c20
cmpl $-0x1, %eax
je 0x3f59
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rcx
imulq $0x1e0, %rcx, %rcx      # imm = 0x1E0
addq %rcx, %rax
movslq 0x44(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x1, (%rax)
movq 0x78(%rsp), %rdi
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x5c20
movl %eax, %ecx
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rdx
imulq $0x1e0, %rdx, %rdx      # imm = 0x1E0
addq %rdx, %rax
movslq 0x44(%rsp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movq 0x78(%rsp), %rdi
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x5ca0
movl %eax, 0x40(%rsp)
jmp 0x3f9d
movq 0xc058(%rip), %rdi      # 0xffb8
leaq 0x81c1(%rip), %rsi      # 0xc128
callq 0x2140
movq %rax, %rdi
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x2140
movq %rax, %rdi
leaq 0x8be7(%rip), %rsi      # 0xcb75
callq 0x2140
movl $0x1, %edi
callq 0x21c0
jmp 0x3f9f
jmp 0x418c
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
cmpl $0x3, (%rax)
jne 0x403d
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rcx
imulq $0x1e0, %rcx, %rcx      # imm = 0x1E0
addq %rcx, %rax
movslq 0x44(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x2, (%rax)
movl 0x54(%rsp), %ecx
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rdx
imulq $0x1e0, %rdx, %rdx      # imm = 0x1E0
addq %rdx, %rax
movslq 0x44(%rsp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movq 0x60(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rcx
leaq 0x54(%rsp), %rdi
movl $0x2, %r8d
callq 0x3c20
movl $0x2, 0x40(%rsp)
jmp 0x418a
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
cmpl $0x2, (%rax)
jne 0x40d3
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rcx
imulq $0x1e0, %rcx, %rcx      # imm = 0x1E0
addq %rcx, %rax
movslq 0x44(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x2, (%rax)
movl 0x54(%rsp), %ecx
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rdx
imulq $0x1e0, %rdx, %rdx      # imm = 0x1E0
addq %rdx, %rax
movslq 0x44(%rsp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movq 0x60(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rcx
leaq 0x54(%rsp), %rdi
xorl %r8d, %r8d
callq 0x3c20
movl $0x0, 0x40(%rsp)
jmp 0x4188
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
cmpl $0x1, (%rax)
jne 0x4169
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rcx
imulq $0x1e0, %rcx, %rcx      # imm = 0x1E0
addq %rcx, %rax
movslq 0x44(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x2, (%rax)
movl 0x54(%rsp), %ecx
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rdx
imulq $0x1e0, %rdx, %rdx      # imm = 0x1E0
addq %rdx, %rax
movslq 0x44(%rsp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movq 0x60(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rcx
leaq 0x54(%rsp), %rdi
movl $0x1, %r8d
callq 0x3c20
movl $0x1, 0x40(%rsp)
jmp 0x4186
movq 0xbe78(%rip), %rdi      # 0xffe8
leaq 0x7fd2(%rip), %rsi      # 0xc149
callq 0x2140
movl $0x1, %edi
callq 0x21c0
jmp 0x4188
jmp 0x418a
jmp 0x418c
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
cmpl $0x4, (%rax)
jne 0x434a
movq 0x80(%rsp), %rdi
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x5c20
cmpl $-0x1, %eax
je 0x4256
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rcx
imulq $0x1e0, %rcx, %rcx      # imm = 0x1E0
addq %rcx, %rax
movslq 0x44(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x8(%rax)
movq 0x80(%rsp), %rdi
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x5c20
movl %eax, %ecx
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rdx
imulq $0x1e0, %rdx, %rdx      # imm = 0x1E0
addq %rdx, %rax
movslq 0x44(%rsp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
movq 0x80(%rsp), %rdi
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x5ca0
movl %eax, 0x3c(%rsp)
jmp 0x4345
movq 0x78(%rsp), %rdi
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x5c20
cmpl $-0x1, %eax
je 0x42ff
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rcx
imulq $0x1e0, %rcx, %rcx      # imm = 0x1E0
addq %rcx, %rax
movslq 0x44(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x1, 0x8(%rax)
movq 0x78(%rsp), %rdi
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x5c20
movl %eax, %ecx
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rdx
imulq $0x1e0, %rdx, %rdx      # imm = 0x1E0
addq %rdx, %rax
movslq 0x44(%rsp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
movq 0x78(%rsp), %rdi
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x5ca0
movl %eax, 0x3c(%rsp)
jmp 0x4343
movq 0xbcb2(%rip), %rdi      # 0xffb8
leaq 0x7e1b(%rip), %rsi      # 0xc128
callq 0x2140
movq %rax, %rdi
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x2140
movq %rax, %rdi
leaq 0x8841(%rip), %rsi      # 0xcb75
callq 0x2140
movl $0x1, %edi
callq 0x21c0
jmp 0x4345
jmp 0x4535
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
cmpl $0x3, (%rax)
jne 0x43e4
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rcx
imulq $0x1e0, %rcx, %rcx      # imm = 0x1E0
addq %rcx, %rax
movslq 0x44(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x2, 0x8(%rax)
movl 0x54(%rsp), %ecx
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rdx
imulq $0x1e0, %rdx, %rdx      # imm = 0x1E0
addq %rdx, %rax
movslq 0x44(%rsp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
movq 0x60(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rcx
leaq 0x54(%rsp), %rdi
movl $0x2, %r8d
callq 0x3c20
movl $0x2, 0x3c(%rsp)
jmp 0x4533
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
cmpl $0x2, (%rax)
jne 0x447b
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rcx
imulq $0x1e0, %rcx, %rcx      # imm = 0x1E0
addq %rcx, %rax
movslq 0x44(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x2, 0x8(%rax)
movl 0x54(%rsp), %ecx
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rdx
imulq $0x1e0, %rdx, %rdx      # imm = 0x1E0
addq %rdx, %rax
movslq 0x44(%rsp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
movq 0x60(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rcx
leaq 0x54(%rsp), %rdi
xorl %r8d, %r8d
callq 0x3c20
movl $0x0, 0x3c(%rsp)
jmp 0x4531
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
cmpl $0x1, (%rax)
jne 0x4512
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rcx
imulq $0x1e0, %rcx, %rcx      # imm = 0x1E0
addq %rcx, %rax
movslq 0x44(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x2, 0x8(%rax)
movl 0x54(%rsp), %ecx
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rdx
imulq $0x1e0, %rdx, %rdx      # imm = 0x1E0
addq %rdx, %rax
movslq 0x44(%rsp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
movq 0x60(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rcx
leaq 0x54(%rsp), %rdi
movl $0x1, %r8d
callq 0x3c20
movl $0x1, 0x3c(%rsp)
jmp 0x452f
movq 0xbacf(%rip), %rdi      # 0xffe8
leaq 0x7c29(%rip), %rsi      # 0xc149
callq 0x2140
movl $0x1, %edi
callq 0x21c0
jmp 0x4531
jmp 0x4533
jmp 0x4535
movl 0x40(%rsp), %eax
cmpl 0x3c(%rsp), %eax
je 0x45aa
movq 0xbaa2(%rip), %rdi      # 0xffe8
leaq 0x7c44(%rip), %rsi      # 0xc191
callq 0x2140
movq %rax, %rdi
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x2140
movq %rax, %rdi
leaq 0x7c3c(%rip), %rsi      # 0xc1b0
callq 0x2140
movq %rax, %rdi
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x2140
movq %rax, %rdi
leaq 0x7c1b(%rip), %rsi      # 0xc1b6
callq 0x2140
movl $0x1, %edi
callq 0x21c0
movl 0x40(%rsp), %ecx
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rdx
imulq $0x1e0, %rdx, %rdx      # imm = 0x1E0
addq %rdx, %rax
movslq 0x44(%rsp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
movq 0x48(%rsp), %rax
movq (%rax), %rax
cmpl $0x1, (%rax)
jne 0x460a
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rcx
imulq $0x1e0, %rcx, %rcx      # imm = 0x1E0
addq %rcx, %rax
movslq 0x44(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x14(%rax)
jmp 0x4697
movq 0x48(%rsp), %rax
movq (%rax), %rax
cmpl $0x2, (%rax)
jne 0x4640
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rcx
imulq $0x1e0, %rcx, %rcx      # imm = 0x1E0
addq %rcx, %rax
movslq 0x44(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x1, 0x14(%rax)
jmp 0x4695
movq 0x48(%rsp), %rax
movq (%rax), %rax
cmpl $0x3, (%rax)
jne 0x4676
movq 0x68(%rsp), %rax
movslq 0x50(%rsp), %rcx
imulq $0x1e0, %rcx, %rcx      # imm = 0x1E0
addq %rcx, %rax
movslq 0x44(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x2, 0x14(%rax)
jmp 0x4693
movq 0xb96b(%rip), %rdi      # 0xffe8
leaq 0x7b4d(%rip), %rsi      # 0xc1d1
callq 0x2140
movl $0x1, %edi
callq 0x21c0
jmp 0x4695
jmp 0x4697
jmp 0x4699
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x48(%rsp)
jmp 0x3dbb
jmp 0x46b9
movl 0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50(%rsp)
movq 0x88(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x88(%rsp)
jmp 0x3d79
movq 0x60(%rsp), %rdi
callq 0x2150
movq 0x58(%rsp), %rdi
leaq 0x7b0d(%rip), %rsi      # 0xc200
xorl %eax, %eax
callq 0x2210
movq 0x58(%rsp), %rdi
callq 0x2150
leaq 0x79e5(%rip), %rdi      # 0xc0f0
leaq 0x83b0(%rip), %rsi      # 0xcac2
callq 0x21a0
movq %rax, 0x60(%rsp)
leaq 0x79db(%rip), %rsi      # 0xc0fe
leaq 0x7adb(%rip), %rdx      # 0xc205
leaq 0x20(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x5d50
movq 0x8(%rsp), %rsi
movq 0x70(%rsp), %rdi
movq 0x60(%rsp), %rdx
callq 0x26d0
jmp 0x474f
movq 0x60(%rsp), %rdi
callq 0x2150
jmp 0x475b
leaq 0x798e(%rip), %rdi      # 0xc0f0
callq 0x22c0
leaq 0x7990(%rip), %rdi      # 0xc0fe
callq 0x22c0
leaq 0x20(%rsp), %rdi
callq 0x6160
addq $0x98, %rsp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x18(%rsp)
movl %eax, 0x14(%rsp)
leaq 0x20(%rsp), %rdi
callq 0x6160
movq 0x18(%rsp), %rdi
callq 0x22b0
nopw (%rax,%rax)