// File: /workspace/github_c_makefile_star2_O3/anuwu[P]ERPLAG-Compiler/symbolTable.c
// Function: checkIP
varST * checkIP (moduleST * thisModule, moduleST * targetModule, astNode * inputNode)
{	
	varSTentry * varEntry = targetModule->inputVars[0] ;	
	astNode * inputIter = inputNode ;
	varST *searchedVar, *entryVar ;

	while(inputIter->next) 
		inputIter = inputIter->next ;

	while (varEntry != NULL && varEntry->thisVarST->varType == VAR_PLACEHOLDER)
		varEntry = varEntry->next ;

	int sameArgNoErr = 0 ;
	
	while(inputIter && varEntry)
	{
		searchedVar = searchVar (thisModule , inputIter->tok->lexeme ) ;
		entryVar = varEntry->thisVarST  ;

		if(searchedVar == NULL)
		{
			errSemantic () ;
			#ifdef _WIN64
				printf ("In module \"%s\" at line %d, variable \"%s\" is undeclared in the call to module \"%s\"\n", getParentModuleName (thisModule) ,inputIter->tok->lineNumber ,inputIter->tok->lexeme, thisModule->lexeme) ;
			#endif
			#if defined __linux__ || __MACH__
				printf ("In module " ANSI_BOLD "%s" ANSI_RESET " at line " ANSI_BOLD ANSI_CYAN "%d" ANSI_RESET ", variable " ANSI_BOLD ANSI_RED "%s" ANSI_RESET " is undeclared in the call to module " ANSI_BOLD "%s" ANSI_RESET "\n",getParentModuleName (thisModule) ,inputIter->tok->lineNumber ,inputIter->tok->lexeme, thisModule->lexeme) ;
			#endif
			realBase->semanticError = 1 ;
			sameArgNoErr = 1 ;
		}
		else 
		{
			if(entryVar->datatype == searchedVar->datatype)
			{
				if (entryVar->datatype == TK_ARRAY) 
				{
					if (entryVar->arrayIndices->type != searchedVar->arrayIndices->type)
					{
						errSemantic () ;
						#ifdef _WIN64
							printf ("In module \"%s\" at line %d,  input array variables \"%s\" and \"%s\" have conflicting base types in the call to module \"%s\"\n",  getParentModuleName (thisModule) ,inputIter->tok->lineNumber , inputIter->tok->lexeme , entryVar->lexeme, targetModule->lexeme) ;
						#endif
						#if defined __linux__ || __MACH__
							printf ("In module " ANSI_BOLD "%s" ANSI_RESET " at line " ANSI_BOLD ANSI_CYAN "%d" ANSI_RESET ", " ANSI_BOLD ANSI_BLACK " input array " ANSI_RESET "variables " ANSI_BOLD ANSI_RED "%s" ANSI_RESET " and " ANSI_BOLD ANSI_RED "%s" ANSI_RESET " have conflicting base types in the call to module " ANSI_BOLD "%s" ANSI_RESET "\n" ,  getParentModuleName (thisModule) ,inputIter->tok->lineNumber , inputIter->tok->lexeme , entryVar->lexeme, targetModule->lexeme) ;
						#endif
						realBase->semanticError = 1 ;
					}

					if (isLeftLimStatic(entryVar) && isLeftLimStatic(searchedVar) && strcmp (entryVar->arrayIndices->tokLeft->lexeme, searchedVar->arrayIndices->tokLeft->lexeme))
					{
						errSemantic () ;
						#ifdef _WIN64
							printf ("In module \"%s\" at line %d, array variables \"%s\" and \"%s\" do not have matching left limits in the call to module \"%s\"\n", getParentModuleName (thisModule), inputIter->tok->lineNumber, entryVar->lexeme, searchedVar->lexeme, targetModule->lexeme) ;
						#endif
						#if defined __linux__ || __MACH__
							printf ("In module " ANSI_BOLD "%s" ANSI_RESET " at line " ANSI_BOLD ANSI_CYAN "%d" ANSI_RESET ", " ANSI_BOLD ANSI_BLACK "array" ANSI_RESET " variables " ANSI_BOLD ANSI_RED "%s" ANSI_RESET " and " ANSI_BOLD ANSI_RED "%s" ANSI_RESET " do not have matching left limits in the call to module " ANSI_BOLD "%s" ANSI_RESET "\n", getParentModuleName (thisModule), inputIter->tok->lineNumber, entryVar->lexeme, searchedVar->lexeme, targetModule->lexeme) ;
						#endif
						realBase->semanticError = 1 ;
					}

					if (isRightLimStatic(entryVar) && isRightLimStatic(searchedVar) && strcmp (entryVar->arrayIndices->tokRight->lexeme, searchedVar->arrayIndices->tokRight->lexeme))
					{
						errSemantic () ;
						#ifdef _WIN64
							printf ("In module \"%s\" at line %d, array variables \"%s\" and \"%s\" do not have right limits in the call to module \"%s\"\n", getParentModuleName (thisModule), inputIter->tok->lineNumber, entryVar->lexeme, searchedVar->lexeme, targetModule->lexeme) ;
						#endif
						#if defined __linux__ || __MACH__
							printf ("In module " ANSI_BOLD "%s" ANSI_RESET " at line " ANSI_BOLD ANSI_CYAN "%d" ANSI_RESET ", " ANSI_BOLD ANSI_BLACK "array" ANSI_RESET " variables " ANSI_BOLD ANSI_RED "%s" ANSI_RESET " and " ANSI_BOLD ANSI_RED "%s" ANSI_RESET " do not have right limits in the call to module " ANSI_BOLD "%s" ANSI_RESET "\n", getParentModuleName (thisModule), inputIter->tok->lineNumber, entryVar->lexeme, searchedVar->lexeme, targetModule->lexeme) ;
						#endif
						realBase->semanticError = 1 ;
					}
				}
			}
			else 
			{
				errSemantic () ;
				#ifdef _WIN64
					printf ("In module \"%s\" at line %d, input variables \"%s\" and \"%s\" have conflicting types in the call to module \"%s\"\n",  getParentModuleName (thisModule) ,inputIter->tok->lineNumber , inputIter->tok->lexeme , entryVar->lexeme, targetModule->lexeme) ;
				#endif
				#if defined __linux__ || __MACH__
					printf ("In module " ANSI_BOLD "%s" ANSI_RESET " at line " ANSI_BOLD ANSI_CYAN "%d" ANSI_RESET ", " ANSI_BOLD ANSI_BLACK "input" ANSI_RESET " variables " ANSI_BOLD ANSI_RED "%s" ANSI_RESET " and " ANSI_BOLD ANSI_RED "%s" ANSI_RESET " have conflicting types in the call to module " ANSI_BOLD "%s" ANSI_RESET "\n" ,  getParentModuleName (thisModule) ,inputIter->tok->lineNumber , inputIter->tok->lexeme , entryVar->lexeme, targetModule->lexeme) ;
				#endif
				realBase->semanticError = 1 ;
				sameArgNoErr = 1 ;
			}
		}
		
		varEntry = varEntry->next ;
		while (varEntry != NULL && varEntry->thisVarST->varType == VAR_PLACEHOLDER)
			varEntry = varEntry->next ;

		inputIter = inputIter->prev ;
	}


	if (varEntry == NULL && inputIter)
	{
		errSemantic () ;
		#ifdef _WIN64
			printf ("In module \"%s\" at line %d, extra actual parameters passed in the call to module \"%s\"\n", getParentModuleName (thisModule), inputIter->tok->lineNumber, targetModule->lexeme) ;
		#endif
		#if defined __linux__ || __MACH__
			printf ("In module " ANSI_BOLD "%s" ANSI_RESET " at line " ANSI_BOLD ANSI_CYAN "%d" ANSI_RESET ", extra actual parameters passed in the call to module " ANSI_BOLD "%s" ANSI_RESET "\n", getParentModuleName (thisModule), inputIter->tok->lineNumber, targetModule->lexeme) ;
		#endif
		realBase->semanticError = 1 ;
		return (varST *) malloc (sizeof(varST)) ;
	}
	else if (varEntry && inputIter == NULL) 
	{
		errSemantic () ;
		#ifdef _WIN64
			printf ("In module \"%s\" at line %d, insufficient number of actual parameters in the call to module \"%s\"\n", getParentModuleName (thisModule), inputNode->tok->lineNumber, targetModule->lexeme) ;
		#endif
		#if defined __linux__ || __MACH__
			printf ("In module " ANSI_BOLD "%s" ANSI_RESET " at line " ANSI_BOLD ANSI_CYAN "%d" ANSI_RESET ", insufficient number of actual parameters in the call to module " ANSI_BOLD "%s" ANSI_RESET "\n", getParentModuleName (thisModule), inputNode->tok->lineNumber, targetModule->lexeme) ;
		#endif
		realBase->semanticError = 1 ;

		return (varST *) malloc (sizeof(varST)) ;
	}
	else
	{
		if (sameArgNoErr)
			return (varST *) 1 ;
		else
			return NULL ;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, %r14
movq 0x88(%rsi), %rbx
movq %rdx, %rax
movq %rax, %r15
movq 0x38(%rax), %rax
testq %rax, %rax
jne 0xbd3c
jmp 0xbd57
movq (%rbx), %rax
cmpl $0x1, 0x30(%rax)
jne 0xbd6e
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
jne 0xbd4a
testq %r15, %r15
setne %dl
movb $0x1, %sil
xorl %eax, %eax
xorl %ecx, %ecx
jmp 0xc044
xorl %eax, %eax
testq %r15, %r15
je 0xc073
xorl %edi, %edi
movq %r12, -0x38(%rbp)
movl %edi, -0x2c(%rbp)
movq 0x8(%r15), %rax
movq 0x8(%rax), %rsi
movq %r14, %rdi
callq 0xb8e8
testq %rax, %rax
je 0xbf5c
movq %rax, %r12
movq (%rbx), %rdx
movl 0x8(%rdx), %eax
cmpl 0x8(%r12), %eax
jne 0xbf9e
cmpl $0x3b, %eax
jne 0xbffe
movq 0x10(%rdx), %rax
movl (%rax), %eax
movq 0x10(%r12), %rcx
cmpl (%rcx), %eax
movq %rdx, -0x40(%rbp)
je 0xbe27
xorl %eax, %eax
callq 0xe989
movq 0x2524f(%rip), %rax     # 0x31028
movq %r14, %rdx
movq %rdx, %rcx
movq 0x10(%rdx), %rdx
cmpq %rax, %rdx
jne 0xbddc
movq (%rcx), %rsi
movq 0x8(%r15), %rax
movl 0x10(%rax), %edx
movq 0x8(%rax), %rcx
movq -0x40(%rbp), %rax
movq (%rax), %r8
movq -0x38(%rbp), %rax
movq (%rax), %r9
leaq 0x5a84(%rip), %rdi      # 0x1188f
xorl %eax, %eax
callq 0x10b0
movq -0x40(%rbp), %rdx
movq 0x2520b(%rip), %rax     # 0x31028
movl $0x1, 0xd8(%rax)
movq %rdx, %rdi
callq 0xdfb8
testl %eax, %eax
je 0xbec1
movq %r12, %rdi
callq 0xdfb8
testl %eax, %eax
je 0xbec1
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
movq 0x10(%r12), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x10f0
testl %eax, %eax
je 0xbec1
xorl %eax, %eax
callq 0xe989
movq 0x251b1(%rip), %rax     # 0x31028
movq %r14, %rdx
movq %rdx, %rcx
movq 0x10(%rdx), %rdx
cmpq %rax, %rdx
jne 0xbe7a
movq (%rcx), %rsi
movq 0x8(%r15), %rax
movl 0x10(%rax), %edx
movq -0x40(%rbp), %rax
movq (%rax), %rcx
movq (%r12), %r8
movq -0x38(%rbp), %rax
movq (%rax), %r9
leaq 0x5a9a(%rip), %rdi      # 0x11943
xorl %eax, %eax
callq 0x10b0
movq 0x25171(%rip), %rax     # 0x31028
movl $0x1, 0xd8(%rax)
movq -0x40(%rbp), %rdi
callq 0xdfe9
testl %eax, %eax
je 0xbffe
movq %r12, %rdi
callq 0xdfe9
testl %eax, %eax
je 0xbffe
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rdi
movq 0x10(%r12), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x10f0
testl %eax, %eax
je 0xbffe
xorl %eax, %eax
callq 0xe989
movq 0x2510e(%rip), %rax     # 0x31028
movq %r14, %rdx
movq %rdx, %rcx
movq 0x10(%rdx), %rdx
cmpq %rax, %rdx
jne 0xbf1d
movq (%rcx), %rsi
movq 0x8(%r15), %rax
movl 0x10(%rax), %edx
movq -0x40(%rbp), %rax
movq (%rax), %rcx
movq (%r12), %r8
movq -0x38(%rbp), %r12
movq (%r12), %r9
leaq 0x5aa8(%rip), %rdi      # 0x119f5
xorl %eax, %eax
callq 0x10b0
movl -0x2c(%rbp), %edi
jmp 0xbfeb
xorl %eax, %eax
callq 0xe989
movq 0x250be(%rip), %rax     # 0x31028
movq %r14, %rdx
movq -0x38(%rbp), %r12
movq %rdx, %rcx
movq 0x10(%rdx), %rdx
cmpq %rax, %rdx
jne 0xbf71
movq (%rcx), %rsi
movq 0x8(%r15), %rax
movl 0x10(%rax), %edx
movq 0x8(%rax), %rcx
movq (%r14), %r8
leaq 0x5883(%rip), %rdi      # 0x11818
xorl %eax, %eax
callq 0x10b0
jmp 0xbfe6
movq %rdx, %r12
xorl %eax, %eax
callq 0xe989
movq 0x25079(%rip), %rax     # 0x31028
movq %r14, %rdx
movq %rdx, %rcx
movq 0x10(%rdx), %rdx
cmpq %rax, %rdx
jne 0xbfb2
movq (%rcx), %rsi
movq 0x8(%r15), %rax
movl 0x10(%rax), %edx
movq 0x8(%rax), %rcx
movq (%r12), %r8
movq -0x38(%rbp), %r12
movq (%r12), %r9
leaq 0x5ac0(%rip), %rdi      # 0x11a9f
xorl %eax, %eax
callq 0x10b0
movl $0x1, %edi
movq 0x25036(%rip), %rax     # 0x31028
movl $0x1, 0xd8(%rax)
jmp 0xc005
movq -0x38(%rbp), %r12
movl -0x2c(%rbp), %edi
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
setne %cl
je 0xc02c
movq (%rbx), %rax
cmpl $0x1, 0x30(%rax)
je 0xc005
movq 0x40(%r15), %r15
testq %r15, %r15
setne %dl
jne 0xbd7f
jmp 0xc036
movq 0x40(%r15), %r15
testq %r15, %r15
setne %dl
testq %rbx, %rbx
sete %sil
xorl %eax, %eax
testl %edi, %edi
setne %al
testb %dl, %dl
je 0xc075
testb %sil, %sil
je 0xc075
xorl %eax, %eax
callq 0xe989
movq 0x24fcd(%rip), %rcx     # 0x31028
leaq 0x5ae5(%rip), %rdi      # 0x11b47
movq %r14, %rax
movq 0x10(%r14), %r14
cmpq %rcx, %r14
jne 0xc062
movq %r15, %r13
jmp 0xc09f
movb $0x1, %cl
testq %r15, %r15
jne 0xc0dd
testb %cl, %cl
je 0xc0dd
xorl %eax, %eax
callq 0xe989
movq 0x24f9c(%rip), %rcx     # 0x31028
leaq 0x5b23(%rip), %rdi      # 0x11bb6
movq %r14, %rax
movq 0x10(%r14), %r14
cmpq %rcx, %r14
jne 0xc093
movq (%rax), %rsi
movq 0x8(%r13), %rax
movl 0x10(%rax), %edx
movq (%r12), %rcx
xorl %eax, %eax
callq 0x10b0
movq 0x24f6d(%rip), %rax     # 0x31028
movl $0x1, 0xd8(%rax)
movl $0x38, %edi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1120
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq