// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/parser_error.c
// Function: subtilis_parser_onerror
void subtilis_parser_onerror(subtilis_parser_t *p, subtilis_token_t *t,
			     subtilis_error_t *err)
{
	subtilis_ir_operand_t handler_label;
	subtilis_ir_operand_t target_label;
	unsigned int start;
	subtilis_ir_operand_t var_reg;

	if (p->current->in_error_handler) {
		subtilis_error_set_nested_handler(err, p->l->stream->name,
						  p->l->line);
		return;
	}

	if (p->current->try_depth > 0) {
		subtilis_error_set_handler_in_try(err, p->l->stream->name,
						  p->l->line);
		return;
	}

	p->current->in_error_handler = true;
	handler_label.label = subtilis_ir_section_new_label(p->current);
	subtilis_ir_section_add_label(p->current, handler_label.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	/*
	 * The error flag needs to be clear when we're inside an error
	 * handler.  Otherwise and procedures or functions call in that
	 * handler may appear to have failed when they return.
	 */

	subtilis_var_set_eflag(p, false, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	p->level++;
	start = p->l->line;
	while (t->type != SUBTILIS_TOKEN_EOF) {
		if ((t->type == SUBTILIS_TOKEN_KEYWORD) &&
		    (t->tok.keyword.type == SUBTILIS_KEYWORD_ENDERROR))
			break;
		subtilis_parser_statement(p, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
	}

	if (t->type == SUBTILIS_TOKEN_EOF)
		subtilis_error_set_compund_not_term(err, p->l->stream->name,
						    start);

	var_reg.reg = SUBTILIS_IR_REG_LOCAL;
	subtilis_reference_deallocate_refs(p, var_reg, p->local_st, p->level,
					   err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	if (!p->current->endproc) {
		if (!p->current->handler_list) {
			if (p->current != p->main) {
				subtilis_var_set_eflag(p, true, err);
				if (err->type != SUBTILIS_ERROR_OK)
					return;
			}
			subtilis_exp_return_default_value(p, err);
			if (err->type != SUBTILIS_ERROR_OK)
				return;
		} else {
			target_label.label = p->current->handler_list->label;
			subtilis_ir_section_add_instr_no_reg(
			    p->current, SUBTILIS_OP_INSTR_JMP, target_label,
			    err);
			if (err->type != SUBTILIS_ERROR_OK)
				goto cleanup;
		}
	}

	p->current->handler_list = subtilis_handler_list_update(
	    p->current->handler_list, p->level - 1, handler_label.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	p->level--;
	subtilis_symbol_table_level_down(p->local_st, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;
	p->current->endproc = false;

	subtilis_lexer_get(p->l, t, err);

cleanup:
	p->current->in_error_handler = false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
testb $0x1, 0x60(%rax)
je 0x2d4ba
movq -0x18(%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 $0x31, %esi
callq 0x158e0
jmp 0x2d7aa
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
cmpq $0x0, 0x68(%rax)
jbe 0x2d4f1
movq -0x18(%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 $0x32, %esi
callq 0x158e0
jmp 0x2d7aa
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movb $0x1, 0x60(%rax)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x39960
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2d531
jmp 0x2d79e
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x133f0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2d553
jmp 0x2d79e
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
xorl %esi, %esi
callq 0x473b0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2d570
jmp 0x2d79e
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rdx
callq 0x3c320
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2d596
jmp 0x2d79e
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x78(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2d5f2
movq -0x10(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x2d5d1
movq -0x10(%rbp), %rax
cmpl $0x26, 0x8(%rax)
jne 0x2d5d1
jmp 0x2d5f2
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x16bb0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2d5f0
jmp 0x2d79e
jmp 0x2d5b3
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x2d624
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %rdx
movl -0x2c(%rbp), %ecx
movl $0x1e, %esi
leaq 0x7d3c7(%rip), %r8      # 0xaa9e0
movl $0x7a, %r9d
callq 0x15930
movq $0x2, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rcx
movq -0x18(%rbp), %r8
movq -0x38(%rbp), %rsi
callq 0x6f4e0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2d65b
jmp 0x2d79e
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
testb $0x1, 0x88(%rax)
jne 0x2d710
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
cmpq $0x0, 0x78(%rax)
jne 0x2d6d0
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x8(%rbp), %rcx
cmpq 0x50(%rcx), %rax
je 0x2d6b3
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl $0x1, %esi
callq 0x473b0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2d6b1
jmp 0x2d7aa
jmp 0x2d6b3
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x36c20
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2d6ce
jmp 0x2d7aa
jmp 0x2d70e
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x78(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %rcx
movq -0x28(%rbp), %rdx
movl $0x45, %esi
callq 0x38540
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2d70c
jmp 0x2d79e
jmp 0x2d70e
jmp 0x2d710
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x78(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rsi
subq $0x1, %rsi
movq -0x20(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x37fd0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq %rcx, 0x78(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2d74f
jmp 0x2d79e
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x78(%rax)
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x3c390
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2d77b
jmp 0x2d79e
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movb $0x0, 0x88(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x133f0
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movb $0x0, 0x60(%rax)
addq $0x40, %rsp
popq %rbp
retq