// File: /workspace/github_c_makefile_star2_O1/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 0xc874
jmp 0xc88f
movq (%rbx), %rax
cmpl $0x1, 0x30(%rax)
jne 0xc894
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
jne 0xc882
testq %r12, %r12
setne %dl
testq %rbx, %rbx
setne %cl
movl %edx, %esi
andb %cl, %sil
xorl %eax, %eax
cmpb $0x1, %sil
jne 0xcaf7
movl $0x0, -0x2c(%rbp)
movq 0x8(%r12), %rax
movq 0x8(%rax), %rsi
movq %r14, %rdi
callq 0xc430
testq %rax, %rax
je 0xca41
movq %rax, %r13
movq (%rbx), %r15
movl 0x8(%r15), %eax
cmpl 0x8(%r13), %eax
jne 0xca72
cmpl $0x3b, %eax
jne 0xcac0
movq 0x10(%r15), %rax
movl (%rax), %eax
movq 0x10(%r13), %rcx
cmpl (%rcx), %eax
je 0xc944
xorl %eax, %eax
callq 0xf205
movq %r14, %rdi
callq 0xcb84
movq 0x8(%r12), %rcx
movl 0x10(%rcx), %edx
movq 0x8(%rcx), %rcx
movq (%r15), %r8
movq -0x38(%rbp), %rsi
movq (%rsi), %r9
leaq 0x5f56(%rip), %rdi      # 0x1287f
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x256ee(%rip), %rax     # 0x32028
movl $0x1, 0xd8(%rax)
movq %r15, %rdi
callq 0xe828
testl %eax, %eax
je 0xc9c4
movq %r13, %rdi
callq 0xe828
testl %eax, %eax
je 0xc9c4
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 0x10f0
testl %eax, %eax
je 0xc9c4
xorl %eax, %eax
callq 0xf205
movq %r14, %rdi
callq 0xcb84
movq 0x8(%r12), %rcx
movl 0x10(%rcx), %edx
movq (%r15), %rcx
movq (%r13), %r8
movq -0x38(%rbp), %rsi
movq (%rsi), %r9
leaq 0x5f8a(%rip), %rdi      # 0x12933
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x2566e(%rip), %rax     # 0x32028
movl $0x1, 0xd8(%rax)
movq %r15, %rdi
callq 0xe859
testl %eax, %eax
je 0xcac0
movq %r13, %rdi
callq 0xe859
testl %eax, %eax
je 0xcac0
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 0x10f0
testl %eax, %eax
je 0xcac0
xorl %eax, %eax
callq 0xf205
movq %r14, %rdi
callq 0xcb84
movq 0x8(%r12), %rcx
movl 0x10(%rcx), %edx
movq (%r15), %rcx
movq (%r13), %r8
movq -0x38(%rbp), %rsi
movq (%rsi), %r9
leaq 0x5fb0(%rip), %rdi      # 0x129e5
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
jmp 0xcaaf
xorl %eax, %eax
callq 0xf205
movq %r14, %rdi
callq 0xcb84
movq 0x8(%r12), %rcx
movl 0x10(%rcx), %edx
movq 0x8(%rcx), %rcx
movq (%r14), %r8
leaq 0x5da2(%rip), %rdi      # 0x12808
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
jmp 0xcaa8
xorl %eax, %eax
callq 0xf205
movq %r14, %rdi
callq 0xcb84
movq 0x8(%r12), %rcx
movl 0x10(%rcx), %edx
movq 0x8(%rcx), %rcx
movq (%r15), %r8
movq -0x38(%rbp), %rsi
movq (%rsi), %r9
leaq 0x5ff1(%rip), %rdi      # 0x12a8f
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movl $0x1, -0x2c(%rbp)
movq 0x25572(%rip), %rax     # 0x32028
movl $0x1, 0xd8(%rax)
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
je 0xcad2
movq (%rbx), %rax
cmpl $0x1, 0x30(%rax)
je 0xcac0
movq 0x40(%r12), %r12
testq %rbx, %rbx
setne %cl
testq %r12, %r12
setne %dl
je 0xcaee
testq %rbx, %rbx
jne 0xc8b8
xorl %eax, %eax
cmpl $0x0, -0x2c(%rbp)
setne %al
testb %dl, %dl
je 0xcb09
testq %rbx, %rbx
jne 0xcb09
leaq 0x6030(%rip), %r15      # 0x12b37
jmp 0xcb21
testq %r12, %r12
setne %dl
xorb $0x1, %cl
orb %dl, %cl
jne 0xcb75
leaq 0x6089(%rip), %r15      # 0x12ba6
movq -0x40(%rbp), %r12
xorl %eax, %eax
callq 0xf205
movq %r14, %rdi
callq 0xcb84
movq 0x8(%r12), %rcx
movl 0x10(%rcx), %edx
movq -0x38(%rbp), %rcx
movq (%rcx), %rcx
movq %r15, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x254d5(%rip), %rax     # 0x32028
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