// File: /workspace/github_c_makefile_star2_O1/anuwu[P]ERPLAG-Compiler/symbolTable.c
// Function: checkOP
varST * checkOP (moduleST * thisModule ,moduleST * targetModule , astNode * outputNode) 
{
	varST *searchedVar, *entryVar ;
	varSTentry *varEntry = targetModule->outputVars[0] ;
	int sameArgNoErr = 0 ;

	astNode * outputIter = outputNode ;
	while(outputIter->next)
		outputIter = outputIter->next ;
	
	while( outputIter && varEntry )
	{
		searchedVar = searchVar (thisModule , outputIter->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) , outputIter->tok->lineNumber , outputIter->tok->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 ", variable " ANSI_BOLD ANSI_RED "%s" ANSI_RESET " is undeclared in the call to module " ANSI_BOLD "%s" ANSI_RESET "\n", getParentModuleName (thisModule) , outputIter->tok->lineNumber , outputIter->tok->lexeme, targetModule->lexeme ) ;
			#endif
			realBase->semanticError = 1 ;
			sameArgNoErr = 1 ;
		}
		else 
		{
			if(entryVar->datatype != searchedVar->datatype)
			{
				errSemantic () ;
				#ifdef _WIN64
					printf ("In module \"%s\" at line %d, \"%s\" and \"%s\" have conflicting return types in the call to module \"%s\"\n", getParentModuleName (thisModule), outputIter->tok->lineNumber, outputIter->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_RED "%s" ANSI_RESET " and " ANSI_BOLD ANSI_RED "%s" ANSI_RESET " have conflicting return types in the call to module " ANSI_BOLD "%s" ANSI_RESET "\n" , getParentModuleName (thisModule), outputIter->tok->lineNumber, outputIter->tok->lexeme , entryVar->lexeme, targetModule->lexeme) ;
				#endif
				realBase->semanticError = 1 ;
				sameArgNoErr = 1 ;
			}
		}
		
		varEntry = varEntry->next ;
		outputIter = outputIter->prev ;
	}

	if (varEntry==NULL && outputIter)
	{
		errSemantic () ;
		#ifdef _WIN64
			printf ("In module \"%s\" at line %d, extra output variables in the call to module \"%s\"\n", getParentModuleName (thisModule), outputIter->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 output variables in the call to module " ANSI_BOLD "%s" ANSI_RESET "\n", getParentModuleName (thisModule), outputIter->tok->lineNumber, targetModule->lexeme) ;
		#endif
		realBase->semanticError = 1 ;
		return searchVar (thisModule , outputIter->tok->lexeme ) ;
	}
	else if (varEntry && outputIter==NULL) 
	{
		errSemantic () ;
		#ifdef _WIN64
			printf ("In module \"%s\" at line %d, insufficient number of outputs in the call to module \"%s\"\n", getParentModuleName (thisModule), outputNode->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 outputs in the call to module " ANSI_BOLD "%s" ANSI_RESET "\n", getParentModuleName (thisModule), outputNode->tok->lineNumber, targetModule->lexeme) ;
		#endif
		realBase->semanticError = 1 ;
		return entryVar ;
	}
	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, %r14
movq %rdi, %rbx
movq %rsi, -0x30(%rbp)
movq 0x90(%rsi), %r12
movq %rdx, %rax
movq %rax, %r15
movq 0x38(%rax), %rax
testq %rax, %rax
jne 0xcbc2
testq %r15, %r15
setne %dl
testq %r12, %r12
setne %cl
movl %edx, %esi
andb %cl, %sil
xorl %eax, %eax
cmpb $0x1, %sil
jne 0xccc7
movq %r14, -0x38(%rbp)
xorl %r14d, %r14d
movq 0x8(%r15), %rax
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0xc430
movq (%r12), %r13
testq %rax, %rax
je 0xcc50
movl 0x8(%r13), %ecx
cmpl 0x8(%rax), %ecx
je 0xcc99
xorl %eax, %eax
callq 0xf205
movq %rbx, %rdi
callq 0xcb84
movq 0x8(%r15), %rcx
movl 0x10(%rcx), %edx
movq 0x8(%rcx), %rcx
movq (%r13), %r8
movq -0x30(%rbp), %rsi
movq (%rsi), %r9
leaq 0x5fdb(%rip), %rdi      # 0x12c1f
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
jmp 0xcc82
xorl %eax, %eax
callq 0xf205
movq %rbx, %rdi
callq 0xcb84
movq 0x8(%r15), %rcx
movl 0x10(%rcx), %edx
movq 0x8(%rcx), %rcx
movq -0x30(%rbp), %rsi
movq (%rsi), %r8
leaq 0x5b90(%rip), %rdi      # 0x12808
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x2539f(%rip), %rax     # 0x32028
movl $0x1, 0xd8(%rax)
movl $0x1, %r14d
movq 0x8(%r12), %r12
movq 0x40(%r15), %r15
testq %r12, %r12
setne %cl
testq %r15, %r15
setne %dl
je 0xccb9
testq %r12, %r12
jne 0xcbf2
xorl %eax, %eax
testl %r14d, %r14d
setne %al
movq -0x38(%rbp), %r14
jmp 0xccc7
testq %r12, %r12
setne %sil
xorb $0x1, %dl
orb %sil, %dl
jne 0xcd33
xorl %eax, %eax
callq 0xf205
movq %rbx, %rdi
callq 0xcb84
movq 0x8(%r15), %rcx
movl 0x10(%rcx), %edx
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
leaq 0x5fb7(%rip), %rdi      # 0x12cb1
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x2531d(%rip), %rax     # 0x32028
movl $0x1, 0xd8(%rax)
movq 0x8(%r15), %rax
movq 0x8(%rax), %rsi
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc430
testq %r15, %r15
setne %dl
xorb $0x1, %cl
orb %dl, %cl
jne 0xcd82
xorl %eax, %eax
callq 0xf205
movq %rbx, %rdi
callq 0xcb84
movq 0x8(%r14), %rcx
movl 0x10(%rcx), %edx
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
leaq 0x5fb4(%rip), %rdi      # 0x12d18
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x252b3(%rip), %rax     # 0x32028
movl $0x1, 0xd8(%rax)
movq %r13, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq