// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/backend/asmgen_gas64.c
// Function: asm_stat_assign
static void _asm_stat_assign(
	ASMGeneratorGas64Context *ctx,
	ParserASTNode *node
) {
	assert(ctx);
	assert(node);
	assert(node->type == BE_NODE_STAT_ASSIGN);

	ParserASTNode *node_target = node->childs[0];
	assert(node_target->type == BE_NODE_IDENTIFIER);
	ParserSymbol *symbol_target = _get_var_symbol_by_id_node(ctx, node_target);

	ParserASTNode *node_source = node->childs[1];
	if (node_source->type == BE_NODE_IDENTIFIER) {
		ParserSymbol *symbol_source = _get_symbol_by_id_node(ctx, node_source);
		if (symbol_source->type == BE_SYM_VAR) {
			_asm_inst_mov_sym_sym(
				ctx,
				ctx->body,
				symbol_target,
				symbol_source
			);
		} else if (symbol_source->type == BE_SYM_FUNC) {
			_asm_inst_mov_x_fsym(
				ctx,
				ctx->body,
				_ASM_REG_NAME_RAX,
				symbol_source
			);

			_asm_inst_mov_sym_x(
				ctx,
				ctx->body,
				symbol_target,
				_ASM_REG_NAME_RAX
			);
		} else {
			assert(0);
		}
	} else if (node_source->type == BE_NODE_EXPR) {
		ResizableString rstr_source;
		rstr_init(&rstr_source);
		_asm_constexpr_param(ctx, &rstr_source, node_source, _ASM_REG_AX);
		
		uint8_t type_target = BE_VAR_SYMBOL_GET_TYPE(symbol_target);
		_move_id_or_constexpr_to_reg(
			ctx,
			_ASM_REG_AX,
			node_source
		);

		_asm_inst_mov_sym_x(
			ctx,
			ctx->body,
			symbol_target,
			_asm_inst_reg(ctx, type_target, _ASM_REG_AX)
		);

		rstr_free(&rstr_source);
	} else {
		assert(0);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x2a649
jmp 0x2a668
leaq 0x55b11(%rip), %rdi     # 0x80161
leaq 0x504ad(%rip), %rsi     # 0x7ab04
movl $0xdba, %edx            # imm = 0xDBA
leaq 0x50a14(%rip), %rcx     # 0x7b077
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x2a671
jmp 0x2a690
leaq 0x4bee4(%rip), %rdi     # 0x7655c
leaq 0x50485(%rip), %rsi     # 0x7ab04
movl $0xdbb, %edx            # imm = 0xDBB
leaq 0x509ec(%rip), %rcx     # 0x7b077
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0xb90, (%rax)          # imm = 0xB90
jne 0x2a69e
jmp 0x2a6bd
leaq 0x4bcf6(%rip), %rdi     # 0x7639b
leaq 0x50458(%rip), %rsi     # 0x7ab04
movl $0xdbc, %edx            # imm = 0xDBC
leaq 0x509bf(%rip), %rcx     # 0x7b077
callq 0x30a0
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x200, (%rax)          # imm = 0x200
jne 0x2a6da
jmp 0x2a6f9
leaq 0x4bcdc(%rip), %rdi     # 0x763bd
leaq 0x5041c(%rip), %rsi     # 0x7ab04
movl $0xdbf, %edx            # imm = 0xDBF
leaq 0x50983(%rip), %rcx     # 0x7b077
callq 0x30a0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x32820
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x200, (%rax)          # imm = 0x200
jne 0x2a7c8
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x32900
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x2a75f
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x329e0
jmp 0x2a7c3
movq -0x30(%rbp), %rax
cmpl $0x3, (%rax)
jne 0x2a7a2
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x30(%rbp), %rcx
leaq 0x5093b(%rip), %rdx     # 0x7b0ba
callq 0x32b90
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x20(%rbp), %rdx
leaq 0x5091f(%rip), %rcx     # 0x7b0ba
callq 0x32d40
jmp 0x2a7c1
leaq 0x48cb1(%rip), %rdi     # 0x7345a
leaq 0x50354(%rip), %rsi     # 0x7ab04
movl $0xddb, %edx            # imm = 0xDDB
leaq 0x508bb(%rip), %rcx     # 0x7b077
callq 0x30a0
jmp 0x2a7c3
jmp 0x2a874
movq -0x28(%rbp), %rax
cmpl $0xe00, (%rax)          # imm = 0xE00
jne 0x2a853
leaq -0x40(%rbp), %rdi
callq 0x8c90
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq -0x40(%rbp), %rsi
xorl %ecx, %ecx
callq 0x32e60
movq -0x20(%rbp), %rax
movb 0x30(%rax), %al
movb %al, -0x41(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
xorl %esi, %esi
callq 0x334a0
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
xorl %edx, %edx
movzbl -0x41(%rbp), %esi
callq 0x334d0
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq %rax, %rcx
callq 0x32d40
leaq -0x40(%rbp), %rdi
callq 0x9310
jmp 0x2a872
leaq 0x48c00(%rip), %rdi     # 0x7345a
leaq 0x502a3(%rip), %rsi     # 0x7ab04
movl $0xdf2, %edx            # imm = 0xDF2
leaq 0x5080a(%rip), %rcx     # 0x7b077
callq 0x30a0
jmp 0x2a874
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)