// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3b8, %rsp            # imm = 0x3B8
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x28(%rsp), %rdx
movl $0x8, (%rdx)
xorl %r13d, %r13d
xorl %ecx, %ecx
movq %r15, %r8
callq 0x1a3cb
movq %rax, 0x20(%rsp)
cmpl $0x0, (%r15)
jne 0x19bd0
movq (%r14), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x12e0e
xorl %r13d, %r13d
cmpl $0x0, (%r15)
je 0x19c6a
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %ebx, %ebx
cmpq %rbx, %r12
je 0x19bf4
movq 0x170(%rsp,%rbx,8), %rdi
callq 0x29d88
incq %rbx
jmp 0x19bdd
movq %rbp, %rdi
movq %r12, %rsi
callq 0x1a66a
testq %r13, %r13
je 0x19c2c
movq %r15, %rbp
movq %r13, %rbx
movq %r12, %r15
subq $0x1, %r15
jb 0x19c21
movq (%rbx), %rdi
callq 0x122c0
addq $0x10, %rbx
jmp 0x19c0d
movq %r13, %rdi
callq 0x122c0
movq %rbp, %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x1a55d
movq %r14, %rdi
callq 0x122c0
movq 0x20(%rsp), %rdi
callq 0x122c0
leaq 0x28(%rsp), %rdi
callq 0x2dc7c
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x3b8, %rsp            # imm = 0x3B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, 0x8(%rsp)
movq %rbx, %rdi
callq 0x12a25
xorl %r13d, %r13d
cmpl $0x2, (%rbx)
movl $0x0, %r12d
movl $0x0, %ebp
movl $0x0, %edi
movl $0x0, %r14d
jne 0x19d82
movb (%rax), %cl
cmpb $0x7b, %cl
jne 0x19d3f
xorl %r13d, %r13d
cmpb $0x0, 0x1(%rax)
movl $0x0, %r12d
movl $0x0, %ebp
movl $0x0, %edi
movl $0x0, %r14d
jne 0x19d82
movb %cl, 0x10(%rsp)
movq 0x8(%rsp), %r14
movq (%r14), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x12e0e
xorl %r13d, %r13d
cmpl $0x0, (%r15)
jne 0x19bd0
movq %rbx, %rdi
callq 0x12a25
cmpl $0x2, (%rbx)
jne 0x19d07
cmpb $0x7d, (%rax)
jne 0x19d07
cmpb $0x0, 0x1(%rax)
je 0x19ff3
movq (%r14), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0x538f7(%rip), %r10     # 0x6d610
leaq 0x538ed(%rip), %rdx     # 0x6d60d
pushq $0x1d
popq %rsi
movq %r15, %rdi
movq %rax, %rcx
pushq $0x1a2                  # imm = 0x1A2
pushq %r10
callq 0x140cd
popq %rax
popq %rcx
xorl %r13d, %r13d
jmp 0x19bd0
movl %ecx, %edx
xorl %r13d, %r13d
movl $0x0, %r12d
movl $0x0, %ebp
movl $0x0, %edi
movl $0x0, %r14d
cmpb $0x28, %dl
jne 0x19d82
xorl %r13d, %r13d
cmpb $0x0, 0x1(%rax)
movl $0x0, %r12d
movl $0x0, %ebp
movl $0x0, %edi
movl $0x0, %r14d
je 0x19e25
movq %r12, %rsi
callq 0x1a55d
leaq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdi
movq %r15, %rdx
callq 0x1a595
movq %rax, 0x20(%rsp)
cmpl $0x0, (%r15)
jne 0x19dc3
leaq 0x28(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r13, %rcx
movq %r15, %r8
callq 0x2d9c4
cmpl $0x0, (%r15)
je 0x19dcb
xorl %r15d, %r15d
jmp 0x19bdb
movq %rax, %rbx
movq %rbp, %rdi
movq %r12, %rsi
callq 0x1a66a
subq $0x8, %rsp
pushq $0x9
popq %rdx
leaq 0x30(%rsp), %r13
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq 0x28(%rsp), %rsi
movq %rbx, %rcx
movq %r14, %r8
movq %r13, %r9
pushq %r15
pushq $0x1
pushq %r12
callq 0x29dcc
addq $0x20, %rsp
movq %rax, %rbx
movq %r13, %rdi
callq 0x2dc7c
movq 0x48(%rbp), %rax
movb $0x1, 0xe0(%rax)
jmp 0x19c55
movl %ecx, %ebp
leaq 0x170(%rsp), %rdx
pushq $0x20
popq %rcx
movq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %r8
callq 0x1e658
movq %rax, %r12
cmpl $0x0, (%r15)
jne 0x19e62
movq (%r14), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x12e0e
cmpl $0x0, (%r15)
je 0x19e6a
xorl %r13d, %r13d
jmp 0x19bd3
movq %rbx, %rdi
callq 0x12a25
cmpb $0x7b, %bpl
je 0x19e8c
cmpl $0x2, (%rbx)
jne 0x19e8c
cmpb $0x28, (%rax)
jne 0x19e8c
cmpb $0x0, 0x1(%rax)
je 0x1a22a
imulq $0x158, %r12, %rdi      # imm = 0x158
callq 0x121d0
testq %rax, %rax
je 0x1a073
movq %rax, %rcx
movq %r12, %rax
movq %rcx, (%rsp)
subq $0x1, %rax
jb 0x19ec0
movl $0x8, (%rcx)
addq $0x158, %rcx            # imm = 0x158
jmp 0x19eab
pushq $0x8
popq %rbx
xorl %r14d, %r14d
movq (%rsp), %rax
movq %rax, 0x10(%rsp)
xorl %r13d, %r13d
cmpq %r14, %r12
je 0x1a171
movq %r14, 0x18(%rsp)
movq 0x170(%rsp,%r14,8), %rbp
movq 0x160(%rbp), %r14
testq %r14, %r14
je 0x19f59
testq %r13, %r13
jne 0x19f10
movq %r12, %rdi
pushq $0x10
popq %rsi
callq 0x12150
movq %rax, %r13
testq %rax, %rax
je 0x1a26a
movq %r14, %rdi
callq 0x120f0
leaq 0x1(%rax), %rdi
callq 0x121d0
movq %rax, -0x8(%r13,%rbx)
testq %rax, %rax
je 0x1a117
movq 0x18(%rsp), %r14
movq 0x170(%rsp,%r14,8), %rbp
movq 0x160(%rbp), %rsi
movq %rax, %rdi
callq 0x12070
movq 0x168(%rbp), %rax
movq %rax, (%r13,%rbx)
jmp 0x19f5e
movq 0x18(%rsp), %r14
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x3415f
andq $0x0, 0x170(%rsp,%r14,8)
movq %rax, %rbp
cmpl $0x0, (%r15)
jne 0x1a065
movq 0x10(%rsp), %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x2db73
cmpl $0x0, (%r15)
jne 0x1a065
movq 0x8(%rsp), %rax
movq 0x48(%rax), %rdi
movq %r15, %rsi
callq 0x2aae2
cmpl $0x0, (%r15)
jne 0x1a065
movq 0x148(%rbp), %rcx
movq %rbp, %rdi
movq 0x10(%rsp), %rbp
movq %rcx, 0x148(%rbp)
movq %rax, 0x150(%rbp)
callq 0x29d88
incq %r14
addq $0x158, %rbp            # imm = 0x158
movq %rbp, 0x10(%rsp)
addq $0x10, %rbx
jmp 0x19ed2
movq (%r14), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x12e0e
xorl %r13d, %r13d
cmpl $0x0, (%r15)
jne 0x19bd0
movq %rbx, %rdi
callq 0x12a25
movq %rax, 0x18(%rsp)
cmpl $0x8, 0x28(%rsp)
jne 0x1a08d
movq (%r14), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x535dc(%rip), %rax     # 0x6d610
leaq 0x53d8a(%rip), %rcx     # 0x6ddc5
pushq $0xb
popq %rsi
movq %r15, %rdi
movq 0x20(%rsp), %rdx
pushq $0x142                  # imm = 0x142
pushq %rax
callq 0x140cd
popq %rax
popq %rcx
xorl %r13d, %r13d
cmpl $0x0, (%r15)
jne 0x19bd0
jmp 0x1a0e5
testq %r13, %r13
jne 0x1a130
jmp 0x1a152
leaq 0x53596(%rip), %rdx     # 0x6d610
pushq $0x1
popq %rsi
pushq $0x7a
popq %rcx
movq %r15, %rdi
callq 0x1429e
jmp 0x1a166
leaq 0x270(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movq %r15, %rdx
callq 0x2db73
cmpl $0x0, (%r15)
jne 0x19d37
leaq 0x270(%rsp), %r14
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x34066
movq %r14, %rdi
callq 0x2dc7c
cmpl $0x0, (%r15)
jne 0x19d37
movabsq $-0xffffffff, %rax      # imm = 0xFFFFFFFF00000001
movq %rax, 0x30(%rsp)
xorl %r13d, %r13d
cmpl $0x2, (%rbx)
movl $0x0, %r12d
movl $0x0, %ebp
movl $0x0, %edi
movl $0x0, %r14d
movb 0x10(%rsp), %cl
movq 0x18(%rsp), %rax
jne 0x19d82
movb (%rax), %dl
jmp 0x19d41
leaq 0x534f2(%rip), %rdx     # 0x6d610
pushq $0x1
popq %rsi
movq %r15, %rdi
movl $0x8c, %ecx
callq 0x1429e
xorl %ebp, %ebp
movq %r12, %rbx
movq %r13, %r14
subq $0x1, %rbx
jb 0x1a14a
movq (%r14), %rdi
callq 0x122c0
addq $0x10, %r14
jmp 0x1a136
movq %r13, %rdi
callq 0x122c0
movq %rbp, %rdi
callq 0x29d88
movq (%rsp), %rdi
movq %r12, %rsi
callq 0x1a55d
xorl %r13d, %r13d
movq $0x0, (%rsp)
cmpl $0x0, (%r15)
je 0x1a17e
xorl %ebp, %ebp
xorl %r14d, %r14d
jmp 0x1a198
movq (%rsp), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x1a4e3
movq %rax, %r14
cmpl $0x0, (%r15)
je 0x1a1a1
xorl %ebp, %ebp
movq (%rsp), %r15
jmp 0x19bdb
imulq $0x148, %r12, %rdi      # imm = 0x148
callq 0x121d0
testq %rax, %rax
je 0x1a1fd
movq %rax, %rbp
pushq $-0x1
popq %rbx
movq %rax, %rdi
movq (%rsp), %rsi
incq %rbx
cmpq %rbx, %r12
je 0x1a261
leaq 0x158(%rsi), %rax
movq %rax, 0x10(%rsp)
leaq 0x148(%rdi), %rax
movq %rax, 0x18(%rsp)
movq %r15, %rdx
callq 0x2db73
cmpl $0x0, (%r15)
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
je 0x1a1bf
jmp 0x1a196
leaq 0x5340c(%rip), %rdx     # 0x6d610
pushq $0x1
popq %rsi
pushq $0x46
popq %rcx
movq %r15, %rdi
callq 0x1429e
xorl %ebp, %ebp
cmpl $0x0, (%r15)
movq (%rsp), %rdi
je 0x19d82
movq %rdi, %r15
jmp 0x19bdb
cmpl $0x8, 0x28(%rsp)
jne 0x1a288
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x533c8(%rip), %rax     # 0x6d610
leaq 0x53b76(%rip), %rcx     # 0x6ddc5
pushq $0xb
popq %rsi
movq %r15, %rdi
movq 0x20(%rsp), %rdx
pushq $0x120                  # imm = 0x120
jmp 0x1a2dd
movq (%rsp), %rdi
jmp 0x19d82
leaq 0x5339f(%rip), %rdx     # 0x6d610
pushq $0x1
popq %rsi
movq %r15, %rdi
movl $0x85, %ecx
callq 0x1429e
xorl %ebp, %ebp
jmp 0x1a152
cmpq $0x1, %r12
jne 0x1a2ad
movq 0x170(%rsp), %rax
cmpl $0x1, (%rax)
jne 0x1a2ad
movl 0x148(%rax), %eax
addl $-0xb, %eax
cmpl $-0xb, %eax
ja 0x1a353
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x5334c(%rip), %rax     # 0x6d610
leaq 0x5335c(%rip), %rdx     # 0x6d627
leaq 0x53af3(%rip), %rcx     # 0x6ddc5
pushq $0x38
popq %rsi
movq %r15, %rdi
pushq $0x129                  # imm = 0x129
pushq %rax
callq 0x140cd
popq %rax
popq %rcx
cmpl $0x0, (%r15)
jne 0x19e62
xorl %r14d, %r14d
cmpq %r14, %r12
je 0x1a309
movq 0x170(%rsp,%r14,8), %rdi
callq 0x29d88
incq %r14
jmp 0x1a2f2
leaq 0x170(%rsp), %rdx
pushq $0x20
popq %rcx
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %r8
callq 0x1e658
movq %rax, %r12
cmpl $0x0, (%r15)
jne 0x19e62
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x12e0e
cmpl $0x0, (%r15)
jne 0x19e62
jmp 0x19e8c
leaq 0x270(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movq %r15, %rdx
callq 0x2db73
cmpl $0x0, (%r15)
jne 0x1a394
leaq 0x270(%rsp), %r14
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x34015
movq %r14, %rdi
callq 0x2dc7c
cmpl $0x0, (%r15)
je 0x1a39d
pushq $0x1
popq %r12
jmp 0x19e62
movq 0x170(%rsp), %rax
movl 0x148(%rax), %ecx
movl %ecx, 0x30(%rsp)
xorl %eax, %eax
movslq %ecx, %rcx
cmpq %rcx, %rax
jae 0x1a2e5
orl $-0x1, 0x34(%rsp,%rax,4)
incq %rax
movl 0x30(%rsp), %ecx
jmp 0x1a3b1