// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/parser_array.c
// Function: subtilis_parser_get_dim
subtilis_exp_t *subtilis_parser_get_dim(subtilis_parser_t *p,
					subtilis_token_t *t,
					subtilis_error_t *err)
{
	const char *tbuf;
	subtilis_exp_t *dim = NULL;
	subtilis_exp_t *ar = NULL;

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

	tbuf = subtilis_token_get_text(t);
	if ((t->type != SUBTILIS_TOKEN_OPERATOR) || (strcmp(tbuf, "("))) {
		subtilis_error_set_expected(err, "(", tbuf, p->l->stream->name,
					    p->l->line);
		goto cleanup;
	}

	ar = subtilis_parser_expression(p, t, err);
	if (err->type == SUBTILIS_ERROR_NUMERIC_EXPECTED) {
		subtilis_error_not_array(err, "First argument to dim",
					 p->l->stream->name, p->l->line);
		goto cleanup;
	} else if (err->type != SUBTILIS_ERROR_OK) {
		goto cleanup;
	}

	if (!subtilis_type_if_is_array(&ar->type) &&
	    !subtilis_type_if_is_vector(&ar->type)) {
		subtilis_error_not_array(err, "First argument to dim",
					 p->l->stream->name, p->l->line);
		goto cleanup;
	}

	tbuf = subtilis_token_get_text(t);
	if (t->type != SUBTILIS_TOKEN_OPERATOR) {
		subtilis_error_set_expected(err, ") or ,", tbuf,
					    p->l->stream->name, p->l->line);
		goto cleanup;
	}

	if (!strcmp(tbuf, ",")) {
		dim = subtilis_parser_expression(p, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;

		dim = subtilis_type_if_to_int(p, dim, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;

		tbuf = subtilis_token_get_text(t);
	}

	if (strcmp(tbuf, ")")) {
		subtilis_error_set_right_bkt_expected(
		    err, tbuf, p->l->stream->name, p->l->line);
		goto cleanup;
	}

	ar = subtilis_array_get_dim(p, ar, dim, err);
	dim = NULL;
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	return ar;

cleanup:

	subtilis_exp_delete(ar);
	subtilis_exp_delete(dim);

	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x133f0
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x19f9e
movq $0x0, -0x8(%rbp)
jmp 0x1a279
movq -0x18(%rbp), %rdi
callq 0x12d70
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x19fc9
movq -0x28(%rbp), %rdi
leaq 0x912dd(%rip), %rsi     # 0xab29c
callq 0x12140
cmpl $0x0, %eax
je 0x1a010
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %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 0x912a9(%rip), %rdx     # 0xab29c
leaq 0x90503(%rip), %rax     # 0xaa4fd
movq %rax, (%rsp)
movl $0x547, 0x8(%rsp)       # imm = 0x547
callq 0x156d0
jmp 0x1a25f
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x24a20
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x2c, (%rax)
jne 0x1a078
movq -0x20(%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 $0x3b, %esi
leaq 0x9053a(%rip), %rdx     # 0xaa58e
leaq 0x9121b(%rip), %rcx     # 0xab276
leaq 0x9049b(%rip), %rax     # 0xaa4fd
movq %rax, (%rsp)
movl $0x54e, 0x8(%rsp)       # imm = 0x54E
callq 0x156d0
jmp 0x1a25f
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1a086
jmp 0x1a25f
jmp 0x1a088
movq -0x38(%rbp), %rdi
callq 0x49ff0
testb $0x1, %al
jne 0x1a0ec
movq -0x38(%rbp), %rdi
callq 0x4a040
testb $0x1, %al
jne 0x1a0ec
movq -0x20(%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 $0x3b, %esi
leaq 0x904c6(%rip), %rdx     # 0xaa58e
leaq 0x911a7(%rip), %rcx     # 0xab276
leaq 0x90427(%rip), %rax     # 0xaa4fd
movq %rax, (%rsp)
movl $0x557, 0x8(%rsp)       # imm = 0x557
callq 0x156d0
jmp 0x1a25f
movq -0x18(%rbp), %rdi
callq 0x12d70
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x2, (%rax)
je 0x1a149
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %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 0x90478(%rip), %rdx     # 0xaa5a4
leaq 0x903ca(%rip), %rax     # 0xaa4fd
movq %rax, (%rsp)
movl $0x55e, 0x8(%rsp)       # imm = 0x55E
callq 0x156d0
jmp 0x1a25f
movq -0x28(%rbp), %rdi
leaq 0x90455(%rip), %rsi     # 0xaa5a9
callq 0x12140
cmpl $0x0, %eax
jne 0x1a1b1
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x24a20
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1a181
jmp 0x1a25f
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x488b0
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1a1a4
jmp 0x1a25f
movq -0x18(%rbp), %rdi
callq 0x12d70
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
leaq 0x90995(%rip), %rsi     # 0xaab51
callq 0x12140
cmpl $0x0, %eax
je 0x1a20a
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rdx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x16, %esi
leaq 0x91086(%rip), %rcx     # 0xab276
leaq 0x90306(%rip), %rax     # 0xaa4fd
movq %rax, (%rsp)
movl $0x570, 0x8(%rsp)       # imm = 0x570
callq 0x156d0
jmp 0x1a25f
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x5fd10
movq %rax, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1a236
jmp 0x1a25f
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x133f0
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1a255
jmp 0x1a25f
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x1a279
movq -0x38(%rbp), %rdi
callq 0x36ee0
movq -0x30(%rbp), %rdi
callq 0x36ee0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)