// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x47d20
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x5da57
jmp 0x5dbf6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x474f0
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x5da7e
jmp 0x5dbed
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
callq 0x6d1e0
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x5daa5
jmp 0x5dbed
movq -0x38(%rbp), %rax
movl %eax, %edi
movq -0x30(%rbp), %rsi
callq 0x37770
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x5dac6
jmp 0x5dbed
movq -0x48(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x5daff
movq -0x48(%rbp), %rax
cmpl $0x0, 0x148(%rax)
jne 0x5daff
movq -0x48(%rbp), %rdi
callq 0x36ee0
movq $0x0, -0x48(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
jmp 0x5db28
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x48e20
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x5db26
jmp 0x5dbed
jmp 0x5db28
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rax
movq 0x148(%rax), %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %r8
xorl %eax, %eax
movl %eax, %ecx
callq 0x6d9a0
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x5db56
jmp 0x5dbed
movq -0x48(%rbp), %rdi
callq 0x36ee0
movq $0x0, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
callq 0x6d230
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x5db8b
jmp 0x5dbed
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %rdx
movl $0x78, %esi
callq 0x38540
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x5dbb0
jmp 0x5dbed
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %r8
xorl %eax, %eax
movl %eax, %ecx
callq 0x6da00
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x5dbd4
jmp 0x5dbed
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %r8
xorl %eax, %eax
movl %eax, %ecx
callq 0x6d540
movq -0x48(%rbp), %rdi
callq 0x36ee0
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)