// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/parser_call.c
// Function: prv_def_parameters
static subtilis_type_t *
prv_def_parameters(subtilis_parser_t *p, subtilis_token_t *t,
		   size_t *num_parameters, const subtilis_symbol_t ***symbols,
		   subtilis_type_t *fn_type, subtilis_error_t *err)
{
	const char *tbuf;
	subtilis_type_t *new_params;
	size_t new_max;
	subtilis_type_t ptype;
	size_t i;
	bool have_params;
	const subtilis_symbol_t *symbol = NULL;
	size_t max_params = 0;
	size_t num_params = 0;
	size_t num_iparams = 0;
	size_t num_fparams = 0;
	const subtilis_symbol_t **new_syms;
	subtilis_type_t *params = NULL;
	const subtilis_symbol_t **syms = NULL;

	ptype.type = SUBTILIS_TYPE_VOID;
	have_params = prv_complete_array_type(p, t, fn_type, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;
	if (!have_params) {
		*num_parameters = 0;
		*symbols = NULL;
		return NULL;
	}

	tbuf = subtilis_token_get_text(t);
	for (;;) {
		if (t->type != SUBTILIS_TOKEN_IDENTIFIER) {
			subtilis_error_set_id_expected(
			    err, tbuf, p->l->stream->name, p->l->line);
			goto on_error;
		}

		/*
		 * TODO: maybe these checks should go in symbol table
		 * insert
		 */

		if (subtilis_symbol_table_lookup(p->local_st, tbuf)) {
			subtilis_error_set_already_defined(
			    err, tbuf, p->l->stream->name, p->l->line);
			goto on_error;
		}

		prv_process_param(p, t, &num_iparams, &num_fparams, &symbol,
				  &ptype, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;

		if (num_params == max_params) {
			new_max = max_params + 16;
			new_params = realloc(params, new_max * sizeof(*params));
			if (!new_params) {
				subtilis_error_set_oom(err);
				goto on_error;
			}
			new_syms = realloc(syms, new_max * sizeof(*syms));
			if (!new_syms) {
				subtilis_error_set_oom(err);
				goto on_error;
			}
			max_params = new_max;
			syms = new_syms;
			params = new_params;
		}
		syms[num_params] = symbol;
		subtilis_type_init_copy(&params[num_params], &ptype, err);
		num_params++;
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;
		subtilis_type_free(&ptype);
		ptype.type = SUBTILIS_TYPE_VOID;

		tbuf = subtilis_token_get_text(t);

		if (t->type != SUBTILIS_TOKEN_OPERATOR) {
			subtilis_error_set_right_bkt_expected(
			    err, tbuf, p->l->stream->name, p->l->line);
			goto on_error;
		}

		if (!strcmp(tbuf, ")"))
			goto read_next;

		if (strcmp(tbuf, ",")) {
			subtilis_error_set_right_bkt_expected(
			    err, tbuf, p->l->stream->name, p->l->line);
		}

		subtilis_lexer_get(p->l, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;
		tbuf = subtilis_token_get_text(t);
	}

read_next:

	*num_parameters = num_params;
	*symbols = syms;
	subtilis_lexer_get(p->l, t, err);
	return params;

on_error:

	subtilis_type_free(&ptype);
	free(syms);
	for (i = 0; i < num_params; i++)
		subtilis_type_free(&params[i]);
	free(params);
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
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, -0x1b0(%rbp)
movq $0x0, -0x1b8(%rbp)
movq $0x0, -0x1c0(%rbp)
movq $0x0, -0x1c8(%rbp)
movq $0x0, -0x1d0(%rbp)
movq $0x0, -0x1e0(%rbp)
movq $0x0, -0x1e8(%rbp)
movl $0x8, -0x198(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x205b0
andb $0x1, %al
movb %al, -0x1a1(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x21c5d
movq $0x0, -0x8(%rbp)
jmp 0x22071
testb $0x1, -0x1a1(%rbp)
jne 0x21c89
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movq $0x0, -0x8(%rbp)
jmp 0x22071
movq -0x18(%rbp), %rdi
callq 0x12d70
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x6, (%rax)
je 0x21ce6
movq -0x38(%rbp), %rdi
movq -0x40(%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 $0x12, %esi
leaq 0x895ad(%rip), %rcx     # 0xab276
leaq 0x88960(%rip), %rax     # 0xaa630
movq %rax, (%rsp)
movl $0x326, 0x8(%rsp)       # imm = 0x326
callq 0x156d0
jmp 0x21ffc
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rdi
movq -0x40(%rbp), %rsi
callq 0x3cff0
cmpq $0x0, %rax
je 0x21d44
movq -0x38(%rbp), %rdi
movq -0x40(%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 $0x20, %esi
leaq 0x8954f(%rip), %rcx     # 0xab276
leaq 0x88902(%rip), %rax     # 0xaa630
movq %rax, (%rsp)
movl $0x331, 0x8(%rsp)       # imm = 0x331
callq 0x156d0
jmp 0x21ffc
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rax
leaq -0x1c8(%rbp), %rdx
leaq -0x1d0(%rbp), %rcx
leaq -0x1b0(%rbp), %r8
leaq -0x198(%rbp), %r9
movq %rax, (%rsp)
callq 0x225f0
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x21d83
jmp 0x21ffc
movq -0x1c0(%rbp), %rax
cmpq -0x1b8(%rbp), %rax
jne 0x21e4c
movq -0x1b8(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x50(%rbp)
movq -0x1e0(%rbp), %rdi
imulq $0x148, -0x50(%rbp), %rsi # imm = 0x148
callq 0x121e0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x21de4
movq -0x38(%rbp), %rdi
movl $0x1, %esi
leaq 0x8885b(%rip), %rdx     # 0xaa630
movl $0x33e, %ecx            # imm = 0x33E
callq 0x158e0
jmp 0x21ffc
movq -0x1e8(%rbp), %rdi
movq -0x50(%rbp), %rsi
shlq $0x3, %rsi
callq 0x121e0
movq %rax, -0x1d8(%rbp)
cmpq $0x0, -0x1d8(%rbp)
jne 0x21e28
movq -0x38(%rbp), %rdi
movl $0x1, %esi
leaq 0x88817(%rip), %rdx     # 0xaa630
movl $0x343, %ecx            # imm = 0x343
callq 0x158e0
jmp 0x21ffc
movq -0x50(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movq -0x1d8(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x1e0(%rbp)
movq -0x1b0(%rbp), %rdx
movq -0x1e8(%rbp), %rax
movq -0x1c0(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x1e0(%rbp), %rdi
imulq $0x148, -0x1c0(%rbp), %rax # imm = 0x148
addq %rax, %rdi
movq -0x38(%rbp), %rdx
leaq -0x198(%rbp), %rsi
callq 0x3dec0
movq -0x1c0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1c0(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x21eaa
jmp 0x21ffc
leaq -0x198(%rbp), %rdi
callq 0x3e100
movl $0x8, -0x198(%rbp)
movq -0x18(%rbp), %rdi
callq 0x12d70
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x2, (%rax)
je 0x21f1d
movq -0x38(%rbp), %rdi
movq -0x40(%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 $0x16, %esi
leaq 0x89376(%rip), %rcx     # 0xab276
leaq 0x88729(%rip), %rax     # 0xaa630
movq %rax, (%rsp)
movl $0x356, 0x8(%rsp)       # imm = 0x356
callq 0x156d0
jmp 0x21ffc
movq -0x40(%rbp), %rdi
leaq 0x88c29(%rip), %rsi     # 0xaab51
callq 0x12140
cmpl $0x0, %eax
jne 0x21f37
jmp 0x21fbf
movq -0x40(%rbp), %rdi
leaq 0x88667(%rip), %rsi     # 0xaa5a9
callq 0x12140
cmpl $0x0, %eax
je 0x21f8e
movq -0x38(%rbp), %rdi
movq -0x40(%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 $0x16, %esi
leaq 0x89300(%rip), %rcx     # 0xab276
leaq 0x886b3(%rip), %rax     # 0xaa630
movq %rax, (%rsp)
movl $0x35f, 0x8(%rsp)       # imm = 0x35F
callq 0x156d0
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 0x21fad
jmp 0x21ffc
movq -0x18(%rbp), %rdi
callq 0x12d70
movq %rax, -0x40(%rbp)
jmp 0x21c96
movq -0x1c0(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x1e8(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x133f0
movq -0x1e0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x22071
leaq -0x198(%rbp), %rdi
callq 0x3e100
movq -0x1e8(%rbp), %rdi
callq 0x12290
movq $0x0, -0x1a0(%rbp)
movq -0x1a0(%rbp), %rax
cmpq -0x1c0(%rbp), %rax
jae 0x2205d
movq -0x1e0(%rbp), %rdi
imulq $0x148, -0x1a0(%rbp), %rax # imm = 0x148
addq %rax, %rdi
callq 0x3e100
movq -0x1a0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1a0(%rbp)
jmp 0x2201f
movq -0x1e0(%rbp), %rdi
callq 0x12290
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
nop