// File: /workspace/github_cpp_makefile_star2_O2/AshOlogn[P]ash-language-interpreter/src/parser.cpp
// Function: parseFunction(unsigned int, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
Function* parseFunction(uint32_t startLine, uint32_t secondStartLine, string functionName) {

	//now create a Function struct
	Function* function = (Function*) malloc(sizeof(Function));
	function->returnFlag = (bool*) malloc(sizeof(bool));
	function->returnValue = (ParseData*) malloc(sizeof(ParseData));

	//assign the global returnFlag and returnValue pointers to this function
	returnFlag.push_back(function->returnFlag);
	returnValue.push_back(function->returnValue);

	//now read in arguments enclosed in parentheses
	Token* leftParenToken = consume(); //consume (

	//if the next token is not a parenthesis, throw an error
	if(leftParenToken->type != LEFT_PAREN) {

		uint32_t endLine = (leftParenToken->type == END) ? secondStartLine : leftParenToken->line+1;

		if(leftParenToken->type == END) {
			throw ParseSyntaxError(startLine, endLine, getCodeLineBlock(startLine-1, endLine-1), "Expected '(' to begin function parameter list"); 
		} else {
			throw ParseSyntaxError(startLine, endLine, getCodeLineBlock(startLine-1, endLine-1), leftParenToken->lexeme, "Expected '(' to begin function parameter list");
		}
	}

	//first scan to figure out how many arguments must be allocated in Function
	uint32_t currentIndex = 0;
	uint32_t argCount = 0;

	uint32_t currentErrorLine = leftParenToken->line+1;
	while(peekAhead(currentIndex)->type != RIGHT_PAREN) {

		//make sure you have a type then variable
		if(!isTypeTokenType(peekAhead(currentIndex)->type)) {

			Token* tempTypeToken = peekAhead(currentIndex);	
			uint32_t endLine = (tempTypeToken->type == END) ? currentErrorLine : tempTypeToken->line+1;

			if(tempTypeToken->type == END) {
				throw ParseSyntaxError(startLine, endLine, getCodeLineBlock(startLine-1, endLine-1), "Expected function parameter type");
			} else {
				throw ParseSyntaxError(startLine, endLine, getCodeLineBlock(startLine-1, endLine-1), tempTypeToken->lexeme, "Expected function parameter type");
			}
		}
		currentErrorLine = peekAhead(currentIndex)->line+1;
		currentIndex++;

		//could be an array type
		if(peekAhead(currentIndex)->type == LEFT_BRACKET) {

			currentErrorLine = peekAhead(currentIndex)->line+1;
			currentIndex++;

			//next token must be ']'
			if(peekAhead(currentIndex)->type != RIGHT_BRACKET) {

				uint32_t endLine = (peekAhead(currentIndex)->type == END) ? currentErrorLine : peekAhead(currentIndex)->line+1;

				if(peekAhead(currentIndex)->type == END) {
					throw ParseSyntaxError(startLine, endLine, getCodeLineBlock(startLine-1, endLine-1), "Expected closing ']' in array type");		
				} else {
					throw ParseSyntaxError(startLine, endLine, getCodeLineBlock(startLine-1, endLine-1), peekAhead(currentIndex)->lexeme, "Expected closing ']' in array type");						
				}
			}

			currentErrorLine = peekAhead(currentIndex)->line+1;
			currentIndex++;
		}

		//make sure parameter name follows type
		if(peekAhead(currentIndex)->type != VARIABLE) {

			Token* tempVariableToken = peekAhead(currentIndex);
			uint32_t endLine = (tempVariableToken->type == END) ? currentErrorLine : tempVariableToken->line+1;

			if(tempVariableToken->type == END) {
				throw ParseSyntaxError(startLine, endLine, getCodeLineBlock(startLine-1, endLine-1), "Expected function parameter name");
			} else {
				throw ParseSyntaxError(startLine, endLine, getCodeLineBlock(startLine-1, endLine-1), tempVariableToken->lexeme, "Expected function parameter name");
			}
		}
		currentErrorLine = peekAhead(currentIndex)->line+1;
		currentIndex++;
		argCount++;

		//if next token is not closing parenthesis, it must be a comma
		Token* nextToken = peekAhead(currentIndex);				
		if(nextToken->type != RIGHT_PAREN && nextToken->type != COMMA) {

			uint32_t endLine = (nextToken->type == END) ? currentErrorLine : nextToken->line+1;

			if(nextToken->type == END) {
				throw ParseSyntaxError(startLine, endLine, getCodeLineBlock(startLine-1, endLine-1), "Expected ',' separating arguments or ')' terminating argument list");
			} else {
				throw ParseSyntaxError(startLine, endLine, getCodeLineBlock(startLine-1, endLine-1), nextToken->lexeme, "Expected ',' separating arguments or ')' terminating argument list"); 
			} 

		} else if(nextToken->type == COMMA) {
			currentErrorLine = nextToken->line+1;
			currentIndex++; //"consume" COMMA token
		}
	}

	//now allocate memory for argument names and types
	function->numArgs = argCount;
	ParseDataType* argTypes = new ParseDataType[argCount];
	ParseDataType* argSubTypes = new ParseDataType[argCount];
	char** argNames = (char**) malloc(sizeof(char*) * argCount);

	//keep track of variable line numbers
	uint32_t typeLines[argCount];
	uint32_t varLines[argCount];

	//now read in arguments for real
	uint32_t argIndex = 0;
	while(peek()->type != RIGHT_PAREN) {

		//read in parameter type
		Token* currTypeToken = consume();

		//could be an array type
		if(peek()->type == LEFT_BRACKET) {

			argTypes[argIndex] = ARRAY_T;
			argSubTypes[argIndex] = typeTokenConversion(currTypeToken->type);

			consume(); //consume '['
			typeLines[argIndex] = consume()->line+1;

		} else {

			argTypes[argIndex] = typeTokenConversion(currTypeToken->type);
			argSubTypes[argIndex] = INVALID_T;
			typeLines[argIndex] = currTypeToken->line+1;
		}

		//read in parameter name
		Token* currVarToken = consume();
		const char* aName = currVarToken->lexeme;
		argNames[argIndex] = copyString(aName);
		varLines[argIndex] = currVarToken->line+1;

		argIndex++;
		if(argIndex < argCount)
			consume(); //consume ,
	}
	leftParenToken = consume(); //consume ')' token

	function->argTypes = argTypes;
	function->argSubTypes = argSubTypes;
	function->argNames = argNames;

	//now get the return type
	Token* rightArrowToken = consume(); //consume ->
	if(rightArrowToken->type != RIGHTARROW) {
		
		uint32_t endLine = (rightArrowToken->line == END) ? leftParenToken->line+1 : rightArrowToken->line+1;

		if(rightArrowToken->line == END) {
			throw ParseSyntaxError(startLine, endLine, getCodeLineBlock(startLine-1, endLine-1), "Expected -> followed by return type");
		} else {
			throw ParseSyntaxError(startLine, endLine, getCodeLineBlock(startLine-1, endLine-1), rightArrowToken->lexeme, "Expected -> followed by return type");
		}
	}

	//make sure following token is a return type
	Token* returnTypeToken = consume();
	if(!isTypeTokenType(returnTypeToken->type)) {

		uint32_t endLine = (returnTypeToken->type == END) ? rightArrowToken->line+1 : returnTypeToken->line+1;

		if(returnTypeToken->type == END) {
			throw ParseSyntaxError(startLine, endLine, getCodeLineBlock(startLine-1, endLine-1), "Expected function return type"); 
		} else {
			throw ParseSyntaxError(startLine, endLine, getCodeLineBlock(startLine-1, endLine-1), returnTypeToken->lexeme, "Expected function return type"); 
		}
	}

	returnType.push_back(typeTokenConversion(returnTypeToken->type));
	function->returnType = typeTokenConversion(returnTypeToken->type);

	//just declare function up front with dummy data and Function public interface data
	//(to allow for recursive definitions)
	ParseData dummyFunctionData;
	dummyFunctionData.type = FUN_T;
	dummyFunctionData.value.allocated = function;
	symbolTable->declare(functionName, dummyFunctionData);

	//now declare the variables just for scope-checking purposes
	//and enter a new scope (in both tables) for function body
	symbolTable->enterNewScope();
	NewAssignmentStatementNode* dummy;

	for(uint32_t i = 0; i < argCount; i++) {
		//this construction declares variable as well
		string argName(argNames[i]);
		dummy = new NewAssignmentStatementNode(argName, argTypes[i], symbolTable, typeLines[i], varLines[i]);
	}

	//now store AbstractStatementNode* vector representing function body
	//make sure the body is braced
	Token* leftBraceToken = consume(); //consume {
	if(leftBraceToken->type != LEFT_BRACE) {

		uint32_t endLine = (leftBraceToken->type == END) ? returnTypeToken->line+1 : leftBraceToken->line+1;

		if(leftBraceToken->type == END) {
			throw ParseSyntaxError(startLine, endLine, getCodeLineBlock(startLine-1, endLine-1), "Expected '{' followed by function body");
		} else {
			throw ParseSyntaxError(startLine, endLine, getCodeLineBlock(startLine-1, endLine-1), leftBraceToken->lexeme, "Expected '{' followed by function body");
		}
	}

	//represents statements in body
	vector<AbstractStatementNode*>* body = new vector<AbstractStatementNode*>();

	while(peek()->type != RIGHT_BRACE) {
		body->push_back(addStatement());  
	}
	consume(); //consume }

	//leave scope
	symbolTable->leaveScope();
	function->body = body;

	//reset global pointers
	returnFlag.pop_back();
	returnValue.pop_back();
	returnType.pop_back();

	return function;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdx, -0x68(%rbp)
movl %esi, %ebx
movq %rdi, -0x30(%rbp)
pushq $0x40
popq %rdi
callq 0x4250
movq %rax, %r15
pushq $0x1
popq %rdi
callq 0x4250
leaq 0x38(%r15), %r14
movq %rax, 0x38(%r15)
pushq $0x10
popq %rdi
callq 0x4250
leaq 0x30(%r15), %r12
movq %r15, -0x48(%rbp)
movq %rax, 0x30(%r15)
leaq 0x15c27(%rip), %rdi     # 0x2b218
movq %r14, %rsi
callq 0x1aa68
leaq 0x15c30(%rip), %rdi     # 0x2b230
movq %r12, %rsi
callq 0x1aa8c
callq 0x154a8
movq %rax, %r14
movl (%rax), %eax
testl %eax, %eax
jne 0x15c72
movl 0x10(%r14), %r15d
incl %r15d
movl $0x0, -0x40(%rbp)
xorl %ebx, %ebx
movl %ebx, %edi
callq 0x154eb
cmpl $0x1, (%rax)
je 0x15708
movl %ebx, %edi
callq 0x154eb
movl (%rax), %edi
callq 0x5a0b
movl %eax, %r14d
movl %ebx, %edi
callq 0x154eb
movq %rax, %r12
testb %r14b, %r14b
je 0x15a7f
movl 0x10(%r12), %r12d
leal 0x1(%rbx), %r14d
movl %r14d, %edi
callq 0x154eb
cmpl $0x2, (%rax)
jne 0x156ab
movl %r14d, %edi
callq 0x154eb
movl 0x10(%rax), %r13d
leal 0x2(%rbx), %r12d
movl %r12d, %edi
callq 0x154eb
movl (%rax), %r14d
movl %r12d, %edi
callq 0x154eb
cmpl $0x3, %r14d
jne 0x15ad8
movl 0x10(%rax), %r12d
addl $0x3, %ebx
movl %ebx, %r14d
movl %r14d, %edi
callq 0x154eb
movl (%rax), %r15d
movl %r14d, %edi
callq 0x154eb
movq %rax, %rbx
cmpl $0x3b, %r15d
jne 0x15a26
movl 0x10(%rbx), %r13d
leal 0x1(%r13), %r15d
leal 0x1(%r14), %ebx
movl %ebx, %edi
callq 0x154eb
movq %rax, %r12
movl (%rax), %eax
cmpl $0x1, %eax
je 0x15700
cmpl $0x2b, %eax
jne 0x159e0
movl 0x10(%r12), %r15d
incl %r15d
addl $0x2, %r14d
movl %r14d, %ebx
incl -0x40(%rbp)
jmp 0x1562a
movq -0x48(%rbp), %rax
movl -0x40(%rbp), %ecx
movl %ecx, (%rax)
movl %ecx, %r14d
leaq (,%r14,4), %rbx
movq %rbx, %rdi
callq 0x4030
movq %rax, -0x50(%rbp)
movq %rbx, %rdi
callq 0x4030
movq %rax, %rbx
leaq (,%r14,8), %rdi
callq 0x4250
movq %rax, -0x58(%rbp)
movq %rsp, %rcx
movq %r14, -0x70(%rbp)
leaq 0xf(,%r14,4), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0x60(%rbp)
movq %rcx, %rsp
movq %rsp, %r13
subq %rax, %r13
movq %r13, %rsp
xorl %r15d, %r15d
callq 0x154d4
movl (%rax), %r12d
callq 0x154a8
movq %rax, %r14
cmpl $0x1, %r12d
je 0x1581c
callq 0x154d4
cmpl $0x2, (%rax)
movl %r15d, %r12d
jne 0x157bb
movq -0x50(%rbp), %rax
movl $0xc, (%rax,%r12,4)
movl (%r14), %edi
callq 0x72b8
movl %eax, (%rbx,%r12,4)
callq 0x154a8
callq 0x154a8
movq %rax, %r14
jmp 0x157d3
movl (%r14), %edi
callq 0x72b8
movq -0x50(%rbp), %rcx
movl %eax, (%rcx,%r12,4)
movl $0x11, (%rbx,%r12,4)
movl 0x10(%r14), %eax
incl %eax
movq -0x60(%rbp), %rcx
movl %eax, (%rcx,%r12,4)
callq 0x154a8
movq %rax, %r14
movq 0x18(%rax), %rdi
callq 0x152e4
movq -0x58(%rbp), %rcx
movq %rax, (%rcx,%r12,8)
movl 0x10(%r14), %eax
incl %eax
movl %eax, (%r13,%r12,4)
incl %r15d
cmpl -0x40(%rbp), %r15d
jae 0x1576d
callq 0x154a8
jmp 0x1576d
movq -0x48(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq %rbx, 0x10(%rax)
movq -0x58(%rbp), %rcx
movq %rcx, 0x18(%rax)
callq 0x154a8
movq %rax, %rbx
cmpl $0x2d, (%rax)
jne 0x15d79
callq 0x154a8
movq %rax, %r14
movl (%rax), %edi
callq 0x5a0b
testb %al, %al
je 0x15dc9
movl (%r14), %edi
callq 0x72b8
leaq -0x90(%rbp), %rsi
movl %eax, (%rsi)
leaq 0x159d4(%rip), %rdi     # 0x2b248
callq 0x1ae56
movq %r14, -0x40(%rbp)
movl (%r14), %edi
callq 0x72b8
movq -0x48(%rbp), %r15
movl %eax, 0x28(%r15)
movq 0x159e4(%rip), %rbx     # 0x2b278
leaq -0xb0(%rbp), %r14
movq %r14, %rdi
movq -0x68(%rbp), %rsi
callq 0x4290
pushq $0xd
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rcx
callq 0x14374
leaq -0xb0(%rbp), %rdi
callq 0x40e0
movq 0x159ad(%rip), %rdi     # 0x2b278
callq 0x14308
xorl %r12d, %r12d
leaq -0x90(%rbp), %r15
leaq -0xd0(%rbp), %rbx
cmpq %r12, -0x70(%rbp)
je 0x1594d
movq -0x58(%rbp), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
leaq -0x31(%rbp), %rdx
callq 0x40a0
pushq $0x48
popq %rdi
callq 0x41f0
movq %rax, %r14
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4290
movq -0x50(%rbp), %rax
movl (%rax,%r12,4), %edx
movq 0x15958(%rip), %rcx     # 0x2b278
movq -0x60(%rbp), %rax
movl (%rax,%r12,4), %r8d
movl (%r13,%r12,4), %r9d
movq %r14, %rdi
movq %rbx, %rsi
callq 0x13a7e
movq %rbx, %rdi
callq 0x40e0
movq %r15, %rdi
callq 0x40e0
incq %r12
jmp 0x158e1
callq 0x154a8
movq %rax, %rbx
movl (%rax), %eax
cmpl $0x4, %eax
jne 0x15cc5
pushq $0x18
popq %rdi
callq 0x41f0
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq -0x90(%rbp), %r14
callq 0x154d4
cmpl $0x5, (%rax)
je 0x159a0
callq 0x15f4c
movq %rax, -0x90(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1afce
jmp 0x1597d
callq 0x154a8
movq 0x158cc(%rip), %rdi     # 0x2b278
callq 0x14362
addq $-0x8, 0x15867(%rip)    # 0x2b220
movq -0x48(%rbp), %rax
movq %rbx, 0x20(%rax)
addq $-0x8, 0x1586f(%rip)    # 0x2b238
addq $-0x4, 0x1587f(%rip)    # 0x2b250
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x4e, %eax
jne 0x15b36
pushq $0x28
popq %rdi
callq 0x4110
movq %rax, %r14
movq -0x30(%rbp), %rax
leal -0x1(%rax), %edi
movl %r13d, %esi
callq 0x15504
leaq 0x14bc6(%rip), %rcx     # 0x2a5d0
addq $0x10, %rcx
movq %rcx, (%r14)
movq %rax, 0x8(%r14)
andq $0x0, 0x10(%r14)
leaq 0xb6a6(%rip), %rax      # 0x210c7
jmp 0x15ac3
cmpl $0x4e, (%rbx)
jne 0x15b7d
pushq $0x28
popq %rdi
callq 0x4110
movq %rax, %r14
movq -0x30(%rbp), %rax
leal -0x1(%rax), %edi
movl %r12d, %esi
callq 0x15504
incl %r12d
leaq 0x14b7d(%rip), %rcx     # 0x2a5d0
addq $0x10, %rcx
movq %rcx, (%r14)
movq %rax, 0x8(%r14)
andq $0x0, 0x10(%r14)
leaq 0xb63c(%rip), %rax      # 0x210a6
movq %rax, 0x18(%r14)
movq -0x30(%rbp), %rax
movl %eax, 0x20(%r14)
movl %r12d, 0x24(%r14)
jmp 0x15c5c
cmpl $0x4e, (%r12)
jne 0x15bc4
pushq $0x28
popq %rdi
callq 0x4110
movq %rax, %r14
movq -0x30(%rbp), %rax
leal -0x1(%rax), %edi
leal -0x1(%r15), %esi
callq 0x15504
leaq 0x14b24(%rip), %rcx     # 0x2a5d0
addq $0x10, %rcx
movq %rcx, (%r14)
movq %rax, 0x8(%r14)
andq $0x0, 0x10(%r14)
leaq 0xb59f(%rip), %rax      # 0x21062
movq %rax, 0x18(%r14)
movq -0x30(%rbp), %rax
movl %eax, 0x20(%r14)
movl %r15d, 0x24(%r14)
jmp 0x15c5c
cmpl $0x4e, (%rax)
je 0x15ae9
movl %r12d, %edi
callq 0x154eb
movl 0x10(%rax), %r13d
leal 0x1(%r13), %r15d
movl %r12d, %edi
callq 0x154eb
movl (%rax), %ebx
pushq $0x28
popq %rdi
callq 0x4110
movq %rax, %r14
movq -0x30(%rbp), %rax
leal -0x1(%rax), %edi
cmpl $0x4e, %ebx
jne 0x15c18
movl %r13d, %esi
callq 0x15504
leaq 0x14aaf(%rip), %rcx     # 0x2a5d0
addq $0x10, %rcx
movq %rcx, (%r14)
movq %rax, 0x8(%r14)
andq $0x0, 0x10(%r14)
jmp 0x15c45
movl 0x10(%r12), %ebx
pushq $0x28
popq %rdi
callq 0x4110
movq %rax, %r14
movq -0x30(%rbp), %rax
leal -0x1(%rax), %edi
movl %ebx, %esi
callq 0x15504
incl %ebx
movq 0x18(%r12), %rcx
leaq 0x14a6e(%rip), %rdx     # 0x2a5d0
addq $0x10, %rdx
movq %rdx, (%r14)
movq %rax, 0x8(%r14)
movq %rcx, 0x10(%r14)
leaq 0xb54f(%rip), %rax      # 0x210c7
jmp 0x15c06
movl 0x10(%rbx), %r15d
pushq $0x28
popq %rdi
callq 0x4110
movq %rax, %r14
movq -0x30(%rbp), %rax
leal -0x1(%rax), %edi
movl %r15d, %esi
callq 0x15504
incl %r15d
movq 0x18(%rbx), %rcx
leaq 0x14a27(%rip), %rdx     # 0x2a5d0
addq $0x10, %rdx
movq %rdx, (%r14)
movq %rax, 0x8(%r14)
movq %rcx, 0x10(%r14)
leaq 0xb4e7(%rip), %rax      # 0x210a6
jmp 0x15c4c
movl 0x10(%r12), %ebx
pushq $0x28
popq %rdi
callq 0x4110
movq %rax, %r14
movq -0x30(%rbp), %rax
leal -0x1(%rax), %edi
movl %ebx, %esi
callq 0x15504
incl %ebx
movq 0x18(%r12), %rcx
leaq 0x149e0(%rip), %rdx     # 0x2a5d0
addq $0x10, %rdx
movq %rdx, (%r14)
movq %rax, 0x8(%r14)
movq %rcx, 0x10(%r14)
leaq 0xb45c(%rip), %rax      # 0x21062
movq %rax, 0x18(%r14)
movq -0x30(%rbp), %rax
movl %eax, 0x20(%r14)
movl %ebx, 0x24(%r14)
jmp 0x15c5c
movl %r13d, %esi
callq 0x15504
movq %rax, %rbx
movl %r12d, %edi
callq 0x154eb
movq 0x18(%rax), %rax
leaq 0x1499a(%rip), %rcx     # 0x2a5d0
addq $0x10, %rcx
movq %rcx, (%r14)
movq %rbx, 0x8(%r14)
movq %rax, 0x10(%r14)
leaq 0xb437(%rip), %rax      # 0x21083
movq %rax, 0x18(%r14)
movq -0x30(%rbp), %rax
movl %eax, 0x20(%r14)
movl %r15d, 0x24(%r14)
leaq 0x14995(%rip), %rsi     # 0x2a5f8
movq 0x1536e(%rip), %rdx     # 0x2afd8
movq %r14, %rdi
callq 0x4310
cmpl $0x4e, %eax
jne 0x15d13
pushq $0x28
popq %rdi
callq 0x4110
movq %rax, %r14
movq -0x30(%rbp), %rax
leal -0x1(%rax), %edi
leal -0x1(%rbx), %esi
callq 0x15504
leaq 0x14934(%rip), %rcx     # 0x2a5d0
addq $0x10, %rcx
movq %rcx, (%r14)
movq %rax, 0x8(%r14)
andq $0x0, 0x10(%r14)
leaq 0xb381(%rip), %rax      # 0x21034
movq %rax, 0x18(%r14)
movq -0x30(%rbp), %rax
movl %eax, 0x20(%r14)
movl %ebx, 0x24(%r14)
jmp 0x15c5c
cmpl $0x4e, %eax
jne 0x15e1e
movq -0x40(%rbp), %rax
movl 0x10(%rax), %ebx
pushq $0x28
popq %rdi
callq 0x4110
movq %rax, %r14
movq -0x30(%rbp), %rax
leal -0x1(%rax), %edi
movl %ebx, %esi
callq 0x15504
incl %ebx
leaq 0x148d9(%rip), %rcx     # 0x2a5d0
addq $0x10, %rcx
movq %rcx, (%r14)
movq %rax, 0x8(%r14)
andq $0x0, 0x10(%r14)
leaq 0xb43e(%rip), %rax      # 0x2114c
jmp 0x15c06
movl 0x10(%r14), %ebx
pushq $0x28
popq %rdi
callq 0x4110
movq %rax, %r15
movq -0x30(%rbp), %rax
leal -0x1(%rax), %edi
movl %ebx, %esi
callq 0x15504
incl %ebx
movq 0x18(%r14), %rcx
leaq 0x14893(%rip), %rdx     # 0x2a5d0
addq $0x10, %rdx
movq %rdx, (%r15)
movq %rax, 0x8(%r15)
movq %rcx, 0x10(%r15)
leaq 0xb2e1(%rip), %rax      # 0x21034
movq %rax, 0x18(%r15)
movq -0x30(%rbp), %rax
movl %eax, 0x20(%r15)
movl %ebx, 0x24(%r15)
leaq 0x1488e(%rip), %rsi     # 0x2a5f8
movq 0x15267(%rip), %rdx     # 0x2afd8
movq %r15, %rdi
callq 0x4310
movl 0x10(%rbx), %r15d
cmpl $0x4e, %r15d
jne 0x15e65
movl 0x10(%r14), %ebx
pushq $0x28
popq %rdi
callq 0x4110
movq %rax, %r14
movq -0x30(%rbp), %rax
leal -0x1(%rax), %edi
movl %ebx, %esi
callq 0x15504
incl %ebx
leaq 0x14823(%rip), %rcx     # 0x2a5d0
addq $0x10, %rcx
movq %rcx, (%r14)
movq %rax, 0x8(%r14)
andq $0x0, 0x10(%r14)
leaq 0xb346(%rip), %rax      # 0x2110a
jmp 0x15c06
movl (%r14), %r12d
cmpl $0x4e, %r12d
movq %r14, %r13
cmoveq %rbx, %r14
movl 0x10(%r14), %ebx
leal 0x1(%rbx), %r15d
pushq $0x28
popq %rdi
callq 0x4110
movq %rax, %r14
movq -0x30(%rbp), %rax
leal -0x1(%rax), %edi
cmpl $0x4e, %r12d
jne 0x15ea8
movl %ebx, %esi
callq 0x15504
leaq 0x147c7(%rip), %rcx     # 0x2a5d0
addq $0x10, %rcx
movq %rcx, (%r14)
movq %rax, 0x8(%r14)
andq $0x0, 0x10(%r14)
jmp 0x15ec9
movl 0x10(%rbx), %r15d
pushq $0x28
popq %rdi
callq 0x4110
movq %rax, %r14
movq -0x30(%rbp), %rax
leal -0x1(%rax), %edi
movl %r15d, %esi
callq 0x15504
incl %r15d
movq 0x18(%rbx), %rcx
leaq 0x14786(%rip), %rdx     # 0x2a5d0
addq $0x10, %rdx
movq %rdx, (%r14)
movq %rax, 0x8(%r14)
movq %rcx, 0x10(%r14)
leaq 0xb2ec(%rip), %rax      # 0x2114c
jmp 0x15c4c
pushq $0x28
popq %rdi
callq 0x4110
movq %rax, %r14
movq -0x30(%rbp), %rax
leal -0x1(%rax), %edi
movl %r15d, %esi
callq 0x15504
incl %r15d
movq 0x18(%rbx), %rcx
leaq 0x14743(%rip), %rdx     # 0x2a5d0
addq $0x10, %rdx
movq %rdx, (%r14)
movq %rax, 0x8(%r14)
movq %rcx, 0x10(%r14)
leaq 0xb267(%rip), %rax      # 0x2110a
jmp 0x15c4c
movl %ebx, %esi
callq 0x15504
movq 0x18(%r13), %rcx
leaq 0x14716(%rip), %rdx     # 0x2a5d0
addq $0x10, %rdx
movq %rdx, (%r14)
movq %rax, 0x8(%r14)
movq %rcx, 0x10(%r14)
leaq 0xb25e(%rip), %rax      # 0x2112e
jmp 0x15c4c
jmp 0x15f05
jmp 0x15f05
jmp 0x15f05
jmp 0x15f05
jmp 0x15f05
jmp 0x15f05
movq %rax, %rbx
movq %r15, %rdi
jmp 0x15f0b
jmp 0x15f05
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
jmp 0x15f3f
jmp 0x15f05
jmp 0x15f05
jmp 0x15f05
jmp 0x15f05
jmp 0x15f05
jmp 0x15f05
jmp 0x15f05
movq %rax, %rbx
movq %r14, %rdi
callq 0x4180
jmp 0x15f44
movq %rax, %rbx
jmp 0x15f44
movq %rax, %rbx
jmp 0x15f38
movq %rax, %rbx
jmp 0x15f30
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x40e0
movq %r14, %rdi
callq 0x41d0
leaq -0x90(%rbp), %rdi
callq 0x40e0
movq %rbx, %rdi
callq 0x4340