// File: /workspace/github_c_makefile_star2_O2/markdryan[P]subtilis/frontend/array_type.c
// Function: prv_slice_set_pointers
static void prv_slice_set_pointers(subtilis_parser_t *p,
				   const subtilis_type_t *type,
				   size_t source_reg, size_t dest_reg,
				   subtilis_exp_t *index1,
				   subtilis_error_t *err)
{
	size_t data_reg;
	subtilis_ir_operand_t heap_reg;
	subtilis_exp_t *offset = NULL;
	subtilis_exp_t *data = NULL;
	subtilis_exp_t *index1_dup = NULL;

	index1_dup = subtilis_type_if_dup(index1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	offset = subtilis_type_if_data_size(p, type, index1_dup, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	data_reg = subtilis_reference_get_data(p, source_reg, 0, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	data = subtilis_exp_new_int32_var(data_reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	if ((offset->type.type == SUBTILIS_TYPE_CONST_INTEGER) &&
	    (offset->exp.ir_op.integer == 0)) {
		subtilis_exp_delete(offset);
		offset = NULL;
		offset = data;
		data = NULL;
	} else {
		offset = subtilis_type_if_add(p, data, offset, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
	}

	subtilis_reference_set_data(p, offset->exp.ir_op.reg, dest_reg, 0, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_exp_delete(offset);
	offset = NULL;

	heap_reg.reg = subtilis_reference_get_heap(p, source_reg, 0, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_instr_no_reg(p->current, SUBTILIS_OP_INSTR_REF,
					     heap_reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_reference_set_heap(p, heap_reg.reg, dest_reg, 0, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_reference_type_push_reference(p, type, dest_reg, 0, err);

cleanup:

	subtilis_exp_delete(offset);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r9, %rbx
movq %rcx, %r14
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %r12
movq %r8, %rdi
movq %r9, %rsi
callq 0x341c4
cmpl $0x0, (%rbx)
je 0x4038f
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
movq %rbx, %rcx
callq 0x33e43
movq %rax, %rbp
cmpl $0x0, (%rbx)
jne 0x404a0
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x4a690
cmpl $0x0, (%rbx)
jne 0x404a0
movl %eax, %edi
movq %rbx, %rsi
callq 0x2a336
cmpl $0x0, (%rbx)
jne 0x404a0
cmpl $0x1, (%rbp)
jne 0x403e7
cmpl $0x0, 0x148(%rbp)
je 0x40406
movq %r12, %rdi
movq %rax, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x34b18
cmpl $0x0, (%rbx)
movq %rax, %rbp
jne 0x404a0
jmp 0x40414
movq %rbp, %rdi
movq %rax, %rbp
callq 0x29d88
movq %rbp, %rax
movq 0x148(%rax), %rsi
movq %r12, %rdi
movq %r14, %rdx
xorl %ecx, %ecx
movq %rbx, %r8
movq %rax, %rbp
callq 0x4ab59
cmpl $0x0, (%rbx)
jne 0x404a0
movq %rbp, %rdi
callq 0x29d88
xorl %ebp, %ebp
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x4a6a8
cmpl $0x0, (%rbx)
jne 0x404a0
movq %rax, %r13
movq 0x48(%r12), %rdi
pushq $0x78
popq %rsi
movq %rax, %rdx
movq %rbx, %rcx
callq 0x2a997
cmpl $0x0, (%rbx)
je 0x40471
xorl %ebp, %ebp
jmp 0x404a0
xorl %ebp, %ebp
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
movq %rbx, %r8
callq 0x4ab75
cmpl $0x0, (%rbx)
jne 0x404a0
xorl %ebp, %ebp
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
movq %rbx, %r8
callq 0x4a8be
movq %rbp, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x29d88