// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbp
movq $0x0, 0x8(%rsp)
movq %rdi, 0x18(%rsp)
movq %r15, %rdi
callq 0x17d99
movq %rax, %r13
movq %r14, %rdi
callq 0x17d99
movq %rax, %r14
movl 0x4(%r13), %eax
cmpl 0x4(%r14), %eax
je 0x1907b
cmpl $0x19, (%r14)
pushq $0x2
popq %rax
jne 0x18abc
xorl %eax, %eax
cmpq $0x0, 0x28(%r14)
setne %al
cmpl $0x19, (%r13)
pushq $0x2
popq %rcx
jne 0x18ad0
xorl %ecx, %ecx
cmpq $0x0, 0x28(%r13)
setne %cl
cmpl %ecx, %eax
movq %r13, %r15
cmovbq %r14, %r15
cmovbq %r13, %r14
cmpl $0x19, (%r15)
jne 0x18b29
cmpl $0x19, (%r14)
je 0x18b38
callq 0x29d3c
movq %rax, %r12
movq %r15, %rdi
callq 0x17d99
movl 0x4(%rax), %esi
movq %r12, %rdi
callq 0x29ed5
movq %r14, %rdi
movq %r12, %rsi
callq 0x19974
movl %eax, %r13d
movq %r12, %rdi
callq 0x29d60
testl %r13d, %r13d
jne 0x191c3
cmpl $0x19, (%r15)
je 0x18b38
movq %r15, %rdi
movq %r14, %rsi
callq 0x215f5
testl %eax, %eax
je 0x18b67
leaq 0x46691(%rip), %rax     # 0x5f1d0
movq (%rax), %rax
movl 0x4(%r15), %ecx
movq %r14, (%rax,%rcx,8)
testq %rbp, %rbp
je 0x18b67
movq (%rbp), %rsi
movq %r15, %rdi
callq 0x195f8
movq (%rbp), %rsi
movq %r14, %rdi
callq 0x195f8
movl (%r15), %eax
cmpl $0x19, %eax
jne 0x18ba2
movq %r15, %rdi
callq 0x19656
movq %rax, %r12
movq %r14, %rdi
callq 0x19656
testq %r12, %r12
je 0x18b9a
testq %rax, %rax
je 0x18b9a
movq %rbp, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x18a60
movl (%r15), %eax
movq %r14, %rbx
jmp 0x18ba4
xorl %ebx, %ebx
cmpl $0x15, %eax
jne 0x18c73
cmpl $0x15, (%r14)
jne 0x18c73
movq 0x88(%r15), %rdi
testq %rdi, %rdi
je 0x18bd4
pushq $0x1
popq %rsi
callq 0x12bd3
movq %rax, 0x88(%r15)
jmp 0x18bd6
xorl %eax, %eax
movq 0x88(%r14), %rdi
testq %rdi, %rdi
je 0x18bfd
pushq $0x1
popq %rsi
callq 0x12bd3
movq %rax, %rdi
movq %rax, 0x88(%r14)
movq 0x88(%r15), %rax
jmp 0x18bff
xorl %edi, %edi
testq %rax, %rax
je 0x18c1c
movq %rax, %rdi
callq 0x1b5e6
cmpl $0x35, %eax
jne 0x1926e
movq 0x88(%r14), %rdi
testq %rdi, %rdi
je 0x18c2f
callq 0x1b5e6
cmpl $0x35, %eax
jne 0x19273
movq 0x88(%r15), %rax
movq 0x88(%r14), %rcx
testq %rax, %rax
je 0x18c63
testq %rcx, %rcx
je 0x18c6c
movq 0x50(%rax), %rax
movq (%rax), %rdi
movq 0x50(%rcx), %rax
movq (%rax), %rsi
callq 0x1bfef
testl %eax, %eax
jne 0x18c73
jmp 0x1929e
movq %rcx, 0x88(%r15)
jmp 0x18c73
movq %rax, 0x88(%r14)
movl (%r15), %ecx
movl (%r14), %eax
cmpl $0x19, %ecx
je 0x18d19
cmpl %eax, %ecx
jne 0x18d19
cmpl $0x1c, %ecx
jne 0x18d23
movq 0x88(%r15), %rdi
movq 0x88(%r14), %rsi
callq 0x1c100
testl %eax, %eax
je 0x19212
cmpl $0x1c, (%r15)
jne 0x18d23
cmpq $0x0, 0x48(%r15)
je 0x18d23
cmpl $0x1c, (%r14)
jne 0x18d23
cmpq $0x0, 0x48(%r14)
je 0x18d23
movq 0x88(%r15), %rdi
movq 0x88(%r14), %rsi
callq 0x1c100
testl %eax, %eax
je 0x19189
movq 0x48(%r15), %rax
cmpq 0x48(%r14), %rax
jne 0x192d7
xorl %ebx, %ebx
cmpq %rax, %rbx
jae 0x18d23
movq 0x40(%r15), %rax
movq (%rax,%rbx,8), %rsi
movq 0x40(%r14), %rax
movq (%rax,%rbx,8), %rdx
movq %rbp, %rdi
callq 0x18a60
incq %rbx
movq 0x48(%r15), %rax
jmp 0x18cf3
cmpl $0x19, %ecx
je 0x18d5f
jmp 0x19189
movq 0x70(%r15), %rax
cmpq 0x70(%r14), %rax
jne 0x19199
xorl %ebx, %ebx
cmpq %rax, %rbx
jae 0x18d59
movq 0x68(%r15), %rax
movq (%rax,%rbx,8), %rsi
movq 0x68(%r14), %rax
movq (%rax,%rbx,8), %rdx
movq %rbp, %rdi
callq 0x18a60
incq %rbx
movq 0x70(%r14), %rax
jmp 0x18d33
movl (%r14), %eax
movq %r14, %rbx
cmpl $0x19, %eax
jne 0x18d8b
movq 0x80(%r15), %rsi
movq 0x80(%r14), %rdi
testq %rsi, %rsi
je 0x1904d
testq %rdi, %rdi
je 0x19067
callq 0x29f5f
jmp 0x18d99
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x19743
cmpb $0x0, 0x95(%r15)
jne 0x18dad
cmpb $0x0, 0x95(%r14)
je 0x18dc5
movq %rbx, %rdi
callq 0x12260
movq %r15, %rdi
callq 0x12260
movq %r14, %rdi
callq 0x12260
movq %rbx, 0x20(%rsp)
movq 0x459cf(%rip), %rdi     # 0x5e7a0
movq %r15, %rsi
callq 0x2a517
movq %r15, %rdi
testl %eax, %eax
je 0x18df2
movq 0x459b9(%rip), %rdi     # 0x5e7a0
movq %r15, %rsi
callq 0x2a3e8
movq %rax, %rdi
movq %r15, 0x28(%rsp)
callq 0x1fcd8
movq %rax, %r13
movq 0x4599a(%rip), %rdi     # 0x5e7a0
movq %r14, %rsi
callq 0x2a517
movq %r14, %rdi
testl %eax, %eax
je 0x18e27
movq 0x45984(%rip), %rdi     # 0x5e7a0
movq %r14, %rsi
callq 0x2a3e8
movq %rax, %rdi
movq %r14, 0x30(%rsp)
callq 0x1fcd8
movq %rax, %r12
movl (%r13), %eax
cmpl $0x17, %eax
je 0x18f0c
cmpl $0x18, %eax
jne 0x18fdf
cmpl $0x18, (%r12)
jne 0x18fdf
cmpq %r12, %r13
je 0x18fdf
movq 0x78(%r13), %rax
cmpq 0x78(%r12), %rax
jne 0x19227
xorl %r14d, %r14d
cmpq 0x78(%r13), %r14
jae 0x18fdf
xorl %r15d, %r15d
xorl %ebx, %ebx
cmpq %rax, %r15
jae 0x18efc
movq 0x88(%r13), %rax
movq (%rax,%r14,8), %rax
movq 0x18(%rax), %rdi
movq 0x88(%r12), %rax
movq (%rax,%r15,8), %rax
movq 0x18(%rax), %rsi
callq 0x1c100
testl %eax, %eax
je 0x18ef2
movq 0x88(%r13), %rax
movq (%rax,%r14,8), %rax
movq 0x28(%rax), %rsi
movq 0x88(%r12), %rax
movq (%rax,%r15,8), %rax
movq 0x28(%rax), %rdx
testq %rsi, %rsi
je 0x18ee6
testq %rdx, %rdx
je 0x19131
movq %rbp, %rdi
callq 0x18a60
pushq $0x1
popq %rbx
jmp 0x18ef2
pushq $0x1
popq %rbx
testq %rdx, %rdx
jne 0x19131
incq %r15
movq 0x78(%r12), %rax
jmp 0x18e7f
incq %r14
testl %ebx, %ebx
jne 0x18e70
jmp 0x19131
cmpl $0x17, (%r12)
jne 0x18fdf
cmpq %r12, %r13
je 0x18fdf
movq 0x78(%r13), %rax
cmpq 0x78(%r12), %rax
jne 0x19131
xorl %r14d, %r14d
cmpq 0x78(%r13), %r14
jae 0x18fdf
xorl %ebx, %ebx
xorl %ebp, %ebp
cmpq %rax, %rbp
jae 0x18fca
movq 0x88(%r13), %rax
movq (%rax,%r14,8), %rax
movq 0x20(%rax), %rdi
callq 0x1c0c8
movq %rax, %r15
movq 0x88(%r12), %rax
movq (%rax,%rbp,8), %rax
movq 0x20(%rax), %rdi
callq 0x1c0c8
movq %r15, %rdi
movq %rax, %rsi
callq 0x4230
testl %eax, %eax
jne 0x18fbd
movq 0x88(%r13), %rax
movq (%rax,%r14,8), %rdi
callq 0x19ae5
movq %rax, %r15
movq 0x88(%r12), %rax
movq (%rax,%rbp,8), %rdi
callq 0x19ae5
movq 0x18(%rsp), %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x18a60
pushq $0x1
popq %rax
movl %eax, %ebx
incq %rbp
movq 0x78(%r12), %rax
jmp 0x18f40
incq %r14
testl %ebx, %ebx
movq 0x18(%rsp), %rbp
jne 0x18f32
jmp 0x19131
movq 0x28(%rsp), %r12
cmpl $0x19, (%r12)
movq 0x30(%rsp), %rbx
jne 0x18ff9
cmpl $0x19, (%rbx)
je 0x1909f
movq 0x457a0(%rip), %rdi     # 0x5e7a0
movq %r12, %rsi
callq 0x2a517
testl %eax, %eax
movq 0x20(%rsp), %r13
je 0x1907b
movq 0x45788(%rip), %rdi     # 0x5e7a0
movq %r12, %rsi
callq 0x2a3e8
movq %rax, %r15
movq %rbx, %rdi
callq 0x1fcd8
movq %rax, %r14
testb $0x1, 0x8(%rsp)
movq 0x10(%rsp), %rax
cmoveq %r13, %rax
movq %rax, 0x10(%rsp)
movb $0x1, %al
movq %rax, 0x8(%rsp)
jmp 0x18a85
testq %rdi, %rdi
je 0x18d99
callq 0x29d7c
movq %rax, 0x80(%r15)
jmp 0x18d99
movq %rsi, %rdi
callq 0x29d7c
movq %rax, 0x80(%r14)
jmp 0x18d99
movq 0x8(%rsp), %r14
movq 0x10(%rsp), %r15
testb $0x1, %r14b
cmovneq %r15, %r13
movq %r13, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x456fa(%rip), %rdi     # 0x5e7a0
movq %r12, %rsi
callq 0x2a517
testl %eax, %eax
movq 0x20(%rsp), %r13
je 0x190ca
movq 0x456e2(%rip), %rdi     # 0x5e7a0
movq %rbx, %rsi
callq 0x2a517
testl %eax, %eax
je 0x190ff
movq 0x456cf(%rip), %rdi     # 0x5e7a0
movq %rbx, %rsi
callq 0x2a517
testl %eax, %eax
movq 0x8(%rsp), %r14
movq 0x10(%rsp), %r15
je 0x19085
movq 0x456b2(%rip), %rdi     # 0x5e7a0
movq %r12, %rsi
callq 0x2a517
movq %rbx, %rsi
testl %eax, %eax
jne 0x19085
jmp 0x1910f
movq %r12, %rsi
movq %rbx, %r12
movq 0x8(%rsp), %r14
movq 0x10(%rsp), %r15
movq 0x4568a(%rip), %rbx     # 0x5e7a0
movq %rbx, %rdi
callq 0x2a3e8
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x2a22a
jmp 0x19085
movq %r13, %rdi
callq 0x21009
movq %rax, %r14
movq %r12, %rdi
callq 0x21009
movq %rax, %r15
movq %rbp, %rdi
callq 0x17f9e
movq %rbp, %rbx
movq %rax, %rbp
movq %r13, %rdi
callq 0x19a61
movq %rax, %r13
movq %r12, %rdi
callq 0x19a61
movq %rax, (%rsp)
leaq 0x1901d(%rip), %rsi     # 0x32190
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
movq %rbp, %r8
movq %r13, %r9
xorl %eax, %eax
callq 0x120fd
movq %r15, %rdi
movq %r14, %rsi
movq %rbp, %rdx
xorl %ecx, %ecx
callq 0x19693
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rbx
movq %r14, %rdx
callq 0x19743
movq %r15, %r14
movq %r15, %rdi
callq 0x1fcd8
cmpl $0x13, (%rax)
jne 0x191fb
leaq 0x18e9a(%rip), %rcx     # 0x3205b
jmp 0x19202
movq %r15, %rdi
callq 0x21009
movq %rax, %r15
movq %r14, %rdi
callq 0x21009
movq %rax, %r14
movq %rbp, %rdi
callq 0x17f9e
leaq 0x18e0c(%rip), %rsi     # 0x31ff4
movq %rbp, %rdi
movq %r15, %rdx
movq %r14, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x120fd
leaq 0x18e71(%rip), %rcx     # 0x32073
movq %r14, %rdi
movq %rbx, %rsi
movq 0x18(%rsp), %rdx
callq 0x19693
leaq 0x18e12(%rip), %rcx     # 0x3202b
movq %r15, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x19693
movq %r13, %rdi
callq 0x21009
movq %rax, %r14
movq %r12, %rdi
callq 0x21009
movq %rax, %r15
movq %rbp, %rdi
callq 0x17f9e
movq %rbp, %rbx
movq %rax, %rbp
movq %r13, %rdi
callq 0x19a61
movq %rax, %r13
movq %r12, %rdi
callq 0x19a61
movq %rax, (%rsp)
leaq 0x18f04(%rip), %rsi     # 0x3216d
jmp 0x19173
movq %r15, %rdi
jmp 0x19276
movq %r14, %rdi
callq 0x21009
movq %rax, %r14
movq %rbp, %rdi
callq 0x17f9e
movq (%rbp), %rdi
leaq 0x18dfe(%rip), %rsi     # 0x3208f
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x121e4
movq %r15, %rdi
callq 0x21009
movq %rax, %r15
movq %r14, %rdi
callq 0x21009
movq %rax, %r14
movq %rbp, %rdi
callq 0x17f9e
movq (%rbp), %rdi
leaq 0x18def(%rip), %rsi     # 0x320b6
movq %r15, %rdx
movq %r14, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x121e4
leaq 0x18d60(%rip), %rcx     # 0x3203e
jmp 0x19219