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

	ParserASTNode *node_target = node->childs[0];
	assert(node_target->type == BE_NODE_LITERAL_STRING);

	ResizableString rstr_reg_target;
	rstr_init(&rstr_reg_target);
	_out_literal_string(ctx, &rstr_reg_target, 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) {
			ParserSymbol *tmp = _instantiate_varsym(ctx, symbol_source, 0);
			_asm_inst_mov_x_sym(
				ctx,
				ctx->body,
				RSTR_CSTR(&rstr_reg_target),
				tmp
			);
			_free_varsym(ctx, tmp);
		} else if (symbol_source->type == BE_SYM_FUNC) {
			_asm_inst_mov_x_fsym(
				ctx,
				ctx->body,
				RSTR_CSTR(&rstr_reg_target),
				symbol_source
			);
		} else {
			assert(0);
		}
	} else if (node_source->type == BE_NODE_EXPR) {
		ResizableString rstr_source;
		rstr_init(&rstr_source);

		bool target_is_not_ax = !_ASM_IS_AX(RSTR_CSTR(&rstr_reg_target));

		if (target_is_not_ax) {
			_asm_inst_push_x(
				ctx,
				ctx->body,
				BE_TYPE_UINT32,
				_ASM_REG_NAME_EAX
			);
		}

		_asm_constexpr_param(ctx, &rstr_source, NULL, node_source, _ASM_REG_AX);

		uint8_t type_source = BE_EXPR_AST_NODE_GET_TYPE(node_source);

		_asm_inst_mov_x_x(
			ctx,
			ctx->body,
			type_source,
			RSTR_CSTR(&rstr_reg_target),
			RSTR_CSTR(&rstr_source)
		);

		if (target_is_not_ax) {
			_asm_inst_pop_x(
				ctx,
				ctx->body,
				BE_TYPE_UINT32,
				_ASM_REG_NAME_EAX
			);
		}

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

	rstr_free(&rstr_reg_target);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x124ac
jmp 0x124cb
leaq 0x6dcae(%rip), %rdi     # 0x80161
leaq 0x6343e(%rip), %rsi     # 0x758f8
movl $0x1144, %edx           # imm = 0x1144
leaq 0x647ea(%rip), %rcx     # 0x76cb0
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x124d4
jmp 0x124f3
leaq 0x64081(%rip), %rdi     # 0x7655c
leaq 0x63416(%rip), %rsi     # 0x758f8
movl $0x1145, %edx           # imm = 0x1145
leaq 0x647c2(%rip), %rcx     # 0x76cb0
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0xb41, (%rax)          # imm = 0xB41
jne 0x12501
jmp 0x12520
leaq 0x647f0(%rip), %rdi     # 0x76cf8
leaq 0x633e9(%rip), %rsi     # 0x758f8
movl $0x1146, %edx           # imm = 0x1146
leaq 0x64795(%rip), %rcx     # 0x76cb0
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0x2, 0x44(%rax)
jne 0x1252c
jmp 0x1254b
leaq 0x70811(%rip), %rdi     # 0x82d44
leaq 0x633be(%rip), %rsi     # 0x758f8
movl $0x1147, %edx           # imm = 0x1147
leaq 0x6476a(%rip), %rcx     # 0x76cb0
callq 0x30a0
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x303, (%rax)          # imm = 0x303
jne 0x12568
jmp 0x12587
leaq 0x647b0(%rip), %rdi     # 0x76d1f
leaq 0x63382(%rip), %rsi     # 0x758f8
movl $0x114a, %edx           # imm = 0x114A
leaq 0x6472e(%rip), %rcx     # 0x76cb0
callq 0x30a0
leaq -0x28(%rbp), %rdi
callq 0x8c90
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq -0x28(%rbp), %rsi
callq 0x21ff0
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x200, (%rax)          # imm = 0x200
jne 0x126c1
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x1f800
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x12642
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
xorl %edx, %edx
callq 0x1f8e0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x12616
leaq 0x6392f(%rip), %rax     # 0x75f3f
movq %rax, -0x70(%rbp)
jmp 0x1261e
movq -0x20(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x60(%rbp), %rsi
movq -0x68(%rbp), %rdi
movq -0x70(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0x21250
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x1fd10
jmp 0x126bc
movq -0x38(%rbp), %rax
cmpl $0x3, (%rax)
jne 0x1269b
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x12676
leaq 0x638d2(%rip), %rax     # 0x75f3f
movq %rax, -0x88(%rbp)
jmp 0x12681
movq -0x20(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x78(%rbp), %rsi
movq -0x80(%rbp), %rdi
movq -0x88(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x1fd90
jmp 0x126ba
leaq 0x60db8(%rip), %rdi     # 0x7345a
leaq 0x6324f(%rip), %rsi     # 0x758f8
movl $0x1164, %edx           # imm = 0x1164
leaq 0x645fb(%rip), %rcx     # 0x76cb0
callq 0x30a0
jmp 0x126bc
jmp 0x12925
movq -0x30(%rbp), %rax
cmpl $0xe00, (%rax)          # imm = 0xE00
jne 0x12904
leaq -0x50(%rbp), %rdi
callq 0x8c90
cmpq $0x0, -0x20(%rbp)
jne 0x126f1
leaq 0x63857(%rip), %rax     # 0x75f3f
movq %rax, -0x90(%rbp)
jmp 0x126fc
movq -0x20(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
leaq 0x6404a(%rip), %rsi     # 0x76754
callq 0x22130
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x91(%rbp)
jne 0x127e5
cmpq $0x0, -0x20(%rbp)
jne 0x12739
leaq 0x6380f(%rip), %rax     # 0x75f3f
movq %rax, -0xa0(%rbp)
jmp 0x12744
movq -0x20(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rdi
leaq 0x645f9(%rip), %rsi     # 0x76d4b
callq 0x22130
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x91(%rbp)
jne 0x127e5
cmpq $0x0, -0x20(%rbp)
jne 0x1277d
leaq 0x637cb(%rip), %rax     # 0x75f3f
movq %rax, -0xa8(%rbp)
jmp 0x12788
movq -0x20(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rdi
leaq 0x63fc2(%rip), %rsi     # 0x76758
callq 0x22130
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x91(%rbp)
jne 0x127e5
cmpq $0x0, -0x20(%rbp)
jne 0x127c1
leaq 0x63787(%rip), %rax     # 0x75f3f
movq %rax, -0xb0(%rbp)
jmp 0x127cc
movq -0x20(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rdi
leaq 0x63c0b(%rip), %rsi     # 0x763e5
callq 0x22130
movb %al, -0x91(%rbp)
movb -0x91(%rbp), %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, -0x51(%rbp)
testb $0x1, -0x51(%rbp)
je 0x12815
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x8, %edx
leaq 0x63bd5(%rip), %rcx     # 0x763e5
callq 0x221b0
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rcx
leaq -0x50(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
xorl %r8d, %r8d
callq 0x21460
movq -0x30(%rbp), %rax
movb 0x60(%rax), %al
movb %al, -0x52(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xc0(%rbp)
movb -0x52(%rbp), %al
movb %al, -0xb1(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x12871
leaq 0x636d7(%rip), %rax     # 0x75f3f
movq %rax, -0xd0(%rbp)
jmp 0x1287c
movq -0x20(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
movq %rax, -0xd8(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x128a1
leaq 0x636a7(%rip), %rax     # 0x75f3f
movq %rax, -0xe0(%rbp)
jmp 0x128ac
movq -0x48(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0xd8(%rbp), %rcx
movb -0xb1(%rbp), %al
movq -0xc0(%rbp), %rsi
movq -0xc8(%rbp), %rdi
movq -0xe0(%rbp), %r8
movzbl %al, %edx
callq 0x20f30
testb $0x1, -0x51(%rbp)
je 0x128f9
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x8, %edx
leaq 0x63af1(%rip), %rcx     # 0x763e5
callq 0x222c0
leaq -0x50(%rbp), %rdi
callq 0x9310
jmp 0x12923
leaq 0x60b4f(%rip), %rdi     # 0x7345a
leaq 0x62fe6(%rip), %rsi     # 0x758f8
movl $0x118c, %edx           # imm = 0x118C
leaq 0x64392(%rip), %rcx     # 0x76cb0
callq 0x30a0
jmp 0x12925
leaq -0x28(%rbp), %rdi
callq 0x9310
addq $0xe0, %rsp
popq %rbp
retq
nopw (%rax,%rax)