// File: /workspace/github_c_makefile_star2_O0/oridb[P]mc/parse/infer.c
// Function: unify
static Type *
unify(Node *ctx, Type *u, Type *v)
{
	Type *t, *r;
	Type *a, *b;
	Type *ea, *eb;
	size_t i;

	/* a ==> b */
	a = tf(u);
	b = tf(v);
	if (a->tid == b->tid)
		return a;

	/* we unify from lower to higher ranked types */
	if (tyrank(b) < tyrank(a)) {
		t = a;
		a = b;
		b = t;
	}

	/* Disallow recursive types */
	if (a->type == Tyvar && b->type != Tyvar) {
		if (occursin(a, b))
			fatal(ctx, "%s occurs within %s, leading to infinite type near %s\n",
				tystr(a), tystr(b), ctxstr(ctx));
	}

	r = NULL;
	if (a->type == Tyvar || tyeq(a, b)) {
		tytab[a->tid] = b;
		if (ctx) {
			marksrc(a, ctx->loc);
			marksrc(b, ctx->loc);
		}
	}
	if (a->type == Tyvar) {
		ea = basetype(a);
		eb = basetype(b);
		if (ea && eb)
			unify(ctx, ea, eb);
		r = b;
	}

	if (a->type == Tyarray && b->type == Tyarray) {
		checksize(ctx, a, b);
	}

	/* if the tyrank of a is 0 (ie, a raw tyvar), just unify.
	 * Otherwise, match up subtypes. */
	if (a->type == b->type && a->type != Tyvar) {
		if (a->type == Tyname)
			if (!nameeq(a->name, b->name))
				typeerror(a, b, ctx, "incompatible types");
		if (hasargs(a) && hasargs(b)) {
			/* Only Tygeneric and Tyname should be able to unify. And they
			 * should have the same names for this to be true. */
			if (!nameeq(a->name, b->name))
				typeerror(a, b, ctx, NULL);
			if (a->narg != b->narg)
				typeerror(a, b, ctx, "incompatible parameter lists");
			for (i = 0; i < a->narg; i++)
				unify(ctx, a->arg[i], b->arg[i]);
			r = b;
		}
		if (a->nsub != b->nsub) {
			verifytraits(ctx, a, b);
			if (tybase(a)->type == Tyfunc)
				typeerror(a, b, ctx, "function arity mismatch");
			else
				typeerror(a, b, ctx, "subtype counts incompatible");
		}
		for (i = 0; i < b->nsub; i++)
			unify(ctx, a->sub[i], b->sub[i]);
		r = b;
	} else if (a->type != Tyvar) {
		typeerror(a, b, ctx, NULL);
	}
	mergetraits(ctx, a, b);
	if (a->isreflect || b->isreflect) {
		tagreflect(r);
		tagreflect(a);
		tagreflect(b);
	}
	membunify(ctx, a, b);

	/* if we have delayed types for a tyvar, transfer it over. */
	if (a->type == Tyvar && b->type == Tyvar) {
		if (hthas(delayed, a) && !hthas(delayed, b))
			htput(delayed, b, htget(delayed, a));
		else if (hthas(delayed, b) && !hthas(delayed, a))
			htput(delayed, a, htget(delayed, b));
	} else if (hthas(delayed, a)) {
		unify(ctx, htget(delayed, a), tybase(b));
	}

	return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x277c0
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
callq 0x277c0
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x40(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jne 0x28c4e
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x29183
movq -0x40(%rbp), %rdi
callq 0x296b0
movl %eax, -0x5c(%rbp)
movq -0x38(%rbp), %rdi
callq 0x296b0
movl %eax, %ecx
movl -0x5c(%rbp), %eax
cmpl %ecx, %eax
jge 0x28c84
movq -0x38(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x19, (%rax)
jne 0x28cf2
movq -0x40(%rbp), %rax
cmpl $0x19, (%rax)
je 0x28cf2
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x296f0
cmpl $0x0, %eax
je 0x28cf0
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x38(%rbp), %rdi
callq 0x38a10
movq %rax, -0x70(%rbp)
movq -0x40(%rbp), %rdi
callq 0x38a10
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
callq 0x27be0
movq -0x78(%rbp), %rdi
movq -0x70(%rbp), %rdx
movq -0x68(%rbp), %rcx
movq %rax, %r8
leaq 0x292b3(%rip), %rsi     # 0x51f9c
movb $0x0, %al
callq 0x1dfe0
jmp 0x28cf2
movq $0x0, -0x30(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x19, (%rax)
je 0x28d15
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x39360
cmpl $0x0, %eax
je 0x28d57
movq -0x40(%rbp), %rdx
leaq 0x54fc8(%rip), %rax     # 0x7dce8
movq (%rax), %rax
movq -0x38(%rbp), %rcx
movl 0x4(%rcx), %ecx
movq %rdx, (%rax,%rcx,8)
cmpq $0x0, -0x10(%rbp)
je 0x28d55
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x29750
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x29750
jmp 0x28d57
movq -0x38(%rbp), %rax
cmpl $0x19, (%rax)
jne 0x28da1
movq -0x38(%rbp), %rdi
callq 0x297f0
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
callq 0x297f0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x28d99
cmpq $0x0, -0x50(%rbp)
je 0x28d99
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x28c00
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x15, (%rax)
jne 0x28dc4
movq -0x40(%rbp), %rax
cmpl $0x15, (%rax)
jne 0x28dc4
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x298a0
movq -0x38(%rbp), %rax
movl (%rax), %eax
movq -0x40(%rbp), %rcx
cmpl (%rcx), %eax
jne 0x28fba
movq -0x38(%rbp), %rax
cmpl $0x19, (%rax)
je 0x28fba
movq -0x38(%rbp), %rax
cmpl $0x1c, (%rax)
jne 0x28e26
movq -0x38(%rbp), %rax
movq 0x88(%rax), %rdi
movq -0x40(%rbp), %rax
movq 0x88(%rax), %rsi
callq 0x30670
cmpl $0x0, %eax
jne 0x28e24
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq 0x291b4(%rip), %rcx     # 0x51fd3
callq 0x29ad0
jmp 0x28e26
movq -0x38(%rbp), %rdi
callq 0x29bb0
cmpl $0x0, %eax
je 0x28efe
movq -0x40(%rbp), %rdi
callq 0x29bb0
cmpl $0x0, %eax
je 0x28efe
movq -0x38(%rbp), %rax
movq 0x88(%rax), %rdi
movq -0x40(%rbp), %rax
movq 0x88(%rax), %rsi
callq 0x30670
cmpl $0x0, %eax
jne 0x28e7f
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x10(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x29ad0
movq -0x38(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x40(%rbp), %rcx
cmpq 0x48(%rcx), %rax
je 0x28ea9
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq 0x29142(%rip), %rcx     # 0x51fe6
callq 0x29ad0
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq -0x38(%rbp), %rcx
cmpq 0x48(%rcx), %rax
jae 0x28ef6
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x40(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x28c00
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x28eb1
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x40(%rbp), %rcx
cmpq 0x70(%rcx), %rax
je 0x28f63
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x29be0
movq -0x38(%rbp), %rdi
callq 0x36a30
cmpl $0x13, (%rax)
jne 0x28f49
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq 0x290c1(%rip), %rcx     # 0x52003
callq 0x29ad0
jmp 0x28f61
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq 0x290bf(%rip), %rcx     # 0x5201b
callq 0x29ad0
jmp 0x28f63
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq -0x40(%rbp), %rcx
cmpq 0x70(%rcx), %rax
jae 0x28fb0
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x68(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x40(%rbp), %rax
movq 0x68(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x28c00
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x28f6b
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x28fda
movq -0x38(%rbp), %rax
cmpl $0x19, (%rax)
je 0x28fd8
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x10(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x29ad0
jmp 0x28fda
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x29f30
movq -0x38(%rbp), %rax
movsbl 0x95(%rax), %eax
cmpl $0x0, %eax
jne 0x2900b
movq -0x40(%rbp), %rax
movsbl 0x95(%rax), %eax
cmpl $0x0, %eax
je 0x29026
movq -0x30(%rbp), %rdi
callq 0x1e1b0
movq -0x38(%rbp), %rdi
callq 0x1e1b0
movq -0x40(%rbp), %rdi
callq 0x1e1b0
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x2a010
movq -0x38(%rbp), %rax
cmpl $0x19, (%rax)
jne 0x29123
movq -0x40(%rbp), %rax
cmpl $0x19, (%rax)
jne 0x29123
movq 0x54268(%rip), %rdi     # 0x7d2c0
movq -0x38(%rbp), %rsi
callq 0x496f0
cmpl $0x0, %eax
je 0x290b6
movq 0x54253(%rip), %rdi     # 0x7d2c0
movq -0x40(%rbp), %rsi
callq 0x496f0
cmpl $0x0, %eax
jne 0x290b6
movq 0x5423e(%rip), %rax     # 0x7d2c0
movq %rax, -0x88(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x80(%rbp)
movq 0x54228(%rip), %rdi     # 0x7d2c0
movq -0x38(%rbp), %rsi
callq 0x49490
movq -0x88(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq %rax, %rdx
callq 0x49100
jmp 0x29121
movq 0x54203(%rip), %rdi     # 0x7d2c0
movq -0x40(%rbp), %rsi
callq 0x496f0
cmpl $0x0, %eax
je 0x2911f
movq 0x541ee(%rip), %rdi     # 0x7d2c0
movq -0x38(%rbp), %rsi
callq 0x496f0
cmpl $0x0, %eax
jne 0x2911f
movq 0x541d9(%rip), %rax     # 0x7d2c0
movq %rax, -0x98(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x90(%rbp)
movq 0x541c0(%rip), %rdi     # 0x7d2c0
movq -0x40(%rbp), %rsi
callq 0x49490
movq -0x98(%rbp), %rdi
movq -0x90(%rbp), %rsi
movq %rax, %rdx
callq 0x49100
jmp 0x29121
jmp 0x2917b
movq 0x54196(%rip), %rdi     # 0x7d2c0
movq -0x38(%rbp), %rsi
callq 0x496f0
cmpl $0x0, %eax
je 0x29179
movq -0x10(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq 0x54176(%rip), %rdi     # 0x7d2c0
movq -0x38(%rbp), %rsi
callq 0x49490
movq %rax, -0xa0(%rbp)
movq -0x40(%rbp), %rdi
callq 0x36a30
movq -0xa8(%rbp), %rdi
movq -0xa0(%rbp), %rsi
movq %rax, %rdx
callq 0x28c00
jmp 0x2917b
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq