// File: /workspace/github_c_makefile_star2_O0/anuwu[P]ERPLAG-Compiler/typeChecker.c
// Function: getExpressionType
tokenID getExpressionType (moduleST *baseModule, astNode *exprNode)
{
	if (exprNode->child == NULL || exprNode->child->next == NULL)	// constant value, integer, or array[index]
	{
		if (exprNode->id != TK_ID)
		{
			if (exprNode->id == TK_NUM)
				return TK_INTEGER ;
			else if (exprNode->id == TK_RNUM)
			{
				realPresent = 1 ;
				return TK_REAL ;
			}
			else
				return TK_BOOLEAN ;
		}
		else
			return validateVar (baseModule, exprNode, NULL) ;
	}
	else
	{
		tokenID typeLeft , typeRight ;
		typeLeft = getExpressionType (baseModule, exprNode->child) ;
		typeRight = getExpressionType (baseModule, exprNode->child->next) ;

		if (typeLeft == TK_ARRAY || typeRight == TK_ARRAY)
		{
			errSemantic () ;
			#ifdef _WIN64
				printf ("In module \"%s\" at line %d, array variable(s) \"%s\" and \"%s\" cannot occur in an expression\n", getParentModuleName (baseModule), exprNode->tok->lineNumber, exprNode->child->tok->lexeme, exprNode->child->next->tok->lexeme) ;
			#endif
			#if defined __linux__ || defined __MACH__
				printf ("In module " ANSI_BOLD "%s" ANSI_RESET " at line " ANSI_BOLD ANSI_CYAN "%d" ANSI_RESET ", " ANSI_BOLD ANSI_BLACK "array" ANSI_RESET " variable(s) " ANSI_BOLD ANSI_RED "%s" ANSI_RESET " and " ANSI_BOLD ANSI_RED "%s" ANSI_RESET " cannot occur in an expression\n", getParentModuleName (baseModule), exprNode->tok->lineNumber, exprNode->child->tok->lexeme, exprNode->child->next->tok->lexeme) ;
			#endif
			return (tokenID)0 ;
		}

		if (!typeLeft || !typeRight)
			return (tokenID)0 ;
		else if (typeLeft != typeRight)
		{
			errSemantic () ;
			#ifdef _WIN64
				printf ("In module \"%s\" at line %d, the operator \"%s\" is not allowed between types \"%s\" and \"%s\" respectively\n", getParentModuleName (baseModule), exprNode->tok->lineNumber,  exprNode->tok->lexeme, typeIDToString(typeLeft), typeIDToString(typeRight)) ;
			#endif
			#if defined __linux__ || defined __MACH__
				printf ("In module " ANSI_BOLD "%s" ANSI_RESET " at line " ANSI_BOLD ANSI_CYAN "%d" ANSI_RESET ", the operator " ANSI_BOLD ANSI_CYAN "%s" ANSI_RESET " is not allowed between types " ANSI_BOLD ANSI_GREEN "%s" ANSI_RESET " and " ANSI_BOLD ANSI_GREEN "%s" ANSI_RESET " respectively\n", getParentModuleName (baseModule), exprNode->tok->lineNumber,  exprNode->tok->lexeme, typeIDToString(typeLeft), typeIDToString(typeRight)) ;
			#endif
			return (tokenID)0 ;
		}
		else
		{
			if (isArithmeticType(typeLeft) && isArithmeticOp (exprNode->id))
				return typeLeft ;
			else if (isArithmeticType(typeLeft) && isRelationalOp(exprNode->id))
				return TK_BOOLEAN ;
			else if (typeLeft == TK_BOOLEAN && isLogicalOp(exprNode->id))
				return typeLeft ;
			else
			{
				errSemantic () ;
				#ifdef _WIN64
					printf ("In module \"%s\" at line %d, the operator \"%s\" cannot be executed between two operands of type \"%s\"\n", getParentModuleName (baseModule), exprNode->tok->lineNumber, exprNode->tok->lexeme, typeIDToString(typeLeft)) ;
				#endif
				#if defined __linux__ || defined __MACH__
					printf ("In module " ANSI_BOLD "%s" ANSI_RESET " at line " ANSI_BOLD ANSI_CYAN "%d" ANSI_RESET ", the operator " ANSI_BOLD ANSI_CYAN "%s" ANSI_RESET " cannot be executed between two operands of type " ANSI_BOLD ANSI_GREEN "%s" ANSI_RESET "\n", getParentModuleName (baseModule), exprNode->tok->lineNumber, exprNode->tok->lexeme, typeIDToString(typeLeft)) ;
				#endif
				realBase->semanticError = 1 ;
				return (tokenID)0 ;
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x1450a
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
cmpq $0x0, 0x38(%rax)
jne 0x1456f
movq -0x18(%rbp), %rax
cmpl $0x40, (%rax)
je 0x14556
movq -0x18(%rbp), %rax
cmpl $0x71, (%rax)
jne 0x14528
movl $0x37, -0x4(%rbp)
jmp 0x14775
movq -0x18(%rbp), %rax
cmpl $0x72, (%rax)
jne 0x1454a
leaq 0x22acc(%rip), %rax     # 0x37004
movl $0x1, (%rax)
movl $0x38, -0x4(%rbp)
jmp 0x14775
movl $0x39, -0x4(%rbp)
jmp 0x14775
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x14200
movl %eax, -0x4(%rbp)
jmp 0x14775
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rsi
callq 0x144e0
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x38(%rax), %rsi
callq 0x144e0
movl %eax, -0x20(%rbp)
cmpl $0x3b, -0x1c(%rbp)
je 0x145a7
cmpl $0x3b, -0x20(%rbp)
jne 0x14603
movb $0x0, %al
callq 0x14d10
movq -0x10(%rbp), %rdi
callq 0x116e0
movq %rax, %rsi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x10(%rax), %edx
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rcx
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %r8
leaq 0x4ce4(%rip), %rdi      # 0x192d4
movb $0x0, %al
callq 0x1090
movl $0x0, -0x4(%rbp)
jmp 0x14775
cmpl $0x0, -0x1c(%rbp)
je 0x1460f
cmpl $0x0, -0x20(%rbp)
jne 0x1461b
movl $0x0, -0x4(%rbp)
jmp 0x14775
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
je 0x14695
movb $0x0, %al
callq 0x14d10
movq -0x10(%rbp), %rdi
callq 0x116e0
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x10(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movl -0x1c(%rbp), %edi
callq 0x12370
movq %rax, -0x28(%rbp)
movl -0x20(%rbp), %edi
callq 0x12370
movq -0x40(%rbp), %rsi
movl -0x34(%rbp), %edx
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %r8
movq %rax, %r9
leaq 0x4ce2(%rip), %rdi      # 0x19364
movb $0x0, %al
callq 0x1090
movl $0x0, -0x4(%rbp)
jmp 0x14775
movl -0x1c(%rbp), %edi
callq 0x144b0
cmpl $0x0, %eax
je 0x146bd
movq -0x18(%rbp), %rax
movl (%rax), %edi
callq 0x14400
cmpl $0x0, %eax
je 0x146bd
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x14775
movl -0x1c(%rbp), %edi
callq 0x144b0
cmpl $0x0, %eax
je 0x146e6
movq -0x18(%rbp), %rax
movl (%rax), %edi
callq 0x14470
cmpl $0x0, %eax
je 0x146e6
movl $0x39, -0x4(%rbp)
jmp 0x14775
cmpl $0x39, -0x1c(%rbp)
jne 0x14704
movq -0x18(%rbp), %rax
movl (%rax), %edi
callq 0x14440
cmpl $0x0, %eax
je 0x14704
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x14775
movb $0x0, %al
callq 0x14d10
movq -0x10(%rbp), %rdi
callq 0x116e0
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x10(%rax), %eax
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
movl -0x1c(%rbp), %edi
callq 0x12370
movq -0x58(%rbp), %rsi
movl -0x4c(%rbp), %edx
movq -0x48(%rbp), %rcx
movq %rax, %r8
leaq 0x4cab(%rip), %rdi      # 0x193fe
movb $0x0, %al
callq 0x1090
leaq 0x228a7(%rip), %rax     # 0x37008
movq (%rax), %rax
movl $0x1, 0xd8(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nop