// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/backend/asmgen_gas64.c
// Function: asm_stat_sitofp
static void _asm_stat_sitofp(
	ASMGeneratorGas64Context *ctx,
	ParserASTNode *node
) {
	assert(ctx);
	assert(node);
	assert(node->type == BE_NODE_STAT_SITOFP);
	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,
		node_source
	);

	if (type_target == BE_TYPE_FLOAT) {
		_asm_inst_cvtsi2ss_x_x(
			ctx,
			ctx->body,
			BE_TYPE_INT64,
			_ASM_REG_NAME_XMM0,
			_ASM_REG_NAME_RAX
		);

		_asm_inst_movss_sym_x(
			ctx,
			ctx->body,
			symbol_target,
			_ASM_REG_NAME_XMM0
		);
	} else if (type_target == BE_TYPE_DOUBLE) {
		_asm_inst_cvtsi2sd_x_x(
			ctx,
			ctx->body,
			BE_TYPE_INT64,
			_ASM_REG_NAME_XMM0,
			_ASM_REG_NAME_RAX
		);

		_asm_inst_movsd_sym_x(
			ctx,
			ctx->body,
			symbol_target,
			_ASM_REG_NAME_XMM0
		);
	} else {
		assert(0);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x2c049
jmp 0x2c068
leaq 0x54111(%rip), %rdi     # 0x80161
leaq 0x4eaad(%rip), %rsi     # 0x7ab04
movl $0x1017, %edx           # imm = 0x1017
leaq 0x4fe83(%rip), %rcx     # 0x7bee6
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x2c071
jmp 0x2c090
leaq 0x4a4e4(%rip), %rdi     # 0x7655c
leaq 0x4ea85(%rip), %rsi     # 0x7ab04
movl $0x1018, %edx           # imm = 0x1018
leaq 0x4fe5b(%rip), %rcx     # 0x7bee6
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0xbc2, (%rax)          # imm = 0xBC2
jne 0x2c09e
jmp 0x2c0bd
leaq 0x4b83a(%rip), %rdi     # 0x778df
leaq 0x4ea58(%rip), %rsi     # 0x7ab04
movl $0x1019, %edx           # imm = 0x1019
leaq 0x4fe2e(%rip), %rcx     # 0x7bee6
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0x2, 0x44(%rax)
jne 0x2c0c9
jmp 0x2c0e8
leaq 0x56c74(%rip), %rdi     # 0x82d44
leaq 0x4ea2d(%rip), %rsi     # 0x7ab04
movl $0x101a, %edx           # imm = 0x101A
leaq 0x4fe03(%rip), %rcx     # 0x7bee6
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 0x2c105
jmp 0x2c124
leaq 0x4a2b1(%rip), %rdi     # 0x763bd
leaq 0x4e9f1(%rip), %rsi     # 0x7ab04
movl $0x101d, %edx           # imm = 0x101D
leaq 0x4fdc7(%rip), %rcx     # 0x7bee6
callq 0x30a0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x32820
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), %rdx
xorl %esi, %esi
callq 0x334a0
movb %al, -0x31(%rbp)
movzbl -0x21(%rbp), %eax
cmpl $0xa, %eax
jne 0x2c1ac
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x5, %edx
leaq 0x4b784(%rip), %rcx     # 0x77906
leaq 0x4ef31(%rip), %r8      # 0x7b0ba
callq 0x352f0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x20(%rbp), %rdx
leaq 0x4b761(%rip), %rcx     # 0x77906
callq 0x35460
jmp 0x2c218
movzbl -0x21(%rbp), %eax
cmpl $0xb, %eax
jne 0x2c1f7
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x5, %edx
leaq 0x4b739(%rip), %rcx     # 0x77906
leaq 0x4eee6(%rip), %r8      # 0x7b0ba
callq 0x35570
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x20(%rbp), %rdx
leaq 0x4b716(%rip), %rcx     # 0x77906
callq 0x356e0
jmp 0x2c216
leaq 0x4725c(%rip), %rdi     # 0x7345a
leaq 0x4e8ff(%rip), %rsi     # 0x7ab04
movl $0x1047, %edx           # imm = 0x1047
leaq 0x4fcd5(%rip), %rcx     # 0x7bee6
callq 0x30a0
jmp 0x2c218
addq $0x40, %rsp
popq %rbp
retq
nop