// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/parser_call.c
// Function: subtilis_parser_call
subtilis_exp_t *subtilis_parser_call(subtilis_parser_t *p, subtilis_token_t *t,
				     subtilis_error_t *err)
{
	subtilis_exp_t *ret_val;
	const char *tbuf;
	subtilis_type_t fn_type;
	subtilis_exp_t *poss_args[SUBTILIS_MAX_ARGS];
	size_t i;
	subtilis_check_args_t *check_args = NULL;
	size_t num_poss_args = 0;
	bool vector = false;
	subtilis_type_section_t *stype = NULL;
	subtilis_type_t *ptypes = NULL;
	char *name = NULL;
	subtilis_parser_param_t *params = NULL;
	subtilis_ir_arg_t *args = NULL;

	fn_type.type = SUBTILIS_TYPE_VOID;

	name = prv_proc_name_and_type(p, t, &fn_type, false, 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;

	tbuf = subtilis_token_get_text(t);
	if ((t->type == SUBTILIS_TOKEN_OPERATOR) && !strcmp(tbuf, "{")) {
		subtilis_lexer_get(p->l, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;

		tbuf = subtilis_token_get_text(t);
		if ((t->type != SUBTILIS_TOKEN_OPERATOR) || strcmp(tbuf, "}")) {
			subtilis_error_set_expected(
			    err, "} ", tbuf, p->l->stream->name, p->l->line);
			goto on_error;
		}
		subtilis_lexer_get(p->l, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;
		tbuf = subtilis_token_get_text(t);

		prv_process_vector_fn_type(p, name, &fn_type, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;
		vector = true;
	}
	if ((t->type == SUBTILIS_TOKEN_OPERATOR) && !strcmp(tbuf, "(")) {
		num_poss_args = subtilis_var_bracketed_args_have_b(
		    p, t, poss_args, SUBTILIS_MAX_ARGS, 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;

		tbuf = subtilis_token_get_text(t);
		if (!vector && (t->type == SUBTILIS_TOKEN_OPERATOR) &&
		    !strcmp(tbuf, "(")) {
			/*
			 * The expressions in poss_args are type information
			 * for the return type of this function which is an
			 * array.
			 */

			prv_process_array_fn_type(p, poss_args, num_poss_args,
						  name, &fn_type, err);
			if (err->type != SUBTILIS_ERROR_OK)
				goto on_error;

			for (i = 0; i < num_poss_args; i++)
				subtilis_exp_delete(poss_args[i]);

			num_poss_args = subtilis_var_bracketed_args_have_b(
			    p, t, poss_args, SUBTILIS_MAX_ARGS, 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;
		}

		params = prv_call_parameters(p, poss_args, num_poss_args,
					     &check_args, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;
		args = prv_parser_to_ir_args(params, num_poss_args, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;
		ptypes = prv_parser_to_ptypes(params, num_poss_args, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;
	}

	prv_delete_params(params, num_poss_args);
	params = NULL;

	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_poss_args, ptypes,
					  check_args, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;
	prv_delete_ptypes(ptypes, num_poss_args);
	ptypes = NULL;

	/* Ownership of stypes, args and name passed to this function. */

	ret_val =
	    subtilis_exp_add_call(p, name, SUBTILIS_BUILTINS_MAX, stype, args,
				  &fn_type, num_poss_args, true, err);

	subtilis_type_free(&fn_type);

	p->current->proc_called = true;

	return ret_val;

on_error:

	for (i = 0; i < num_poss_args; i++)
		subtilis_exp_delete(poss_args[i]);

	prv_delete_ptypes(ptypes, num_poss_args);
	if (check_args) {
		for (i = 0; i < num_poss_args; i++)
			free(check_args[i].arg_name);
		free(check_args);
	}
	prv_delete_params(params, num_poss_args);
	free(args);
	free(name);

	subtilis_type_free(&fn_type);

	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2e0, %rsp            # imm = 0x2E0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x290(%rbp)
movq $0x0, -0x298(%rbp)
movb $0x0, -0x299(%rbp)
movq $0x0, -0x2a8(%rbp)
movq $0x0, -0x2b0(%rbp)
movq $0x0, -0x2b8(%rbp)
movq $0x0, -0x2c0(%rbp)
movq $0x0, -0x2c8(%rbp)
movl $0x8, -0x178(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %r8
leaq -0x178(%rbp), %rdx
xorl %ecx, %ecx
callq 0x1e750
movq %rax, -0x2b8(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1e1d4
jmp 0x1e64b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x133f0
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1e1f6
jmp 0x1e64b
movq -0x18(%rbp), %rdi
callq 0x12d70
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x1e31c
movq -0x30(%rbp), %rdi
leaq 0x8f3f0(%rip), %rsi     # 0xad60b
callq 0x12140
cmpl $0x0, %eax
jne 0x1e31c
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x133f0
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1e24b
jmp 0x1e64b
movq -0x18(%rbp), %rdi
callq 0x12d70
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x1e276
movq -0x30(%rbp), %rdi
leaq 0x8c3bf(%rip), %rsi     # 0xaa62b
callq 0x12140
cmpl $0x0, %eax
je 0x1e2bd
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x1d, %esi
leaq 0x8c38d(%rip), %rdx     # 0xaa62d
leaq 0x8c389(%rip), %rax     # 0xaa630
movq %rax, (%rsp)
movl $0x1a2, 0x8(%rsp)       # imm = 0x1A2
callq 0x156d0
jmp 0x1e64b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x133f0
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1e2df
jmp 0x1e64b
movq -0x18(%rbp), %rdi
callq 0x12d70
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movq -0x2b8(%rbp), %rsi
movq -0x20(%rbp), %rcx
leaq -0x178(%rbp), %rdx
callq 0x1e910
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1e315
jmp 0x1e64b
movb $0x1, -0x299(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x1e537
movq -0x30(%rbp), %rdi
leaq 0x8cf68(%rip), %rsi     # 0xab29c
callq 0x12140
cmpl $0x0, %eax
jne 0x1e537
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x280(%rbp), %rdx
movq -0x20(%rbp), %r8
movl $0x20, %ecx
callq 0x255b0
movq %rax, -0x298(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1e374
jmp 0x1e64b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x133f0
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1e396
jmp 0x1e64b
movq -0x18(%rbp), %rdi
callq 0x12d70
movq %rax, -0x30(%rbp)
testb $0x1, -0x299(%rbp)
jne 0x1e4a6
movq -0x18(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x1e4a6
movq -0x30(%rbp), %rdi
leaq 0x8ced4(%rip), %rsi     # 0xab29c
callq 0x12140
cmpl $0x0, %eax
jne 0x1e4a6
movq -0x10(%rbp), %rdi
leaq -0x280(%rbp), %rsi
movq -0x298(%rbp), %rdx
movq -0x2b8(%rbp), %rcx
movq -0x20(%rbp), %r9
leaq -0x178(%rbp), %r8
callq 0x1e9f0
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1e40d
jmp 0x1e64b
movq $0x0, -0x288(%rbp)
movq -0x288(%rbp), %rax
cmpq -0x298(%rbp), %rax
jae 0x1e450
movq -0x288(%rbp), %rax
movq -0x280(%rbp,%rax,8), %rdi
callq 0x36ee0
movq -0x288(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x288(%rbp)
jmp 0x1e418
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x280(%rbp), %rdx
movq -0x20(%rbp), %r8
movl $0x20, %ecx
callq 0x255b0
movq %rax, -0x298(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1e482
jmp 0x1e64b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x133f0
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1e4a4
jmp 0x1e64b
jmp 0x1e4a6
movq -0x10(%rbp), %rdi
leaq -0x280(%rbp), %rsi
movq -0x298(%rbp), %rdx
movq -0x20(%rbp), %r8
leaq -0x290(%rbp), %rcx
callq 0x1eb90
movq %rax, -0x2c0(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1e4dd
jmp 0x1e64b
movq -0x2c0(%rbp), %rdi
movq -0x298(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x1eed0
movq %rax, -0x2c8(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1e509
jmp 0x1e64b
movq -0x2c0(%rbp), %rdi
movq -0x298(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x1efd0
movq %rax, -0x2b0(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1e535
jmp 0x1e64b
jmp 0x1e537
movq -0x2c0(%rbp), %rdi
movq -0x298(%rbp), %rsi
callq 0x1f090
movq $0x0, -0x2c0(%rbp)
movq -0x2b8(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq -0x178(%rbp), %rsi
callq 0x1f0f0
movq %rax, -0x2b8(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1e581
jmp 0x1e64b
movq -0x298(%rbp), %rsi
movq -0x2b0(%rbp), %rdx
movq -0x290(%rbp), %rcx
movq -0x20(%rbp), %r8
leaq -0x178(%rbp), %rdi
callq 0x3dc00
movq %rax, -0x2a8(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1e5bb
jmp 0x1e64b
movq -0x2b0(%rbp), %rdi
movq -0x298(%rbp), %rsi
callq 0x1f210
movq $0x0, -0x2b0(%rbp)
movq -0x10(%rbp), %rdi
movq -0x2b8(%rbp), %rsi
movq -0x2a8(%rbp), %rcx
movq -0x2c8(%rbp), %r8
movq -0x298(%rbp), %r10
movq -0x20(%rbp), %rax
movl $0x9, %edx
leaq -0x178(%rbp), %r9
movq %r10, (%rsp)
movl $0x1, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x36f50
movq %rax, -0x28(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x3e100
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movb $0x1, 0xe0(%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x1e742
movq $0x0, -0x288(%rbp)
movq -0x288(%rbp), %rax
cmpq -0x298(%rbp), %rax
jae 0x1e68e
movq -0x288(%rbp), %rax
movq -0x280(%rbp,%rax,8), %rdi
callq 0x36ee0
movq -0x288(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x288(%rbp)
jmp 0x1e656
movq -0x2b0(%rbp), %rdi
movq -0x298(%rbp), %rsi
callq 0x1f210
cmpq $0x0, -0x290(%rbp)
je 0x1e703
movq $0x0, -0x288(%rbp)
movq -0x288(%rbp), %rax
cmpq -0x298(%rbp), %rax
jae 0x1e6f7
movq -0x290(%rbp), %rax
movq -0x288(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x12290
movq -0x288(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x288(%rbp)
jmp 0x1e6b6
movq -0x290(%rbp), %rdi
callq 0x12290
movq -0x2c0(%rbp), %rdi
movq -0x298(%rbp), %rsi
callq 0x1f090
movq -0x2c8(%rbp), %rdi
callq 0x12290
movq -0x2b8(%rbp), %rdi
callq 0x12290
leaq -0x178(%rbp), %rdi
callq 0x3e100
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x2e0, %rsp            # imm = 0x2E0
popq %rbp
retq
nop