// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x90, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x12110
movq $0x0, -0x68(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x60(%rbp), %rdx
movq 0x10(%rbp), %rcx
callq 0x255f0
movq %rax, -0x40(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1841e
movq $0x0, -0x8(%rbp)
jmp 0x18673
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq 0x10(%rbp), %rdx
callq 0x133f0
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x18440
jmp 0x18659
movq -0x18(%rbp), %rdi
callq 0x12d70
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rcx
xorl %eax, %eax
cmpl $0x2, (%rcx)
movb %al, -0x69(%rbp)
jne 0x18476
movq -0x50(%rbp), %rdi
leaq 0x920af(%rip), %rsi     # 0xaa515
callq 0x12140
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
andb $0x1, %al
movb %al, -0x41(%rbp)
testb $0x1, -0x41(%rbp)
je 0x184e4
movq -0x20(%rbp), %rax
cmpl $0x15, (%rax)
je 0x184e4
movq 0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x20(%rbp), %rdi
callq 0x3e190
movq -0x78(%rbp), %rdi
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x1d, %esi
leaq 0x92050(%rip), %rdx     # 0xaa517
leaq 0x9202f(%rip), %rax     # 0xaa4fd
movq %rax, (%rsp)
movl $0x119, 0x8(%rsp)       # imm = 0x119
callq 0x156d0
jmp 0x18659
cmpq $0x0, -0x40(%rbp)
jne 0x1855f
testb $0x1, -0x41(%rbp)
je 0x1853b
movq 0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x1d, %esi
leaq 0x92047(%rip), %rdx     # 0xaa55e
leaq 0x9204f(%rip), %rcx     # 0xaa56d
leaq 0x91fd8(%rip), %rax     # 0xaa4fd
movq %rax, (%rsp)
movl $0x121, 0x8(%rsp)       # imm = 0x121
callq 0x156d0
jmp 0x18659
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rax
movl %eax, %edx
movq -0x30(%rbp), %rcx
movq 0x10(%rbp), %r8
callq 0x37660
movq %rax, -0x68(%rbp)
jmp 0x18657
cmpq $0x1, -0x40(%rbp)
jne 0x185df
testb $0x1, -0x41(%rbp)
je 0x185ab
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq -0x60(%rbp), %rcx
movq -0x28(%rbp), %r9
movq -0x30(%rbp), %r11
movq -0x38(%rbp), %r10
movq 0x10(%rbp), %rax
movl $0x1, %r8d
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x17ef0
movq %rax, -0x68(%rbp)
jmp 0x185dd
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
leaq -0x60(%rbp), %r9
movq 0x10(%rbp), %rax
movq $0x1, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x48440
movq %rax, -0x68(%rbp)
jmp 0x18655
testb $0x1, -0x41(%rbp)
je 0x1862c
movq 0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x1d, %esi
leaq 0x91f53(%rip), %rdx     # 0xaa55e
leaq 0x91f3e(%rip), %rcx     # 0xaa550
leaq 0x91ee4(%rip), %rax     # 0xaa4fd
movq %rax, (%rsp)
movl $0x133, 0x8(%rsp)       # imm = 0x133
callq 0x156d0
jmp 0x18659
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x60(%rbp), %r8
movq -0x58(%rbp), %r9
movq 0x10(%rbp), %rax
movq %rax, (%rsp)
callq 0x5ce90
movq %rax, -0x68(%rbp)
jmp 0x18657
jmp 0x18659
movq -0x60(%rbp), %rdi
callq 0x36ee0
movq -0x58(%rbp), %rdi
callq 0x36ee0
movq -0x68(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq