// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/parser_rec.c
// Function: prv_parse_dim
static void prv_parse_dim(subtilis_parser_t *p, subtilis_token_t *t,
			  subtilis_type_t *type, subtilis_error_t *err)
{
	const char *tbuf;
	subtilis_type_t element_type;
	size_t i;
	subtilis_type_t field;
	size_t size;
	size_t align;
	subtilis_exp_t *e[SUBTILIS_MAX_DIMENSIONS];
	char *var_name = NULL;
	bool vec = false;
	size_t dims = 0;
	int32_t vec_dim = 0;

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

	prv_check_id(p, t, &element_type, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	tbuf = subtilis_token_get_text(t);
	var_name = malloc(strlen(tbuf) + 1);
	if (!var_name) {
		subtilis_error_set_oom(err);
		goto cleanup;
	}
	strcpy(var_name, tbuf);

	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);
		goto cleanup;
	}

	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	if (!vec && dims == 0) {
		subtilis_error_set_const_integer_expected(
		    err, p->l->stream->name, p->l->line);
		goto cleanup;
	}

	for (i = 0; i < dims; i++) {
		if (e[i]->type.type == SUBTILIS_TYPE_CONST_INTEGER)
			continue;

		subtilis_error_set_const_integer_expected(
		    err, p->l->stream->name, p->l->line);
		goto cleanup;
	}

	if (vec) {
		subtilis_array_type_vector_init(&element_type, &field, err);
		vec_dim = dims > 0 ? e[0]->exp.ir_op.integer : -1;
	} else {
		subtilis_array_type_init(p, var_name, &element_type, &field,
					 &e[0], dims, err);
	}

	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	size = subtilis_type_if_size(&field, err);
	if (err->type != SUBTILIS_ERROR_OK) {
		subtilis_type_free(&field);
		goto cleanup;
	}
	align = subtilis_type_if_align(&field, err);
	if (err->type != SUBTILIS_ERROR_OK) {
		subtilis_type_free(&field);
		goto cleanup;
	}
	subtilis_type_rec_add_field(type, var_name, &field, align, size,
				    vec_dim, err);
	subtilis_type_free(&field);

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

cleanup:

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

	subtilis_type_free(&element_type);
	free(var_name);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x350, %rsp            # imm = 0x350
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq $0x0, -0x328(%rbp)
movb $0x0, -0x329(%rbp)
movq $0x0, -0x338(%rbp)
movl $0x0, -0x33c(%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 0x35ce4
jmp 0x36074
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rcx
leaq -0x170(%rbp), %rdx
callq 0x36080
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x35d0a
jmp 0x36074
movq -0x10(%rbp), %rdi
callq 0x12d70
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x120d0
movq %rax, %rdi
addq $0x1, %rdi
callq 0x121b0
movq %rax, -0x328(%rbp)
cmpq $0x0, -0x328(%rbp)
jne 0x35d5c
movq -0x20(%rbp), %rdi
movl $0x1, %esi
leaq 0x74de9(%rip), %rdx     # 0xaab36
movl $0x51, %ecx
callq 0x158e0
jmp 0x36019
movq -0x328(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x12060
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x320(%rbp), %rdx
movq -0x20(%rbp), %r9
movl $0xa, %ecx
leaq -0x329(%rbp), %r8
callq 0x18a90
movq %rax, -0x338(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x16, (%rax)
jne 0x35dea
movq -0x20(%rbp), %rdi
movq -0x328(%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 0x754a9(%rip), %rcx     # 0xab276
leaq 0x74d62(%rip), %rax     # 0xaab36
movq %rax, (%rsp)
movl $0x5a, 0x8(%rsp)
callq 0x156d0
jmp 0x36019
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x35df8
jmp 0x36019
testb $0x1, -0x329(%rbp)
jne 0x35e40
cmpq $0x0, -0x338(%rbp)
jne 0x35e40
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %ecx
movl $0x43, %esi
leaq 0x74d06(%rip), %r8      # 0xaab36
movl $0x63, %r9d
callq 0x15930
jmp 0x36019
movq $0x0, -0x178(%rbp)
movq -0x178(%rbp), %rax
cmpq -0x338(%rbp), %rax
jae 0x35eba
movq -0x178(%rbp), %rax
movq -0x320(%rbp,%rax,8), %rax
cmpl $0x1, (%rax)
jne 0x35e71
jmp 0x35ea6
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %ecx
movl $0x43, %esi
leaq 0x74ca0(%rip), %r8      # 0xaab36
movl $0x6c, %r9d
callq 0x15930
jmp 0x36019
movq -0x178(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x178(%rbp)
jmp 0x35e4b
testb $0x1, -0x329(%rbp)
je 0x35f14
movq -0x20(%rbp), %rdx
leaq -0x170(%rbp), %rdi
leaq -0x2c0(%rbp), %rsi
callq 0x5c1d0
cmpq $0x0, -0x338(%rbp)
jbe 0x35ef9
movq -0x320(%rbp), %rax
movl 0x148(%rax), %eax
movl %eax, -0x340(%rbp)
jmp 0x35f06
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x340(%rbp)
jmp 0x35f06
movl -0x340(%rbp), %eax
movl %eax, -0x33c(%rbp)
jmp 0x35f48
movq -0x8(%rbp), %rdi
movq -0x328(%rbp), %rsi
leaq -0x320(%rbp), %r8
movq -0x338(%rbp), %r9
movq -0x20(%rbp), %rax
leaq -0x170(%rbp), %rdx
leaq -0x2c0(%rbp), %rcx
movq %rax, (%rsp)
callq 0x5c080
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x35f56
jmp 0x36019
movq -0x20(%rbp), %rsi
leaq -0x2c0(%rbp), %rdi
callq 0x47420
movq %rax, -0x2c8(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x35f87
leaq -0x2c0(%rbp), %rdi
callq 0x3e100
jmp 0x36019
movq -0x20(%rbp), %rsi
leaq -0x2c0(%rbp), %rdi
callq 0x47490
movq %rax, -0x2d0(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x35fb5
leaq -0x2c0(%rbp), %rdi
callq 0x3e100
jmp 0x36019
movq -0x18(%rbp), %rdi
movq -0x328(%rbp), %rsi
movq -0x2d0(%rbp), %rax
movl %eax, %ecx
movq -0x2c8(%rbp), %rax
movl %eax, %r8d
movl -0x33c(%rbp), %r9d
movq -0x20(%rbp), %rax
leaq -0x2c0(%rbp), %rdx
movq %rax, (%rsp)
callq 0x3ed00
leaq -0x2c0(%rbp), %rdi
callq 0x3e100
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x36017
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x133f0
jmp 0x36019
movq $0x0, -0x178(%rbp)
movq -0x178(%rbp), %rax
cmpq -0x338(%rbp), %rax
jae 0x3605c
movq -0x178(%rbp), %rax
movq -0x320(%rbp,%rax,8), %rdi
callq 0x36ee0
movq -0x178(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x178(%rbp)
jmp 0x36024
leaq -0x170(%rbp), %rdi
callq 0x3e100
movq -0x328(%rbp), %rdi
callq 0x12290
addq $0x350, %rsp            # imm = 0x350
popq %rbp
retq
nopl (%rax)