// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/assembler/ins_directive_enc.c
// Function: ins_enc_floats
void ins_enc_floats(
	Instruction *ins,
	InstructionEncoderData *data
) {
	assert(ins);
	assert(data);
	assert(data->ins_node->nchilds == 2);

	ParserASTNode *node_count = data->ins_node->childs[0];
	assert(node_count->type == ASM_NODE_EXPR);

	AsmExprEvalResult *result_count = &ASM_EXPR_AST_NODE_GET_RESULT(node_count);
	assert(result_count->type == ASM_EXPR_EVAL_RESULT_TYPE_UINT64);

	ASM_PARSER_CONTEXT_DATA_INC_ADDRESS_COUNTER(data->ctx, result_count->value.u64 * 4);
	if (ASM_PARSER_CONTEXT_DATA_GET_STEP(data->ctx) == ASM_STEP_SCAN) {
		return;
	}

	ParserASTNode *node_val = data->ins_node->childs[1];
	assert(node_val->type == ASM_NODE_EXPR);

	AsmExprEvalResult *result_val = &ASM_EXPR_AST_NODE_GET_RESULT(node_val);
	assert(result_val->type == ASM_EXPR_EVAL_RESULT_TYPE_DOUBLE);

	float value = (float) result_val->value.d;

	for (uint64_t i = 0; i < result_count->value.u64; i++) {
		fwrite(&value, 4, 1, ASM_PARSER_CONTEXT_DATA_GET_OUT(data->ctx));
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x1db29
jmp 0x1db48
leaq 0x2bfd6(%rip), %rdi     # 0x49b06
leaq 0x2ce1f(%rip), %rsi     # 0x4a956
movl $0x13f, %edx            # imm = 0x13F
leaq 0x2d2d0(%rip), %rcx     # 0x4ae13
callq 0xa0b0
cmpq $0x0, -0x10(%rbp)
je 0x1db51
jmp 0x1db70
leaq 0x32497(%rip), %rdi     # 0x4ffef
leaq 0x2cdf7(%rip), %rsi     # 0x4a956
movl $0x140, %edx            # imm = 0x140
leaq 0x2d2a8(%rip), %rcx     # 0x4ae13
callq 0xa0b0
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpl $0x2, 0x44(%rax)
jne 0x1db7f
jmp 0x1db9e
leaq 0x2d10b(%rip), %rdi     # 0x4ac91
leaq 0x2cdc9(%rip), %rsi     # 0x4a956
movl $0x141, %edx            # imm = 0x141
leaq 0x2d27a(%rip), %rcx     # 0x4ae13
callq 0xa0b0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpl $0xe00, (%rax)          # imm = 0xE00
jne 0x1dbbe
jmp 0x1dbdd
leaq 0x2d0e9(%rip), %rdi     # 0x4acae
leaq 0x2cd8a(%rip), %rsi     # 0x4a956
movl $0x144, %edx            # imm = 0x144
leaq 0x2d23b(%rip), %rcx     # 0x4ae13
callq 0xa0b0
movq -0x18(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0x1dbf7
jmp 0x1dc16
leaq 0x2d0d2(%rip), %rdi     # 0x4acd0
leaq 0x2cd51(%rip), %rsi     # 0x4a956
movl $0x147, %edx            # imm = 0x147
leaq 0x2d202(%rip), %rcx     # 0x4ae13
callq 0xa0b0
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
shlq $0x2, %rcx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
addq 0xc0(%rax), %rcx
movq %rcx, 0xc0(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x1, 0xc8(%rax)
jne 0x1dc4e
jmp 0x1dd1f
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpl $0xe00, (%rax)          # imm = 0xE00
jne 0x1dc6f
jmp 0x1dc8e
leaq 0x2d091(%rip), %rdi     # 0x4ad07
leaq 0x2ccd9(%rip), %rsi     # 0x4a956
movl $0x14f, %edx            # imm = 0x14F
leaq 0x2d18a(%rip), %rcx     # 0x4ae13
callq 0xa0b0
movq -0x28(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x2, %eax
jne 0x1dca8
jmp 0x1dcc7
leaq 0x2d1a1(%rip), %rdi     # 0x4ae50
leaq 0x2cca0(%rip), %rsi     # 0x4a956
movl $0x152, %edx            # imm = 0x152
leaq 0x2d151(%rip), %rcx     # 0x4ae13
callq 0xa0b0
movq -0x30(%rbp), %rax
movsd 0x8(%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x34(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x1dd1f
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0xb8(%rax), %rcx
leaq -0x34(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0xa190
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x1dce1
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)