// File: /workspace/github_c_makefile_star2_O0/oridb[P]mc/parse/type.c
// Function: tyeq_rec
int
tyeq_rec(Type *a, Type *b, Bitset *avisited, Bitset *bvisited, int search)
{
	Type *x, *y, *t;
	Typair p;
	size_t i;
	int ret;

	if (!a || !b)
		return a == b;
	if (search) {
		a = tysearch(a);
		b = tysearch(b);
		if ((t = boundtype(a)) != NULL)
			a = tysearch(t);
		if ((t = boundtype(b)) != NULL)
			b = tysearch(t);
	}
	if (a->type != b->type)
		return 0;
	if (a->narg != b->narg)
		return 0;
	if (a->nsub != b->nsub)
		return 0;
	if (a->nmemb != b->nmemb)
		return 0;
	p = (Typair){a->tid, b->tid};
	if (hthas(eqcache, &p))
		return 1;

	if (a->tid == b->tid)
		return 1;

	if (bshas(avisited, a->tid) && bshas(bvisited, b->tid))
		return 1;
	if (bshas(bvisited, a->tid) && bshas(avisited, b->tid))
		return 1;

	bsput(avisited, a->tid);
	bsput(bvisited, b->tid);
	ret = 1;

	switch (a->type) {
	case Typaram:
		ret = (a == b);
		ret = ret || streq(a->pname, b->pname);
		//if (ret != streq(a->pname, b->pname))
		//	die("wat");
		break;
	case Tyvar:
		if (a->tid != b->tid)
			ret = 0;
		break;
	case Tyunres:
		if (!nameeq(a->name, b->name))
			ret = 0;
	case Tyunion:
		for (i = 0; i < a->nmemb; i++) {
			if (!nameeq(a->udecls[i]->name, b->udecls[i]->name))
				ret = 0;
			x = a->udecls[i]->etype;
			y = b->udecls[i]->etype;
			if (!tyeq_rec(x, y, avisited, bvisited, search))
				ret = 0;
			if (!ret)
				break;
		}
		break;
	case Tystruct:
		for (i = 0; i < a->nmemb; i++) {
			if (strcmp(declname(a->sdecls[i]), declname(b->sdecls[i])) != 0)
				ret = 0;
			x = decltype(a->sdecls[i]);
			y = decltype(b->sdecls[i]);
			if (!tyeq_rec(x, y, avisited, bvisited, search))
				ret = 0;
			if (!ret)
				break;
		}
		break;
	case Tygeneric:
		if (!nameeq(a->name, b->name))
			ret = 0;
		for (i = 0; i < a->ngparam; i++) {
			ret = ret && tyeq_rec(a->gparam[i], b->gparam[i], avisited, bvisited, search);
			if (!ret)
				break;
		}
		break;
	case Tyname:
		if (!nameeq(a->name, b->name))
			ret = 0;
		for (i = 0; i < a->narg; i++) {
			ret = ret && tyeq_rec(a->arg[i], b->arg[i], avisited, bvisited, search);
			if (!ret)
				break;
		}
		break;
	case Tyarray:
		if (arraysz(a->asize) != arraysz(b->asize))
			ret = 0;
		break;
	default:
		break;
	}
	if (ret) {
		for (i = 0; i < a->nsub; i++) {
			x = a->sub[i];
			y = b->sub[i];
			if (!tyeq_rec(x, y, avisited, bvisited, search)) {
				ret = 0;
				break;
			}
		}
	}
	if (ret)
		equate(a->tid, b->tid);
	bsdel(avisited, a->tid);
	bsdel(bvisited, b->tid);

	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x38b7d
cmpq $0x0, -0x18(%rbp)
jne 0x38b95
movq -0x10(%rbp), %rax
cmpq -0x18(%rbp), %rax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x39241
cmpl $0x0, -0x2c(%rbp)
je 0x38bf7
movq -0x10(%rbp), %rdi
callq 0x25450
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
callq 0x25450
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x34c90
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
je 0x38bd5
movq -0x48(%rbp), %rdi
callq 0x25450
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
callq 0x34c90
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
je 0x38bf5
movq -0x48(%rbp), %rdi
callq 0x25450
movq %rax, -0x18(%rbp)
jmp 0x38bf7
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
je 0x38c11
movl $0x0, -0x4(%rbp)
jmp 0x39241
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x48(%rcx), %rax
je 0x38c2f
movl $0x0, -0x4(%rbp)
jmp 0x39241
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x70(%rcx), %rax
je 0x38c4d
movl $0x0, -0x4(%rbp)
jmp 0x39241
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x78(%rcx), %rax
je 0x38c6b
movl $0x0, -0x4(%rbp)
jmp 0x39241
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x64(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x60(%rbp)
movq -0x64(%rbp), %rax
movq %rax, -0x50(%rbp)
movq 0x4508a(%rip), %rdi     # 0x7dd18
leaq -0x50(%rbp), %rsi
callq 0x496f0
cmpl $0x0, %eax
je 0x38ca8
movl $0x1, -0x4(%rbp)
jmp 0x39241
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jne 0x38cc4
movl $0x1, -0x4(%rbp)
jmp 0x39241
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %esi
callq 0x37c60
cmpl $0x0, %eax
je 0x38cfe
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %esi
callq 0x37c60
cmpl $0x0, %eax
je 0x38cfe
movl $0x1, -0x4(%rbp)
jmp 0x39241
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %esi
callq 0x37c60
cmpl $0x0, %eax
je 0x38d38
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %esi
callq 0x37c60
cmpl $0x0, %eax
je 0x38d38
movl $0x1, -0x4(%rbp)
jmp 0x39241
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %esi
callq 0x48a50
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %esi
callq 0x48a50
movl $0x1, -0x5c(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
addl $-0x15, %eax
movl %eax, %ecx
movq %rcx, -0x70(%rbp)
subl $0x8, %eax
ja 0x3917f
movq -0x70(%rbp), %rax
leaq 0x1b23e(%rip), %rcx     # 0x53fc4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
cmpq -0x18(%rbp), %rax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x5c(%rbp)
movb $0x1, %al
cmpl $0x0, -0x5c(%rbp)
movb %al, -0x71(%rbp)
jne 0x38dd1
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rsi
callq 0x499b0
cmpl $0x0, %eax
setne %al
movb %al, -0x71(%rbp)
movb -0x71(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x5c(%rbp)
jmp 0x39181
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x4(%rcx), %eax
je 0x38df8
movl $0x0, -0x5c(%rbp)
jmp 0x39181
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rsi
callq 0x30670
cmpl $0x0, %eax
jne 0x38e24
movl $0x0, -0x5c(%rbp)
jmp 0x38e26
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x78(%rcx), %rax
jae 0x38ef5
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x18(%rax), %rsi
callq 0x30670
cmpl $0x0, %eax
jne 0x38e7f
movl $0x0, -0x5c(%rbp)
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x28(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x28(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl -0x2c(%rbp), %r8d
callq 0x38b50
cmpl $0x0, %eax
jne 0x38eda
movl $0x0, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
jne 0x38ee2
jmp 0x38ef5
jmp 0x38ee4
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x38e2e
jmp 0x39181
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x78(%rcx), %rax
jae 0x38fd8
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x30200
movq %rax, -0x80(%rbp)
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x30200
movq -0x80(%rbp), %rdi
movq %rax, %rsi
callq 0x6220
cmpl $0x0, %eax
je 0x38f60
movl $0x0, -0x5c(%rbp)
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x30260
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x30260
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl -0x2c(%rbp), %r8d
callq 0x38b50
cmpl $0x0, %eax
jne 0x38fbd
movl $0x0, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
jne 0x38fc5
jmp 0x38fd8
jmp 0x38fc7
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x38f02
jmp 0x39181
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rsi
callq 0x30670
cmpl $0x0, %eax
jne 0x39004
movl $0x0, -0x5c(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0x3908b
xorl %eax, %eax
cmpl $0x0, -0x5c(%rbp)
movb %al, -0x81(%rbp)
je 0x39065
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl -0x2c(%rbp), %r8d
callq 0x38b50
cmpl $0x0, %eax
setne %al
movb %al, -0x81(%rbp)
movb -0x81(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
jne 0x3907b
jmp 0x3908b
jmp 0x3907d
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x3900c
jmp 0x39181
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rsi
callq 0x30670
cmpl $0x0, %eax
jne 0x390b7
movl $0x0, -0x5c(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x48(%rcx), %rax
jae 0x3913e
xorl %eax, %eax
cmpl $0x0, -0x5c(%rbp)
movb %al, -0x82(%rbp)
je 0x39118
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl -0x2c(%rbp), %r8d
callq 0x38b50
cmpl $0x0, %eax
setne %al
movb %al, -0x82(%rbp)
movb -0x82(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
jne 0x3912e
jmp 0x3913e
jmp 0x39130
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x390bf
jmp 0x39181
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rdi
callq 0x2f180
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rdi
callq 0x2f180
movq %rax, %rcx
movq -0x90(%rbp), %rax
cmpq %rcx, %rax
je 0x3917d
movl $0x0, -0x5c(%rbp)
jmp 0x39181
jmp 0x39181
cmpl $0x0, -0x5c(%rbp)
je 0x391fe
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x70(%rcx), %rax
jae 0x391fc
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl -0x2c(%rbp), %r8d
callq 0x38b50
cmpl $0x0, %eax
jne 0x391ec
movl $0x0, -0x5c(%rbp)
jmp 0x391fc
jmp 0x391ee
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x3918f
jmp 0x391fe
cmpl $0x0, -0x5c(%rbp)
je 0x39217
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x39250
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %esi
callq 0x48af0
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %esi
callq 0x48af0
movl -0x5c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)