// File: /workspace/github_c_makefile_star2_O1/Ihsoh[P]ilang/compiler/frontend/irgen.c
// Function: ir_constexpr
static void _ir_constexpr(
	IRGeneratorContext *ctx,
	ResizableString *rstr_val,
	ParserASTNode *node_constexpr
) {
	assert(ctx);
	assert(rstr_val);
	assert(node_constexpr);
	assert(FE_EXPR_AST_NODE_GET_CONSTANT(node_constexpr));

	switch (FE_EXPR_AST_NODE_GET_CONSTANT_TYPE(node_constexpr)) {
		case FE_TYPE_CHAR: {
			char str[128];
			snprintf(
				str, sizeof(str), "cast<char>(%d)",
				FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_CHAR_VAL(node_constexpr)
			);
			rstr_append_with_cstr(rstr_val, str);
			break;
		}
		case FE_TYPE_INT8: {
			char str[128];
			snprintf(
				str, sizeof(str), "cast<int8>(%d)",
				FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_INT8_VAL(node_constexpr)
			);
			rstr_append_with_cstr(rstr_val, str);
			break;
		}
		case FE_TYPE_INT16: {
			char str[128];
			snprintf(
				str, sizeof(str), "cast<int16>(%d)",
				FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_INT16_VAL(node_constexpr)
			);
			rstr_append_with_cstr(rstr_val, str);
			break;
		}
		case FE_TYPE_INT32: {
			char str[128];
			snprintf(
				str, sizeof(str), "cast<int32>(%d)",
				FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_INT32_VAL(node_constexpr)
			);
			rstr_append_with_cstr(rstr_val, str);
			break;
		}
		case FE_TYPE_INT64: {
			char str[128];
			snprintf(
				str, sizeof(str), "cast<int64>(%lld)",
				FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_INT64_VAL(node_constexpr)
			);
			rstr_append_with_cstr(rstr_val, str);
			break;
		}
		case FE_TYPE_UINT8: {
			char str[128];
			snprintf(
				str, sizeof(str), "cast<uint8>(%u)",
				FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_UINT8_VAL(node_constexpr)
			);
			rstr_append_with_cstr(rstr_val, str);
			break;
		}
		case FE_TYPE_UINT16: {
			char str[128];
			snprintf(
				str, sizeof(str), "cast<uint16>(%u)",
				FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_UINT16_VAL(node_constexpr)
			);
			rstr_append_with_cstr(rstr_val, str);
			break;
		}
		case FE_TYPE_UINT32: {
			char str[128];
			snprintf(
				str, sizeof(str), "cast<uint32>(%u)",
				FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_UINT32_VAL(node_constexpr)
			);
			rstr_append_with_cstr(rstr_val, str);
			break;
		}
		case FE_TYPE_UINT64: {
			char str[128];
			snprintf(
				str, sizeof(str), "cast<uint64>(%llu)",
				FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_UINT64_VAL(node_constexpr)
			);
			rstr_append_with_cstr(rstr_val, str);
			break;
		}
		case FE_TYPE_FLOAT: {
			char str[128];
			float val = FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_FLOAT_VAL(node_constexpr);
			snprintf(
				str, sizeof(str), "cast<float>(%f)",
				val
			);
			rstr_append_with_cstr(rstr_val, str);
			break;
		}
		case FE_TYPE_DOUBLE: {
			char str[128];
			double val = FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_DOUBLE_VAL(node_constexpr);
			snprintf(
				str, sizeof(str), "cast<double>(%lf)",
				val
			);
			rstr_append_with_cstr(rstr_val, str);
			break;
		}
		case FE_TYPE_POINTER: {
			if (FE_EXPR_AST_NODE_GET_HAS_CONSTSTR(node_constexpr)) {
				FeParserConstexprString *conststr = FE_EXPR_AST_NODE_GET_CONSTSTR(node_constexpr);
				uint64_t ptr_val = FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_POINTER_VAL(node_constexpr);

				ResizableString rstr_string;
				rstr_init(&rstr_string);
				rstr_append_with_char(&rstr_string, '"');
				rstr_append_with_raw(&rstr_string, conststr->str, conststr->len);
				rstr_append_with_char(&rstr_string, '"');

				ResizableString target_type;
				rstr_init(&target_type);
				_ir_type(ctx, &target_type, FE_EXPR_AST_NODE_GET_TYPE_NODE(node_constexpr));

				char str[1024];
				if (ptr_val == 0) {
					snprintf(
						str, sizeof(str), "cast<%s>(%s)",
						RSTR_CSTR(&target_type),
						RSTR_CSTR(&rstr_string)
					);
				} else {
					snprintf(
						str, sizeof(str), "cast<%s>(%s + %llu)",
						RSTR_CSTR(&target_type),
						RSTR_CSTR(&rstr_string),
						ptr_val
					);
				}

				rstr_append_with_cstr(rstr_val, str);

				rstr_free(&rstr_string);
				rstr_free(&target_type);
			} else {
				ResizableString target_type;
				rstr_init(&target_type);
				_ir_type(ctx, &target_type, FE_EXPR_AST_NODE_GET_TYPE_NODE(node_constexpr));

				char str[1024];
				snprintf(
					str, sizeof(str), "cast<%s>(%llu)",
					RSTR_CSTR(&target_type),
					FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_POINTER_VAL(node_constexpr)
				);
				rstr_append_with_cstr(rstr_val, str);

				rstr_free(&target_type);
			}
			break;
		}
		default: {
			assert(0);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
testq %rdi, %rdi
je 0xdd60
movq %rsi, %r14
cmpb $0x0, 0x70(%rsi)
je 0xdd7f
movzbl 0x71(%r14), %eax
decl %eax
cmpl $0xf, %eax
ja 0xdd9e
movq %rdi, %rbx
leaq 0x3475f(%rip), %rcx     # 0x42250
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl 0x88(%r14), %ecx
leaq 0x34f98(%rip), %rdx     # 0x42aa1
jmp 0xdc8f
cmpb $0x1, 0x72(%r14)
jne 0xdcc2
movq 0x88(%r14), %r15
leaq -0x38(%rbp), %r12
movq %r12, %rdi
callq 0x7548
movq %r12, %rdi
movl $0x22, %esi
callq 0x76cb
movq 0x78(%r14), %rsi
movl 0x80(%r14), %edx
movq %r12, %rdi
callq 0x7768
movq %r12, %rdi
movl $0x22, %esi
callq 0x76cb
leaq -0x48(%rbp), %r13
movq %r13, %rdi
callq 0x7548
movq 0x68(%r14), %rsi
movq %r13, %rdi
callq 0xcbf5
movq 0x8(%r13), %rcx
testq %rcx, %rcx
leaq 0x3633b(%rip), %rax     # 0x43eba
cmoveq %rax, %rcx
movq 0x8(%r12), %r8
testq %r8, %r8
cmoveq %rax, %r8
testq %r15, %r15
je 0xdd20
leaq 0x34fc6(%rip), %rdx     # 0x42b65
leaq -0x450(%rbp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %r15, %r9
xorl %eax, %eax
callq 0x3090
jmp 0xdd3a
cvtss2sd 0x88(%r14), %xmm0
leaq 0x34f6c(%rip), %rdx     # 0x42b36
jmp 0xdbdc
movsd 0x88(%r14), %xmm0
leaq 0x34f6a(%rip), %rdx     # 0x42b46
leaq -0x450(%rbp), %r14
movl $0x80, %esi
movq %r14, %rdi
movb $0x1, %al
callq 0x3090
jmp 0xdca5
movq 0x88(%r14), %rcx
leaq 0x34f1e(%rip), %rdx     # 0x42b23
jmp 0xdc15
movq 0x88(%r14), %rcx
leaq 0x34eca(%rip), %rdx     # 0x42adf
leaq -0x450(%rbp), %r14
movl $0x80, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x3090
jmp 0xdca5
movsbl 0x88(%r14), %ecx
leaq 0x34e74(%rip), %rdx     # 0x42ab0
jmp 0xdc8f
movzbl 0x88(%r14), %ecx
leaq 0x34ea4(%rip), %rdx     # 0x42af1
jmp 0xdc8f
movswl 0x88(%r14), %ecx
leaq 0x34e61(%rip), %rdx     # 0x42abf
jmp 0xdc8f
movl 0x88(%r14), %ecx
leaq 0x34ea4(%rip), %rdx     # 0x42b12
jmp 0xdc8f
movl 0x88(%r14), %ecx
leaq 0x34e51(%rip), %rdx     # 0x42acf
jmp 0xdc8f
movzwl 0x88(%r14), %ecx
leaq 0x34e72(%rip), %rdx     # 0x42b01
leaq -0x450(%rbp), %r14
movl $0x80, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x3090
movq %rbx, %rdi
movq %r14, %rsi
callq 0x75cf
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x38(%rbp), %r15
movq %r15, %rdi
callq 0x7548
movq 0x68(%r14), %rsi
movq %r15, %rdi
callq 0xcbf5
movq 0x8(%r15), %rax
testq %rax, %rax
leaq 0x361d2(%rip), %rcx     # 0x43eba
cmovneq %rax, %rcx
movq 0x88(%r14), %r8
leaq 0x34e7f(%rip), %rdx     # 0x42b79
leaq -0x450(%rbp), %r14
movl $0x400, %esi            # imm = 0x400
movq %r14, %rdi
xorl %eax, %eax
callq 0x3090
movq %rbx, %rdi
movq %r14, %rsi
callq 0x75cf
movq %r15, %rdi
jmp 0xdd56
leaq 0x34e31(%rip), %rdx     # 0x42b58
leaq -0x450(%rbp), %rdi
movl $0x400, %esi            # imm = 0x400
xorl %eax, %eax
callq 0x3090
leaq -0x450(%rbp), %rsi
movq %rbx, %rdi
callq 0x75cf
leaq -0x38(%rbp), %rdi
callq 0x7a38
leaq -0x48(%rbp), %rdi
callq 0x7a38
jmp 0xdcb0
leaq 0x34d31(%rip), %rdi     # 0x42a98
leaq 0x345aa(%rip), %rsi     # 0x42318
leaq 0x34cd6(%rip), %rcx     # 0x42a4b
movl $0x2c3, %edx            # imm = 0x2C3
callq 0x30a0
leaq 0x34c97(%rip), %rdi     # 0x42a1d
leaq 0x3458b(%rip), %rsi     # 0x42318
leaq 0x34cb7(%rip), %rcx     # 0x42a4b
movl $0x2c5, %edx            # imm = 0x2C5
callq 0x30a0
leaq 0x325df(%rip), %rdi     # 0x40384
leaq 0x3456c(%rip), %rsi     # 0x42318
leaq 0x34c98(%rip), %rcx     # 0x42a4b
movl $0x362, %edx            # imm = 0x362
callq 0x30a0