// File: /workspace/github_c_makefile_star2_O3/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 0x1e22b
movq %rcx, %r14
movq %rdx, %r12
movl %esi, %ebx
movq %rdi, %r15
movl (%rdx), %eax
cmpl $0xe00, %eax            # imm = 0xE00
je 0x1dfb1
cmpl $0x200, %eax            # imm = 0x200
jne 0x1e24a
movq %r15, %rdi
movq %r12, %rsi
callq 0x1d657
movq %rax, %r13
movl (%rax), %eax
cmpl $0x3, %eax
je 0x1e0b0
cmpl $0x1, %eax
jne 0x1e269
movl %ebx, %r12d
movb 0x30(%r13), %bl
movq 0x70(%r13), %rcx
testq %r14, %r14
je 0x1df41
movb %bl, (%r14)
movq %rcx, 0x8(%r14)
movq 0x38(%r13), %rax
movq %rax, 0x10(%r14)
movq %rcx, -0x48(%rbp)
movzbl %bl, %r14d
movl %r14d, %edi
callq 0x2a937
testb %al, %al
je 0x1e1d5
movl %r14d, %edi
movl %r12d, -0x2c(%rbp)
movl %r12d, %esi
callq 0x1db33
movq %rax, %r12
movq 0x20(%r15), %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x1db8d
cmpq $0x7, -0x48(%rbp)
ja 0x1e21a
movq 0x20(%r15), %rdi
movl -0x2c(%rbp), %eax
shlq $0x5, %rax
leaq 0x3b829(%rip), %rcx     # 0x597c0
movq 0x18(%rax,%rcx), %rdx
movl $0x5, %esi
movl %r14d, %ecx
movq %r12, %r8
callq 0x1e288
jmp 0x1e21a
movl %ebx, -0x2c(%rbp)
movb 0x60(%r12), %bl
movq 0x68(%r12), %r13
movq (%r15), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x2a367
testq %r14, %r14
je 0x1dfdc
movb %bl, (%r14)
movq %rax, 0x8(%r14)
movq %r13, 0x10(%r14)
movzbl %bl, %r13d
movl %r13d, %edi
callq 0x2a937
testb %al, %al
je 0x1e049
leaq -0x40(%rbp), %r14
movq %r14, %rdi
callq 0x7314
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movl -0x2c(%rbp), %r12d
movl %r12d, %ecx
callq 0x1d869
cmpb $0x5, %bl
jne 0x1e0f5
movq 0x20(%r15), %rdi
movl %r12d, %eax
shlq $0x5, %rax
leaq 0x3b798(%rip), %rcx     # 0x597c0
movq 0x18(%rax,%rcx), %rsi
movq -0x38(%rbp), %rax
testq %rax, %rax
leaq 0x229e0(%rip), %rdx     # 0x40a1b
cmovneq %rax, %rdx
callq 0x1e39c
jmp 0x1e14b
cmpb $0x9, %bl
jne 0x1e151
leaq -0x40(%rbp), %rbx
movq %rbx, %rdi
callq 0x7314
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movl -0x2c(%rbp), %r14d
movl %r14d, %ecx
callq 0x1d869
movq 0x20(%r15), %rdi
movl %r14d, %eax
shlq $0x5, %rax
leaq 0x3b73b(%rip), %rcx     # 0x597c0
movq 0x18(%rax,%rcx), %rsi
movq 0x8(%rbx), %rax
testq %rax, %rax
leaq 0x22983(%rip), %rdx     # 0x40a1b
cmovneq %rax, %rdx
callq 0x1e39c
movq %rbx, %rdi
callq 0x7812
movb $0x9, %bl
jmp 0x1e21a
testq %r14, %r14
je 0x1e0d0
movq 0x58(%r13), %rdx
movq %rdx, 0x10(%r14)
movb $0x10, (%r14)
movq (%r15), %rdi
movq %r12, %rsi
callq 0x2a367
movq %rax, 0x8(%r14)
movq 0x20(%r15), %rdi
movl %ebx, %eax
shlq $0x5, %rax
leaq 0x3b6df(%rip), %rcx     # 0x597c0
movq 0x18(%rax,%rcx), %rsi
movq %r13, %rdx
callq 0x1d6da
movb $0x10, %bl
jmp 0x1e21a
movl %r13d, %edi
movl %r12d, %esi
callq 0x1db33
movq %rax, %r14
movq 0x20(%r15), %rdi
movq -0x38(%rbp), %rax
testq %rax, %rax
leaq 0x22906(%rip), %rcx     # 0x40a1b
cmovneq %rax, %rcx
movl %r13d, %esi
movq %r14, %rdx
callq 0x1dbf8
movq 0x20(%r15), %rdi
movl %r12d, %eax
shlq $0x5, %rax
leaq 0x3b68a(%rip), %rcx     # 0x597c0
movq 0x18(%rax,%rcx), %rdx
movl $0x5, %esi
movl %r13d, %ecx
movq %r14, %r8
callq 0x1e288
leaq -0x40(%rbp), %rdi
jmp 0x1e1ce
movq 0x20(%r15), %rdi
movl -0x2c(%rbp), %r14d
movl %r14d, %eax
shlq $0x5, %rax
leaq 0x3b659(%rip), %rcx     # 0x597c0
movq 0x18(%rax,%rcx), %rdx
leaq 0x2322b(%rip), %rcx     # 0x4139e
movl $0x9, %esi
callq 0x1dbf8
leaq -0x40(%rbp), %rdi
callq 0x7314
movq %r15, %rdi
leaq -0x40(%rbp), %rsi
movq %r12, %rdx
movl %r14d, %ecx
callq 0x1d869
movq 0x20(%r15), %r15
movl %r13d, %edi
movl %r14d, %esi
callq 0x1db33
leaq -0x40(%rbp), %r14
movq 0x8(%r14), %rdx
testq %rdx, %rdx
leaq 0x22862(%rip), %rcx     # 0x40a1b
cmovneq %rdx, %rcx
movq %r15, %rdi
movl %r13d, %esi
movq %rax, %rdx
callq 0x1dbf8
movq %r14, %rdi
callq 0x7812
jmp 0x1e21a
movq 0x20(%r15), %rdi
movl %r12d, %eax
shlq $0x5, %rax
leaq 0x3b5d9(%rip), %rcx     # 0x597c0
movq 0x18(%rax,%rcx), %rdx
leaq 0x231ab(%rip), %rcx     # 0x4139e
movl $0x9, %esi
callq 0x1dbf8
movq 0x20(%r15), %r15
movl %r14d, %edi
movl %r12d, %esi
callq 0x1db33
movq %r15, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x1db8d
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x230d4(%rip), %rdi     # 0x41306
leaq 0x2642f(%rip), %rsi     # 0x44668
leaq 0x26d0c(%rip), %rcx     # 0x44f4c
movl $0xd04, %edx            # imm = 0xD04
callq 0x30a0
leaq 0x20118(%rip), %rdi     # 0x3e369
leaq 0x26410(%rip), %rsi     # 0x44668
leaq 0x26ced(%rip), %rcx     # 0x44f4c
movl $0xd9f, %edx            # imm = 0xD9F
callq 0x30a0
leaq 0x200f9(%rip), %rdi     # 0x3e369
leaq 0x263f1(%rip), %rsi     # 0x44668
leaq 0x26cce(%rip), %rcx     # 0x44f4c
movl $0xd47, %edx            # imm = 0xD47
callq 0x30a0