// File: /workspace/github_c_makefile_star2_O2/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 0x1e663
cmpl $0x0, (%r12)
je 0x15c6a
xorl %ebx, %ebx
jmp 0x15df8
movq %rax, 0x28(%rsp)
movq %rbp, (%rsp)
movq %r13, 0x8(%rsp)
movq (%r15), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x12e0e
cmpl $0x0, (%r12)
je 0x15c94
xorl %ebx, %ebx
jmp 0x15de4
movq %r14, %rdi
callq 0x12a25
cmpl $0x2, (%r14)
jne 0x15cbf
cmpb $0x2e, (%rax)
movq 0x30(%rsp), %r11
movq 0x28(%rsp), %rcx
jne 0x15cbb
cmpb $0x0, 0x1(%rax)
je 0x15e0a
xorl %eax, %eax
jmp 0x15ccb
xorl %eax, %eax
movq 0x30(%rsp), %r11
movq 0x28(%rsp), %rcx
cmpq $0x1, %rcx
je 0x15d14
testq %rcx, %rcx
jne 0x15d4d
testb %al, %al
movq 0x8(%rsp), %rcx
movq (%rsp), %rdx
je 0x15d92
movq (%r15), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x577ef(%rip), %rax     # 0x6d4e8
leaq 0x57847(%rip), %rdx     # 0x6d547
leaq 0x5784f(%rip), %rcx     # 0x6d556
pushq $0x1d
popq %rsi
movq %r12, %rdi
pushq $0x121                  # imm = 0x121
jmp 0x15d85
testb %al, %al
je 0x15da2
subq $0x8, %rsp
leaq 0x18(%rsp), %rcx
pushq $0x1
popq %r8
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq 0x8(%rsp), %r9
pushq %r12
pushq %r11
pushq 0x20(%rsp)
callq 0x158de
addq $0x20, %rsp
jmp 0x15de1
testb %al, %al
movq 0x8(%rsp), %rcx
movq (%rsp), %rdx
je 0x15dc4
movq (%r15), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x5777c(%rip), %rax     # 0x6d4e8
leaq 0x577d4(%rip), %rdx     # 0x6d547
leaq 0x577bf(%rip), %rcx     # 0x6d539
pushq $0x1d
popq %rsi
movq %r12, %rdi
pushq $0x133                  # imm = 0x133
pushq %rax
callq 0x140cd
popq %rax
popq %rcx
jmp 0x15c8d
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %r8
callq 0x2a285
jmp 0x15de1
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 0x34571
jmp 0x15ddf
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r9
subq $0x8, %rsp
movq %r15, %rdi
movq %rbx, %rsi
pushq %r12
callq 0x3fb7b
popq %rcx
popq %rdx
movq %rax, %rbx
movq 0x10(%rsp), %rdi
callq 0x29d88
movq 0x18(%rsp), %rdi
callq 0x29d88
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 0x15ccb
movq %rbx, %rdi
callq 0x2dcbb
movq (%r15), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0x576b9(%rip), %r10     # 0x6d4e8
leaq 0x576ca(%rip), %rdx     # 0x6d500
pushq $0x1d
popq %rsi
movq %r12, %rdi
movq %rax, %rcx
pushq $0x119                  # imm = 0x119
pushq %r10
jmp 0x15d86