// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/parser_array.c
// Function: subtilis_parser_create_array
void subtilis_parser_create_array(subtilis_parser_t *p, subtilis_token_t *t,
				  bool local, subtilis_error_t *err)
{
	const char *tbuf;
	subtilis_exp_t *e[SUBTILIS_MAX_DIMENSIONS];
	subtilis_type_t element_type;

	size_t i;
	subtilis_ir_operand_t local_global;
	bool vec = false;
	size_t dims = 0;
	char *var_name = NULL;

	local_global.reg =
	    local ? SUBTILIS_IR_REG_LOCAL : SUBTILIS_IR_REG_GLOBAL;

	do {
		subtilis_lexer_get(p->l, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		tbuf = subtilis_token_get_text(t);
		if (t->type != SUBTILIS_TOKEN_IDENTIFIER) {
			subtilis_error_set_id_expected(
			    err, tbuf, p->l->stream->name, p->l->line);
			return;
		}

		if (!local && p->current->proc_called) {
			subtilis_error_set_global_after_proc(
			    err, tbuf, p->l->stream->name, p->l->line);
			return;
		}

		tbuf = subtilis_token_get_text(t);
		if (subtilis_symbol_table_lookup(p->local_st, tbuf) ||
		    (!local && subtilis_symbol_table_lookup(p->st, tbuf))) {
			subtilis_error_set_already_defined(
			    err, tbuf, p->l->stream->name, p->l->line);
			return;
		}

		var_name = malloc(strlen(tbuf) + 1);
		if (!var_name) {
			subtilis_error_set_oom(err);
			return;
		}
		strcpy(var_name, tbuf);
		subtilis_type_init_copy(&element_type, &t->tok.id_type, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;

		if ((element_type.type == SUBTILIS_TYPE_FN) ||
		    (element_type.type == SUBTILIS_TYPE_REC)) {
			subtilis_complete_custom_type(p, var_name,
						      &element_type, err);
			if (err->type != SUBTILIS_ERROR_OK)
				goto cleanup;
		}

		dims = parser_array_var_bracketed_int_args(
		    p, t, e, SUBTILIS_MAX_DIMENSIONS, &vec, err);
		if (err->type == SUBTILIS_ERROR_RIGHT_BKT_EXPECTED) {
			subtilis_error_too_many_dims(
			    err, var_name, p->l->stream->name, p->l->line);
			subtilis_type_free(&element_type);
			goto cleanup;
		}
		if (err->type != SUBTILIS_ERROR_OK) {
			subtilis_type_free(&element_type);
			goto cleanup;
		}

		if (!local && (p->level != 0)) {
			subtilis_error_variable_bad_level(
			    err, var_name, p->l->stream->name, p->l->line);
			subtilis_type_free(&element_type);
			goto cleanup;
		}

		if (vec)
			prv_create_vector(p, local_global, &element_type, &dims,
					  e, var_name, local, err);
		else
			prv_create_array(p, local_global, &element_type, dims,
					 e, var_name, local, err);
		subtilis_type_free(&element_type);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;

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

		free(var_name);
		var_name = NULL;

		subtilis_lexer_get(p->l, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
		tbuf = subtilis_token_get_text(t);
	} while (t->type == SUBTILIS_TOKEN_OPERATOR && !strcmp(tbuf, ","));

cleanup:
	for (i = 0; i < dims; i++)
		subtilis_exp_delete(e[i]);

	free(var_name);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq %rcx, -0x20(%rbp)
movb $0x0, -0x1d9(%rbp)
movq $0x0, -0x1e8(%rbp)
movq $0x0, -0x1f0(%rbp)
movb -0x11(%rbp), %dl
movl $0x1, %eax
movl $0x2, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
cltq
movq %rax, -0x1d8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x133f0
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x19809
jmp 0x19cce
movq -0x10(%rbp), %rdi
callq 0x12d70
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x6, (%rax)
je 0x19866
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x12, %esi
leaq 0x91a2d(%rip), %rcx     # 0xab276
leaq 0x90cad(%rip), %rax     # 0xaa4fd
movq %rax, (%rsp)
movl $0x4e2, 0x8(%rsp)       # imm = 0x4E2
callq 0x156d0
jmp 0x19cce
testb $0x1, -0x11(%rbp)
jne 0x198c4
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
testb $0x1, 0xe0(%rax)
je 0x198c4
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x6c, %esi
leaq 0x919cf(%rip), %rcx     # 0xab276
leaq 0x90c4f(%rip), %rax     # 0xaa4fd
movq %rax, (%rsp)
movl $0x4e8, 0x8(%rsp)       # imm = 0x4E8
callq 0x156d0
jmp 0x19cce
movq -0x10(%rbp), %rdi
callq 0x12d70
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x3cff0
cmpq $0x0, %rax
jne 0x19905
testb $0x1, -0x11(%rbp)
jne 0x1994c
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x3cff0
cmpq $0x0, %rax
je 0x1994c
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x20, %esi
leaq 0x91947(%rip), %rcx     # 0xab276
leaq 0x90bc7(%rip), %rax     # 0xaa4fd
movq %rax, (%rsp)
movl $0x4f0, 0x8(%rsp)       # imm = 0x4F0
callq 0x156d0
jmp 0x19cce
movq -0x28(%rbp), %rdi
callq 0x120d0
movq %rax, %rdi
addq $0x1, %rdi
callq 0x121b0
movq %rax, -0x1f0(%rbp)
cmpq $0x0, -0x1f0(%rbp)
jne 0x19991
movq -0x20(%rbp), %rdi
movl $0x1, %esi
leaq 0x90b7b(%rip), %rdx     # 0xaa4fd
movl $0x4f6, %ecx            # imm = 0x4F6
callq 0x158e0
jmp 0x19cce
movq -0x1f0(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x12060
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
movq -0x20(%rbp), %rdx
leaq -0x1c8(%rbp), %rdi
callq 0x3dec0
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x199c7
jmp 0x19c82
cmpl $0x9, -0x1c8(%rbp)
je 0x199d9
cmpl $0x16, -0x1c8(%rbp)
jne 0x19a04
movq -0x8(%rbp), %rdi
movq -0x1f0(%rbp), %rsi
movq -0x20(%rbp), %rcx
leaq -0x1c8(%rbp), %rdx
callq 0x25e50
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x19a02
jmp 0x19c82
jmp 0x19a04
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x80(%rbp), %rdx
movq -0x20(%rbp), %r9
movl $0xa, %ecx
leaq -0x1d9(%rbp), %r8
callq 0x18a90
movq %rax, -0x1e8(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x16, (%rax)
jne 0x19a8b
movq -0x20(%rbp), %rdi
movq -0x1f0(%rbp), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x36, %esi
leaq 0x91814(%rip), %rcx     # 0xab276
leaq 0x90a94(%rip), %rax     # 0xaa4fd
movq %rax, (%rsp)
movl $0x50a, 0x8(%rsp)       # imm = 0x50A
callq 0x156d0
leaq -0x1c8(%rbp), %rdi
callq 0x3e100
jmp 0x19c82
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x19aa5
leaq -0x1c8(%rbp), %rdi
callq 0x3e100
jmp 0x19c82
testb $0x1, -0x11(%rbp)
jne 0x19b0c
movq -0x8(%rbp), %rax
cmpq $0x0, 0x78(%rax)
je 0x19b0c
movq -0x20(%rbp), %rdi
movq -0x1f0(%rbp), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x3e, %esi
leaq 0x91793(%rip), %rcx     # 0xab276
leaq 0x90a13(%rip), %rax     # 0xaa4fd
movq %rax, (%rsp)
movl $0x515, 0x8(%rsp)       # imm = 0x515
callq 0x156d0
leaq -0x1c8(%rbp), %rdi
callq 0x3e100
jmp 0x19c82
testb $0x1, -0x1d9(%rbp)
je 0x19b59
movq -0x8(%rbp), %rdi
leaq -0x80(%rbp), %r8
movq -0x1f0(%rbp), %r9
movb -0x11(%rbp), %r10b
movq -0x20(%rbp), %rax
movq -0x1d8(%rbp), %rsi
leaq -0x1c8(%rbp), %rdx
leaq -0x1e8(%rbp), %rcx
andb $0x1, %r10b
movzbl %r10b, %r10d
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x19ce0
jmp 0x19b9b
movq -0x8(%rbp), %rdi
movq -0x1e8(%rbp), %rcx
leaq -0x80(%rbp), %r8
movq -0x1f0(%rbp), %r9
movb -0x11(%rbp), %r10b
movq -0x20(%rbp), %rax
movq -0x1d8(%rbp), %rsi
leaq -0x1c8(%rbp), %rdx
andb $0x1, %r10b
movzbl %r10b, %r10d
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x19e10
leaq -0x1c8(%rbp), %rdi
callq 0x3e100
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x19bb5
jmp 0x19c82
movq $0x0, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rax
cmpq -0x1e8(%rbp), %rax
jae 0x19bf5
movq -0x1d0(%rbp), %rax
movq -0x80(%rbp,%rax,8), %rdi
callq 0x36ee0
movq -0x1d0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1d0(%rbp)
jmp 0x19bc0
movq $0x0, -0x1e8(%rbp)
movq -0x1f0(%rbp), %rdi
callq 0x12290
movq $0x0, -0x1f0(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x133f0
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x19c36
jmp 0x19c82
movq -0x10(%rbp), %rdi
callq 0x12d70
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpl $0x2, (%rcx)
movb %al, -0x1f1(%rbp)
jne 0x19c72
movq -0x28(%rbp), %rdi
leaq 0x9094a(%rip), %rsi     # 0xaa5a9
callq 0x12140
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, -0x1f1(%rbp)
movb -0x1f1(%rbp), %al
testb $0x1, %al
jne 0x197e7
jmp 0x19c82
movq $0x0, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rax
cmpq -0x1e8(%rbp), %rax
jae 0x19cc2
movq -0x1d0(%rbp), %rax
movq -0x80(%rbp,%rax,8), %rdi
callq 0x36ee0
movq -0x1d0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1d0(%rbp)
jmp 0x19c8d
movq -0x1f0(%rbp), %rdi
callq 0x12290
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
nopw (%rax,%rax)