// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/assembler/ins_directive_enc.c
// Function: ins_enc_int64s
void ins_enc_int64s(
	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 * 8);
	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_UINT64);

	for (uint64_t i = 0; i < result_count->value.u64; i++) {
		fwrite(&result_val->value.u64, 8, 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 0x1d919
jmp 0x1d938
leaq 0x2c1e6(%rip), %rdi     # 0x49b06
leaq 0x2d02f(%rip), %rsi     # 0x4a956
movl $0x121, %edx            # imm = 0x121
leaq 0x2d4a3(%rip), %rcx     # 0x4add6
callq 0xa0b0
cmpq $0x0, -0x10(%rbp)
je 0x1d941
jmp 0x1d960
leaq 0x326a7(%rip), %rdi     # 0x4ffef
leaq 0x2d007(%rip), %rsi     # 0x4a956
movl $0x122, %edx            # imm = 0x122
leaq 0x2d47b(%rip), %rcx     # 0x4add6
callq 0xa0b0
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpl $0x2, 0x44(%rax)
jne 0x1d96f
jmp 0x1d98e
leaq 0x2d31b(%rip), %rdi     # 0x4ac91
leaq 0x2cfd9(%rip), %rsi     # 0x4a956
movl $0x123, %edx            # imm = 0x123
leaq 0x2d44d(%rip), %rcx     # 0x4add6
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 0x1d9ae
jmp 0x1d9cd
leaq 0x2d2f9(%rip), %rdi     # 0x4acae
leaq 0x2cf9a(%rip), %rsi     # 0x4a956
movl $0x126, %edx            # imm = 0x126
leaq 0x2d40e(%rip), %rcx     # 0x4add6
callq 0xa0b0
movq -0x18(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0x1d9e7
jmp 0x1da06
leaq 0x2d2e2(%rip), %rdi     # 0x4acd0
leaq 0x2cf61(%rip), %rsi     # 0x4a956
movl $0x129, %edx            # imm = 0x129
leaq 0x2d3d5(%rip), %rcx     # 0x4add6
callq 0xa0b0
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
shlq $0x3, %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 0x1da3e
jmp 0x1db01
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 0x1da5f
jmp 0x1da7e
leaq 0x2d2a1(%rip), %rdi     # 0x4ad07
leaq 0x2cee9(%rip), %rsi     # 0x4a956
movl $0x131, %edx            # imm = 0x131
leaq 0x2d35d(%rip), %rcx     # 0x4add6
callq 0xa0b0
movq -0x28(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0x1da98
jmp 0x1dab7
leaq 0x2d288(%rip), %rdi     # 0x4ad27
leaq 0x2ceb0(%rip), %rsi     # 0x4a956
movl $0x134, %edx            # imm = 0x134
leaq 0x2d324(%rip), %rcx     # 0x4add6
callq 0xa0b0
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x1db01
movq -0x30(%rbp), %rdi
addq $0x8, %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0xb8(%rax), %rcx
movl $0x8, %esi
movl $0x1, %edx
callq 0xa190
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x1dabf
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)