// File: /workspace/github_c_makefile_star2_O2/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 0x1c2cd
movq %rcx, %r14
movq %rdx, %r12
movl %esi, %ebx
movq %rdi, %r15
movl (%rdx), %eax
cmpl $0xe00, %eax            # imm = 0xE00
je 0x1c059
cmpl $0x200, %eax            # imm = 0x200
jne 0x1c2ec
movq %r15, %rdi
movq %r12, %rsi
callq 0x1b707
movq %rax, %r13
movl (%rax), %eax
cmpl $0x3, %eax
je 0x1c158
cmpl $0x1, %eax
jne 0x1c30b
movl %ebx, %r12d
movb 0x30(%r13), %bl
movq 0x70(%r13), %rcx
testq %r14, %r14
je 0x1bfeb
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 0x27ff7
testb %al, %al
je 0x1c279
movl %r14d, %edi
movl %r12d, -0x2c(%rbp)
movl %r12d, %esi
callq 0x1bbdd
movq %rax, %r12
movq 0x20(%r15), %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x1bc37
cmpq $0x7, -0x48(%rbp)
ja 0x1c2bc
movq 0x20(%r15), %rdi
movl -0x2c(%rbp), %eax
shlq $0x5, %rax
leaq 0x3a77f(%rip), %rcx     # 0x567c0
movq 0x18(%rax,%rcx), %rdx
pushq $0x5
popq %rsi
movl %r14d, %ecx
movq %r12, %r8
callq 0x1c32a
jmp 0x1c2bc
movl %ebx, -0x2c(%rbp)
movb 0x60(%r12), %bl
movq 0x68(%r12), %r13
movq (%r15), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x27a58
testq %r14, %r14
je 0x1c084
movb %bl, (%r14)
movq %rax, 0x8(%r14)
movq %r13, 0x10(%r14)
movzbl %bl, %r13d
movl %r13d, %edi
callq 0x27ff7
testb %al, %al
je 0x1c0f1
leaq -0x40(%rbp), %r14
movq %r14, %rdi
callq 0x6e1c
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movl -0x2c(%rbp), %r12d
movl %r12d, %ecx
callq 0x1b909
cmpb $0x5, %bl
jne 0x1c19d
movq 0x20(%r15), %rdi
movl %r12d, %eax
shlq $0x5, %rax
leaq 0x3a6f0(%rip), %rcx     # 0x567c0
movq 0x18(%rax,%rcx), %rsi
movq -0x38(%rbp), %rax
testq %rax, %rax
leaq 0x21948(%rip), %rdx     # 0x3da2b
cmovneq %rax, %rdx
callq 0x1c43e
jmp 0x1c1f1
cmpb $0x9, %bl
jne 0x1c1f7
leaq -0x40(%rbp), %rbx
movq %rbx, %rdi
callq 0x6e1c
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movl -0x2c(%rbp), %r14d
movl %r14d, %ecx
callq 0x1b909
movq 0x20(%r15), %rdi
movl %r14d, %eax
shlq $0x5, %rax
leaq 0x3a693(%rip), %rcx     # 0x567c0
movq 0x18(%rax,%rcx), %rsi
movq 0x8(%rbx), %rax
testq %rax, %rax
leaq 0x218eb(%rip), %rdx     # 0x3da2b
cmovneq %rax, %rdx
callq 0x1c43e
movq %rbx, %rdi
callq 0x72b9
movb $0x9, %bl
jmp 0x1c2bc
testq %r14, %r14
je 0x1c178
movq 0x58(%r13), %rdx
movq %rdx, 0x10(%r14)
movb $0x10, (%r14)
movq (%r15), %rdi
movq %r12, %rsi
callq 0x27a58
movq %rax, 0x8(%r14)
movq 0x20(%r15), %rdi
movl %ebx, %eax
shlq $0x5, %rax
leaq 0x3a637(%rip), %rcx     # 0x567c0
movq 0x18(%rax,%rcx), %rsi
movq %r13, %rdx
callq 0x1b78a
movb $0x10, %bl
jmp 0x1c2bc
movl %r13d, %edi
movl %r12d, %esi
callq 0x1bbdd
movq %rax, %r14
movq 0x20(%r15), %rdi
movq -0x38(%rbp), %rax
testq %rax, %rax
leaq 0x2186e(%rip), %rcx     # 0x3da2b
cmovneq %rax, %rcx
movl %r13d, %esi
movq %r14, %rdx
callq 0x1bca2
movq 0x20(%r15), %rdi
movl %r12d, %eax
shlq $0x5, %rax
leaq 0x3a5e2(%rip), %rcx     # 0x567c0
movq 0x18(%rax,%rcx), %rdx
pushq $0x5
popq %rsi
movl %r13d, %ecx
movq %r14, %r8
callq 0x1c32a
leaq -0x40(%rbp), %rdi
jmp 0x1c272
movq 0x20(%r15), %rdi
movl -0x2c(%rbp), %r14d
movl %r14d, %eax
shlq $0x5, %rax
leaq 0x3a5b3(%rip), %rcx     # 0x567c0
movq 0x18(%rax,%rcx), %rdx
leaq 0x22184(%rip), %rcx     # 0x3e39d
pushq $0x9
popq %rsi
callq 0x1bca2
leaq -0x40(%rbp), %rdi
callq 0x6e1c
movq %r15, %rdi
leaq -0x40(%rbp), %rsi
movq %r12, %rdx
movl %r14d, %ecx
callq 0x1b909
movq 0x20(%r15), %r15
movl %r13d, %edi
movl %r14d, %esi
callq 0x1bbdd
leaq -0x40(%rbp), %r14
movq 0x8(%r14), %rdx
testq %rdx, %rdx
leaq 0x217ce(%rip), %rcx     # 0x3da2b
cmovneq %rdx, %rcx
movq %r15, %rdi
movl %r13d, %esi
movq %rax, %rdx
callq 0x1bca2
movq %r14, %rdi
callq 0x72b9
jmp 0x1c2bc
movq 0x20(%r15), %rdi
movl %r12d, %eax
shlq $0x5, %rax
leaq 0x3a535(%rip), %rcx     # 0x567c0
movq 0x18(%rax,%rcx), %rdx
leaq 0x22106(%rip), %rcx     # 0x3e39d
pushq $0x9
popq %rsi
callq 0x1bca2
movq 0x20(%r15), %r15
movl %r14d, %edi
movl %r12d, %esi
callq 0x1bbdd
movq %r15, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x1bc37
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x22031(%rip), %rdi     # 0x3e305
leaq 0x253bd(%rip), %rsi     # 0x41698
leaq 0x25c9a(%rip), %rcx     # 0x41f7c
movl $0xd04, %edx            # imm = 0xD04
callq 0x30a0
leaq 0x1f076(%rip), %rdi     # 0x3b369
leaq 0x2539e(%rip), %rsi     # 0x41698
leaq 0x25c7b(%rip), %rcx     # 0x41f7c
movl $0xd9f, %edx            # imm = 0xD9F
callq 0x30a0
leaq 0x1f057(%rip), %rdi     # 0x3b369
leaq 0x2537f(%rip), %rsi     # 0x41698
leaq 0x25c5c(%rip), %rcx     # 0x41f7c
movl $0xd47, %edx            # imm = 0xD47
callq 0x30a0