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

	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_STRING);

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

	for (uint64_t i = 0; i < result_count->value.u64; i++) {
		fwrite(
			result_val->value.str.ptr,
			result_val->value.str.len,
			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 0x1df59
jmp 0x1df78
leaq 0x2bba6(%rip), %rdi     # 0x49b06
leaq 0x2c9ef(%rip), %rsi     # 0x4a956
movl $0x17d, %edx            # imm = 0x17D
leaq 0x2cf50(%rip), %rcx     # 0x4aec3
callq 0xa0b0
cmpq $0x0, -0x10(%rbp)
je 0x1df81
jmp 0x1dfa0
leaq 0x32067(%rip), %rdi     # 0x4ffef
leaq 0x2c9c7(%rip), %rsi     # 0x4a956
movl $0x17e, %edx            # imm = 0x17E
leaq 0x2cf28(%rip), %rcx     # 0x4aec3
callq 0xa0b0
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpl $0x2, 0x44(%rax)
jne 0x1dfaf
jmp 0x1dfce
leaq 0x2ccdb(%rip), %rdi     # 0x4ac91
leaq 0x2c999(%rip), %rsi     # 0x4a956
movl $0x17f, %edx            # imm = 0x17F
leaq 0x2cefa(%rip), %rcx     # 0x4aec3
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 0x1dfee
jmp 0x1e00d
leaq 0x2ccb9(%rip), %rdi     # 0x4acae
leaq 0x2c95a(%rip), %rsi     # 0x4a956
movl $0x182, %edx            # imm = 0x182
leaq 0x2cebb(%rip), %rcx     # 0x4aec3
callq 0xa0b0
movq -0x18(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0x1e027
jmp 0x1e046
leaq 0x2cca2(%rip), %rdi     # 0x4acd0
leaq 0x2c921(%rip), %rsi     # 0x4a956
movl $0x185, %edx            # imm = 0x185
leaq 0x2ce82(%rip), %rcx     # 0x4aec3
callq 0xa0b0
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 0x1e067
jmp 0x1e086
leaq 0x2cc99(%rip), %rdi     # 0x4ad07
leaq 0x2c8e1(%rip), %rsi     # 0x4a956
movl $0x188, %edx            # imm = 0x188
leaq 0x2ce42(%rip), %rcx     # 0x4aec3
callq 0xa0b0
movq -0x28(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x3, %eax
jne 0x1e0a0
jmp 0x1e0bf
leaq 0x2ce5a(%rip), %rdi     # 0x4af01
leaq 0x2c8a8(%rip), %rsi     # 0x4a956
movl $0x18b, %edx            # imm = 0x18B
leaq 0x2ce09(%rip), %rcx     # 0x4aec3
callq 0xa0b0
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x30(%rbp), %rax
imulq 0x10(%rax), %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 0x1e0f9
jmp 0x1e146
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x1e146
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0xb8(%rax), %rcx
movl $0x1, %edx
callq 0xa190
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x1e101
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)