// File: /workspace/github_c_makefile_star2_O1/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
movl $0x20, %ecx
callq 0x1f290
cmpl $0x0, (%r14)
je 0x1c056
xorl %r14d, %r14d
jmp 0x1c1f1
movq %rax, %rbx
movq 0x10(%rbp), %rcx
cmpq %rcx, %rax
jne 0x1c18b
movq (%r12), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x12eda
cmpl $0x0, (%r14)
jne 0x1c1b7
imulq $0x158, %rbx, %rdi      # imm = 0x158
callq 0x121d0
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x1c206
testq %rbx, %rbx
je 0x1c255
movq %rbp, 0x10(%rsp)
movq %r13, 0x18(%rsp)
movq 0x8(%rsp), %rbp
movq %rbp, %rax
movq %rbx, %rcx
movl $0x8, (%rax)
addq $0x158, %rax            # imm = 0x158
decq %rcx
jne 0x1c0b7
xorl %r13d, %r13d
movq 0x20(%rsp,%r13,8), %rdx
cmpq $0x0, 0x160(%rdx)
movq 0x10(%rsp), %rax
movq 0x18(%rax,%r13,8), %rax
movq %r12, %rdi
je 0x1c0f9
movq %rax, %rsi
movq %r14, %rcx
callq 0x1d2a6
movq 0x20(%rsp,%r13,8), %r15
jmp 0x1c127
movq %rdx, %rsi
movq %rax, %rdx
movq %r14, %rcx
callq 0x379c3
movq %rax, 0x20(%rsp,%r13,8)
cmpl $0x0, (%r14)
jne 0x1c22a
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x36269
movq %rax, %r15
movq $0x0, 0x20(%rsp,%r13,8)
cmpl $0x0, (%r14)
jne 0x1c22d
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2f72e
cmpl $0x0, (%r14)
jne 0x1c22d
movq 0x148(%r15), %rax
movq %rax, 0x148(%rbp)
movq $-0x1, 0x150(%rbp)
movq %r15, %rdi
callq 0x2b4c3
incq %r13
addq $0x158, %rbp            # imm = 0x158
cmpq %r13, %rbx
jne 0x1c0cb
jmp 0x1c24b
movq (%r12), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x57482(%rip), %rax     # 0x73620
movq %r14, %rdi
movl $0x28, %esi
movl %ebx, %edx
pushq $0x5b2                  # imm = 0x5B2
pushq %rax
callq 0x144d6
addq $0x10, %rsp
xorl %r14d, %r14d
xorl %r15d, %r15d
movq %r15, %rdi
callq 0x122c0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1adb8
testq %rbx, %rbx
je 0x1c04e
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x20(%rsp,%r15,8), %rdi
callq 0x2b4c3
incq %r15
cmpq %r15, %rbx
jne 0x1c1df
movq %r14, %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x57413(%rip), %rdx     # 0x73620
movq %r14, %rdi
movl $0x1, %esi
movl $0xbe, %ecx
callq 0x145f4
movq $0x0, 0x8(%rsp)
jmp 0x1c255
xorl %r15d, %r15d
movq %r15, %rdi
callq 0x2b4c3
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x1adb8
movq $0x0, 0x8(%rsp)
movq 0x18(%rsp), %r13
movq 0x10(%rsp), %rbp
cmpl $0x0, (%r14)
je 0x1c260
xorl %r15d, %r15d
jmp 0x1c27e
movq 0x8(%rsp), %rdi
movq %rdi, 0x8(%rsp)
movq %rbx, %rsi
movq %r14, %rdx
callq 0x1aca3
movq %rax, %r15
cmpl $0x0, (%r14)
je 0x1c288
movq 0x8(%rsp), %r14
jmp 0x1c1bd
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x1adb8
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 0x2b86e
movq %rax, %r14
jmp 0x1c1f1