// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/parser_exp.c
// Function: subtilis_var_lookup_ref
subtilis_exp_t *subtilis_var_lookup_ref(subtilis_parser_t *p,
					subtilis_token_t *t, bool *local,
					subtilis_error_t *err)
{
	const char *tbuf;
	size_t reg;
	const subtilis_symbol_t *s;
	subtilis_exp_t *e;
	subtilis_ir_operand_t op0;
	subtilis_ir_operand_t op1;

	tbuf = subtilis_token_get_text(t);

	reg = SUBTILIS_IR_REG_LOCAL;
	s = subtilis_symbol_table_lookup(p->local_st, tbuf);
	if (!s) {
		s = subtilis_symbol_table_lookup(p->st, tbuf);
		if (!s) {
			subtilis_error_set_unknown_variable(
			    err, tbuf, p->l->stream->name, p->l->line);
			return NULL;
		}
		reg = SUBTILIS_IR_REG_GLOBAL;
	}

	if (s->t.type == SUBTILIS_TYPE_INTEGER) {
		if (!s->is_reg) {
			*local = false;
			if (s->loc != 0) {
				op0.reg = reg;
				op1.integer = s->loc;
				reg = subtilis_ir_section_add_instr(
				    p->current, SUBTILIS_OP_INSTR_ADDI_I32, op0,
				    op1, err);
				if (err->type != SUBTILIS_ERROR_OK)
					return NULL;
			}
			e = subtilis_exp_new_var(&s->t, reg, err);
		} else {
			*local = true;
			e = subtilis_exp_new_var(&s->t, s->loc, err);
		}

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

		return e;
	} else if ((s->t.type == SUBTILIS_TYPE_ARRAY_INTEGER) ||
		   (s->t.type == SUBTILIS_TYPE_ARRAY_BYTE)) {
		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_exp_expected(
			    err, "(", p->l->stream->name, p->l->line);

			return NULL;
		}

		*local = false;
		return subtils_parser_element_address(p, t, s, reg, tbuf, err);
	}

	subtilis_error_set_integer_variable_expected(
	    err, subtilis_type_name(&s->t), p->l->stream->name, p->l->line);
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x18(%rbp), %rdi
callq 0x12d70
movq %rax, -0x30(%rbp)
movq $0x2, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x3cff0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x25bfc
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x3cff0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x25bf4
movq -0x28(%rbp), %rdi
movq -0x30(%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 $0x1b, %esi
leaq 0x856a7(%rip), %rcx     # 0xab276
leaq 0x84d16(%rip), %rax     # 0xaa8ec
movq %rax, (%rsp)
movl $0x569, 0x8(%rsp)       # imm = 0x569
callq 0x156d0
movq $0x0, -0x8(%rbp)
jmp 0x25e3f
movq $0x1, -0x38(%rbp)
movq -0x40(%rbp), %rax
cmpl $0x5, 0x8(%rax)
jne 0x25cf6
movq -0x40(%rbp), %rax
testb $0x1, 0x2a8(%rax)
jne 0x25c91
movq -0x20(%rbp), %rax
movb $0x0, (%rax)
movq -0x40(%rbp), %rax
cmpq $0x0, (%rax)
je 0x25c74
movq -0x38(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq (%rax), %rax
movl %eax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r8
movq -0x50(%rbp), %rdx
movq -0x58(%rbp), %rcx
movl $0x9, %esi
callq 0x38230
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x25c72
movq $0x0, -0x8(%rbp)
jmp 0x25e3f
jmp 0x25c74
movq -0x40(%rbp), %rdi
addq $0x8, %rdi
movq -0x38(%rbp), %rax
movl %eax, %esi
movq -0x28(%rbp), %rdx
callq 0x37590
movq %rax, -0x48(%rbp)
jmp 0x25cb6
movq -0x20(%rbp), %rax
movb $0x1, (%rax)
movq -0x40(%rbp), %rdi
addq $0x8, %rdi
movq -0x40(%rbp), %rax
movq (%rax), %rax
movl %eax, %esi
movq -0x28(%rbp), %rdx
callq 0x37590
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x133f0
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x25ce9
movq -0x48(%rbp), %rdi
callq 0x36ee0
movq $0x0, -0x8(%rbp)
jmp 0x25e3f
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x25e3f
movq -0x40(%rbp), %rax
cmpl $0xb, 0x8(%rax)
je 0x25d0e
movq -0x40(%rbp), %rax
cmpl $0xc, 0x8(%rax)
jne 0x25ddf
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x133f0
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x25d38
movq $0x0, -0x8(%rbp)
jmp 0x25e3f
movq -0x18(%rbp), %rdi
callq 0x12d70
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x25d63
movq -0x30(%rbp), %rdi
leaq 0x85543(%rip), %rsi     # 0xab29c
callq 0x12140
cmpl $0x0, %eax
je 0x25db5
movq -0x28(%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 $0x15, %esi
leaq 0x85513(%rip), %rdx     # 0xab29c
leaq 0x854e6(%rip), %rcx     # 0xab276
leaq 0x84b55(%rip), %rax     # 0xaa8ec
movq %rax, (%rsp)
movl $0x591, 0x8(%rsp)       # imm = 0x591
callq 0x156d0
movq $0x0, -0x8(%rbp)
jmp 0x25e3f
movq -0x20(%rbp), %rax
movb $0x0, (%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %r8
movq -0x28(%rbp), %r9
callq 0x18910
movq %rax, -0x8(%rbp)
jmp 0x25e3f
jmp 0x25de1
movq -0x28(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x40(%rbp), %rdi
addq $0x8, %rdi
callq 0x3e190
movq -0x60(%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 $0x4f, %esi
leaq 0x85457(%rip), %rcx     # 0xab276
leaq 0x84ac6(%rip), %rax     # 0xaa8ec
movq %rax, (%rsp)
movl $0x59b, 0x8(%rsp)       # imm = 0x59B
callq 0x156d0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)