// File: /workspace/github_c_makefile_star2_O2/oridb[P]mc/parse/infer.c
// Function: tyresolve
static void
tyresolve(Type *t)
{
	size_t i, j;
	Trait *tr;

	if (t->resolved)
		return;
	/* type resolution should never throw errors about non-generic
	 * showing up within a generic type, so we push and pop a generic
	 * around resolution */
	ingeneric++;
	t->resolved = 1;
	/* Walk through aggregate type members */
	pushenv(t->env);
	switch (t->type) {
	case Tystruct:
		inaggr++;
		for (i = 0; i < t->nmemb; i++)
			infernode(&t->sdecls[i], NULL, NULL);
		inaggr--;
		break;
	case Tyunion:
		inaggr++;
		for (i = 0; i < t->nmemb; i++) {
			if (!t->udecls[i]->utype)
				t->udecls[i]->utype = t;
			t->udecls[i]->utype = tf(t->udecls[i]->utype);
			if (t->udecls[i]->etype) {
				tyresolve(t->udecls[i]->etype);
				t->udecls[i]->etype = tf(t->udecls[i]->etype);
			}
		}
		inaggr--;
		break;
	case Tyarray:
		if (!inaggr && !t->asize)
			lfatal(t->loc, "unsized array type outside of struct");
		infernode(&t->asize, NULL, NULL);
		break;
	case Typaram:
		if (!boundtype(t))
			lfatal(t->loc, "type parameter %s is undefined in generic context", tystr(t));
		break;
	default:
		break;
	}

	for (i = 0; i < t->nspec; i++) {
		for (j = 0; j < t->spec[i]->ntrait; j++) {
			tr = gettrait(curstab(), t->spec[i]->trait[j]);
			if (!tr)
				lfatal(t->loc, "trait %s does not exist", ctxstr(t->spec[i]->trait[j]));
			if (!t->trneed)
				t->trneed = mkbs();
			bsput(t->trneed, tr->uid);
			if (nameeq(t->spec[i]->trait[j], traittab[Tciter]->name))
				t->seqaux = t->spec[i]->aux;
			t->spec[i]->trait[j] = tr->name;
		}
	}

	for (i = 0; i < t->nsub; i++) {
		t->sub[i] = tf(t->sub[i]);
		if (t->sub[i] == t) {
			lfatal(t->loc,
			     "%s occurs within %s, leading to infinite type\n",
			     tystr(t->sub[i]), tystr(t));
		}
	}
	if (occurs(t))
		lfatal(t->loc, "type %s includes itself", tystr(t));
	popenv(t->env);
	ingeneric--;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpb $0x0, 0x97(%rdi)
jne 0x19584
movq %rdi, %rbx
incl 0x455ec(%rip)           # 0x5e8f0
movb $0x1, 0x97(%rdi)
movq 0x60(%rdi), %rdi
callq 0x1d970
movl (%rbx), %eax
addl $-0x15, %eax
cmpl $0x5, %eax
ja 0x19437
leaq 0x1876b(%rip), %rcx     # 0x31a94
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x0, 0x4559f(%rip)     # 0x5e8d8
jne 0x19349
cmpq $0x0, 0x88(%rbx)
je 0x195e6
leaq 0x88(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x16e0d
jmp 0x19437
incl 0x45574(%rip)           # 0x5e8d8
xorl %r14d, %r14d
cmpq 0x78(%rbx), %r14
jae 0x1941e
movq 0x88(%rbx), %rax
movq (%rax,%r14,8), %rax
movq 0x20(%rax), %rdi
testq %rdi, %rdi
jne 0x19398
movq %rbx, 0x20(%rax)
movq 0x88(%rbx), %rax
movq (%rax,%r14,8), %rax
movq 0x20(%rax), %rdi
callq 0x17d99
movq 0x88(%rbx), %rcx
movq (%rcx,%r14,8), %rcx
movq %rax, 0x20(%rcx)
movq 0x88(%rbx), %rax
movq (%rax,%r14,8), %rax
movq 0x28(%rax), %rdi
testq %rdi, %rdi
je 0x193e8
callq 0x192e3
movq 0x88(%rbx), %rax
movq (%rax,%r14,8), %rax
movq 0x28(%rax), %rdi
callq 0x17d99
movq 0x88(%rbx), %rcx
movq (%rcx,%r14,8), %rcx
movq %rax, 0x28(%rcx)
incq %r14
jmp 0x19367
incl 0x454e2(%rip)           # 0x5e8d8
xorl %r14d, %r14d
xorl %r15d, %r15d
cmpq 0x78(%rbx), %r15
jae 0x1941e
movq 0x88(%rbx), %rdi
addq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x16e0d
incq %r15
addq $0x8, %r14
jmp 0x193fc
decl 0x454b4(%rip)           # 0x5e8d8
jmp 0x19437
movq %rbx, %rdi
callq 0x1e938
testq %rax, %rax
je 0x195d1
xorl %r15d, %r15d
leaq 0x45db7(%rip), %r12     # 0x5f1f8
cmpq 0x20(%rbx), %r15
jae 0x194fe
xorl %r13d, %r13d
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rax
cmpq 0x8(%rax), %r13
jae 0x194f6
callq 0x1d859
movq 0x18(%rbx), %rcx
movq (%rcx,%r15,8), %rcx
movq (%rcx), %rcx
movq (%rcx,%r13,8), %rsi
movq %rax, %rdi
callq 0x1de33
testq %rax, %rax
je 0x19593
movq %rax, %r14
movq 0x80(%rbx), %rdi
testq %rdi, %rdi
jne 0x194a3
callq 0x29d3c
movq %rax, %rdi
movq %rax, 0x80(%rbx)
movslq (%r14), %rsi
callq 0x29ed5
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rax
movq (%rax), %rax
movq (%rax,%r13,8), %rdi
movq (%r12), %rax
movq 0x30(%rax), %rax
movq 0x10(%rax), %rsi
callq 0x1c100
movq 0x18(%rbx), %rcx
testl %eax, %eax
je 0x194df
movq (%rcx,%r15,8), %rax
movq 0x18(%rax), %rax
movq %rax, 0x28(%rbx)
movq 0x10(%r14), %rax
movq (%rcx,%r15,8), %rcx
movq (%rcx), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
jmp 0x1944e
incq %r15
jmp 0x19441
xorl %r14d, %r14d
cmpq 0x70(%rbx), %r14
jae 0x19554
movq 0x68(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x17d99
movq 0x68(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
movq 0x68(%rbx), %rax
movq (%rax,%r14,8), %rdi
incq %r14
cmpq %rbx, %rdi
jne 0x19501
callq 0x21009
movq %rax, %r14
movq %rbx, %rdi
callq 0x21009
movq 0x8(%rbx), %rdi
leaq 0x18ced(%rip), %rsi     # 0x32234
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x121e4
callq 0x29d3c
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x19974
movl %eax, %ebp
movq %r14, %rdi
callq 0x29d60
testl %ebp, %ebp
jne 0x195bc
movq 0x60(%rbx), %rdi
callq 0x1d9bb
decl 0x4536c(%rip)           # 0x5e8f0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rax
movq (%rax), %rax
movq (%rax,%r13,8), %rdi
callq 0x17f9e
movq 0x8(%rbx), %rdi
leaq 0x18c6a(%rip), %rsi     # 0x3221c
movq %rax, %rdx
xorl %eax, %eax
callq 0x121e4
movq %rbx, %rdi
callq 0x21009
movq 0x8(%rbx), %rdi
leaq 0x18c94(%rip), %rsi     # 0x32263
jmp 0x195b2
movq %rbx, %rdi
callq 0x21009
movq 0x8(%rbx), %rdi
leaq 0x18c06(%rip), %rsi     # 0x321ea
jmp 0x195b2
movq 0x8(%rbx), %rdi
leaq 0x18bd4(%rip), %rsi     # 0x321c5
xorl %eax, %eax
callq 0x121e4