// File: /workspace/github_c_makefile_star2_O2/anuwu[P]ERPLAG-Compiler/symbolTable.c
// Function: isValidCall
int isValidCall (moduleST * thisModule , astNode * funcNode , int haveReturns) 
{
	if(haveReturns == 0) 
	{
		varST * varPtr = searchVarInbaseST(funcNode->tok->lexeme) ;
		moduleST * modPtr = searchModuleInbaseST (funcNode->tok->lexeme) ;

		if (modPtr != NULL)
		{
			if (varPtr == NULL && !modPtr->filledMod)
			{
				errSemantic () ;
				#ifdef _WIN64
					printf ("In module \"%s\" at line %d, module \"%s\" has not been declared before its call\n", getParentModuleName (thisModule), funcNode->tok->lineNumber, funcNode->tok->lexeme) ;
				#endif
				#if defined __linux__ || __MACH__
					printf ("In module " ANSI_BOLD "%s" ANSI_RESET " at line " ANSI_BOLD ANSI_CYAN "%d" ANSI_RESET ", module " ANSI_BOLD ANSI_RED "%s" ANSI_RESET " has not been declared before its call\n", getParentModuleName (thisModule), funcNode->tok->lineNumber, funcNode->tok->lexeme) ;
				#endif
				realBase->semanticError = 1 ;
			}

			if (modPtr->outputVars[0] != NULL)
			{
				errSemantic () ;
				#ifdef _WIN64
					printf ("In module \"%s\" at line %d, call to function \"%s\" has return data but no receiving variables\n", getParentModuleName (thisModule), funcNode->tok->lineNumber, modPtr->lexeme) ;
				#endif
				#if defined __linux__ || __MACH__
					printf ("In module " ANSI_BOLD "%s" ANSI_RESET " at line " ANSI_BOLD ANSI_CYAN "%d" ANSI_RESET ", call to function " ANSI_BOLD ANSI_RED "%s" ANSI_RESET " has return data but no receiving variables\n", getParentModuleName (thisModule), funcNode->tok->lineNumber, modPtr->lexeme) ;
				#endif
				realBase->semanticError = 1 ;
			}

			if (checkIP(thisModule, modPtr, funcNode->next->child) !=NULL)
				return -3 ;		// Errors printed in checkIP
			else
				return 1 ;
		}
		else
		{
			if (varPtr == NULL)
				return -1 ;
			else
				return -2 ;
		}
	}
	else
	{
		varST * varPtr = searchVarInbaseST(funcNode->next->next->tok->lexeme ) ;
		moduleST * modPtr = searchModuleInbaseST (funcNode->next->next->tok->lexeme) ;

		if (modPtr != NULL)
		{
			if (varPtr == NULL && !modPtr->filledMod)
			{
				errSemantic () ;
				#ifdef _WIN64
					printf ("In module \"%s\" at line %d, module \"%s\" has not been declared before its call\n", getParentModuleName (thisModule), funcNode->next->next->tok->lineNumber, funcNode->next->next->tok->lexeme) ;
				#endif
				#if defined __linux__ || __MACH__
					printf ("In module " ANSI_BOLD "%s" ANSI_RESET " at line " ANSI_BOLD ANSI_CYAN "%d" ANSI_RESET ", module " ANSI_BOLD ANSI_RED "%s" ANSI_RESET " has not been declared before its call\n", getParentModuleName (thisModule), funcNode->next->next->tok->lineNumber, funcNode->next->next->tok->lexeme) ;
				#endif
				realBase->semanticError = 1 ;
			}

			if (modPtr->outputVars[0] == NULL)
			{
				errSemantic () ;
				#ifdef _WIN64
					printf ("In module \"%s\" at line %d, call to function \"%s\" has no return data but receiving variables are present\n", getParentModuleName (thisModule), funcNode->next->next->tok->lineNumber, modPtr->lexeme) ;
				#endif
				#if defined __linux__ || __MACH__
					printf ("In module " ANSI_BOLD "%s" ANSI_RESET " at line " ANSI_BOLD ANSI_CYAN "%d" ANSI_RESET ", call to function " ANSI_BOLD ANSI_RED "%s" ANSI_RESET " has no return data but receiving variables are present\n", getParentModuleName (thisModule), funcNode->next->next->tok->lineNumber, modPtr->lexeme) ;
				#endif
				realBase->semanticError = 1 ;
			}
			
			if (checkIP(thisModule, modPtr, funcNode->next->next->next->child) !=NULL | checkOP(thisModule, modPtr, funcNode->child) !=NULL )
				return -3 ;		// Errors printed in checkIP and checkOP
			else
				return 1 ;
		}
		else
		{
			if (varPtr == NULL)
				return -1 ;
			else
				return -2 ;
		}
	}
	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
testl %edx, %edx
je 0xb6a4
movq 0x38(%r14), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %r15
movq %r15, %rdi
callq 0xaabd
movq %rax, %r12
movq %r15, %rdi
callq 0xab11
testq %rax, %rax
je 0xb77f
movq %rax, %r15
testq %r12, %r12
jne 0xb620
cmpl $0x0, 0x100(%r15)
jne 0xb620
xorl %eax, %eax
callq 0xd671
movq %rbx, %rdi
callq 0xb395
movq 0x38(%r14), %rcx
movq 0x38(%rcx), %rcx
movq 0x8(%rcx), %rcx
movl 0x10(%rcx), %edx
movq 0x8(%rcx), %rcx
leaq 0x5782(%rip), %rdi      # 0x10d87
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x24a02(%rip), %rax     # 0x30018
movl $0x1, 0xd8(%rax)
cmpq $0x0, 0x90(%r15)
jne 0xb66d
xorl %eax, %eax
callq 0xd671
movq %rbx, %rdi
callq 0xb395
movq 0x38(%r14), %rcx
movq 0x38(%rcx), %rcx
movq 0x8(%rcx), %rcx
movl 0x10(%rcx), %edx
movq (%r15), %rcx
leaq 0x581c(%rip), %rdi      # 0x10e6e
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x249b5(%rip), %rax     # 0x30018
movl $0x1, 0xd8(%rax)
movq 0x38(%r14), %rax
movq 0x38(%rax), %rax
movq 0x38(%rax), %rax
movq 0x30(%rax), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xb067
movq %rax, %r12
movq 0x30(%r14), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xb3b1
xorl %ecx, %ecx
orq %r12, %rax
jmp 0xb773
movq 0x8(%r14), %rax
movq 0x8(%rax), %r15
movq %r15, %rdi
callq 0xaabd
movq %rax, %r12
movq %r15, %rdi
callq 0xab11
testq %rax, %rax
je 0xb77f
movq %rax, %r15
testq %r12, %r12
jne 0xb716
cmpl $0x0, 0x100(%r15)
jne 0xb716
xorl %eax, %eax
callq 0xd671
movq %rbx, %rdi
callq 0xb395
movq 0x8(%r14), %rcx
movl 0x10(%rcx), %edx
movq 0x8(%rcx), %rcx
leaq 0x568c(%rip), %rdi      # 0x10d87
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x2490c(%rip), %rax     # 0x30018
movl $0x1, 0xd8(%rax)
cmpq $0x0, 0x90(%r15)
je 0xb75b
xorl %eax, %eax
callq 0xd671
movq %rbx, %rdi
callq 0xb395
movq 0x8(%r14), %rcx
movl 0x10(%rcx), %edx
movq (%r15), %rcx
leaq 0x56b3(%rip), %rdi      # 0x10df3
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x248c7(%rip), %rax     # 0x30018
movl $0x1, 0xd8(%rax)
movq 0x38(%r14), %rax
movq 0x30(%rax), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xb067
xorl %ecx, %ecx
testq %rax, %rax
sete %cl
leal -0x3(,%rcx,4), %eax
jmp 0xb78a
xorl %eax, %eax
testq %r12, %r12
sete %al
orl $-0x2, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq