// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/assembler/ins_directive_enc.c
// Function: ins_enc_int8s
void ins_enc_int8s(
	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 * 1);
	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, 1, 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 0x1d2e9
jmp 0x1d308
leaq 0x2c816(%rip), %rdi     # 0x49b06
leaq 0x2d65f(%rip), %rsi     # 0x4a956
movl $0xc7, %edx
leaq 0x2d952(%rip), %rcx     # 0x4ac55
callq 0xa0b0
cmpq $0x0, -0x10(%rbp)
je 0x1d311
jmp 0x1d330
leaq 0x32cd7(%rip), %rdi     # 0x4ffef
leaq 0x2d637(%rip), %rsi     # 0x4a956
movl $0xc8, %edx
leaq 0x2d92a(%rip), %rcx     # 0x4ac55
callq 0xa0b0
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpl $0x2, 0x44(%rax)
jne 0x1d33f
jmp 0x1d35e
leaq 0x2d94b(%rip), %rdi     # 0x4ac91
leaq 0x2d609(%rip), %rsi     # 0x4a956
movl $0xc9, %edx
leaq 0x2d8fc(%rip), %rcx     # 0x4ac55
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 0x1d37e
jmp 0x1d39d
leaq 0x2d929(%rip), %rdi     # 0x4acae
leaq 0x2d5ca(%rip), %rsi     # 0x4a956
movl $0xcc, %edx
leaq 0x2d8bd(%rip), %rcx     # 0x4ac55
callq 0xa0b0
movq -0x18(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0x1d3b7
jmp 0x1d3d6
leaq 0x2d912(%rip), %rdi     # 0x4acd0
leaq 0x2d591(%rip), %rsi     # 0x4a956
movl $0xcf, %edx
leaq 0x2d884(%rip), %rcx     # 0x4ac55
callq 0xa0b0
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
shlq $0x0, %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 0x1d40e
jmp 0x1d4cf
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 0x1d42f
jmp 0x1d44e
leaq 0x2d8d1(%rip), %rdi     # 0x4ad07
leaq 0x2d519(%rip), %rsi     # 0x4a956
movl $0xd7, %edx
leaq 0x2d80c(%rip), %rcx     # 0x4ac55
callq 0xa0b0
movq -0x28(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0x1d468
jmp 0x1d487
leaq 0x2d8b8(%rip), %rdi     # 0x4ad27
leaq 0x2d4e0(%rip), %rsi     # 0x4a956
movl $0xda, %edx
leaq 0x2d7d3(%rip), %rcx     # 0x4ac55
callq 0xa0b0
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x1d4cf
movq -0x30(%rbp), %rdi
addq $0x8, %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0xb8(%rax), %rcx
movl $0x1, %edx
movq %rdx, %rsi
callq 0xa190
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x1d48f
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)