// File: /workspace/github_c_makefile_star2_O0/oridb[P]mc/parse/infer.c
// Function: unifycall
static void
unifycall(Node *n)
{
	size_t i;
	Type *ft;

	ft = type(n->expr.args[0]);
	if (ft->type == Tyvar) {
		/* the first arg is the function itself, so it shouldn't be counted */
		ft = mktyfunc(n->loc, &n->expr.args[1], n->expr.nargs - 1, mktyvar(n->loc));
		unify(n, ft, type(n->expr.args[0]));
	} else if (tybase(ft)->type != Tyfunc) {
		fatal(n, "calling uncallable type %s", tystr(ft));
	}
	/* first arg: function itself */
	for (i = 1; i < n->expr.nargs; i++) {
		if (i == ft->nsub)
			fatal(n, "%s arity mismatch (expected %zd args, got %zd)",
					ctxstr(n->expr.args[0]), ft->nsub - 1, n->expr.nargs - 1);

		if (ft->sub[i]->type == Tyvalist) {
			break;
		}
		unify(n->expr.args[0], ft->sub[i], type(n->expr.args[i]));
	}
	if (i < ft->nsub && ft->sub[i]->type != Tyvalist)
		fatal(n, "%s arity mismatch (expected %zd args, got %zd)",
				ctxstr(n->expr.args[0]), ft->nsub - 1, i - 1);
	settype(n, ft->sub[0]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movq (%rax), %rdi
callq 0x2a8f0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x19, (%rax)
jne 0x2d84e
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
addq $0x8, %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
subq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x370c0
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq (%rax), %rdi
callq 0x37520
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movq (%rax), %rdi
callq 0x2a8f0
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq %rax, %rdx
callq 0x28c00
jmp 0x2d884
movq -0x18(%rbp), %rdi
callq 0x36a30
cmpl $0x13, (%rax)
je 0x2d882
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
callq 0x38a10
movq -0x48(%rbp), %rdi
movq %rax, %rdx
leaq 0x24dae(%rip), %rsi     # 0x52629
movb $0x0, %al
callq 0x1dfe0
jmp 0x2d884
movq $0x1, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x40(%rcx), %rax
jae 0x2d961
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x70(%rcx), %rax
jne 0x2d8f1
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movq (%rax), %rdi
callq 0x27be0
movq -0x50(%rbp), %rdi
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq 0x70(%rax), %rcx
subq $0x1, %rcx
movq -0x8(%rbp), %rax
movq 0x40(%rax), %r8
subq $0x1, %r8
leaq 0x24d5a(%rip), %rsi     # 0x52644
movb $0x0, %al
callq 0x1dfe0
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpl $0x11, (%rax)
jne 0x2d908
jmp 0x2d961
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2a8f0
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq %rax, %rdx
callq 0x28c00
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x2d88c
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x70(%rcx), %rax
jae 0x2d9c5
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpl $0x11, (%rax)
je 0x2d9c5
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movq (%rax), %rdi
callq 0x27be0
movq -0x68(%rbp), %rdi
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq 0x70(%rax), %rcx
subq $0x1, %rcx
movq -0x10(%rbp), %r8
subq $0x1, %r8
leaq 0x24c86(%rip), %rsi     # 0x52644
movb $0x0, %al
callq 0x1dfe0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movq (%rax), %rsi
callq 0x2ce80
addq $0x70, %rsp
popq %rbp
retq
nop