// File: /workspace/github_c_makefile_star2_O3/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 0x36182
cmpl $0x0, (%rbx)
je 0x42984
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 0x35ddb
movq %rax, %rbp
cmpl $0x0, (%rbx)
jne 0x42a97
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x4d258
cmpl $0x0, (%rbx)
jne 0x42a97
movl %eax, %edi
movq %rbx, %rsi
callq 0x2b71f
cmpl $0x0, (%rbx)
jne 0x42a97
cmpl $0x1, (%rbp)
jne 0x429dc
cmpl $0x0, 0x148(%rbp)
je 0x429fb
movq %r12, %rdi
movq %rax, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x36b28
cmpl $0x0, (%rbx)
movq %rax, %rbp
jne 0x42a97
jmp 0x42a09
movq %rbp, %rdi
movq %rax, %rbp
callq 0x2b166
movq %rbp, %rax
movq 0x148(%rax), %rsi
movq %r12, %rdi
movq %r14, %rdx
xorl %ecx, %ecx
movq %rbx, %r8
movq %rax, %rbp
callq 0x4d752
cmpl $0x0, (%rbx)
jne 0x42a97
movq %rbp, %rdi
callq 0x2b166
xorl %ebp, %ebp
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x4d272
cmpl $0x0, (%rbx)
jne 0x42a97
movq %rax, %r13
movq 0x48(%r12), %rdi
movl $0x78, %esi
movq %rax, %rdx
movq %rbx, %rcx
callq 0x2be1f
cmpl $0x0, (%rbx)
je 0x42a68
xorl %ebp, %ebp
jmp 0x42a97
xorl %ebp, %ebp
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
movq %rbx, %r8
callq 0x4d770
cmpl $0x0, (%rbx)
jne 0x42a97
xorl %ebp, %ebp
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
movq %rbx, %r8
callq 0x4d4a6
movq %rbp, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2b166