// File: /workspace/github_c_makefile_star2_O3/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 %rdi, %rbx
movq %rsi, -0x30(%rbp)
movq 0x90(%rsi), %r12
movq %rdx, -0x38(%rbp)
movq %rdx, %rax
movq %rax, %r15
movq 0x38(%rax), %rax
testq %rax, %rax
jne 0xc12e
xorl %eax, %eax
testq %r12, %r12
setne %cl
je 0xc245
xorl %r14d, %r14d
movq 0x8(%r15), %rax
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0xb8e8
movq (%r12), %r13
testq %rax, %rax
je 0xc1b7
movl 0x8(%r13), %ecx
cmpl 0x8(%rax), %ecx
je 0xc20e
xorl %eax, %eax
callq 0xe989
movq 0x24ea9(%rip), %rax     # 0x31028
movq %rbx, %rdx
movq %rdx, %rcx
movq 0x10(%rdx), %rdx
cmpq %rax, %rdx
jne 0xc182
movq (%rcx), %rsi
movq 0x8(%r15), %rax
movl 0x10(%rax), %edx
movq 0x8(%rax), %rcx
movq (%r13), %r8
movq -0x30(%rbp), %rax
movq (%rax), %r9
leaq 0x5a81(%rip), %rdi      # 0x11c2f
xorl %eax, %eax
callq 0x10b0
jmp 0xc1f7
xorl %eax, %eax
callq 0xe989
movq 0x24e63(%rip), %rax     # 0x31028
movq %rbx, %rdx
movq %rdx, %rcx
movq 0x10(%rdx), %rdx
cmpq %rax, %rdx
jne 0xc1c8
movq (%rcx), %rsi
movq 0x8(%r15), %rax
movl 0x10(%rax), %edx
movq 0x8(%rax), %rcx
movq -0x30(%rbp), %rax
movq (%rax), %r8
leaq 0x5628(%rip), %rdi      # 0x11818
xorl %eax, %eax
callq 0x10b0
movq 0x24e2a(%rip), %rax     # 0x31028
movl $0x1, 0xd8(%rax)
movl $0x1, %r14d
movq 0x8(%r12), %r12
movq 0x40(%r15), %r15
testq %r12, %r12
setne %cl
testq %r15, %r15
je 0xc22b
testq %r12, %r12
jne 0xc14b
testq %r15, %r15
setne %sil
xorl %eax, %eax
testl %r14d, %r14d
setne %al
testq %r12, %r12
sete %dl
andb %sil, %dl
jmp 0xc247
movb $0x1, %dl
testb %dl, %dl
je 0xc2b6
xorl %eax, %eax
callq 0xe989
movq 0x24dcf(%rip), %rax     # 0x31028
movq %rbx, %rdx
movq %rdx, %rcx
movq 0x10(%rdx), %rdx
cmpq %rax, %rdx
jne 0xc25c
movq (%rcx), %rsi
movq 0x8(%r15), %rax
movl 0x10(%rax), %edx
movq -0x30(%rbp), %rax
movq (%rax), %rcx
leaq 0x5a41(%rip), %rdi      # 0x11cc1
xorl %eax, %eax
callq 0x10b0
movq 0x24d9a(%rip), %rax     # 0x31028
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 0xb8e8
testq %r15, %r15
setne %dl
xorb $0x1, %cl
orb %dl, %cl
jne 0xc314
xorl %eax, %eax
callq 0xe989
movq 0x24d57(%rip), %rax     # 0x31028
movq %rbx, %rcx
movq 0x10(%rbx), %rbx
cmpq %rax, %rbx
jne 0xc2d1
movq (%rcx), %rsi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x10(%rax), %edx
movq -0x30(%rbp), %rax
movq (%rax), %rcx
leaq 0x5a2f(%rip), %rdi      # 0x11d28
xorl %eax, %eax
callq 0x10b0
movq 0x24d21(%rip), %rax     # 0x31028
movl $0x1, 0xd8(%rax)
movq %r13, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq