// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/backend/asmgen_gas32.c
// Function: asm_stat_zext
static void _asm_stat_zext(
	ASMGeneratorGas32Context *ctx,
	ParserASTNode *node
) {
	assert(ctx);
	assert(node);
	assert(node->type == BE_NODE_STAT_ZEXT);
	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);

	_asm_inst_xor_x_x(
		ctx,
		ctx->body,
		BE_TYPE_UINT32,
		_ASM_REG_NAME_EAX,
		_ASM_REG_NAME_EAX
	);

	ParserASTNode *node_source = node->childs[1];
	uint8_t type_source = _move_id_or_constexpr_to_reg(
		ctx,
		_ASM_REG_AX,
		_ASM_REG_BX,
		node_source
	);

	assert(type_source != BE_TYPE_UINT64 && type_source != BE_TYPE_INT64);

	if (type_target == BE_TYPE_UINT64 || type_target == BE_TYPE_INT64) {
		ParserSymbol *symbol_target_l = _instantiate_varsym(ctx, symbol_target, 0);
		ParserSymbol *symbol_target_h = _instantiate_varsym(ctx, symbol_target, 4);

		if (type_source != BE_TYPE_UINT32 && type_source != BE_TYPE_INT32) {
			_asm_inst_movzx_x_x(
				ctx,
				ctx->body,
				BE_TYPE_UINT32,
				_ASM_REG_NAME_EAX,
				type_source,
				_asm_inst_reg(ctx, type_source, _ASM_REG_AX)
			);			
		}

		_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_CONST_0
		);

		_free_varsym(ctx, symbol_target_l);
		_free_varsym(ctx, symbol_target_h);
	} else {
		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);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x1489c
jmp 0x148bb
leaq 0x6b8be(%rip), %rdi     # 0x80161
leaq 0x6104e(%rip), %rsi     # 0x758f8
movl $0x1488, %edx           # imm = 0x1488
leaq 0x6344a(%rip), %rcx     # 0x77d00
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x148c4
jmp 0x148e3
leaq 0x61c91(%rip), %rdi     # 0x7655c
leaq 0x61026(%rip), %rsi     # 0x758f8
movl $0x1489, %edx           # imm = 0x1489
leaq 0x63422(%rip), %rcx     # 0x77d00
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0xbc4, (%rax)          # imm = 0xBC4
jne 0x148f1
jmp 0x14910
leaq 0x63449(%rip), %rdi     # 0x77d41
leaq 0x60ff9(%rip), %rsi     # 0x758f8
movl $0x148a, %edx           # imm = 0x148A
leaq 0x633f5(%rip), %rcx     # 0x77d00
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0x2, 0x44(%rax)
jne 0x1491c
jmp 0x1493b
leaq 0x6e421(%rip), %rdi     # 0x82d44
leaq 0x60fce(%rip), %rsi     # 0x758f8
movl $0x148b, %edx           # imm = 0x148B
leaq 0x633ca(%rip), %rcx     # 0x77d00
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 0x14958
jmp 0x14977
leaq 0x61a5e(%rip), %rdi     # 0x763bd
leaq 0x60f92(%rip), %rsi     # 0x758f8
movl $0x148e, %edx           # imm = 0x148E
leaq 0x6338e(%rip), %rcx     # 0x77d00
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 -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x8, %edx
leaq 0x61a3b(%rip), %r8      # 0x763e5
movq %r8, %rcx
callq 0x230c0
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 $0x9, %eax
je 0x149ed
movzbl -0x31(%rbp), %eax
cmpl $0x5, %eax
je 0x149ed
jmp 0x14a0c
leaq 0x62d7c(%rip), %rdi     # 0x77770
leaq 0x60efd(%rip), %rsi     # 0x758f8
movl $0x14a2, %edx           # imm = 0x14A2
leaq 0x632f9(%rip), %rcx     # 0x77d00
callq 0x30a0
movzbl -0x21(%rbp), %eax
cmpl $0x9, %eax
je 0x14a22
movzbl -0x21(%rbp), %eax
cmpl $0x5, %eax
jne 0x14b0a
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)
movzbl -0x31(%rbp), %eax
cmpl $0x8, %eax
je 0x14ab6
movzbl -0x31(%rbp), %eax
cmpl $0x4, %eax
je 0x14ab6
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x60(%rbp)
movb -0x31(%rbp), %al
movb %al, -0x51(%rbp)
movq -0x8(%rbp), %rdi
xorl %edx, %edx
leaq 0x60e74(%rip), %rcx     # 0x758f8
movl $0x14af, %r8d           # imm = 0x14AF
movzbl -0x31(%rbp), %esi
callq 0x20d10
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq %rax, %r9
movb -0x51(%rbp), %al
movl $0x8, %edx
leaq 0x61938(%rip), %rcx     # 0x763e5
movzbl %al, %r8d
callq 0x23990
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x40(%rbp), %rdx
leaq 0x61918(%rip), %rcx     # 0x763e5
callq 0x20080
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x48(%rbp), %rdx
leaq 0x61f82(%rip), %rcx     # 0x76a6b
callq 0x20080
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x1fd10
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x1fd10
jmp 0x14b76
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x1f8e0
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rdi
xorl %edx, %edx
leaq 0x60db2(%rip), %rcx     # 0x758f8
movl $0x14ca, %r8d           # imm = 0x14CA
movzbl -0x21(%rbp), %esi
callq 0x20d10
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq %rax, %rcx
callq 0x20080
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x1fd10
addq $0x80, %rsp
popq %rbp
retq
nop