// File: /workspace/github_c_makefile_star2_O1/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 0xceb0
movq 0x38(%r14), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %r15
movq %r15, %rdi
callq 0xc251
movq %rax, %r12
movq %r15, %rdi
callq 0xc2da
testq %rax, %rax
je 0xcf8b
movq %rax, %r15
testq %r12, %r12
jne 0xce2c
cmpl $0x0, 0x100(%r15)
jne 0xce2c
xorl %eax, %eax
callq 0xf205
movq %rbx, %rdi
callq 0xcb84
movq 0x38(%r14), %rcx
movq 0x38(%rcx), %rcx
movq 0x8(%rcx), %rcx
movl 0x10(%rcx), %edx
movq 0x8(%rcx), %rcx
leaq 0x5f76(%rip), %rdi      # 0x12d87
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x25206(%rip), %rax     # 0x32028
movl $0x1, 0xd8(%rax)
cmpq $0x0, 0x90(%r15)
jne 0xce79
xorl %eax, %eax
callq 0xf205
movq %rbx, %rdi
callq 0xcb84
movq 0x38(%r14), %rcx
movq 0x38(%rcx), %rcx
movq 0x8(%rcx), %rcx
movl 0x10(%rcx), %edx
movq (%r15), %rcx
leaq 0x6010(%rip), %rdi      # 0x12e6e
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x251b9(%rip), %rax     # 0x32028
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 0xc84e
movq %rax, %r12
movq 0x30(%r14), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xcb9d
xorl %ecx, %ecx
orq %r12, %rax
jmp 0xcf7f
movq 0x8(%r14), %rax
movq 0x8(%rax), %r15
movq %r15, %rdi
callq 0xc251
movq %rax, %r12
movq %r15, %rdi
callq 0xc2da
testq %rax, %rax
je 0xcf8b
movq %rax, %r15
testq %r12, %r12
jne 0xcf22
cmpl $0x0, 0x100(%r15)
jne 0xcf22
xorl %eax, %eax
callq 0xf205
movq %rbx, %rdi
callq 0xcb84
movq 0x8(%r14), %rcx
movl 0x10(%rcx), %edx
movq 0x8(%rcx), %rcx
leaq 0x5e80(%rip), %rdi      # 0x12d87
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x25110(%rip), %rax     # 0x32028
movl $0x1, 0xd8(%rax)
cmpq $0x0, 0x90(%r15)
je 0xcf67
xorl %eax, %eax
callq 0xf205
movq %rbx, %rdi
callq 0xcb84
movq 0x8(%r14), %rcx
movl 0x10(%rcx), %edx
movq (%r15), %rcx
leaq 0x5ea7(%rip), %rdi      # 0x12df3
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x250cb(%rip), %rax     # 0x32028
movl $0x1, 0xd8(%rax)
movq 0x38(%r14), %rax
movq 0x30(%rax), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xc84e
xorl %ecx, %ecx
testq %rax, %rax
sete %cl
leal -0x3(,%rcx,4), %eax
jmp 0xcf96
xorl %eax, %eax
testq %r12, %r12
sete %al
orl $-0x2, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq