// File: /workspace/github_c_makefile_star2_O1/Ihsoh[P]ilang/compiler/frontend/semantics.c
// Function: calc_cast_constexpr
static void _calc_cast_constexpr(
	ParserContext *ctx,
	uint8_t target_type,
	ParserASTNode *target,
	ParserASTNode *source
) {
	assert(ctx);
	assert(target);
	assert(source);

	uint8_t source_type = _get_type_by_type_node(ctx, FE_EXPR_AST_NODE_GET_TYPE_NODE(source));

	// 常量表达式不能把指针类型转换为非指针类型。
	if (source_type == FE_TYPE_POINTER
			&& target_type != FE_TYPE_POINTER) {
		_SYNERR_NODE(ctx, source, "not a compile-time constant.");
	}

	#define	_A(target_t, target_t_c)	\
		case FE_TYPE_##target_t: {	\
			switch (source_type) {	\
				case FE_TYPE_CHAR: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_CHAR_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_INT8: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_INT8_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_INT16: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_INT16_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_INT32: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_INT32_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_INT64: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_INT64_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_UINT8: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_UINT8_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_UINT16: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_UINT16_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_UINT32: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_UINT32_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_UINT64: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_UINT64_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_FLOAT: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_FLOAT_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_DOUBLE: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_DOUBLE_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_POINTER: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_POINTER_VAL(source)	\
					);	\
					break;	\
				}	\
				default: {	\
					assert(0);	\
				}	\
			}	\
			break;	\
		}


	switch (target_type) {
		_A(CHAR, char)
		_A(INT8, int8_t)
		_A(INT16, int16_t)
		_A(INT32, int32_t)
		_A(INT64, int64_t)
		_A(UINT8, uint8_t)
		_A(UINT16, uint16_t)
		_A(UINT32, uint32_t)
		_A(UINT64, uint64_t)
		_A(FLOAT, float)
		_A(DOUBLE, double)
		_A(POINTER, uint64_t)
		default: {
			assert(0);
		}
	}


	#undef	_A
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
testq %rcx, %rcx
je 0x32094
movq %rcx, %r15
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r13
movq 0x68(%rcx), %rsi
callq 0x2b04a
movl %eax, %r12d
cmpb $0x10, %al
setne %al
cmpb $0x10, %r14b
sete %cl
orb %al, %cl
jne 0x31b39
movups 0x1b018(%rip), %xmm0    # 0x4cb30
leaq -0x430(%rbp), %rdx
movups %xmm0, 0xd(%rdx)
movupd 0x1aff8(%rip), %xmm0    # 0x4cb23
movapd %xmm0, (%rdx)
movq %r13, %rdi
movq %r15, %rsi
callq *0x58(%r13)
movzbl %r14b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x320b3
leaq 0x19699(%rip), %rcx     # 0x4b1e8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x31b73
leaq 0x1997e(%rip), %rcx     # 0x4b4e8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xe80a(%rip), %rdi      # 0x40384
leaq 0x19cd9(%rip), %rsi     # 0x4b85a
leaq 0x1af45(%rip), %rcx     # 0x4cacd
movl $0x8e3, %edx            # imm = 0x8E3
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x31bad
leaq 0x19684(%rip), %rcx     # 0x4b228
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xe7d0(%rip), %rdi      # 0x40384
leaq 0x19c9f(%rip), %rsi     # 0x4b85a
leaq 0x1af0b(%rip), %rcx     # 0x4cacd
movl $0x8ee, %edx            # imm = 0x8EE
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x320d2
leaq 0x196c6(%rip), %rcx     # 0x4b2a8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl 0x88(%r15), %eax
jmp 0x32056
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x320f1
leaq 0x1965a(%rip), %rcx     # 0x4b268
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl 0x88(%r15), %eax
jmp 0x3206f
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x3214e
leaq 0x196ae(%rip), %rcx     # 0x4b2e8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movss 0x88(%r15), %xmm0
cvttss2si %xmm0, %rax
movq %rax, %rcx
subss 0x19bc4(%rip), %xmm0    # 0x4b820
cvttss2si %xmm0, %rdx
jmp 0x31e64
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x32110
leaq 0x1976c(%rip), %rcx     # 0x4b3e8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x88(%r15), %rax
jmp 0x31fe9
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x31cac
leaq 0x19805(%rip), %rcx     # 0x4b4a8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xe6d1(%rip), %rdi      # 0x40384
leaq 0x19ba0(%rip), %rsi     # 0x4b85a
leaq 0x1ae0c(%rip), %rcx     # 0x4cacd
movl $0x8e4, %edx            # imm = 0x8E4
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x3216d
leaq 0x196c7(%rip), %rcx     # 0x4b3a8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb 0x88(%r15), %al
movb %al, 0x88(%rbx)
jmp 0x3207e
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x31d17
leaq 0x1975a(%rip), %rcx     # 0x4b468
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xe666(%rip), %rdi      # 0x40384
leaq 0x19b35(%rip), %rsi     # 0x4b85a
leaq 0x1ada1(%rip), %rcx     # 0x4cacd
movl $0x8e5, %edx            # imm = 0x8E5
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x3218c
leaq 0x195dc(%rip), %rcx     # 0x4b328
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cvttss2si 0x88(%r15), %rax
jmp 0x31fad
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x3212f
leaq 0x196af(%rip), %rcx     # 0x4b428
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x88(%r15), %eax
jmp 0x32046
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x321ab
leaq 0x195c4(%rip), %rcx     # 0x4b368
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzwl 0x88(%r15), %eax
movw %ax, 0x88(%rbx)
jmp 0x3207e
movsbq 0x88(%r15), %rax
jmp 0x31fe9
movsbl 0x88(%r15), %eax
jmp 0x32046
movsbl 0x88(%r15), %eax
jmp 0x31f1d
movl 0x88(%r15), %eax
jmp 0x31fe9
cvttsd2si 0x88(%r15), %eax
jmp 0x31e3b
movswq 0x88(%r15), %rax
jmp 0x31fe9
movzbl 0x88(%r15), %eax
jmp 0x31fe9
movslq 0x88(%r15), %rax
jmp 0x31fe9
movzwl 0x88(%r15), %eax
jmp 0x31fe9
cvttss2si 0x88(%r15), %eax
movb %al, 0x88(%rbx)
jmp 0x3207e
movsd 0x88(%r15), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
subsd 0x199b9(%rip), %xmm0    # 0x4b818
cvttsd2si %xmm0, %rdx
sarq $0x3f, %rcx
andq %rcx, %rdx
orq %rax, %rdx
movq %rdx, 0x88(%rbx)
jmp 0x3207e
movq 0x88(%r15), %rax
testq %rax, %rax
jns 0x31ffc
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
jmp 0x3205d
cvttsd2si 0x88(%r15), %eax
jmp 0x31f1d
movsd 0x88(%r15), %xmm0
unpcklps 0x1996e(%rip), %xmm0    # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x19976(%rip), %xmm0    # 0x4b840
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm1, 0x88(%rbx)
jmp 0x3207e
movzwl 0x88(%r15), %eax
jmp 0x32046
movzbl 0x88(%r15), %eax
jmp 0x31f1d
movzbl 0x88(%r15), %eax
jmp 0x32046
movswl 0x88(%r15), %eax
jmp 0x32046
cvttss2si 0x88(%r15), %eax
movw %ax, 0x88(%rbx)
jmp 0x3207e
xorps %xmm0, %xmm0
cvtsd2ss 0x88(%r15), %xmm0
jmp 0x3205d
movsd 0x88(%r15), %xmm0
jmp 0x32076
movss 0x88(%r15), %xmm0
jmp 0x3205d
cvttsd2si 0x88(%r15), %rax
jmp 0x31fe9
xorps %xmm0, %xmm0
cvtss2sd 0x88(%r15), %xmm0
jmp 0x32076
xorps %xmm0, %xmm0
cvtsi2ssq 0x88(%r15), %xmm0
jmp 0x3205d
movzbl 0x88(%r15), %eax
jmp 0x32056
xorps %xmm0, %xmm0
cvtsi2sdq 0x88(%r15), %xmm0
jmp 0x32076
cvttsd2si 0x88(%r15), %rax
movl %eax, 0x88(%rbx)
jmp 0x3207e
cvttsd2si 0x88(%r15), %eax
jmp 0x32046
movswl 0x88(%r15), %eax
jmp 0x32056
movzbl 0x88(%r15), %eax
jmp 0x3206f
cvttss2si 0x88(%r15), %rax
movq %rax, 0x88(%rbx)
jmp 0x3207e
movl 0x88(%r15), %eax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
jmp 0x3205d
xorps %xmm0, %xmm0
cvtsi2ssl 0x88(%r15), %xmm0
jmp 0x3205d
movswl 0x88(%r15), %eax
jmp 0x3206f
movl 0x88(%r15), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
jmp 0x32076
xorps %xmm0, %xmm0
cvtsi2sdl 0x88(%r15), %xmm0
jmp 0x32076
cvttss2si 0x88(%r15), %eax
movl %eax, 0x88(%rbx)
jmp 0x3207e
movzwl 0x88(%r15), %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x88(%rbx)
jmp 0x3207e
movzwl 0x88(%r15), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x88(%rbx)
movb %r14b, 0x71(%rbx)
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd49b(%rip), %rdi      # 0x3f536
leaq 0x197b8(%rip), %rsi     # 0x4b85a
leaq 0x1aa24(%rip), %rcx     # 0x4cacd
movl $0x879, %edx            # imm = 0x879
callq 0x30a0
leaq 0xe2ca(%rip), %rdi      # 0x40384
leaq 0x19799(%rip), %rsi     # 0x4b85a
leaq 0x1aa05(%rip), %rcx     # 0x4cacd
movl $0x8f0, %edx            # imm = 0x8F0
callq 0x30a0
leaq 0xe2ab(%rip), %rdi      # 0x40384
leaq 0x1977a(%rip), %rsi     # 0x4b85a
leaq 0x1a9e6(%rip), %rcx     # 0x4cacd
movl $0x8ec, %edx            # imm = 0x8EC
callq 0x30a0
leaq 0xe28c(%rip), %rdi      # 0x40384
leaq 0x1975b(%rip), %rsi     # 0x4b85a
leaq 0x1a9c7(%rip), %rcx     # 0x4cacd
movl $0x8ed, %edx            # imm = 0x8ED
callq 0x30a0
leaq 0xe26d(%rip), %rdi      # 0x40384
leaq 0x1973c(%rip), %rsi     # 0x4b85a
leaq 0x1a9a8(%rip), %rcx     # 0x4cacd
movl $0x8e7, %edx            # imm = 0x8E7
callq 0x30a0
leaq 0xe24e(%rip), %rdi      # 0x40384
leaq 0x1971d(%rip), %rsi     # 0x4b85a
leaq 0x1a989(%rip), %rcx     # 0x4cacd
movl $0x8e6, %edx            # imm = 0x8E6
callq 0x30a0
leaq 0xe22f(%rip), %rdi      # 0x40384
leaq 0x196fe(%rip), %rsi     # 0x4b85a
leaq 0x1a96a(%rip), %rcx     # 0x4cacd
movl $0x8eb, %edx            # imm = 0x8EB
callq 0x30a0
leaq 0xe210(%rip), %rdi      # 0x40384
leaq 0x196df(%rip), %rsi     # 0x4b85a
leaq 0x1a94b(%rip), %rcx     # 0x4cacd
movl $0x8e8, %edx            # imm = 0x8E8
callq 0x30a0
leaq 0xe1f1(%rip), %rdi      # 0x40384
leaq 0x196c0(%rip), %rsi     # 0x4b85a
leaq 0x1a92c(%rip), %rcx     # 0x4cacd
movl $0x8ea, %edx            # imm = 0x8EA
callq 0x30a0
leaq 0xe1d2(%rip), %rdi      # 0x40384
leaq 0x196a1(%rip), %rsi     # 0x4b85a
leaq 0x1a90d(%rip), %rcx     # 0x4cacd
movl $0x8e9, %edx            # imm = 0x8E9
callq 0x30a0