// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/frontend/parser_array.c
// Function: subtils_parser_read_vector_with_type
subtilis_exp_t *subtils_parser_read_vector_with_type(subtilis_parser_t *p,
						     subtilis_token_t *t,
						     const subtilis_type_t *typ,
						     size_t mem_reg, size_t loc,
						     const char *var_name,
						     subtilis_error_t *err)
/* clang-format on */

{
	size_t indices_count;
	bool rec;
	const char *tbuf;
	subtilis_exp_t *indices[2] = {NULL, NULL};
	subtilis_exp_t *e = NULL;

	indices_count =
	    subtilis_curly_bracketed_slice_have_b(p, t, indices, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;

	subtilis_lexer_get(p->l, t, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	tbuf = subtilis_token_get_text(t);
	rec = (t->type == SUBTILIS_TOKEN_OPERATOR) && !strcmp(tbuf, ".");
	if (rec && (typ->type != SUBTILIS_TYPE_VECTOR_REC)) {
		subtilis_error_set_expected(err, "Collection of RECs",
					    subtilis_type_name(typ),
					    p->l->stream->name, p->l->line);
		goto cleanup;
	}

	if (indices_count == 0) {
		if (rec) {
			subtilis_error_set_expected(
			    err, "Vector of RECs", "Vector of RECs  reference",
			    p->l->stream->name, p->l->line);
			goto cleanup;
		}

		/* What we have here is an array reference. */
		e = subtilis_exp_new_var_block(p, typ, mem_reg, loc, err);
	} else if (indices_count == 1) {
		/* And here we're reading an individual entry. */
		if (rec)
			e = prv_read_rec_el(p, t, typ, &indices[0], 1, mem_reg,
					    loc, var_name, err);
		else
			e = subtilis_type_if_indexed_read(
			    p, var_name, typ, mem_reg, loc, indices, 1, err);
	} else {
		if (rec) {
			subtilis_error_set_expected(
			    err, "Vector of RECs", "Slice of RECs",
			    p->l->stream->name, p->l->line);
			goto cleanup;
		}

		/* We have a slice */
		e = subtilis_array_type_slice_vector(
		    p, typ, mem_reg, loc, indices[0], indices[1], err);
	}

cleanup:

	subtilis_exp_delete(indices[0]);
	subtilis_exp_delete(indices[1]);

	return e;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, 0x30(%rsp)
movq %r8, %r13
movq %rcx, %rbp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq 0x70(%rsp), %r12
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdx
movaps %xmm0, (%rdx)
movq %r12, %rcx
callq 0x1f325
cmpl $0x0, (%r12)
je 0x160dc
xorl %ebx, %ebx
jmp 0x16274
movq %rax, 0x28(%rsp)
movq %rbp, (%rsp)
movq %r13, 0x8(%rsp)
movq (%r15), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x12edc
cmpl $0x0, (%r12)
je 0x16106
xorl %ebx, %ebx
jmp 0x16260
movq %r14, %rdi
callq 0x12ad0
cmpl $0x2, (%r14)
jne 0x16131
cmpb $0x2e, (%rax)
movq 0x30(%rsp), %r11
movq 0x28(%rsp), %rcx
jne 0x1612d
cmpb $0x0, 0x1(%rax)
je 0x16286
xorl %eax, %eax
jmp 0x1613d
xorl %eax, %eax
movq 0x30(%rsp), %r11
movq 0x28(%rsp), %rcx
cmpq $0x1, %rcx
je 0x16188
testq %rcx, %rcx
jne 0x161c3
testb %al, %al
movq 0x8(%rsp), %rcx
movq (%rsp), %rdx
je 0x1620c
movq (%r15), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x5d37d(%rip), %rax     # 0x734e8
leaq 0x5d3d5(%rip), %rdx     # 0x73547
leaq 0x5d3dd(%rip), %rcx     # 0x73556
movq %r12, %rdi
movl $0x1d, %esi
pushq $0x121                  # imm = 0x121
jmp 0x161fd
testb %al, %al
je 0x1621c
subq $0x8, %rsp
leaq 0x18(%rsp), %rcx
movl $0x1, %r8d
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq 0x8(%rsp), %r9
pushq %r12
pushq %r11
pushq 0x20(%rsp)
callq 0x15d0e
addq $0x20, %rsp
jmp 0x1625d
testb %al, %al
movq 0x8(%rsp), %rcx
movq (%rsp), %rdx
je 0x1623e
movq (%r15), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x5d306(%rip), %rax     # 0x734e8
leaq 0x5d35e(%rip), %rdx     # 0x73547
leaq 0x5d349(%rip), %rcx     # 0x73539
movq %r12, %rdi
movl $0x1d, %esi
pushq $0x133                  # imm = 0x133
pushq %rax
callq 0x143da
addq $0x10, %rsp
jmp 0x160ff
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %r8
callq 0x2b668
jmp 0x1625d
leaq 0x10(%rsp), %r9
movq %r15, %rdi
movq %r11, %rsi
movq %rbx, %rdx
movq (%rsp), %rcx
movq 0x8(%rsp), %r8
pushq %r12
pushq $0x1
callq 0x36555
jmp 0x16259
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r9
subq $0x8, %rsp
movq %r15, %rdi
movq %rbx, %rsi
pushq %r12
callq 0x42114
addq $0x10, %rsp
movq %rax, %rbx
movq 0x10(%rsp), %rdi
callq 0x2b166
movq 0x18(%rsp), %rdi
callq 0x2b166
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %al
cmpl $0x15, (%rbx)
je 0x1613d
movq %rbx, %rdi
callq 0x2f5ad
movq (%r15), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0x5d23d(%rip), %r10     # 0x734e8
leaq 0x5d24e(%rip), %rdx     # 0x73500
movq %r12, %rdi
movl $0x1d, %esi
movq %rax, %rcx
pushq $0x119                  # imm = 0x119
pushq %r10
jmp 0x161fe