// File: /workspace/github_c_makefile_star2_O0/anuwu[P]ERPLAG-Compiler/codegen.c
// Function: moduleGeneration
void moduleGeneration (astNode *node, moduleST *lst)
{
	if (node == NULL)
		return ;

	varST *searchedVar ;
	astNode *idListHead ;
	moduleST *calledModule ;
	varSTentry *varEntry ;

	switch (node->id)
	{
		int start_label, end_label ;
		int reserveLabel[10] ;

		case statements :
			if (node->child == NULL && node->localST->parent == realBase)
				retModule (node->localST) ;
			else
				moduleGeneration (node->child, node->localST);		// Access local scope and move below

			break ;

		case statement :
		{
			moduleGeneration(node->child, lst);
			if (node->next == NULL)
			{
				if (lst->tableType == SWITCH_ST)
					break ;

				varEntry = lst->dynamicVars[0] ;
				freeDynamic (varEntry) ;

				if (lst->parent == realBase)
					retModule (lst) ;
				else if (lst->scopeSize > 0)
				{
					codePrint ("\n\t\tADD RSP, %d", lst->scopeSize) ;
					codeComment (10, "restoring to parent scope") ;
				}

			}
			else
				moduleGeneration(node->next, lst);

			break ;
		}

		case TK_DECLARE :
		{
			;
			switchDeclareStatus stat ;
			if (lst->tableType != SWITCH_ST)
				stat = NOT_SWITCH ; // Subtract RSP, and allocate memory if dynamic
			else if (node->parent != node)
				stat = SWITCH_INIT ; // Subtract RSP only, and do not allocate memory for dynamic
			else
			{
				stat = SWITCH_GEN ; // Do not subtract RSP, allocate memory if dynamic AND restore parent
				node->parent = node->next->parent ;
			}

			int declCount = 1 ;
			idListHead = node->next->child ;
			astNode *dtNode = node->next->next ;

			while (idListHead->next != NULL)
			{
				declCount++ ;
				idListHead = idListHead->next ;
			}

			searchedVar = searchVar (lst, idListHead->tok->lexeme) ;
			if (searchedVar->size > 0 && stat != SWITCH_GEN)
			{	
				codePrint ("\t\tSUB RSP, %d", searchedVar->size * declCount) ;
				if (stat == NOT_SWITCH)
					codeComment (11, "making space for declaration") ;
				else if (stat == SWITCH_INIT)
					codeComment (11, "declaring before switch") ;

				codePrint ("\n") ;
			}

			if (dtNode->dtTag == ARRAY && !isVarStaticArr(searchedVar) && stat != SWITCH_GEN)
				dynamicDeclaration (lst, searchedVar, declCount) ;

			break ;	
		}									

		case TK_ASSIGNOP :
		{
			if (isSingleRHS(node))
			{
				if (isArrayRHS (node, lst))
				{
					//printf ("CANNOT HANDLE ARRAY ASSIGNMENT YET\n") ;
					varST *lhs, *rhs ;
					lhs = searchVar (lst, node->child->tok->lexeme) ;
					rhs = searchVar (lst, node->child->next->tok->lexeme) ;
				
					if (isVarStaticArr (lhs) && isVarStaticArr (rhs))
					{
						tf |= 1 << asgnArr ;

						loadRegLeftLim (lhs, "CX") ;
						loadRegRightLim (lhs, "DX") ;
						loadArrBase (lhs, "RDI") ;
						loadArrBase (rhs, "RSI") ;
						codePrint ("\t\tSUB DX, CX\n") ;
						codePrint ("\t\tADD DX, 1\n") ;
						codePrint ("\t\tADD DX, DX\n") ;
						codePrint ("\t\tCALL @asgnArr\n") ;
					}
					else
						dynAsgnArr (lhs, rhs) ;
				}
				else
				{
					expr(node->child->next, lst, 1);
					exprAssign (node->child, lst, 1) ;
				}
			}
			else
			{
				int singleAssign = 0 ;

				if (isAssignUnary (node))
				{
					if (isExprLeaf (node->child->next->child->id))
						singleAssign = 1 ;

					expr(node->child->next->child, lst, singleAssign) ;
				}
				else
					expr(node->child->next, lst, 0);	

				exprAssign (node->child, lst, singleAssign) ;
			}

			codePrint ("\n") ;
			break ;
		}

		case TK_FOR :
		{
			node=node->next;
			start_label = get_label (LABEL_FOR) ;
			end_label = get_label (LABEL_FOR) ;

			searchedVar = searchVar (lst, node->tok->lexeme) ;

			codePrint ("\t\tMOV CX,%s\n", node->next->tok->lexeme);
			codePrint ("\t\tMOV [RBP%s], CX" , getOffsetStr(searchedVar->offset)) ;

			codePrint ("\n\t@FOR%d:\n", start_label) ;
			codePrint ("\t\tMOV AX, %s\n", node->next->next->tok->lexeme) ;
			codePrint ("\t\tCMP CX, AX\n");
			codePrint ("\t\tJG @FOR%d\n\n", end_label);

			moduleGeneration(node->next->next->next, lst);		// Statements

			codePrint ("\n\t\tMOV CX, [RBP%s]", getOffsetStr(searchedVar->offset)) ;
			codeComment (8, "For loop increment") ;
			codePrint ("\t\tINC CX\n");
			codePrint ("\t\tMOV [RBP%s],CX\n", getOffsetStr(searchedVar->offset)) ;
			codePrint ("\t\tJMP @FOR%d\n", start_label) ;
			codePrint ("\n\t@FOR%d:\n", end_label) ;
			break ;
		}

		
		case TK_WHILE :
		{
			node=node->next;
			start_label = get_label(LABEL_WHILE);
			end_label =  get_label(LABEL_WHILE);

			codePrint ("\n\t@WHILE%d:\n", start_label) ;

			expr (node, lst, 0);	// expr

			codePrint ("\t\tPOP AX\n");
			codePrint ("\t\tCMP AX, 0");
			codeComment (11, "checking while loop condition") ;
			codePrint ("\t\tJE @WHILE%d\n\n", end_label) ;

			moduleGeneration(node->next, lst);		// statements

			codePrint ("\t\tJMP @WHILE%d\n", start_label) ;
			codePrint ("\n\t@WHILE%d:\n", end_label) ;

			break ;
		}
		
		case TK_PRINT :
			node = node->next ;
			print (node, lst) ;
			break ;

		case TK_GET_VALUE :
			searchedVar = searchVar (lst, node->next->tok->lexeme) ;
			getValue (lst, searchedVar) ;
			break ;

		case TK_SWITCH :
		{
			int i, caseCount, def_label ;
			int *caseLabels ;
			astNode *statementsNode = node->next->next->next->next ;

			switchDeclareVars (node->next->next->next->next) ;
			caseCount = getCaseCount (node->next->next->next->next) ;
			caseLabels = (int *) malloc (sizeof(int) * caseCount) ;
			def_label = switchCaseLabels (node , lst, caseCount, caseLabels) ;

			end_label = get_label (LABEL_SWITCH) ;
			i = 0 ;
			while (statementsNode != NULL)
			{
				codePrint ("\n@SWITCH%d:\n", caseLabels[i]) ;
				moduleGeneration (statementsNode, lst) ;
				codePrint ("\n\t\tJMP @SWITCH%d\n", end_label) ;

				i++ ;
				if (statementsNode->next != NULL)
				{
					if (statementsNode->next->id == TK_DEFAULT)
					{
						statementsNode = statementsNode->next->next ;
						codePrint ("\n@SWITCH%d:\n", def_label) ;
						moduleGeneration (statementsNode, lst) ;
						codePrint ("\n\t\tJMP @SWITCH%d\n", end_label) ;

						break ;
					}
					statementsNode = statementsNode->next->next->next ;
				}
				else
					statementsNode = NULL ;
			}

			statementsNode = node->next->next->next->next ;
			codePrint ("\n@SWITCH%d:\n", end_label) ;

			varEntry = statementsNode->localST->dynamicVars[0] ;
			freeDynamic (varEntry) ;

			if (statementsNode->localST->scopeSize > 0)
			{
				codePrint ("\t\tADD RSP, %d", statementsNode->localST->scopeSize) ;
				codeComment (11, "restoring to parent scope") ;
			}

			break ;
		}

		case TK_ID :
		{
			calledModule = searchModuleInbaseST (node->tok->lexeme) ;
			varEntry = calledModule->inputVars[0] ;

			idListHead = node->next->child ; 
			while (idListHead->next != NULL)
				idListHead = idListHead->next ;

			pushInput (idListHead, varEntry, lst) ;

			codePrint ("\t\tCALL %s", strcmp(node->tok->lexeme, "main") ? node->tok->lexeme : "@main") ;
			codeComment (11, "calling user function") ;
			codePrint ("\t\tADD RSP, %d\n", calledModule->inputSize) ;
			break ;
		}

		case idList :
		{
			calledModule = searchModuleInbaseST (node->next->next->tok->lexeme) ;
			varEntry = calledModule->inputVars[0] ;

			idListHead = node->next->next->next->child ;
			while (idListHead->next != NULL)
				idListHead = idListHead->next ;

			codePrint ("\t\tSUB RSP, %d\n", calledModule->outputSize) ;
			pushInput (idListHead, varEntry, lst) ;

			codePrint ("\t\tCALL %s", node->next->next->tok->lexeme) ;
			codeComment (11, "calling user function") ;
			codePrint ("\t\tADD RSP, %d\n", calledModule->inputSize) ;

			popOutput (node->child, lst) ;
			break ;
		}
	}

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x350f
jmp 0x417e
movq -0x8(%rbp), %rax
movl (%rax), %eax
addl $-0xc, %eax
movl %eax, %ecx
movq %rcx, -0xa8(%rbp)
subl $0x5d, %eax
ja 0x417e
movq -0xa8(%rbp), %rax
leaq 0x11cc0(%rip), %rcx     # 0x151f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x3573
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x10(%rax), %rax
leaq 0x33aa9(%rip), %rcx     # 0x37008
cmpq (%rcx), %rax
jne 0x3573
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x4830
jmp 0x3588
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x34f0
jmp 0x417e
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x34f0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x38(%rax)
jne 0x3637
movq -0x10(%rbp), %rax
cmpl $0x4, 0x8(%rax)
jne 0x35bc
jmp 0x417e
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x48f0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
leaq 0x33a25(%rip), %rcx     # 0x37008
cmpq (%rcx), %rax
jne 0x35f3
movq -0x10(%rbp), %rdi
callq 0x4830
jmp 0x3635
movq -0x10(%rbp), %rax
cmpl $0x0, 0x110(%rax)
jle 0x3633
leaq 0x19d21(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x110(%rax), %edx
leaq 0x125d4(%rip), %rsi     # 0x15bef
movb $0x0, %al
callq 0x10d0
movl $0xa, %edi
leaq 0x125d0(%rip), %rsi     # 0x15bfe
callq 0x16c0
jmp 0x3635
jmp 0x3648
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x34f0
jmp 0x417e
movq -0x10(%rbp), %rax
cmpl $0x4, 0x8(%rax)
je 0x3660
movl $0x0, -0x64(%rbp)
jmp 0x3694
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
cmpq -0x8(%rbp), %rax
je 0x3677
movl $0x1, -0x64(%rbp)
jmp 0x3692
movl $0x2, -0x64(%rbp)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x28(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x28(%rax)
jmp 0x3694
movl $0x1, -0x68(%rbp)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x30(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x36dd
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x36bb
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x10ba0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jle 0x3773
cmpl $0x2, -0x64(%rbp)
je 0x3773
leaq 0x19c1b(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movl 0x18(%rax), %edx
imull -0x68(%rbp), %edx
leaq 0x124f6(%rip), %rsi     # 0x15c18
movb $0x0, %al
callq 0x10d0
cmpl $0x0, -0x64(%rbp)
jne 0x3742
movl $0xb, %edi
leaq 0x124eb(%rip), %rsi     # 0x15c26
callq 0x16c0
jmp 0x375b
cmpl $0x1, -0x64(%rbp)
jne 0x3759
movl $0xb, %edi
leaq 0x124ef(%rip), %rsi     # 0x15c43
callq 0x16c0
jmp 0x375b
leaq 0x19bc6(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x12695(%rip), %rsi     # 0x15e01
movb $0x0, %al
callq 0x10d0
movq -0x70(%rbp), %rax
cmpl $0x1, 0x10(%rax)
jne 0x37a1
movq -0x18(%rbp), %rdi
callq 0x13fc0
cmpl $0x0, %eax
jne 0x37a1
cmpl $0x2, -0x64(%rbp)
je 0x37a1
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x68(%rbp), %edx
callq 0x2f10
jmp 0x417e
movq -0x8(%rbp), %rdi
callq 0x1d00
cmpl $0x0, %eax
je 0x3927
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x1c80
cmpl $0x0, %eax
je 0x38f2
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x10ba0
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x10ba0
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rdi
callq 0x13fc0
cmpl $0x0, %eax
je 0x38e3
movq -0x80(%rbp), %rdi
callq 0x13fc0
cmpl $0x0, %eax
je 0x38e3
movl 0x19b12(%rip), %eax     # 0x1d348
orl $0x8000, %eax           # imm = 0x8000
movl %eax, 0x19b07(%rip)     # 0x1d348
movq -0x78(%rbp), %rdi
leaq 0x12440(%rip), %rsi     # 0x15c8c
callq 0x17e0
movq -0x78(%rbp), %rdi
leaq 0x11b9c(%rip), %rsi     # 0x153f8
callq 0x1870
movq -0x78(%rbp), %rdi
leaq 0x11c19(%rip), %rsi     # 0x15485
callq 0x1900
movq -0x80(%rbp), %rdi
leaq 0x123df(%rip), %rsi     # 0x15c5b
callq 0x1900
leaq 0x19aa0(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x11dd4(%rip), %rsi     # 0x15666
movb $0x0, %al
callq 0x10d0
leaq 0x19a88(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x11dca(%rip), %rsi     # 0x15674
movb $0x0, %al
callq 0x10d0
leaq 0x19a70(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x11dbf(%rip), %rsi     # 0x15681
movb $0x0, %al
callq 0x10d0
leaq 0x19a58(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x12385(%rip), %rsi     # 0x15c5f
movb $0x0, %al
callq 0x10d0
jmp 0x38f0
movq -0x78(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0x1d30
jmp 0x3922
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x38(%rax), %rdi
movq -0x10(%rbp), %rsi
movl $0x1, %edx
callq 0x22f0
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x10(%rbp), %rsi
movl $0x1, %edx
callq 0x1ec0
jmp 0x39b4
movl $0x0, -0x84(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1c20
cmpl $0x0, %eax
je 0x3986
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x38(%rax), %rax
movq 0x30(%rax), %rax
movl (%rax), %edi
callq 0x1b80
cmpl $0x0, %eax
je 0x3965
movl $0x1, -0x84(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x38(%rax), %rax
movq 0x30(%rax), %rdi
movq -0x10(%rbp), %rsi
movl -0x84(%rbp), %edx
callq 0x22f0
jmp 0x399d
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x38(%rax), %rdi
movq -0x10(%rbp), %rsi
xorl %edx, %edx
callq 0x22f0
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x10(%rbp), %rsi
movl -0x84(%rbp), %edx
callq 0x1ec0
leaq 0x1996d(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x1243c(%rip), %rsi     # 0x15e01
movb $0x0, %al
callq 0x10d0
jmp 0x417e
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x8(%rbp)
movl $0x1, %edi
callq 0x1600
movl %eax, -0x34(%rbp)
movl $0x1, %edi
callq 0x1600
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x10ba0
movq %rax, -0x18(%rbp)
leaq 0x19911(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdx
leaq 0x1223f(%rip), %rsi     # 0x15c70
movb $0x0, %al
callq 0x10d0
leaq 0x198e9(%rip), %rax     # 0x1d328
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0x18(%rbp), %rax
movl 0x1c(%rax), %edi
callq 0x1730
movq -0xc0(%rbp), %rdi
movq %rax, %rdx
leaq 0x12217(%rip), %rsi     # 0x15c7d
movb $0x0, %al
callq 0x10d0
leaq 0x198b4(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movl -0x34(%rbp), %edx
leaq 0x1220e(%rip), %rsi     # 0x15c8f
movb $0x0, %al
callq 0x10d0
leaq 0x19899(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdx
leaq 0x11d97(%rip), %rsi     # 0x15844
movb $0x0, %al
callq 0x10d0
leaq 0x1986d(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x121d5(%rip), %rsi     # 0x15c9a
movb $0x0, %al
callq 0x10d0
leaq 0x19855(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movl -0x38(%rbp), %edx
leaq 0x121c8(%rip), %rsi     # 0x15ca8
movb $0x0, %al
callq 0x10d0
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x34f0
leaq 0x19821(%rip), %rax     # 0x1d328
movq (%rax), %rax
movq %rax, -0xb8(%rbp)
movq -0x18(%rbp), %rax
movl 0x1c(%rax), %edi
callq 0x1730
movq -0xb8(%rbp), %rdi
movq %rax, %rdx
leaq 0x12188(%rip), %rsi     # 0x15cb6
movb $0x0, %al
callq 0x10d0
movl $0x8, %edi
leaq 0x12188(%rip), %rsi     # 0x15cc9
callq 0x16c0
leaq 0x197db(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x12185(%rip), %rsi     # 0x15cdc
movb $0x0, %al
callq 0x10d0
leaq 0x197c3(%rip), %rax     # 0x1d328
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0x18(%rbp), %rax
movl 0x1c(%rax), %edi
callq 0x1730
movq -0xb0(%rbp), %rdi
movq %rax, %rdx
leaq 0x1215a(%rip), %rsi     # 0x15ce6
movb $0x0, %al
callq 0x10d0
leaq 0x1978e(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movl -0x34(%rbp), %edx
leaq 0x12151(%rip), %rsi     # 0x15cf8
movb $0x0, %al
callq 0x10d0
leaq 0x19773(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movl -0x38(%rbp), %edx
leaq 0x120cd(%rip), %rsi     # 0x15c8f
movb $0x0, %al
callq 0x10d0
jmp 0x417e
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x8(%rbp)
movl $0x2, %edi
callq 0x1600
movl %eax, -0x34(%rbp)
movl $0x2, %edi
callq 0x1600
movl %eax, -0x38(%rbp)
leaq 0x1972d(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movl -0x34(%rbp), %edx
leaq 0x120fe(%rip), %rsi     # 0x15d06
movb $0x0, %al
callq 0x10d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %edx, %edx
callq 0x22f0
leaq 0x19703(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x1185a(%rip), %rsi     # 0x15489
movb $0x0, %al
callq 0x10d0
leaq 0x196eb(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x120cc(%rip), %rsi     # 0x15d13
movb $0x0, %al
callq 0x10d0
movl $0xb, %edi
leaq 0x120c5(%rip), %rsi     # 0x15d1f
callq 0x16c0
leaq 0x196c2(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movl -0x38(%rbp), %edx
leaq 0x120ca(%rip), %rsi     # 0x15d3d
movb $0x0, %al
callq 0x10d0
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x34f0
leaq 0x19696(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movl -0x34(%rbp), %edx
leaq 0x120ae(%rip), %rsi     # 0x15d4d
movb $0x0, %al
callq 0x10d0
leaq 0x1967b(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movl -0x38(%rbp), %edx
leaq 0x1204c(%rip), %rsi     # 0x15d06
movb $0x0, %al
callq 0x10d0
jmp 0x417e
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x2630
jmp 0x417e
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x10ba0
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2b00
jmp 0x417e
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rdi
callq 0x33d0
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rdi
callq 0x3360
movl %eax, -0x8c(%rbp)
movslq -0x8c(%rbp), %rdi
shlq $0x2, %rdi
callq 0x10e0
movq %rax, -0x98(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x8c(%rbp), %edx
movq -0x98(%rbp), %rcx
callq 0x4190
movl %eax, -0x90(%rbp)
xorl %edi, %edi
callq 0x1600
movl %eax, -0x38(%rbp)
movl $0x0, -0x88(%rbp)
cmpq $0x0, -0xa0(%rbp)
je 0x3ed1
leaq 0x19562(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movq -0x98(%rbp), %rax
movslq -0x88(%rbp), %rcx
movl (%rax,%rcx,4), %edx
leaq 0x11f7c(%rip), %rsi     # 0x15d5d
movb $0x0, %al
callq 0x10d0
movq -0xa0(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x34f0
leaq 0x19529(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movl -0x38(%rbp), %edx
leaq 0x11f5e(%rip), %rsi     # 0x15d6a
movb $0x0, %al
callq 0x10d0
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
movq -0xa0(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x3ec1
movq -0xa0(%rbp), %rax
movq 0x38(%rax), %rax
cmpl $0x55, (%rax)
jne 0x3ea5
movq -0xa0(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq %rax, -0xa0(%rbp)
leaq 0x194c7(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movl -0x90(%rbp), %edx
leaq 0x11eec(%rip), %rsi     # 0x15d5d
movb $0x0, %al
callq 0x10d0
movq -0xa0(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x34f0
leaq 0x19499(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movl -0x38(%rbp), %edx
leaq 0x11ece(%rip), %rsi     # 0x15d6a
movb $0x0, %al
callq 0x10d0
jmp 0x3ed1
movq -0xa0(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq %rax, -0xa0(%rbp)
jmp 0x3ecc
movq $0x0, -0xa0(%rbp)
jmp 0x3db1
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq %rax, -0xa0(%rbp)
leaq 0x19435(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movl -0x38(%rbp), %edx
leaq 0x11e5d(%rip), %rsi     # 0x15d5d
movb $0x0, %al
callq 0x10d0
movq -0xa0(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x80(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x48f0
movq -0xa0(%rbp), %rax
movq 0x20(%rax), %rax
cmpl $0x0, 0x110(%rax)
jle 0x3f74
leaq 0x193e7(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movq -0xa0(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x110(%rax), %edx
leaq 0x11c94(%rip), %rsi     # 0x15bf0
movb $0x0, %al
callq 0x10d0
movl $0xb, %edi
leaq 0x11c8f(%rip), %rsi     # 0x15bfe
callq 0x16c0
jmp 0x417e
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
callq 0x109b0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x30(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x3fc6
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x3fad
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x45e0
leaq 0x1934a(%rip), %rax     # 0x1d328
movq (%rax), %rax
movq %rax, -0xc8(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x11d8c(%rip), %rsi     # 0x15d87
callq 0x10c0
cmpl $0x0, %eax
je 0x401a
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0xd0(%rbp)
jmp 0x402a
leaq 0x11d65(%rip), %rax     # 0x15d86
movq %rax, -0xd0(%rbp)
jmp 0x402a
movq -0xc8(%rbp), %rdi
movq -0xd0(%rbp), %rdx
leaq 0x11d3d(%rip), %rsi     # 0x15d7c
movb $0x0, %al
callq 0x10d0
movl $0xb, %edi
leaq 0x11d3a(%rip), %rsi     # 0x15d8c
callq 0x16c0
leaq 0x192ca(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movl 0x104(%rax), %edx
leaq 0x118db(%rip), %rsi     # 0x1594d
movb $0x0, %al
callq 0x10d0
jmp 0x417e
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
callq 0x109b0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq 0x30(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x40db
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x40c2
leaq 0x19246(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movl 0x108(%rax), %edx
leaq 0x11839(%rip), %rsi     # 0x1592f
movb $0x0, %al
callq 0x10d0
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x45e0
leaq 0x19213(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdx
leaq 0x11c49(%rip), %rsi     # 0x15d7c
movb $0x0, %al
callq 0x10d0
movl $0xb, %edi
leaq 0x11c46(%rip), %rsi     # 0x15d8c
callq 0x16c0
leaq 0x191d6(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movl 0x104(%rax), %edx
leaq 0x117e7(%rip), %rsi     # 0x1594d
movb $0x0, %al
callq 0x10d0
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x4780
addq $0xd0, %rsp
popq %rbp
retq
nopw (%rax,%rax)