// File: /workspace/github_c_makefile_star2_O1/Ihsoh[P]ilang/compiler/backend/asmgen_gas64.c
// Function: move_id_or_constexpr_to_reg_ex
static uint8_t _move_id_or_constexpr_to_reg_ex(
	ASMGeneratorGas64Context *ctx,
	int target_reg,
	ParserASTNode *source_id_or_constexpr,
	MoveIdOrConstexprToRegEx *result
) {
	assert(ctx);
	assert(source_id_or_constexpr);

	if (source_id_or_constexpr->type == BE_NODE_IDENTIFIER) {
		ParserSymbol *symbol = _get_symbol_by_id_node(ctx, source_id_or_constexpr);
		if (symbol->type == BE_SYM_VAR) {
			uint8_t symbol_type = BE_VAR_SYMBOL_GET_TYPE(symbol);
			size_t type_size = BE_VAR_SYMBOL_GET_TYPE_SIZE(symbol);
			if (result != NULL) {
				result->type = symbol_type;
				result->type_size = type_size;
				result->node_type = BE_VAR_SYMBOL_GET_TYPE_NODE(symbol);
			}

			if (be_sem_is_signed_type(symbol_type)) {
				const char *target_reg_name = _asm_inst_reg(ctx, symbol_type, target_reg);
			
				_asm_inst_mov_x_sym(
					ctx,
					ctx->body,
					target_reg_name,
					symbol
				);

				if (type_size < 8) {
					_asm_inst_movsx_x_x(
						ctx,
						ctx->body,
						BE_TYPE_INT64,
						_asm_inst_reg(ctx, BE_TYPE_INT64, target_reg),
						symbol_type,
						target_reg_name
					);
				}
			} else {
				_asm_inst_mov_x_x(
					ctx,
					ctx->body,
					BE_TYPE_UINT64,
					_asm_inst_reg(ctx, BE_TYPE_UINT64, target_reg),
					_ASM_CONST_0
				);

				_asm_inst_mov_x_sym(
					ctx,
					ctx->body,
					_asm_inst_reg(ctx, symbol_type, target_reg),
					symbol
				);
			}

			return symbol_type;
		} else if (symbol->type == BE_SYM_FUNC) {
			if (result != NULL) {
				result->node_type = BE_FUNC_SYMBOL_GET_FUNC_NAME_NODE(symbol);
				result->type = BE_TYPE_POINTER;
				result->type_size = be_sem_calc_type_size(ctx->psrctx, source_id_or_constexpr, result->node_type);
			}

			_asm_inst_mov_x_fsym(
				ctx,
				ctx->body,
				_asm_inst_reg(ctx, BE_TYPE_UINT64, target_reg),
				symbol
			);

			return BE_TYPE_POINTER;
		} else {
			assert(0);
			return BE_TYPE_UNKNOWN;
		}
	} else if (source_id_or_constexpr->type == BE_NODE_EXPR) {
		uint8_t type = BE_EXPR_AST_NODE_GET_TYPE(source_id_or_constexpr);
		ParserASTNode *node_type = BE_EXPR_AST_NODE_GET_TYPE_NODE(source_id_or_constexpr);
		size_t type_size = be_sem_calc_type_size(ctx->psrctx, source_id_or_constexpr, node_type);
		if (result != NULL) {
			result->type = type;
			result->type_size = type_size;
			result->node_type = node_type;
		}
		
		if (be_sem_is_signed_type(type)) {
			ResizableString rstr;
			rstr_init(&rstr);
			_asm_constexpr_param(ctx, &rstr, source_id_or_constexpr, target_reg);

			if (type == BE_TYPE_INT64) {
				_asm_inst_mov_reg64_imm64(
					ctx,
					ctx->body,
					_asm_inst_reg(ctx, BE_TYPE_INT64, target_reg),
					RSTR_CSTR(&rstr)
				);
			} else {
				const char *target_reg_name = _asm_inst_reg(ctx, type, target_reg);

				_asm_inst_mov_x_x(
					ctx,
					ctx->body,
					type,
					target_reg_name,
					RSTR_CSTR(&rstr)
				);

				_asm_inst_movsx_x_x(
					ctx,
					ctx->body,
					BE_TYPE_INT64,
					_asm_inst_reg(ctx, BE_TYPE_INT64, target_reg),
					type,
					target_reg_name
				);
			}

			rstr_free(&rstr);
		} else {
			if (type == BE_TYPE_UINT64) {
				ResizableString rstr;
				rstr_init(&rstr);
				_asm_constexpr_param(ctx, &rstr, source_id_or_constexpr, target_reg);

				_asm_inst_mov_reg64_imm64(
					ctx,
					ctx->body,
					_asm_inst_reg(ctx, BE_TYPE_UINT64, target_reg),
					RSTR_CSTR(&rstr)
				);

				rstr_free(&rstr);
			} else {
				_asm_inst_mov_x_x(
					ctx,
					ctx->body,
					BE_TYPE_UINT64,
					_asm_inst_reg(ctx, BE_TYPE_UINT64, target_reg),
					_ASM_CONST_0
				);

				ResizableString rstr;
				rstr_init(&rstr);
				_asm_constexpr_param(ctx, &rstr, source_id_or_constexpr, target_reg);

				_asm_inst_mov_x_x(
					ctx,
					ctx->body,
					type,
					_asm_inst_reg(ctx, type, target_reg),
					RSTR_CSTR(&rstr)
				);

				rstr_free(&rstr);
			}
		}

		return type;
	} else {
		assert(0);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
testq %rdx, %rdx
je 0x1e610
movq %rcx, %rbx
movq %rdx, %r12
movl %esi, %r14d
movq %rdi, %r15
movl (%rdx), %eax
cmpl $0xe00, %eax            # imm = 0xE00
je 0x1e39b
cmpl $0x200, %eax            # imm = 0x200
jne 0x1e62f
movq %r15, %rdi
movq %r12, %rsi
callq 0x1da4c
movq %rax, %r13
movl (%rax), %eax
cmpl $0x3, %eax
je 0x1e497
cmpl $0x1, %eax
jne 0x1e64e
movb 0x30(%r13), %cl
movq 0x70(%r13), %r12
testq %rbx, %rbx
je 0x1e333
movb %cl, (%rbx)
movq %r12, 0x8(%rbx)
movq 0x38(%r13), %rax
movq %rax, 0x10(%rbx)
movb %cl, -0x29(%rbp)
movzbl %cl, %ebx
movl %ebx, %edi
callq 0x2b31a
testb %al, %al
je 0x1e5ca
movl %ebx, %edi
movl %r14d, %esi
callq 0x1df28
movq 0x20(%r15), %rdi
movq %rax, -0x38(%rbp)
movq %rax, %rsi
movq %r13, %rdx
callq 0x1df82
cmpq $0x7, %r12
ja 0x1e5b8
movq 0x20(%r15), %rdi
movl %r14d, %eax
shlq $0x5, %rax
leaq 0x3d43f(%rip), %rcx     # 0x5b7c0
movq 0x18(%rax,%rcx), %rdx
movl $0x5, %esi
movl %ebx, %ecx
movq -0x38(%rbp), %r8
callq 0x1e66d
jmp 0x1e5b8
movl %r14d, -0x38(%rbp)
movb 0x60(%r12), %r14b
movq 0x68(%r12), %r13
movq (%r15), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x2ad41
testq %rbx, %rbx
je 0x1e3c7
movb %r14b, (%rbx)
movq %rax, 0x8(%rbx)
movq %r13, 0x10(%rbx)
movzbl %r14b, %r13d
movl %r13d, %edi
callq 0x2b31a
testb %al, %al
movb %r14b, -0x29(%rbp)
je 0x1e439
leaq -0x48(%rbp), %rbx
movq %rbx, %rdi
callq 0x7508
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movl -0x38(%rbp), %r12d
movl %r12d, %ecx
callq 0x1dc5e
cmpb $0x5, %r14b
jne 0x1e4dc
movq 0x20(%r15), %rdi
movl %r12d, %eax
shlq $0x5, %rax
leaq 0x3d3a8(%rip), %rcx     # 0x5b7c0
movq 0x18(%rax,%rcx), %rsi
movq -0x40(%rbp), %rax
testq %rax, %rax
leaq 0x24630(%rip), %rdx     # 0x42a5b
cmovneq %rax, %rdx
callq 0x1e781
jmp 0x1e532
cmpb $0x9, %r14b
jne 0x1e538
leaq -0x48(%rbp), %rbx
movq %rbx, %rdi
callq 0x7508
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movl -0x38(%rbp), %r14d
movl %r14d, %ecx
callq 0x1dc5e
movq 0x20(%r15), %rdi
movl %r14d, %eax
shlq $0x5, %rax
leaq 0x3d34a(%rip), %rcx     # 0x5b7c0
movq 0x18(%rax,%rcx), %rsi
movq 0x8(%rbx), %rax
testq %rax, %rax
leaq 0x245d2(%rip), %rdx     # 0x42a5b
cmovneq %rax, %rdx
callq 0x1e781
jmp 0x1e5b0
testq %rbx, %rbx
je 0x1e4b6
movq 0x58(%r13), %rdx
movq %rdx, 0x10(%rbx)
movb $0x10, (%rbx)
movq (%r15), %rdi
movq %r12, %rsi
callq 0x2ad41
movq %rax, 0x8(%rbx)
movq 0x20(%r15), %rdi
movl %r14d, %eax
shlq $0x5, %rax
leaq 0x3d2f8(%rip), %rcx     # 0x5b7c0
movq 0x18(%rax,%rcx), %rsi
movq %r13, %rdx
callq 0x1dacf
movb $0x10, %al
jmp 0x1e5bb
movl %r13d, %edi
movl %r12d, %esi
callq 0x1df28
movq %rax, %rbx
movq 0x20(%r15), %rdi
movq -0x40(%rbp), %rax
testq %rax, %rax
leaq 0x2455f(%rip), %rcx     # 0x42a5b
cmovneq %rax, %rcx
movl %r13d, %esi
movq %rbx, %rdx
callq 0x1dfed
movq 0x20(%r15), %rdi
movl %r12d, %eax
shlq $0x5, %rax
leaq 0x3d2a3(%rip), %rcx     # 0x5b7c0
movq 0x18(%rax,%rcx), %rdx
movl $0x5, %esi
movl %r13d, %ecx
movq %rbx, %r8
callq 0x1e66d
leaq -0x48(%rbp), %rdi
jmp 0x1e5b3
movq 0x20(%r15), %rdi
movl -0x38(%rbp), %r14d
movl %r14d, %eax
shlq $0x5, %rax
leaq 0x3d272(%rip), %rcx     # 0x5b7c0
movq 0x18(%rax,%rcx), %rdx
leaq 0x24e84(%rip), %rcx     # 0x433de
movl $0x9, %esi
callq 0x1dfed
leaq -0x48(%rbp), %rbx
movq %rbx, %rdi
callq 0x7508
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movl %r14d, %ecx
callq 0x1dc5e
movq 0x20(%r15), %r15
movl %r13d, %edi
movl %r14d, %esi
callq 0x1df28
movq 0x8(%rbx), %rdx
testq %rdx, %rdx
leaq 0x244bd(%rip), %rcx     # 0x42a5b
cmovneq %rdx, %rcx
movq %r15, %rdi
movl %r13d, %esi
movq %rax, %rdx
callq 0x1dfed
movq %rbx, %rdi
callq 0x79f8
movb -0x29(%rbp), %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x20(%r15), %rdi
movl %r14d, %eax
shlq $0x5, %rax
leaq 0x3d1e4(%rip), %rcx     # 0x5b7c0
movq 0x18(%rax,%rcx), %rdx
leaq 0x24df6(%rip), %rcx     # 0x433de
movl $0x9, %esi
callq 0x1dfed
movq 0x20(%r15), %r15
movl %ebx, %edi
movl %r14d, %esi
callq 0x1df28
movq %r15, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x1df82
jmp 0x1e5b8
leaq 0x24d2f(%rip), %rdi     # 0x43346
leaq 0x2808a(%rip), %rsi     # 0x466a8
leaq 0x28967(%rip), %rcx     # 0x46f8c
movl $0xd04, %edx            # imm = 0xD04
callq 0x30a0
leaq 0x21d57(%rip), %rdi     # 0x4038d
leaq 0x2806b(%rip), %rsi     # 0x466a8
leaq 0x28948(%rip), %rcx     # 0x46f8c
movl $0xd9f, %edx            # imm = 0xD9F
callq 0x30a0
leaq 0x21d38(%rip), %rdi     # 0x4038d
leaq 0x2804c(%rip), %rsi     # 0x466a8
leaq 0x28929(%rip), %rcx     # 0x46f8c
movl $0xd47, %edx            # imm = 0xD47
callq 0x30a0