// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/backend/asmgen_gas32.c
// Function: asm_stat_load
static void _asm_stat_load(
	ASMGeneratorGas32Context *ctx,
	ParserASTNode *node
) {
	assert(ctx);
	assert(node);
	assert(node->type == BE_NODE_STAT_LOAD);
	assert(node->nchilds == 2);

	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);
	uint8_t type_target = BE_VAR_SYMBOL_GET_TYPE(symbol_target);

	ParserASTNode *node_source = node->childs[1];
	uint8_t type_source = _move_id_or_constexpr_to_reg(
		ctx,
		_ASM_REG_AX,
		_ASM_REG_BX,	// 32位指针，EBX应该不会被改变！
		node_source
	);
	assert(type_source == BE_TYPE_POINTER);

	ResizableString rstr_memref_l;
	rstr_init(&rstr_memref_l);
	_asm_inst_memref_base_disp(ctx, &rstr_memref_l, _ASM_REG_NAME_EAX, "0");

	ResizableString rstr_memref_h;
	rstr_init(&rstr_memref_h);
	_asm_inst_memref_base_disp(ctx, &rstr_memref_h, _ASM_REG_NAME_EAX, "4");

	if (type_target == BE_TYPE_UINT64
			|| type_target == BE_TYPE_INT64
			|| type_target == BE_TYPE_DOUBLE) {
		const char *tmp_reg = _asm_inst_reg(ctx, BE_TYPE_UINT32, _ASM_REG_BX);

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

		_asm_inst_mov_x_x(
			ctx,
			ctx->body,
			BE_TYPE_UINT32,
			tmp_reg,
			RSTR_CSTR(&rstr_memref_l)
		);

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

		_asm_inst_mov_x_x(
			ctx,
			ctx->body,
			BE_TYPE_UINT32,
			tmp_reg,
			RSTR_CSTR(&rstr_memref_h)
		);

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

		_free_varsym(ctx, symbol_target_l);
		_free_varsym(ctx, symbol_target_h);
	} else {
		const char *tmp_reg = _asm_inst_reg(ctx, type_target, _ASM_REG_BX);

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

		_asm_inst_mov_x_x(
			ctx,
			ctx->body,
			type_target,
			tmp_reg,
			RSTR_CSTR(&rstr_memref_l)
		);

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

		_free_varsym(ctx, symbol_target_l);
	}

	rstr_free(&rstr_memref_l);
	rstr_free(&rstr_memref_h);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x1391c
jmp 0x1393b
leaq 0x6c83e(%rip), %rdi     # 0x80161
leaq 0x61fce(%rip), %rsi     # 0x758f8
movl $0x12d7, %edx           # imm = 0x12D7
leaq 0x63cf6(%rip), %rcx     # 0x7762c
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x13944
jmp 0x13963
leaq 0x62c11(%rip), %rdi     # 0x7655c
leaq 0x61fa6(%rip), %rsi     # 0x758f8
movl $0x12d8, %edx           # imm = 0x12D8
leaq 0x63cce(%rip), %rcx     # 0x7762c
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0xb81, (%rax)          # imm = 0xB81
jne 0x13971
jmp 0x13990
leaq 0x63cf5(%rip), %rdi     # 0x7766d
leaq 0x61f79(%rip), %rsi     # 0x758f8
movl $0x12d9, %edx           # imm = 0x12D9
leaq 0x63ca1(%rip), %rcx     # 0x7762c
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0x2, 0x44(%rax)
jne 0x1399c
jmp 0x139bb
leaq 0x6f3a1(%rip), %rdi     # 0x82d44
leaq 0x61f4e(%rip), %rsi     # 0x758f8
movl $0x12da, %edx           # imm = 0x12DA
leaq 0x63c76(%rip), %rcx     # 0x7762c
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 0x139d8
jmp 0x139f7
leaq 0x629de(%rip), %rdi     # 0x763bd
leaq 0x61f12(%rip), %rsi     # 0x758f8
movl $0x12dd, %edx           # imm = 0x12DD
leaq 0x63c3a(%rip), %rcx     # 0x7762c
callq 0x30a0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1f720
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movb 0x30(%rax), %al
movb %al, -0x21(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rcx
xorl %esi, %esi
movl $0x1, %edx
callq 0x22a20
movb %al, -0x31(%rbp)
movzbl -0x31(%rbp), %eax
cmpl $0x10, %eax
jne 0x13a44
jmp 0x13a63
leaq 0x63c42(%rip), %rdi     # 0x7768d
leaq 0x61ea6(%rip), %rsi     # 0x758f8
movl $0x12e8, %edx           # imm = 0x12E8
leaq 0x63bce(%rip), %rcx     # 0x7762c
callq 0x30a0
leaq -0x48(%rbp), %rdi
callq 0x8c90
movq -0x8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq 0x6296a(%rip), %rdx     # 0x763e5
leaq 0x5f9d8(%rip), %rcx     # 0x7345a
callq 0x10e00
leaq -0x58(%rbp), %rdi
callq 0x8c90
movq -0x8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq 0x62946(%rip), %rdx     # 0x763e5
leaq 0x62ac1(%rip), %rcx     # 0x76567
callq 0x10e00
movzbl -0x21(%rbp), %eax
cmpl $0x9, %eax
je 0x13aca
movzbl -0x21(%rbp), %eax
cmpl $0x5, %eax
je 0x13aca
movzbl -0x21(%rbp), %eax
cmpl $0xb, %eax
jne 0x13c42
movq -0x8(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
leaq 0x61e19(%rip), %rcx     # 0x758f8
movl $0x12f5, %r8d           # imm = 0x12F5
callq 0x20d10
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x1f8e0
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl $0x4, %edx
callq 0x1f8e0
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x13b53
leaq 0x623f5(%rip), %rax     # 0x75f3f
movq %rax, -0xa0(%rbp)
jmp 0x13b5e
movq -0x40(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x88(%rbp), %rcx
movq -0x90(%rbp), %rsi
movq -0x98(%rbp), %rdi
movq -0xa0(%rbp), %r8
movl $0x8, %edx
callq 0x20f30
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x68(%rbp), %rdx
movq -0x60(%rbp), %rcx
callq 0x20080
movq -0x8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x13bd9
leaq 0x6236f(%rip), %rax     # 0x75f3f
movq %rax, -0xc0(%rbp)
jmp 0x13be4
movq -0x50(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xa8(%rbp), %rcx
movq -0xb0(%rbp), %rsi
movq -0xb8(%rbp), %rdi
movq -0xc0(%rbp), %r8
movl $0x8, %edx
callq 0x20f30
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x70(%rbp), %rdx
movq -0x60(%rbp), %rcx
callq 0x20080
movq -0x8(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x1fd10
movq -0x8(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x1fd10
jmp 0x13d18
movq -0x8(%rbp), %rdi
movl $0x1, %edx
leaq 0x61ca6(%rip), %rcx     # 0x758f8
movl $0x131b, %r8d           # imm = 0x131B
movzbl -0x21(%rbp), %esi
callq 0x20d10
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x1f8e0
movq %rax, -0x80(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xd8(%rbp)
movb -0x21(%rbp), %al
movb %al, -0xc9(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0xc8(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x13cbd
leaq 0x6228b(%rip), %rax     # 0x75f3f
movq %rax, -0xe8(%rbp)
jmp 0x13cc8
movq -0x40(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xc8(%rbp), %rcx
movb -0xc9(%rbp), %al
movq -0xd8(%rbp), %rsi
movq -0xe0(%rbp), %rdi
movq -0xe8(%rbp), %r8
movzbl %al, %edx
callq 0x20f30
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x80(%rbp), %rdx
movq -0x78(%rbp), %rcx
callq 0x20080
movq -0x8(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0x1fd10
leaq -0x48(%rbp), %rdi
callq 0x9310
leaq -0x58(%rbp), %rdi
callq 0x9310
addq $0xf0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)