// File: /workspace/github_c_makefile_star2_O1/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 0x1f29b
cmpl $0x0, (%r12)
je 0x1613d
xorl %ebx, %ebx
jmp 0x162c1
movq %rax, 0x28(%rsp)
movq %rbp, (%rsp)
movq %r13, 0x8(%rsp)
movq (%r15), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x12eda
cmpl $0x0, (%r12)
jne 0x162ab
movq %r14, %rdi
callq 0x12ad0
cmpl $0x2, (%r14)
jne 0x16188
leaq 0x5d38b(%rip), %rsi     # 0x73504
movq %rax, %rdi
callq 0x12160
testl %eax, %eax
sete %al
jmp 0x1618a
xorl %eax, %eax
movq 0x30(%rsp), %r11
movq 0x28(%rsp), %rcx
testb %al, %al
je 0x161a1
cmpl $0x15, (%rbx)
jne 0x1622e
cmpq $0x1, %rcx
je 0x161f3
testq %rcx, %rcx
jne 0x16263
testb %al, %al
movq 0x8(%rsp), %rcx
movq (%rsp), %rdx
je 0x162d3
movq (%r15), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x5d319(%rip), %rax     # 0x734ec
leaq 0x5d373(%rip), %rdx     # 0x7354d
leaq 0x5d37b(%rip), %rcx     # 0x7355c
movq %r12, %rdi
movl $0x1d, %esi
pushq $0x121                  # imm = 0x121
jmp 0x162a1
testb %al, %al
je 0x162e3
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 0x15d66
addq $0x20, %rsp
jmp 0x16324
movq %rbx, %rdi
callq 0x2f882
movq (%r15), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0x5d2a4(%rip), %r10     # 0x734ec
leaq 0x5d2b7(%rip), %rdx     # 0x73506
movq %r12, %rdi
movl $0x1d, %esi
movq %rax, %rcx
pushq $0x119                  # imm = 0x119
pushq %r10
jmp 0x162a2
testb %al, %al
movq 0x8(%rsp), %rcx
movq (%rsp), %rdx
je 0x16305
movq (%r15), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x5d266(%rip), %rax     # 0x734ec
leaq 0x5d2c0(%rip), %rdx     # 0x7354d
leaq 0x5d2ab(%rip), %rcx     # 0x7353f
movq %r12, %rdi
movl $0x1d, %esi
pushq $0x133                  # imm = 0x133
pushq %rax
callq 0x1442a
addq $0x10, %rsp
xorl %ebx, %ebx
movq 0x10(%rsp), %rdi
callq 0x2b4c3
movq 0x18(%rsp), %rdi
callq 0x2b4c3
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %r8
callq 0x2b9e2
jmp 0x16324
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 0x366a5
jmp 0x16320
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r9
subq $0x8, %rsp
movq %r15, %rdi
movq %rbx, %rsi
pushq %r12
callq 0x42242
addq $0x10, %rsp
movq %rax, %rbx
jmp 0x162ad