// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/parser_loops.c
// Function: prv_get_range_vars
static subtilis_range_var_t *
prv_get_range_vars(subtilis_parser_t *p, subtilis_token_t *t, size_t *count,
		   subtilis_exp_t **col, bool *locals, subtilis_error_t *err)
{
	const char *tbuf;
	size_t i;
	subtilis_type_t el_type;
	subtilis_buffer_t buf;
	subtilis_error_t err2;
	const char *error_type_name;
	subtilis_exp_t *e = NULL;
	size_t var_count = 0;
	subtilis_range_var_t *range_vars = NULL;
	bool new_locals = false;

	el_type.type = SUBTILIS_TYPE_VOID;

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

	if (t->type == SUBTILIS_TOKEN_KEYWORD) {
		tbuf = subtilis_token_get_text(t);
		if (t->tok.keyword.type != SUBTILIS_KEYWORD_LOCAL) {
			subtilis_error_set_expected(
			    err, "LOCAL", tbuf, p->l->stream->name, p->l->line);
			return NULL;
		}

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

		new_locals = true;
	}

	range_vars = prv_get_varnames(p, t, &var_count, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;

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

	if (!strcmp(tbuf, ":=")) {
		if (new_locals) {
			subtilis_error_set_expected(
			    err, "=", tbuf, p->l->stream->name, p->l->line);
			goto cleanup;
		}
		new_locals = true;
	} else if (strcmp(tbuf, "=")) {
		subtilis_error_set_expected(err, (new_locals) ? "=" : "= or :=",
					    tbuf, p->l->stream->name,
					    p->l->line);
		goto cleanup;
	}

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

	if (!subtilis_type_if_is_array(&e->type) &&
	    !subtilis_type_if_is_vector(&e->type)) {
		subtilis_error_not_array_or_vector(
		    err, subtilis_type_name(&e->type), p->l->stream->name,
		    p->l->line);
		goto cleanup;
	}

	subtilis_type_if_element_type(p, &e->type, &el_type, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	if (range_vars[0].name) {
		if (!subtilis_type_eq(&el_type, &range_vars[0].type)) {
			subtilis_error_init(&err2);
			subtilis_buffer_init(&buf, 64);
			subtilis_full_type_name(&e->type, &buf, &err2);
			if (err2.type == SUBTILIS_ERROR_OK)
				subtilis_buffer_zero_terminate(&buf, &err2);
			error_type_name =
			    (err2.type != SUBTILIS_ERROR_OK)
				? subtilis_type_name(&e->type)
				: subtilis_buffer_get_string(&buf);
			subtilis_error_set_range_type_mismatch(
			    err, range_vars[0].name, error_type_name,
			    p->l->stream->name, p->l->line);
			subtilis_buffer_free(&buf);
			subtilis_type_free(&el_type);
			goto cleanup;
		}
	} else {
		/*
		 * If we're ignoring the range variable we can simply
		 * copy it's type from that of the collection.
		 */

		subtilis_type_copy(&range_vars[0].type, &el_type, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
	}
	subtilis_type_free(&el_type);

	if ((var_count > 1) &&
	    (e->type.params.array.num_dims != var_count - 1)) {
		subtilis_error_set_range_bad_var_count(
		    err, e->type.params.array.num_dims + 1, var_count,
		    p->l->stream->name, p->l->line);
		goto cleanup;
	}

	*col = e;
	*count = var_count;
	*locals = new_locals;
	return range_vars;

cleanup:

	subtilis_exp_delete(e);
	for (i = 0; i < var_count; i++) {
		subtilis_type_free(&range_vars[i].type);
		subtilis_type_free(&range_vars[i].for_ctx.type);
		free(range_vars[i].name);
	}
	free(range_vars);

	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe00, %rsp            # imm = 0xE00
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, -0xdc0(%rbp)
movq $0x0, -0xdc8(%rbp)
movq $0x0, -0xdd0(%rbp)
movb $0x0, -0xdd1(%rbp)
movl $0x8, -0x190(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x133f0
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2a34f
movq $0x0, -0x8(%rbp)
jmp 0x2a8f1
movq -0x18(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x2a3f3
movq -0x18(%rbp), %rdi
callq 0x12d70
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x4a, 0x8(%rax)
je 0x2a3c2
movq -0x38(%rbp), %rdi
movq -0x40(%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 0x7fd11(%rip), %rdx     # 0xaa0ae
leaq 0x80606(%rip), %rax     # 0xaa9aa
movq %rax, (%rsp)
movl $0x496, 0x8(%rsp)       # imm = 0x496
callq 0x156d0
movq $0x0, -0x8(%rbp)
jmp 0x2a8f1
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x133f0
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2a3ec
movq $0x0, -0x8(%rbp)
jmp 0x2a8f1
movb $0x1, -0xdd1(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rcx
leaq -0xdc8(%rbp), %rdx
callq 0x2b830
movq %rax, -0xdd0(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2a428
movq $0x0, -0x8(%rbp)
jmp 0x2a8f1
movq -0x18(%rbp), %rdi
callq 0x12d70
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x2, (%rax)
je 0x2a499
movq -0x38(%rbp), %rdi
movb -0xdd1(%rbp), %cl
leaq 0x80573(%rip), %rdx     # 0xaa9c2
leaq 0x801be(%rip), %rax     # 0xaa614
testb $0x1, %cl
cmovneq %rax, %rdx
movq -0x40(%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 0x80527(%rip), %rax     # 0xaa9aa
movq %rax, (%rsp)
movl $0x4a9, 0x8(%rsp)       # imm = 0x4A9
callq 0x156d0
jmp 0x2a857
movq -0x40(%rbp), %rdi
leaq 0x80523(%rip), %rsi     # 0xaa9c7
callq 0x12140
cmpl $0x0, %eax
jne 0x2a507
testb $0x1, -0xdd1(%rbp)
je 0x2a4fe
movq -0x38(%rbp), %rdi
movq -0x40(%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 0x80133(%rip), %rdx     # 0xaa614
leaq 0x804c2(%rip), %rax     # 0xaa9aa
movq %rax, (%rsp)
movl $0x4b0, 0x8(%rsp)       # imm = 0x4B0
callq 0x156d0
jmp 0x2a857
movb $0x1, -0xdd1(%rbp)
jmp 0x2a579
movq -0x40(%rbp), %rdi
leaq 0x80102(%rip), %rsi     # 0xaa614
callq 0x12140
cmpl $0x0, %eax
je 0x2a577
movq -0x38(%rbp), %rdi
movb -0xdd1(%rbp), %cl
leaq 0x80495(%rip), %rdx     # 0xaa9c2
leaq 0x800e0(%rip), %rax     # 0xaa614
testb $0x1, %cl
cmovneq %rax, %rdx
movq -0x40(%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 0x80449(%rip), %rax     # 0xaa9aa
movq %rax, (%rsp)
movl $0x4b7, 0x8(%rsp)       # imm = 0x4B7
callq 0x156d0
jmp 0x2a857
jmp 0x2a579
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x24a20
movq %rax, -0xdc0(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2a59f
jmp 0x2a857
movq -0xdc0(%rbp), %rdi
callq 0x49ff0
testb $0x1, %al
jne 0x2a61f
movq -0xdc0(%rbp), %rdi
callq 0x4a040
testb $0x1, %al
jne 0x2a61f
movq -0x38(%rbp), %rax
movq %rax, -0xde0(%rbp)
movq -0xdc0(%rbp), %rdi
callq 0x3e190
movq -0xde0(%rbp), %rdi
movq %rax, %rdx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x3d, %esi
leaq 0x80c74(%rip), %rcx     # 0xab276
leaq 0x803a1(%rip), %rax     # 0xaa9aa
movq %rax, (%rsp)
movl $0x4c3, 0x8(%rsp)       # imm = 0x4C3
callq 0x156d0
jmp 0x2a857
movq -0x10(%rbp), %rdi
movq -0xdc0(%rbp), %rsi
movq -0x38(%rbp), %rcx
leaq -0x190(%rbp), %rdx
callq 0x47b70
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2a648
jmp 0x2a857
movq -0xdd0(%rbp), %rax
cmpq $0x0, (%rax)
je 0x2a771
movq -0xdd0(%rbp), %rsi
addq $0x8, %rsi
leaq -0x190(%rbp), %rdi
callq 0x3d880
testb $0x1, %al
jne 0x2a76f
leaq -0xdac(%rbp), %rdi
callq 0x15670
leaq -0x1a0(%rbp), %rdi
movl $0x40, %esi
callq 0x15f80
movq -0xdc0(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
leaq -0xdac(%rbp), %rdx
callq 0x3e1f0
cmpl $0x0, -0xdac(%rbp)
jne 0x2a6cb
leaq -0x1a0(%rbp), %rdi
leaq -0xdac(%rbp), %rsi
callq 0x16560
cmpl $0x0, -0xdac(%rbp)
je 0x2a6e9
movq -0xdc0(%rbp), %rdi
callq 0x3e190
movq %rax, -0xde8(%rbp)
jmp 0x2a6fc
leaq -0x1a0(%rbp), %rdi
callq 0x16760
movq %rax, -0xde8(%rbp)
movq -0xde8(%rbp), %rax
movq %rax, -0xdb8(%rbp)
movq -0x38(%rbp), %rdi
movq -0xdd0(%rbp), %rax
movq (%rax), %rdx
movq -0xdb8(%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 $0x54, %esi
leaq 0x80269(%rip), %rax     # 0xaa9aa
movq %rax, (%rsp)
movl $0x4d8, 0x8(%rsp)       # imm = 0x4D8
callq 0x156d0
leaq -0x1a0(%rbp), %rdi
callq 0x16650
leaq -0x190(%rbp), %rdi
callq 0x3e100
jmp 0x2a857
jmp 0x2a79c
movq -0xdd0(%rbp), %rdi
addq $0x8, %rdi
movq -0x38(%rbp), %rdx
leaq -0x190(%rbp), %rsi
callq 0x3e4f0
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2a79a
jmp 0x2a857
jmp 0x2a79c
leaq -0x190(%rbp), %rdi
callq 0x3e100
cmpq $0x1, -0xdc8(%rbp)
jbe 0x2a81c
movq -0xdc0(%rbp), %rax
movslq 0x8(%rax), %rax
movq -0xdc8(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
je 0x2a81c
movq -0x38(%rbp), %rdi
movq -0xdc0(%rbp), %rax
movl 0x8(%rax), %edx
addl $0x1, %edx
movq -0xdc8(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x56, %esi
leaq 0x801a1(%rip), %rax     # 0xaa9aa
movq %rax, (%rsp)
movl $0x4ed, 0x8(%rsp)       # imm = 0x4ED
callq 0x157b0
jmp 0x2a857
movq -0xdc0(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0xdc8(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movb -0xdd1(%rbp), %cl
movq -0x30(%rbp), %rax
andb $0x1, %cl
movb %cl, (%rax)
movq -0xdd0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2a8f1
movq -0xdc0(%rbp), %rdi
callq 0x36ee0
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0xdc8(%rbp), %rax
jae 0x2a8dd
movq -0xdd0(%rbp), %rdi
imulq $0x2c8, -0x48(%rbp), %rax # imm = 0x2C8
addq %rax, %rdi
addq $0x8, %rdi
callq 0x3e100
movq -0xdd0(%rbp), %rdi
imulq $0x2c8, -0x48(%rbp), %rax # imm = 0x2C8
addq %rax, %rdi
addq $0x150, %rdi            # imm = 0x150
addq $0x18, %rdi
callq 0x3e100
movq -0xdd0(%rbp), %rax
imulq $0x2c8, -0x48(%rbp), %rcx # imm = 0x2C8
addq %rcx, %rax
movq (%rax), %rdi
callq 0x12290
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x2a86b
movq -0xdd0(%rbp), %rdi
callq 0x12290
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xe00, %rsp            # imm = 0xE00
popq %rbp
retq
nop