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

	if (type_source == BE_TYPE_FLOAT) {
		_asm_inst_cvttss2si_x_x(
			ctx,
			ctx->body,
			_ASM_REG_NAME_RAX,
			_ASM_REG_NAME_XMM0
		);
	} else if (type_source == BE_TYPE_DOUBLE) {
		_asm_inst_cvttsd2si_x_x(
			ctx,
			ctx->body,
			_ASM_REG_NAME_RAX,
			_ASM_REG_NAME_XMM0
		);
	} else {
		assert(0);
	}

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x2cad9
jmp 0x2caf8
leaq 0x53681(%rip), %rdi     # 0x80161
leaq 0x4e01d(%rip), %rsi     # 0x7ab04
movl $0x1140, %edx           # imm = 0x1140
leaq 0x4f9f4(%rip), %rcx     # 0x7c4e7
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x2cb01
jmp 0x2cb20
leaq 0x49a54(%rip), %rdi     # 0x7655c
leaq 0x4dff5(%rip), %rsi     # 0x7ab04
movl $0x1141, %edx           # imm = 0x1141
leaq 0x4f9cc(%rip), %rcx     # 0x7c4e7
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0xbc6, (%rax)          # imm = 0xBC6
jne 0x2cb2e
jmp 0x2cb4d
leaq 0x4b65f(%rip), %rdi     # 0x78194
leaq 0x4dfc8(%rip), %rsi     # 0x7ab04
movl $0x1142, %edx           # imm = 0x1142
leaq 0x4f99f(%rip), %rcx     # 0x7c4e7
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0x2, 0x44(%rax)
jne 0x2cb59
jmp 0x2cb78
leaq 0x561e4(%rip), %rdi     # 0x82d44
leaq 0x4df9d(%rip), %rsi     # 0x7ab04
movl $0x1143, %edx           # imm = 0x1143
leaq 0x4f974(%rip), %rcx     # 0x7c4e7
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 0x2cb95
jmp 0x2cbb4
leaq 0x49821(%rip), %rdi     # 0x763bd
leaq 0x4df61(%rip), %rsi     # 0x7ab04
movl $0x1146, %edx           # imm = 0x1146
leaq 0x4f938(%rip), %rcx     # 0x7c4e7
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
leaq 0x4ad18(%rip), %rsi     # 0x77906
callq 0x36060
movb %al, -0x31(%rbp)
movzbl -0x31(%rbp), %eax
cmpl $0xa, %eax
jne 0x2cc20
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
leaq 0x4e4a8(%rip), %rdx     # 0x7b0ba
leaq 0x4aced(%rip), %rcx     # 0x77906
callq 0x36430
jmp 0x2cc6b
movzbl -0x31(%rbp), %eax
cmpl $0xb, %eax
jne 0x2cc4a
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
leaq 0x4e47e(%rip), %rdx     # 0x7b0ba
leaq 0x4acc3(%rip), %rcx     # 0x77906
callq 0x36520
jmp 0x2cc69
leaq 0x46809(%rip), %rdi     # 0x7345a
leaq 0x4deac(%rip), %rsi     # 0x7ab04
movl $0x1160, %edx           # imm = 0x1160
leaq 0x4f883(%rip), %rcx     # 0x7c4e7
callq 0x30a0
jmp 0x2cc6b
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
xorl %edx, %edx
movzbl -0x21(%rbp), %esi
callq 0x334d0
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %rax, %rcx
callq 0x32d40
addq $0x50, %rsp
popq %rbp
retq