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

{
	subtilis_exp_t *indices[SUBTILIS_MAX_DIMENSIONS];
	size_t i;
	bool rec;
	const char *tbuf;
	subtilis_exp_t *e = NULL;
	size_t dims = 0;

	if (type->params.array.num_dims == 1)
		dims =
		    subtilis_round_bracketed_slice_have_b(p, t, indices, err);
	else
		dims = subtilis_var_bracketed_int_args_have_b(
		    p, t, indices, SUBTILIS_MAX_DIMENSIONS, 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 && (type->type != SUBTILIS_TYPE_ARRAY_REC)) {
		subtilis_error_set_expected(err, "Collection of RECs",
					    subtilis_type_name(type),
					    p->l->stream->name, p->l->line);
		goto cleanup;
	}

	if (dims == 0) {
		if (rec) {
			subtilis_error_set_expected(
			    err, "Array of RECs", "Array 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, type, mem_reg, loc, err);
	} else if ((type->params.array.num_dims == 1) && (dims == 2)) {
		if (rec) {
			subtilis_error_set_expected(
			    err, "Array of RECs", "Slice of RECs",
			    p->l->stream->name, p->l->line);
			goto cleanup;
		}
		/* We have a slice. */
		e = subtilis_array_type_slice_array(
		    p, type, mem_reg, loc, indices[0], indices[1], err);
	} else {
		if (rec)
			e = prv_read_rec_el(p, t, type, &indices[0], dims,
					    mem_reg, loc, var_name, err);
		else
			e = subtilis_type_if_indexed_read(p, var_name, type,
							  mem_reg, loc, indices,
							  dims, err);
	}

cleanup:

	for (i = 0; i < dims; i++)
		subtilis_exp_delete(indices[i]);

	return e;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %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)
movq $0x0, -0xb0(%rbp)
movq $0x0, -0xb8(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jne 0x17bb8
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x90(%rbp), %rdx
movq 0x10(%rbp), %rcx
callq 0x259a0
movq %rax, -0xb8(%rbp)
jmp 0x17bdc
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x90(%rbp), %rdx
movq 0x10(%rbp), %r8
movl $0xa, %ecx
callq 0x251f0
movq %rax, -0xb8(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x17bf2
movq $0x0, -0x8(%rbp)
jmp 0x17edb
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 0x17c14
jmp 0x17e8d
movq -0x18(%rbp), %rdi
callq 0x12d70
movq %rax, -0xa8(%rbp)
movq -0x18(%rbp), %rcx
xorl %eax, %eax
cmpl $0x2, (%rcx)
movb %al, -0xb9(%rbp)
jne 0x17c56
movq -0xa8(%rbp), %rdi
leaq 0x928d2(%rip), %rsi     # 0xaa515
callq 0x12140
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, -0xb9(%rbp)
movb -0xb9(%rbp), %al
andb $0x1, %al
movb %al, -0x99(%rbp)
testb $0x1, -0x99(%rbp)
je 0x17cd3
movq -0x20(%rbp), %rax
cmpl $0xf, (%rax)
je 0x17cd3
movq 0x10(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x20(%rbp), %rdi
callq 0x3e190
movq -0xc8(%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 0x92861(%rip), %rdx     # 0xaa517
leaq 0x92840(%rip), %rax     # 0xaa4fd
movq %rax, (%rsp)
movl $0x75, 0x8(%rsp)
callq 0x156d0
jmp 0x17e8d
cmpq $0x0, -0xb8(%rbp)
jne 0x17d57
testb $0x1, -0x99(%rbp)
je 0x17d30
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 0x9281e(%rip), %rdx     # 0xaa52a
leaq 0x92825(%rip), %rcx     # 0xaa538
leaq 0x927e3(%rip), %rax     # 0xaa4fd
movq %rax, (%rsp)
movl $0x7d, 0x8(%rsp)
callq 0x156d0
jmp 0x17e8d
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, -0xb0(%rbp)
jmp 0x17e8b
movq -0x20(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jne 0x17dfd
cmpq $0x2, -0xb8(%rbp)
jne 0x17dfd
testb $0x1, -0x99(%rbp)
je 0x17dc6
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 0x92788(%rip), %rdx     # 0xaa52a
leaq 0x927a7(%rip), %rcx     # 0xaa550
leaq 0x9274d(%rip), %rax     # 0xaa4fd
movq %rax, (%rsp)
movl $0x86, 0x8(%rsp)
callq 0x156d0
jmp 0x17e8d
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x90(%rbp), %r8
movq -0x88(%rbp), %r9
movq 0x10(%rbp), %rax
movq %rax, (%rsp)
callq 0x5dc00
movq %rax, -0xb0(%rbp)
jmp 0x17e89
testb $0x1, -0x99(%rbp)
je 0x17e4c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq -0x90(%rbp), %rcx
movq -0xb8(%rbp), %r8
movq -0x28(%rbp), %r9
movq -0x30(%rbp), %r11
movq -0x38(%rbp), %r10
movq 0x10(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x17ef0
movq %rax, -0xb0(%rbp)
jmp 0x17e87
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
leaq -0x90(%rbp), %r9
movq -0xb8(%rbp), %r10
movq 0x10(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x48440
movq %rax, -0xb0(%rbp)
jmp 0x17e89
jmp 0x17e8b
jmp 0x17e8d
movq $0x0, -0x98(%rbp)
movq -0x98(%rbp), %rax
cmpq -0xb8(%rbp), %rax
jae 0x17ed0
movq -0x98(%rbp), %rax
movq -0x90(%rbp,%rax,8), %rdi
callq 0x36ee0
movq -0x98(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
jmp 0x17e98
movq -0xb0(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
nopl (%rax,%rax)