// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/parser_call.c
// Function: prv_check_call_addr
static void prv_check_call_addr(subtilis_parser_t *p,
				subtilis_parser_call_addr_t *call_addr,
				subtilis_error_t *err)
{
	size_t index;
	size_t call_index;
	size_t i;
	subtilis_type_section_t *st;
	const char *expected_typname;
	const char *got_typname;
	subtilis_ir_inst_t *call_site;
	subtilis_type_fn_t *fn_st;
	subtilis_type_fn_t *ct_fn_type = &call_addr->call_type.params.fn;
	subtilis_type_type_t ct_ret_type = ct_fn_type->ret_val->type;

	if (!subtilis_string_pool_find(p->prog->string_pool, call_addr->name,
				       &index)) {
		if (ct_ret_type == SUBTILIS_TYPE_VOID)
			subtilis_error_set_unknown_procedure(
			    err, call_addr->name, p->l->stream->name,
			    call_addr->line);
		else
			subtilis_error_set_unknown_function(
			    err, call_addr->name, p->l->stream->name,
			    call_addr->line);
		return;
	}

	/* We need to fix up the call site of procedures call in an
	 * error handler.
	 */

	call_index = call_addr->index;
	if (call_addr->in_error_handler)
		call_index += call_addr->s->handler_offset;

	st = p->prog->sections[index]->type;
	fn_st = &st->type.params.fn;

	if ((fn_st->ret_val->type == SUBTILIS_TYPE_VOID) &&
	    (ct_ret_type != SUBTILIS_TYPE_VOID)) {
		subtilis_error_set_procedure_expected(
		    err, call_addr->name, p->l->stream->name, call_addr->line);
		return;
	} else if ((fn_st->ret_val->type != SUBTILIS_TYPE_VOID) &&
		   (ct_ret_type == SUBTILIS_TYPE_VOID)) {
		subtilis_error_set_function_expected(
		    err, call_addr->name, p->l->stream->name, call_addr->line);
		return;
	}

	if (fn_st->num_params != ct_fn_type->num_params) {
		subtilis_error_set_bad_arg_count(
		    err, ct_fn_type->num_params, fn_st->num_params,
		    p->l->stream->name, call_addr->line);
		return;
	}

	call_site = &call_addr->s->ops[call_index]->op.instr;

	for (i = 0; i < fn_st->num_params; i++) {
		if (!subtilis_type_eq(fn_st->params[i],
				      ct_fn_type->params[i])) {
			expected_typname = subtilis_type_name(fn_st->params[i]);
			got_typname = subtilis_type_name(ct_fn_type->params[i]);
			subtilis_error_set_bad_arg_type(
			    err, i + 1, expected_typname, got_typname,
			    p->l->stream->name, call_addr->line, __FILE__,
			    __LINE__);
			return;
		}
	}

	call_site->operands[1].label = index;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
addq $0x20, %rax
addq $0x8, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
movl %eax, -0x64(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
leaq -0x20(%rbp), %rdx
callq 0x3d5a0
testb $0x1, %al
jne 0x21697
cmpl $0x8, -0x64(%rbp)
jne 0x21649
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq 0x168(%rax), %rax
movl %eax, %r9d
movl $0x24, %esi
leaq 0x89c47(%rip), %rcx     # 0xab276
leaq 0x88ffa(%rip), %rax     # 0xaa630
movq %rax, (%rsp)
movl $0x7d9, 0x8(%rsp)       # imm = 0x7D9
callq 0x156d0
jmp 0x21692
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq 0x168(%rax), %rax
movl %eax, %r9d
movl $0x25, %esi
leaq 0x89bfc(%rip), %rcx     # 0xab276
leaq 0x88faf(%rip), %rax     # 0xaa630
movq %rax, (%rsp)
movl $0x7dd, 0x8(%rsp)       # imm = 0x7DD
callq 0x156d0
jmp 0x218fb
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
testb $0x1, 0x8(%rax)
je 0x216c3
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x80(%rax), %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq (%rax), %rax
cmpl $0x8, (%rax)
jne 0x2174a
cmpl $0x8, -0x64(%rbp)
je 0x2174a
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq 0x168(%rax), %rax
movl %eax, %r9d
movl $0x22, %esi
leaq 0x89b49(%rip), %rcx     # 0xab276
leaq 0x88efc(%rip), %rax     # 0xaa630
movq %rax, (%rsp)
movl $0x7ef, 0x8(%rsp)       # imm = 0x7EF
callq 0x156d0
jmp 0x218fb
movq -0x58(%rbp), %rax
movq (%rax), %rax
cmpl $0x8, (%rax)
je 0x217aa
cmpl $0x8, -0x64(%rbp)
jne 0x217aa
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq 0x168(%rax), %rax
movl %eax, %r9d
movl $0x23, %esi
leaq 0x89ae9(%rip), %rcx     # 0xab276
leaq 0x88e9c(%rip), %rax     # 0xaa630
movq %rax, (%rsp)
movl $0x7f4, 0x8(%rsp)       # imm = 0x7F4
callq 0x156d0
jmp 0x218fb
jmp 0x217ac
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x60(%rbp), %rcx
cmpq 0x8(%rcx), %rax
je 0x21811
movq -0x18(%rbp), %rdi
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %edx
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq 0x168(%rax), %rax
movl %eax, %r9d
movl $0x28, %esi
leaq 0x88e35(%rip), %rax     # 0xaa630
movq %rax, (%rsp)
movl $0x7fb, 0x8(%rsp)       # imm = 0x7FB
callq 0x157b0
jmp 0x218fb
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x48(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
addq $0x8, %rax
movq %rax, -0x50(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x58(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x218ef
movq -0x58(%rbp), %rax
movq -0x30(%rbp), %rcx
movq 0x10(%rax,%rcx,8), %rdi
movq -0x60(%rbp), %rax
movq -0x30(%rbp), %rcx
movq 0x10(%rax,%rcx,8), %rsi
callq 0x3d880
testb $0x1, %al
jne 0x218dc
movq -0x58(%rbp), %rax
movq -0x30(%rbp), %rcx
movq 0x10(%rax,%rcx,8), %rdi
callq 0x3e190
movq %rax, -0x40(%rbp)
movq -0x60(%rbp), %rax
movq -0x30(%rbp), %rcx
movq 0x10(%rax,%rcx,8), %rdi
callq 0x3e190
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq $0x1, %rsi
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq 0x168(%rax), %rax
movl %eax, %r9d
leaq 0x88d67(%rip), %rax     # 0xaa630
movq %rax, (%rsp)
movl $0x809, 0x8(%rsp)       # imm = 0x809
callq 0x15bd0
jmp 0x218fb
jmp 0x218de
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x21834
movq -0x20(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x10(%rax)
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)