// File: /workspace/github_c_makefile_star2_O2/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 %rdi, %r14
movq %rsi, -0x38(%rbp)
movq 0x88(%rsi), %rbx
movq %rdx, -0x40(%rbp)
movq %rdx, %rax
movq %rax, %r12
movq 0x38(%rax), %rax
testq %rax, %rax
jne 0xb08d
jmp 0xb0a8
movq (%rbx), %rax
cmpl $0x1, 0x30(%rax)
jne 0xb0ad
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
jne 0xb09b
movl $0x0, -0x2c(%rbp)
testq %r12, %r12
je 0xb2e9
testq %rbx, %rbx
je 0xb2e9
movq 0x8(%r12), %rax
movq 0x8(%rax), %rsi
movq %r14, %rdi
callq 0xac19
testq %rax, %rax
je 0xb24f
movq %rax, %r13
movq (%rbx), %r15
movl 0x8(%r15), %eax
cmpl 0x8(%r13), %eax
jne 0xb280
cmpl $0x3b, %eax
jne 0xb2cd
movq 0x10(%r15), %rax
movl (%rax), %eax
movq 0x10(%r13), %rcx
cmpl (%rcx), %eax
je 0xb152
xorl %eax, %eax
callq 0xd671
movq %r14, %rdi
callq 0xb395
movq 0x8(%r12), %rcx
movl 0x10(%rcx), %edx
movq 0x8(%rcx), %rcx
movq (%r15), %r8
movq -0x38(%rbp), %rsi
movq (%rsi), %r9
leaq 0x5748(%rip), %rdi      # 0x1087f
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x24ed0(%rip), %rax     # 0x30018
movl $0x1, 0xd8(%rax)
movq %r15, %rdi
callq 0xcd04
testl %eax, %eax
je 0xb1d2
movq %r13, %rdi
callq 0xcd04
testl %eax, %eax
je 0xb1d2
movq 0x10(%r15), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
movq 0x10(%r13), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x10e0
testl %eax, %eax
je 0xb1d2
xorl %eax, %eax
callq 0xd671
movq %r14, %rdi
callq 0xb395
movq 0x8(%r12), %rcx
movl 0x10(%rcx), %edx
movq (%r15), %rcx
movq (%r13), %r8
movq -0x38(%rbp), %rsi
movq (%rsi), %r9
leaq 0x577c(%rip), %rdi      # 0x10933
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x24e50(%rip), %rax     # 0x30018
movl $0x1, 0xd8(%rax)
movq %r15, %rdi
callq 0xcd35
testl %eax, %eax
je 0xb2cd
movq %r13, %rdi
callq 0xcd35
testl %eax, %eax
je 0xb2cd
movq 0x10(%r15), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rdi
movq 0x10(%r13), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x10e0
testl %eax, %eax
je 0xb2cd
xorl %eax, %eax
callq 0xd671
movq %r14, %rdi
callq 0xb395
movq 0x8(%r12), %rcx
movl 0x10(%rcx), %edx
movq (%r15), %rcx
movq (%r13), %r8
movq -0x38(%rbp), %rsi
movq (%rsi), %r9
leaq 0x57a2(%rip), %rdi      # 0x109e5
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
jmp 0xb2bc
xorl %eax, %eax
callq 0xd671
movq %r14, %rdi
callq 0xb395
movq 0x8(%r12), %rcx
movl 0x10(%rcx), %edx
movq 0x8(%rcx), %rcx
movq (%r14), %r8
leaq 0x5594(%rip), %rdi      # 0x10808
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
jmp 0xb2b6
xorl %eax, %eax
callq 0xd671
movq %r14, %rdi
callq 0xb395
movq 0x8(%r12), %rcx
movl 0x10(%rcx), %edx
movq 0x8(%rcx), %rcx
movq (%r15), %r8
movq -0x38(%rbp), %rsi
movq (%rsi), %r9
leaq 0x57e3(%rip), %rdi      # 0x10a8f
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
pushq $0x1
popq %rax
movl %eax, -0x2c(%rbp)
movq 0x24d55(%rip), %rax     # 0x30018
movl $0x1, 0xd8(%rax)
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
je 0xb2df
movq (%rbx), %rax
cmpl $0x1, 0x30(%rax)
je 0xb2cd
movq 0x40(%r12), %r12
jmp 0xb0b4
testq %r12, %r12
je 0xb31a
testq %rbx, %rbx
jne 0xb31a
xorl %eax, %eax
callq 0xd671
movq %r14, %rdi
callq 0xb395
movq 0x8(%r12), %rcx
movl 0x10(%rcx), %edx
movq -0x38(%rbp), %rcx
movq (%rcx), %rcx
leaq 0x581f(%rip), %rdi      # 0x10b37
jmp 0xb34c
testq %r12, %r12
jne 0xb37d
testq %rbx, %rbx
je 0xb37d
xorl %eax, %eax
callq 0xd671
movq %r14, %rdi
callq 0xb395
movq -0x40(%rbp), %rcx
movq 0x8(%rcx), %rcx
movl 0x10(%rcx), %edx
movq -0x38(%rbp), %rcx
movq (%rcx), %rcx
leaq 0x585a(%rip), %rdi      # 0x10ba6
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x24cbb(%rip), %rax     # 0x30018
movl $0x1, 0xd8(%rax)
pushq $0x38
popq %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1110
xorl %eax, %eax
cmpl $0x0, -0x2c(%rbp)
setne %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq