// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/frontend/parser_compound.c
// Function: subtilis_parser_local
void subtilis_parser_local(subtilis_parser_t *p, subtilis_token_t *t,
			   subtilis_error_t *err)
{
	const char *tbuf;
	subtilis_type_t type;
	bool value_present;
	const subtilis_symbol_t *s;
	subtilis_exp_t *e = NULL;
	char *var_name = NULL;

	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_KEYWORD) &&
	    (t->tok.keyword.type == SUBTILIS_KEYWORD_DIM)) {
		subtilis_parser_create_array(p, t, true, err);
		return;
	} else if (t->type != SUBTILIS_TOKEN_IDENTIFIER) {
		subtilis_error_set_id_expected(err, tbuf, p->l->stream->name,
					       p->l->line);
		return;
	}

	if ((p->current == p->main) && (p->level == 0)) {
		s = subtilis_symbol_table_lookup(p->st, tbuf);
		if (s) {
			subtilis_error_set_local_obscures_global(
			    err, tbuf, p->l->stream->name, p->l->line);
			return;
		}
	}

	if (subtilis_symbol_table_lookup(p->local_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(&type, &t->tok.id_type, err);
	if (err->type != SUBTILIS_ERROR_OK) {
		free(var_name);
		return;
	}

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

	tbuf = subtilis_token_get_text(t);
	if ((t->type == SUBTILIS_TOKEN_OPERATOR) && !strcmp(tbuf, "(")) {
		prv_local_array_ref(p, t, var_name, &type, err);
		subtilis_type_free(&type);
		free(var_name);
		return;
	}

	if ((t->type == SUBTILIS_TOKEN_OPERATOR) && !strcmp(tbuf, "{")) {
		prv_local_vector_ref(p, t, var_name, &type, err);
		subtilis_type_free(&type);
		free(var_name);
		return;
	}

	value_present =
	    (t->type == SUBTILIS_TOKEN_OPERATOR) && !strcmp(tbuf, "=");
	if (subtilis_type_if_is_numeric(&type)) {
		if (!value_present) {
			e = subtilis_type_if_zero(p, &type, err);
			if (err->type != SUBTILIS_ERROR_OK)
				goto cleanup;
		} else {
			e = subtilis_parser_assign_local_num(p, t, var_name,
							     &type, err);
			if (err->type != SUBTILIS_ERROR_OK)
				goto cleanup;
		}
		(void)subtilis_symbol_table_insert_reg(
		    p->local_st, var_name, &type, e->exp.ir_op.reg, err);
	} else if (type.type == SUBTILIS_TYPE_FN) {
		if (!value_present)
			subtilis_parser_zero_local_fn(p, t, var_name, &type,
						      err);
		else
			subtilis_parser_assign_local_fn(p, t, var_name, &type,
							err);
	} else if (subtilis_type_if_is_reference(&type)) {
		s = subtilis_symbol_table_insert(p->local_st, var_name, &type,
						 err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;

		if (!value_present) {
			subtilis_type_if_zero_ref(
			    p, &type, SUBTILIS_IR_REG_LOCAL, s->loc, true, err);
		} else {
			e = subtilis_parser_expression(p, t, err);
			if (err->type != SUBTILIS_ERROR_OK)
				goto cleanup;
			subtilis_type_if_new_ref(
			    p, &type, SUBTILIS_IR_REG_LOCAL, s->loc, e, err);
			e = NULL;
		}
	} else if (type.type == SUBTILIS_TYPE_REC) {
		subtilis_complete_custom_type(p, var_name, &type, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;

		if (value_present) {
			subtilis_parser_rec_init(p, t, &type, var_name, true,
						 true, err);
		} else {
			s = subtilis_symbol_table_insert(p->local_st, var_name,
							 &type, err);
			if (err->type != SUBTILIS_ERROR_OK)
				goto cleanup;

			subtilis_rec_type_zero(p, &type, SUBTILIS_IR_REG_LOCAL,
					       s->loc, true, err);
		}
	} else {
		subtilis_error_set_assertion_failed(err);
	}

cleanup:

	subtilis_type_free(&type);
	subtilis_exp_delete(e);
	free(var_name);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
movq (%rdi), %rdi
callq 0x12edc
cmpl $0x0, (%r14)
je 0x1db48
addq $0x148, %rsp            # imm = 0x148
jmp 0x1dc14
movq %r12, %rdi
callq 0x12ad0
movq %rax, %r13
movl (%r12), %eax
cmpl $0x6, %eax
je 0x1dbb8
cmpl $0x1, %eax
jne 0x1db8d
cmpl $0x1f, 0x8(%r12)
jne 0x1db8d
movq %r15, %rdi
movq %r12, %rsi
movl $0x1, %edx
movq %r14, %rcx
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x16fd4
movq (%r15), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x55ae0(%rip), %rax     # 0x7367f
leaq 0x5626f(%rip), %rcx     # 0x73e15
movq %r14, %rdi
movl $0x12, %esi
movq %r13, %rdx
pushq $0x8f
jmp 0x1dc07
movq 0x48(%r15), %rax
cmpq 0x50(%r15), %rax
jne 0x1dbcd
cmpq $0x0, 0x78(%r15)
je 0x1dc95
movq 0x68(%r15), %rdi
movq %r13, %rsi
callq 0x2ebbc
testq %rax, %rax
je 0x1dc1f
movq (%r15), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x55a8f(%rip), %rax     # 0x7367f
leaq 0x5621e(%rip), %rcx     # 0x73e15
movq %r14, %rdi
movl $0x20, %esi
movq %r13, %rdx
pushq $0x9e
pushq %rax
callq 0x143da
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rdi
callq 0x120f0
leaq 0x1(%rax), %rdi
callq 0x121d0
testq %rax, %rax
je 0x1dcd8
movq %rax, %rbx
movq %rax, %rdi
movq %r13, %rsi
callq 0x12070
leaq 0x8(%r12), %rsi
movq %rsp, %rdi
movq %r14, %rdx
callq 0x2f457
cmpl $0x0, (%r14)
jne 0x1dc88
movq (%r15), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x12edc
cmpl $0x0, (%r14)
je 0x1dd02
xorl %r12d, %r12d
movq %rsp, %rdi
callq 0x2f56e
movq %r12, %rdi
callq 0x2b166
movq %rbx, %rdi
callq 0x122c0
jmp 0x1db3c
movq 0x60(%r15), %rdi
movq %r13, %rsi
callq 0x2ebbc
testq %rax, %rax
je 0x1dbcd
movq (%r15), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x559c3(%rip), %rax     # 0x7367f
leaq 0x56152(%rip), %rcx     # 0x73e15
movq %r14, %rdi
movl $0x52, %esi
movq %r13, %rdx
pushq $0x97
jmp 0x1dc07
leaq 0x559a0(%rip), %rdx     # 0x7367f
movq %r14, %rdi
movl $0x1, %esi
movl $0xa4, %ecx
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x145a4
movq %r12, %rdi
callq 0x12ad0
cmpl $0x2, (%r12)
jne 0x1dd45
movzbl (%rax), %ecx
cmpl $0x7b, %ecx
je 0x1dd6c
cmpl $0x3d, %ecx
je 0x1dd62
cmpl $0x28, %ecx
jne 0x1dd76
cmpb $0x0, 0x1(%rax)
jne 0x1dd76
movq %rsp, %r13
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %r13, %rcx
movq %r14, %r8
callq 0x1df81
jmp 0x1df15
movq %rsp, %rdi
callq 0x37534
testb %al, %al
jne 0x1dd9f
cmpl $0x9, (%rsp)
je 0x1de6f
xorl %ebp, %ebp
jmp 0x1de01
cmpb $0x0, 0x1(%rax)
sete %bpl
jmp 0x1dd78
cmpb $0x0, 0x1(%rax)
je 0x1defe
xorl %ebp, %ebp
movq %rsp, %rdi
callq 0x37534
testb %al, %al
je 0x1ddd9
testb %bpl, %bpl
je 0x1dd9f
movq %rsp, %rcx
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %r14, %r8
callq 0x17f3b
jmp 0x1ddad
movq %rsp, %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0x35e20
movq %rax, %r12
cmpl $0x0, (%r14)
jne 0x1dc78
movq 0x68(%r15), %rdi
movq 0x148(%r12), %rcx
movq %rsp, %rdx
movq %rbx, %rsi
movq %r14, %r8
callq 0x2e922
jmp 0x1dc78
cmpl $0x9, (%rsp)
jne 0x1de01
testb %bpl, %bpl
je 0x1de6f
movq %rsp, %rcx
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %r14, %r8
callq 0x18097
jmp 0x1dc75
movq %rsp, %rdi
callq 0x376f1
testb %al, %al
je 0x1de88
movq 0x68(%r15), %rdi
movq %rsp, %rdx
movq %rbx, %rsi
movq %r14, %rcx
callq 0x2e3cd
cmpl $0x0, (%r14)
jne 0x1dc75
movq %rax, %r13
testb %bpl, %bpl
je 0x1df22
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x1ec4c
movq %rax, %r12
cmpl $0x0, (%r14)
jne 0x1dc78
movq (%r13), %rcx
movq %rsp, %rsi
movl $0x2, %edx
movq %r15, %rdi
movq %r12, %r8
movq %r14, %r9
callq 0x35ebf
jmp 0x1dc75
movq %rsp, %rcx
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %r14, %r8
callq 0x18003
jmp 0x1dc75
cmpl $0x16, (%rsp)
jne 0x1dee0
movq %rsp, %rdx
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rcx
callq 0x1f81b
cmpl $0x0, (%r14)
jne 0x1dc75
testb %bpl, %bpl
je 0x1df44
subq $0x8, %rsp
leaq 0x8(%rsp), %rdx
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rcx
movl $0x1, %r8d
movl $0x1, %r9d
pushq %r14
callq 0x29bff
addq $0x10, %rsp
jmp 0x1dc75
leaq 0x55798(%rip), %rdx     # 0x7367f
movq %r14, %rdi
movl $0xf, %esi
movl $0xfa, %ecx
callq 0x145a4
jmp 0x1dc75
movq %rsp, %r13
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %r13, %rcx
movq %r14, %r8
callq 0x1e0ca
movq %r13, %rdi
callq 0x2f56e
jmp 0x1dc88
movq (%r13), %rcx
movq %rsp, %rsi
movl $0x2, %edx
movq %r15, %rdi
movl $0x1, %r8d
movq %r14, %r9
callq 0x35e59
jmp 0x1dc75
movq 0x68(%r15), %rdi
movq %rsp, %rdx
movq %rbx, %rsi
movq %r14, %rcx
callq 0x2e3cd
cmpl $0x0, (%r14)
jne 0x1dc75
movq (%rax), %rcx
movq %rsp, %rsi
movl $0x2, %edx
movq %r15, %rdi
movl $0x1, %r8d
movq %r14, %r9
callq 0x45c2d
jmp 0x1dc75