// File: /workspace/github_c_makefile_star2_O1/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 0x362d2
cmpl $0x0, (%rbx)
je 0x42a6c
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 0x35f2b
movq %rax, %rbp
cmpl $0x0, (%rbx)
jne 0x42b7f
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x4d29c
cmpl $0x0, (%rbx)
jne 0x42b7f
movl %eax, %edi
movq %rbx, %rsi
callq 0x2ba99
cmpl $0x0, (%rbx)
jne 0x42b7f
cmpl $0x1, (%rbp)
jne 0x42ac4
cmpl $0x0, 0x148(%rbp)
je 0x42ae3
movq %r12, %rdi
movq %rax, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x36c85
cmpl $0x0, (%rbx)
movq %rax, %rbp
jne 0x42b7f
jmp 0x42af1
movq %rbp, %rdi
movq %rax, %rbp
callq 0x2b4c3
movq %rbp, %rax
movq 0x148(%rax), %rsi
movq %r12, %rdi
movq %r14, %rdx
xorl %ecx, %ecx
movq %rbx, %r8
movq %rax, %rbp
callq 0x4d796
cmpl $0x0, (%rbx)
jne 0x42b7f
movq %rbp, %rdi
callq 0x2b4c3
xorl %ebp, %ebp
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x4d2b6
cmpl $0x0, (%rbx)
jne 0x42b7f
movq %rax, %r13
movq 0x48(%r12), %rdi
movl $0x78, %esi
movq %rax, %rdx
movq %rbx, %rcx
callq 0x2c19f
cmpl $0x0, (%rbx)
je 0x42b50
xorl %ebp, %ebp
jmp 0x42b7f
xorl %ebp, %ebp
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
movq %rbx, %r8
callq 0x4d7b4
cmpl $0x0, (%rbx)
jne 0x42b7f
xorl %ebp, %ebp
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
movq %rbx, %r8
callq 0x4d4ea
movq %rbp, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2b4c3