// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/backend/asmgen_gas32.c
// Function: asm_stat_assign
static void _asm_stat_assign(
	ASMGeneratorGas32Context *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) {
			uint8_t type_target = BE_VAR_SYMBOL_GET_TYPE(symbol_target);
			if (type_target == BE_TYPE_UINT64
					|| type_target == BE_TYPE_INT64
					|| type_target == BE_TYPE_DOUBLE) {
				ParserSymbol *symbol_target_l = _instantiate_varsym(ctx, symbol_target, 0);
				ParserSymbol *symbol_target_h = _instantiate_varsym(ctx, symbol_target, 4);

				ParserSymbol *symbol_source_l = _instantiate_varsym(ctx, symbol_source, 0);
				ParserSymbol *symbol_source_h = _instantiate_varsym(ctx, symbol_source, 4);

				_asm_inst_mov_sym_sym(
					ctx,
					ctx->body,
					symbol_target_l,
					symbol_source_l
				);

				_asm_inst_mov_sym_sym(
					ctx,
					ctx->body,
					symbol_target_h,
					symbol_source_h
				);

				_free_varsym(ctx, symbol_target_l);
				_free_varsym(ctx, symbol_target_h);

				_free_varsym(ctx, symbol_source_l);
				_free_varsym(ctx, symbol_source_h);
			} else {
				ParserSymbol *symbol_target_l = _instantiate_varsym(ctx, symbol_target, 0);

				ParserSymbol *symbol_source_l = _instantiate_varsym(ctx, symbol_source, 0);

				_asm_inst_mov_sym_sym(
					ctx,
					ctx->body,
					symbol_target_l,
					symbol_source_l
				);

				_free_varsym(ctx, symbol_target_l);

				_free_varsym(ctx, symbol_source_l);
			}
		} else if (symbol_source->type == BE_SYM_FUNC) {
			_asm_inst_mov_x_fsym(
				ctx,
				ctx->body,
				_ASM_REG_NAME_EAX,
				symbol_source
			);

			ParserSymbol *symbol_target_l = _instantiate_varsym(ctx, symbol_target, 0);

			_asm_inst_mov_sym_x(
				ctx,
				ctx->body,
				symbol_target_l,
				_ASM_REG_NAME_EAX
			);

			_free_varsym(ctx, symbol_target_l);
		} else {
			assert(0);
		}
	} else if (node_source->type == BE_NODE_EXPR) {
		MoveIdOrConstexprToRegEx result;

		uint8_t type_target = BE_VAR_SYMBOL_GET_TYPE(symbol_target);
		_move_id_or_constexpr_to_reg_ex(
			ctx,
			_ASM_REG_AX,
			_ASM_REG_BX,
			node_source,
			&result
		);

		if (result.type_size < 8) {
			ParserSymbol *symbol_target_l = _instantiate_varsym(ctx, symbol_target, 0);

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

			_free_varsym(ctx, symbol_target_l);
		} else {
			ParserSymbol *symbol_target_l = _instantiate_varsym(ctx, symbol_target, 0);
			ParserSymbol *symbol_target_h = _instantiate_varsym(ctx, symbol_target, 4);

			_asm_inst_mov_sym_x(
				ctx,
				ctx->body,
				symbol_target_l,
				_ASM_REG_NAME_EAX
			);

			_asm_inst_mov_sym_x(
				ctx,
				ctx->body,
				symbol_target_h,
				_ASM_REG_NAME_EBX
			);

			_free_varsym(ctx, symbol_target_l);
			_free_varsym(ctx, symbol_target_h);
		}
	} else {
		assert(0);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x11f2c
jmp 0x11f4b
leaq 0x6e22e(%rip), %rdi     # 0x80161
leaq 0x639be(%rip), %rsi     # 0x758f8
movl $0x1097, %edx           # imm = 0x1097
leaq 0x64412(%rip), %rcx     # 0x76358
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x11f54
jmp 0x11f73
leaq 0x64601(%rip), %rdi     # 0x7655c
leaq 0x63996(%rip), %rsi     # 0x758f8
movl $0x1098, %edx           # imm = 0x1098
leaq 0x643ea(%rip), %rcx     # 0x76358
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0xb90, (%rax)          # imm = 0xB90
jne 0x11f81
jmp 0x11fa0
leaq 0x64413(%rip), %rdi     # 0x7639b
leaq 0x63969(%rip), %rsi     # 0x758f8
movl $0x1099, %edx           # imm = 0x1099
leaq 0x643bd(%rip), %rcx     # 0x76358
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 0x11fbd
jmp 0x11fdc
leaq 0x643f9(%rip), %rdi     # 0x763bd
leaq 0x6392d(%rip), %rsi     # 0x758f8
movl $0x109c, %edx           # imm = 0x109C
leaq 0x64381(%rip), %rcx     # 0x76358
callq 0x30a0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1f720
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 0x121f5
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x1f800
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x1216c
movq -0x20(%rbp), %rax
movb 0x30(%rax), %al
movb %al, -0x31(%rbp)
movzbl -0x31(%rbp), %eax
cmpl $0x9, %eax
je 0x12054
movzbl -0x31(%rbp), %eax
cmpl $0x5, %eax
je 0x12054
movzbl -0x31(%rbp), %eax
cmpl $0xb, %eax
jne 0x1210e
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x1f8e0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl $0x4, %edx
callq 0x1f8e0
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
xorl %edx, %edx
callq 0x1f8e0
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl $0x4, %edx
callq 0x1f8e0
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x40(%rbp), %rdx
movq -0x50(%rbp), %rcx
callq 0x1fb70
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x48(%rbp), %rdx
movq -0x58(%rbp), %rcx
callq 0x1fb70
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x1fd10
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x1fd10
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x1fd10
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x1fd10
jmp 0x12167
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x1f8e0
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
xorl %edx, %edx
callq 0x1f8e0
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x60(%rbp), %rdx
movq -0x68(%rbp), %rcx
callq 0x1fb70
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x1fd10
movq -0x8(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x1fd10
jmp 0x121f0
movq -0x30(%rbp), %rax
cmpl $0x3, (%rax)
jne 0x121cf
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x30(%rbp), %rcx
leaq 0x64259(%rip), %rdx     # 0x763e5
callq 0x1fd90
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x1f8e0
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x70(%rbp), %rdx
leaq 0x6422a(%rip), %rcx     # 0x763e5
callq 0x20080
movq -0x8(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x1fd10
jmp 0x121ee
leaq 0x61284(%rip), %rdi     # 0x7345a
leaq 0x6371b(%rip), %rsi     # 0x758f8
movl $0x10e3, %edx           # imm = 0x10E3
leaq 0x6416f(%rip), %rcx     # 0x76358
callq 0x30a0
jmp 0x121f0
jmp 0x12377
movq -0x28(%rbp), %rax
cmpl $0xe00, (%rax)          # imm = 0xE00
jne 0x12356
movq -0x20(%rbp), %rax
movb 0x30(%rax), %al
movb %al, -0x89(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rcx
xorl %esi, %esi
movl $0x1, %edx
leaq -0x88(%rbp), %r8
callq 0x201a0
cmpq $0x8, -0x80(%rbp)
jae 0x122c7
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x1f8e0
movq %rax, -0x98(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xb8(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x8(%rbp), %rdi
xorl %edx, %edx
leaq 0x63675(%rip), %rcx     # 0x758f8
movl $0x10f8, %r8d           # imm = 0x10F8
movzbl -0x89(%rbp), %esi
callq 0x20d10
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
movq -0xb0(%rbp), %rdx
movq %rax, %rcx
callq 0x20080
movq -0x8(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x1fd10
jmp 0x12354
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x1f8e0
movq %rax, -0xa0(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl $0x4, %edx
callq 0x1f8e0
movq %rax, -0xa8(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0xa0(%rbp), %rdx
leaq 0x640d5(%rip), %rcx     # 0x763e5
callq 0x20080
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0xa8(%rbp), %rdx
leaq 0x640bb(%rip), %rcx     # 0x763ea
callq 0x20080
movq -0x8(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0x1fd10
movq -0x8(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x1fd10
jmp 0x12375
leaq 0x610fd(%rip), %rdi     # 0x7345a
leaq 0x63594(%rip), %rsi     # 0x758f8
movl $0x1112, %edx           # imm = 0x1112
leaq 0x63fe8(%rip), %rcx     # 0x76358
callq 0x30a0
jmp 0x12377
addq $0xc0, %rsp
popq %rbp
retq