// File: /workspace/github_c_makefile_star2_O1/markdryan[P]subtilis/frontend/array_type.c
// Function: prv_slice_set_sizes
static size_t prv_slice_set_sizes(subtilis_parser_t *p,
				  const subtilis_type_t *type,
				  size_t source_reg, size_t dest_reg,
				  subtilis_exp_t *index1,
				  subtilis_exp_t *index2, subtilis_error_t *err)
{
	size_t size_reg;
	size_t orig_size_reg;
	subtilis_exp_t *one = NULL;
	subtilis_exp_t *size = NULL;
	subtilis_exp_t *index1_dup = NULL;
	subtilis_exp_t *index2_dup = NULL;
	subtilis_exp_t *size_dup = NULL;
	subtilis_exp_t *el_count = NULL;

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

	index2_dup = subtilis_type_if_dup(index2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	size = subtilis_type_if_sub(p, index2_dup, index1_dup, err);
	index1_dup = NULL;
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	size_dup = subtilis_type_if_dup(size, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	one = subtilis_exp_new_int32(1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	el_count = subtilis_type_if_sub(p, size_dup, one, err);
	size_dup = NULL;
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	size = subtilis_type_if_exp_to_var(p, size, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	size_reg = size->exp.ir_op.reg;
	subtilis_exp_delete(size);
	size = NULL;

	subtilis_reference_type_set_size(p, dest_reg, 0, size_reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	subtilis_reference_type_set_orig_size(p, dest_reg, 0, orig_size_reg,
					      err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_type_if_assign_to_mem(p, dest_reg, SUBTIILIS_ARRAY_DIMS_OFF,
				       el_count, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	return size_reg;

cleanup:
	subtilis_exp_delete(el_count);
	subtilis_exp_delete(size);
	subtilis_exp_delete(size_dup);
	subtilis_exp_delete(index1_dup);

	return SIZE_MAX;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r12
movq %rcx, %r14
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %rbx
movq 0x60(%rsp), %rbp
movq %r8, %rdi
movq %rbp, %rsi
callq 0x362d2
movq %rax, %rcx
movq $-0x1, %rax
cmpl $0x0, (%rbp)
jne 0x42922
movq %rcx, %rbp
movq %r15, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq %rbx, 0x10(%rsp)
movq %r14, 0x8(%rsp)
movq %r12, %rdi
movq 0x60(%rsp), %r15
movq %r15, %rsi
callq 0x362d2
cmpl $0x0, (%r15)
je 0x428a0
xorl %r13d, %r13d
xorl %r12d, %r12d
xorl %ebx, %ebx
jmp 0x428fb
movq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x36f23
cmpl $0x0, (%r15)
je 0x428c8
xorl %ebp, %ebp
xorl %r12d, %r12d
xorl %ebx, %ebx
movq %rax, %r13
jmp 0x428fb
movq %rax, (%rsp)
movq %rax, %rdi
movq %r15, %rsi
callq 0x362d2
movq %rax, %r12
cmpl $0x0, (%r15)
jne 0x428f3
movl $0x1, %edi
movq %r15, %rsi
callq 0x2bb29
cmpl $0x0, (%r15)
je 0x42931
xorl %ebp, %ebp
xorl %ebx, %ebx
movq (%rsp), %r13
movq %rbx, %rdi
callq 0x2b4c3
movq %r13, %rdi
callq 0x2b4c3
movq %r12, %rdi
callq 0x2b4c3
movq %rbp, %rdi
callq 0x2b4c3
movq $-0x1, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
movq %r15, %rcx
callq 0x36f23
movq %rax, %rbx
cmpl $0x0, (%r15)
je 0x42952
xorl %ebp, %ebp
xorl %r12d, %r12d
jmp 0x428f7
movq %r14, %rdi
movq 0x20(%rsp), %rsi
movq (%rsp), %rdx
movq %r15, %rcx
callq 0x35f2b
movq %rax, %r13
cmpl $0x0, (%r15)
jne 0x429d1
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x36269
movq %rax, %r13
cmpl $0x0, (%r15)
jne 0x429d1
movq 0x148(%r13), %r12
movq %r13, %rdi
callq 0x2b4c3
xorl %r13d, %r13d
movq %r14, %rdi
movq 0x8(%rsp), %rbp
movq %rbp, %rsi
xorl %edx, %edx
movq %r12, %rcx
movq %r15, %r8
callq 0x4d921
cmpl $0x0, (%r15)
jne 0x429d1
xorl %r13d, %r13d
movq %r14, %rdi
movq 0x18(%rsp), %rsi
xorl %edx, %edx
movq %r15, %rcx
callq 0x4ddd4
cmpl $0x0, (%r15)
je 0x429db
xorl %ebp, %ebp
xorl %r12d, %r12d
jmp 0x428fb
movq %r14, %rdi
movq %rbp, %rsi
xorl %edx, %edx
movq %rax, %rcx
movq %r15, %r8
callq 0x4db75
cmpl $0x0, (%r15)
je 0x42a01
xorl %ebp, %ebp
xorl %r12d, %r12d
xorl %r13d, %r13d
jmp 0x428fb
movl $0x10, %edx
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %rbx, %rcx
movq 0x60(%rsp), %r14
movq %r14, %r8
callq 0x36416
xorl %ebx, %ebx
cmpl (%r14), %ebx
sbbq %rbx, %rbx
orq %r12, %rbx
movq %rbx, %rax
jmp 0x42922