// File: /workspace/github_c_makefile_star2_O2/markdryan[P]subtilis/frontend/parser_call.c
// Function: subtilis_parser_call_known_ptr
subtilis_exp_t *subtilis_parser_call_known_ptr(subtilis_parser_t *p,
					       subtilis_token_t *t,
					       const subtilis_type_t *type,
					       size_t reg,
					       subtilis_error_t *err)
{
	size_t i;
	subtilis_exp_t *args[SUBTILIS_MAX_ARGS];
	size_t num_args = 0;
	subtilis_parser_param_t *params = NULL;
	subtilis_ir_arg_t *ir_args = NULL;

	num_args = subtilis_var_bracketed_args_have_b(p, t, args,
						      SUBTILIS_MAX_ARGS, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;

	if (num_args != type->params.fn.num_params) {
		subtilis_error_set_bad_arg_count(
		    err, num_args, type->params.fn.num_params,
		    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;

	params = prv_call_ptr_parameters(p, args, num_args, type, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;

	ir_args = prv_parser_to_ir_args(params, num_args, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;
	prv_delete_params(params, num_args);
	params = NULL;

	p->current->proc_called = true;

	return subtilis_exp_add_call_ptr(p, ir_args, type->params.fn.ret_val,
					 reg, num_args, err);

on_error:
	free(ir_args);
	prv_delete_params(params, num_args);
	for (i = 0; i < num_args; i++)
		subtilis_exp_delete(args[i]);

	return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %r8, %r14
movq %rcx, %r13
movq %rdx, %rbp
movq %rsi, %r15
movq %rdi, %r12
leaq 0x20(%rsp), %rdx
pushq $0x20
popq %rcx
callq 0x1e658
cmpl $0x0, (%r14)
je 0x1bb2d
xorl %r14d, %r14d
movq %r14, %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x10(%rbp), %rcx
cmpq %rcx, %rax
jne 0x1bb83
movq (%r12), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x12e0e
cmpl $0x0, (%r14)
jne 0x1bbab
imulq $0x158, %rbx, %rdi      # imm = 0x158
callq 0x121d0
testq %rax, %rax
je 0x1bca6
movq %rax, %rcx
movq %rbx, %rax
movq %rcx, 0x8(%rsp)
subq $0x1, %rax
jb 0x1bbe2
movl $0x8, (%rcx)
addq $0x158, %rcx            # imm = 0x158
jmp 0x1bb6e
movq (%r12), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x51a7a(%rip), %rax     # 0x6d610
pushq $0x28
popq %rsi
movq %r14, %rdi
movl %ebx, %edx
pushq $0x5b2                  # imm = 0x5B2
pushq %rax
callq 0x14179
popq %rax
popq %rcx
xorl %r14d, %r14d
xorl %r15d, %r15d
movq %r15, %rdi
callq 0x122c0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1a55d
xorl %r14d, %r14d
xorl %r15d, %r15d
cmpq %r15, %rbx
je 0x1bb18
movq 0x20(%rsp,%r15,8), %rdi
callq 0x29d88
incq %r15
jmp 0x1bbca
movq %rbp, 0x10(%rsp)
movq %r13, 0x18(%rsp)
movq 0x8(%rsp), %rbp
xorl %r13d, %r13d
cmpq %r13, %rbx
je 0x1bce9
movq 0x20(%rsp,%r13,8), %rdx
cmpq $0x0, 0x160(%rdx)
movq 0x10(%rsp), %rax
movq 0x18(%rax,%r13,8), %rax
movq %r12, %rdi
je 0x1bc2b
movq %rax, %rsi
movq %r14, %rcx
callq 0x1cc3c
movq 0x20(%rsp,%r13,8), %r15
jmp 0x1bc59
movq %rdx, %rsi
movq %rax, %rdx
movq %r14, %rcx
callq 0x35977
movq %rax, 0x20(%rsp,%r13,8)
cmpl $0x0, (%r14)
jne 0x1bcc8
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x3415f
movq %rax, %r15
andq $0x0, 0x20(%rsp,%r13,8)
cmpl $0x0, (%r14)
jne 0x1bccb
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2db73
cmpl $0x0, (%r14)
jne 0x1bccb
movq 0x148(%r15), %rax
movq %rax, 0x148(%rbp)
orq $-0x1, 0x150(%rbp)
movq %r15, %rdi
callq 0x29d88
incq %r13
addq $0x158, %rbp            # imm = 0x158
jmp 0x1bbf4
leaq 0x51963(%rip), %rdx     # 0x6d610
pushq $0x1
popq %rsi
movq %r14, %rdi
movl $0xbe, %ecx
callq 0x1429e
movq $0x0, 0x8(%rsp)
jmp 0x1bcf3
xorl %r15d, %r15d
movq %r15, %rdi
callq 0x29d88
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x1a55d
movq $0x0, 0x8(%rsp)
movq 0x18(%rsp), %r13
movq 0x10(%rsp), %rbp
cmpl $0x0, (%r14)
je 0x1bcfe
xorl %r15d, %r15d
jmp 0x1bd1c
movq 0x8(%rsp), %rdi
movq %rdi, 0x8(%rsp)
movq %rbx, %rsi
movq %r14, %rdx
callq 0x1a4e3
movq %rax, %r15
cmpl $0x0, (%r14)
je 0x1bd26
movq 0x8(%rsp), %r14
jmp 0x1bbb1
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x1a55d
movq 0x48(%r12), %rax
movb $0x1, 0xe0(%rax)
movq 0x8(%rbp), %rdx
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rcx
movq %rbx, %r8
movq %r14, %r9
callq 0x2a127
movq %rax, %r14
jmp 0x1bb18