// File: /workspace/github_c_makefile_star2_O2/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), %r13
movq %rdx, -0x38(%rbp)
movq %rdx, %rax
movq %rax, %r15
movq 0x38(%rax), %rax
testq %rax, %rax
jne 0xb3d7
xorl %r14d, %r14d
testq %r15, %r15
je 0xb4a7
testq %r13, %r13
je 0xb4a7
movq 0x8(%r15), %rax
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0xac19
movq (%r13), %r12
testq %rax, %rax
je 0xb453
movl 0x8(%r12), %ecx
cmpl 0x8(%rax), %ecx
je 0xb49a
xorl %eax, %eax
callq 0xd671
movq %rbx, %rdi
callq 0xb395
movq 0x8(%r15), %rcx
movl 0x10(%rcx), %edx
movq 0x8(%rcx), %rcx
movq (%r12), %r8
movq -0x30(%rbp), %rsi
movq (%rsi), %r9
leaq 0x57d8(%rip), %rdi      # 0x10c1f
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
jmp 0xb485
xorl %eax, %eax
callq 0xd671
movq %rbx, %rdi
callq 0xb395
movq 0x8(%r15), %rcx
movl 0x10(%rcx), %edx
movq 0x8(%rcx), %rcx
movq -0x30(%rbp), %rsi
movq (%rsi), %r8
leaq 0x538d(%rip), %rdi      # 0x10808
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x24b8c(%rip), %rax     # 0x30018
movl $0x1, 0xd8(%rax)
pushq $0x1
popq %r14
movq 0x8(%r13), %r13
movq 0x40(%r15), %r15
jmp 0xb3e6
testq %r15, %r15
sete %al
testq %r13, %r13
setne %cl
orb %al, %cl
jne 0xb514
xorl %eax, %eax
callq 0xd671
movq %rbx, %rdi
callq 0xb395
movq 0x8(%r15), %rcx
movl 0x10(%rcx), %edx
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
leaq 0x57d6(%rip), %rdi      # 0x10cb1
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x24b2c(%rip), %rax     # 0x30018
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 0xac19
testq %r13, %r13
sete %al
testq %r15, %r15
setne %cl
orb %al, %cl
jne 0xb569
xorl %eax, %eax
callq 0xd671
movq %rbx, %rdi
callq 0xb395
movq -0x38(%rbp), %rcx
movq 0x8(%rcx), %rcx
movl 0x10(%rcx), %edx
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
leaq 0x57cc(%rip), %rdi      # 0x10d18
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x24abb(%rip), %rax     # 0x30018
movl $0x1, 0xd8(%rax)
jmp 0xb573
xorl %r12d, %r12d
testl %r14d, %r14d
setne %r12b
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq