// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/parser_call.c
// Function: prv_def_internal
static void prv_def_internal(subtilis_parser_t *p, subtilis_token_t *t,
			     subtilis_type_t *fn_type, subtilis_type_t *type,
			     char *name, subtilis_symbol_table_t *local_st,
			     size_t *call_index, subtilis_error_t *err)
{
	const char *tbuf;
	subtilis_type_section_t *stype;
	subtilis_exp_t *e;
	size_t blocks;
	subtilis_ir_operand_t zero_op;
	size_t num_params = 0;
	subtilis_type_t *params = NULL;
	const subtilis_symbol_t **symbols = NULL;

	tbuf = subtilis_token_get_text(t);
	if ((t->type == SUBTILIS_TOKEN_OPERATOR) && !strcmp(tbuf, "(")) {
		params = prv_def_parameters(p, t, &num_params, &symbols,
					    fn_type, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;
	}

	name = prv_complete_fn_name(name, fn_type, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;

	stype =
	    subtilis_type_section_new(fn_type, num_params, params, NULL, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;
	prv_delete_ptypes(params, num_params);
	params = NULL;
	subtilis_type_copy(type, &stype->type, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;

	if ((t->type == SUBTILIS_TOKEN_OPERATOR) && !strcmp(tbuf, "[")) {
		prv_parser_assembly(p, t, name, stype, call_index, err);
		goto on_error;
	}

	p->current = subtilis_ir_prog_section_new(
	    p->prog, name, 0, stype, SUBTILIS_BUILTINS_MAX, p->l->stream->name,
	    p->l->line, p->eflag_offset, p->error_offset, call_index, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;

	subtilis_parser_handle_escape(p, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;

	blocks = prv_init_block_variables(p, stype, local_st, symbols, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;
	if (blocks > 0) {
		zero_op.integer = blocks;
		p->current->cleanup_stack = subtilis_ir_section_add_instr2(
		    p->current, SUBTILIS_OP_INSTR_MOVI_I32, zero_op, err);
	} else {
		p->current->cleanup_stack_nop =
		    subtilis_ir_section_add_nop(p->current, err);
	}
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;

	if (fn_type->type != SUBTILIS_TYPE_VOID) {
		prv_fn_compound(p, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;

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

		/* Ownership of e is passed to add_fn_ret */

		if (p->current->endproc) {
			subtilis_exp_delete(e);
		} else {
			prv_set_fn_retval(p, e, fn_type, err);
			if (err->type != SUBTILIS_ERROR_OK)
				goto on_error;
		}
		subtilis_ir_section_add_label(p->current, p->current->end_label,
					      err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;

		subtilis_parser_unwind(p, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;

		subtilis_type_if_ret(p, fn_type, p->current->ret_reg, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;
	} else {
		prv_proc_compound(p, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;

		subtilis_ir_section_add_label(p->current, p->current->end_label,
					      err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;

		subtilis_parser_unwind(p, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;

		subtilis_ir_section_add_instr_no_arg(
		    p->current, SUBTILIS_OP_INSTR_RET, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;

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

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

	subtilis_ir_merge_errors(p->current, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;

	subtilis_array_gen_index_error_code(p, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;

	p->current->locals = p->local_st->max_allocated;

on_error:

	free(symbols);
	prv_delete_ptypes(params, num_params);
	free(name);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0xa0, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movq %r9, -0x40(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
movq -0x20(%rbp), %rdi
callq 0x12d70
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x1f5b2
movq -0x48(%rbp), %rdi
leaq 0x8bd25(%rip), %rsi     # 0xab29c
callq 0x12140
cmpl $0x0, %eax
jne 0x1f5b2
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %r8
movq 0x18(%rbp), %r9
leaq -0x70(%rbp), %rdx
leaq -0x80(%rbp), %rcx
callq 0x21bb0
movq %rax, -0x78(%rbp)
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f5b0
jmp 0x1f9ac
jmp 0x1f5b2
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq 0x18(%rbp), %rdx
callq 0x1f0f0
movq %rax, -0x38(%rbp)
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f5d5
jmp 0x1f9ac
movq -0x28(%rbp), %rdi
movq -0x70(%rbp), %rsi
movq -0x78(%rbp), %rdx
movq 0x18(%rbp), %r8
xorl %eax, %eax
movl %eax, %ecx
callq 0x3dc00
movq %rax, -0x50(%rbp)
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f600
jmp 0x1f9ac
movq -0x78(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x1f210
movq $0x0, -0x78(%rbp)
movq -0x30(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq 0x18(%rbp), %rdx
callq 0x3e4f0
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f634
jmp 0x1f9ac
movq -0x20(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x1f674
movq -0x48(%rbp), %rdi
leaq 0x8b010(%rip), %rsi     # 0xaa658
callq 0x12140
cmpl $0x0, %eax
jne 0x1f674
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x50(%rbp), %rcx
movq 0x10(%rbp), %r8
movq 0x18(%rbp), %r9
callq 0x22080
jmp 0x1f9ac
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x38(%rbp), %rsi
movq -0x50(%rbp), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r9
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %eax
movl %eax, %r14d
movq -0x18(%rbp), %rax
movl 0xb0(%rax), %ebx
movq -0x18(%rbp), %rax
movl 0xb4(%rax), %r11d
movq 0x10(%rbp), %r10
movq 0x18(%rbp), %rax
xorl %edx, %edx
movl $0x9, %r8d
movq %r14, (%rsp)
movl %ebx, 0x8(%rsp)
movl %r11d, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x38bd0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x48(%rax)
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f6f6
jmp 0x1f9ac
movq -0x18(%rbp), %rdi
movq 0x18(%rbp), %rsi
callq 0x2d400
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f711
jmp 0x1f9ac
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x80(%rbp), %rcx
movq 0x18(%rbp), %r8
callq 0x22210
movq %rax, -0x60(%rbp)
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f73c
jmp 0x1f9ac
cmpq $0x0, -0x60(%rbp)
jbe 0x1f778
movq -0x60(%rbp), %rax
movl %eax, -0x68(%rbp)
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x18(%rbp), %rcx
movq -0x68(%rbp), %rdx
movl $0x1b, %esi
callq 0x38490
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq %rcx, 0xb8(%rax)
jmp 0x1f79b
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x18(%rbp), %rsi
callq 0x38800
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq %rcx, 0xc0(%rax)
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f7a9
jmp 0x1f9ac
movq -0x28(%rbp), %rax
cmpl $0x8, (%rax)
je 0x1f8b5
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq 0x18(%rbp), %rdx
callq 0x22450
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f7d5
jmp 0x1f9ac
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq 0x18(%rbp), %rdx
callq 0x24a20
movq %rax, -0x58(%rbp)
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f7f8
jmp 0x1f9ac
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
testb $0x1, 0x88(%rax)
je 0x1f814
movq -0x58(%rbp), %rdi
callq 0x36ee0
jmp 0x1f839
movq -0x18(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq 0x18(%rbp), %rcx
callq 0x20c90
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f837
jmp 0x1f9ac
jmp 0x1f839
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x98(%rax), %rsi
movq 0x18(%rbp), %rdx
callq 0x39960
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f867
jmp 0x1f9ac
movq -0x18(%rbp), %rdi
movq 0x18(%rbp), %rsi
callq 0x209e0
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f882
jmp 0x1f9ac
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq 0xa8(%rax), %rdx
movq 0x18(%rbp), %rcx
callq 0x49e90
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f8b0
jmp 0x1f9ac
jmp 0x1f952
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq 0x18(%rbp), %rdx
callq 0x22530
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f8d4
jmp 0x1f9ac
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x98(%rax), %rsi
movq 0x18(%rbp), %rdx
callq 0x39960
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f902
jmp 0x1f9ac
movq -0x18(%rbp), %rdi
movq 0x18(%rbp), %rsi
callq 0x209e0
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f91d
jmp 0x1f9ac
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x18(%rbp), %rdx
movl $0x46, %esi
callq 0x385f0
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f93e
jmp 0x1f9ac
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rsi
movq 0x18(%rbp), %rdx
callq 0x133f0
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f95d
jmp 0x1f9ac
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x18(%rbp), %rsi
callq 0x380c0
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f979
jmp 0x1f9ac
movq -0x18(%rbp), %rdi
movq 0x18(%rbp), %rsi
callq 0x5ed10
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1f991
jmp 0x1f9ac
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movq 0x310(%rax), %rcx
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq %rcx, 0x10(%rax)
movq -0x80(%rbp), %rdi
callq 0x12290
movq -0x78(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x1f210
movq -0x38(%rbp), %rdi
callq 0x12290
addq $0xa0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nopw (%rax,%rax)