// File: /workspace/github_c_makefile_star2_O3/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 0x1af49
movq %rdi, %rbx
incl 0x46c42(%rip)           # 0x618f0
movb $0x1, 0x97(%rdi)
movq 0x60(%rdi), %rdi
callq 0x1ff19
movl (%rbx), %eax
addl $-0x15, %eax
cmpl $0x5, %eax
ja 0x1ae04
leaq 0x1adf1(%rip), %rcx     # 0x35ac4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x0, 0x46bf5(%rip)     # 0x618d8
jne 0x1acf3
cmpq $0x0, 0x88(%rbx)
je 0x1afd3
leaq 0x88(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x187ee
jmp 0x1ae04
movl 0x46bca(%rip), %eax     # 0x618d8
leal 0x1(%rax), %ecx
movl %ecx, 0x46bc1(%rip)     # 0x618d8
cmpq $0x0, 0x78(%rbx)
je 0x1adeb
xorl %r14d, %r14d
movq 0x88(%rbx), %rax
movq (%rax,%r14,8), %rax
movq 0x20(%rax), %rdi
testq %rdi, %rdi
jne 0x1ad4c
movq %rbx, 0x20(%rax)
movq 0x88(%rbx), %rax
movq (%rax,%r14,8), %rax
movq 0x20(%rax), %rdi
callq 0x19640
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 0x1ad9c
callq 0x1ac8d
movq 0x88(%rbx), %rax
movq (%rax,%r14,8), %rax
movq 0x28(%rax), %rdi
callq 0x19640
movq 0x88(%rbx), %rcx
movq (%rcx,%r14,8), %rcx
movq %rax, 0x28(%rcx)
incq %r14
cmpq 0x78(%rbx), %r14
jb 0x1ad25
jmp 0x1ade3
movl 0x46b2b(%rip), %eax     # 0x618d8
leal 0x1(%rax), %ecx
movl %ecx, 0x46b22(%rip)     # 0x618d8
cmpq $0x0, 0x78(%rbx)
je 0x1adeb
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x88(%rbx), %rdi
addq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x187ee
incq %r15
addq $0x8, %r14
cmpq 0x78(%rbx), %r15
jb 0x1adc3
movl 0x46aef(%rip), %eax     # 0x618d8
decl %eax
movl %eax, 0x46ae7(%rip)     # 0x618d8
jmp 0x1ae04
movq %rbx, %rdi
callq 0x21019
testq %rax, %rax
je 0x1afbe
movq 0x20(%rbx), %rcx
testq %rcx, %rcx
je 0x1aee4
movq 0x18(%rbx), %rax
xorl %r15d, %r15d
leaq 0x473d9(%rip), %r12     # 0x621f8
movq (%rax,%r15,8), %rdx
cmpq $0x0, 0x8(%rdx)
je 0x1aed8
xorl %r13d, %r13d
callq 0x1fdf7
movq 0x18(%rbx), %rcx
movq (%rcx,%r15,8), %rcx
movq (%rcx), %rcx
movq (%rcx,%r13,8), %rsi
movq %rax, %rdi
callq 0x20429
testq %rax, %rax
je 0x1af58
movq %rax, %r14
movq 0x80(%rbx), %rdi
testq %rdi, %rdi
jne 0x1ae74
callq 0x2d13c
movq %rax, %rdi
movq %rax, 0x80(%rbx)
movslq (%r14), %rsi
callq 0x2d369
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 0x1e523
movq 0x18(%rbx), %rcx
testl %eax, %eax
je 0x1aeb0
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
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rcx
cmpq 0x8(%rcx), %r13
jb 0x1ae31
movq 0x20(%rbx), %rcx
incq %r15
cmpq %rcx, %r15
jb 0x1ae1f
cmpq $0x0, 0x70(%rbx)
je 0x1af19
movq 0x68(%rbx), %rax
xorl %r14d, %r14d
movq (%rax,%r14,8), %rdi
callq 0x19640
movq 0x68(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
movq 0x68(%rbx), %rax
movq (%rax,%r14,8), %rdi
cmpq %rbx, %rdi
je 0x1af81
incq %r14
cmpq 0x70(%rbx), %r14
jb 0x1aef2
callq 0x2d13c
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1b37e
movl %eax, %ebp
movq %r14, %rdi
callq 0x2d164
testl %ebp, %ebp
jne 0x1afa9
movq 0x60(%rbx), %rdi
callq 0x1ff64
decl 0x469a7(%rip)           # 0x618f0
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 0x19858
movq 0x8(%rbx), %rdi
leaq 0x1b2d5(%rip), %rsi     # 0x3624c
movq %rax, %rdx
xorl %eax, %eax
callq 0x139d2
callq 0x2398e
movq %rax, %r14
movq %rbx, %rdi
callq 0x2398e
movq 0x8(%rbx), %rdi
leaq 0x1b2c8(%rip), %rsi     # 0x36264
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x139d2
movq %rbx, %rdi
callq 0x2398e
movq 0x8(%rbx), %rdi
leaq 0x1b2d7(%rip), %rsi     # 0x36293
jmp 0x1af77
movq %rbx, %rdi
callq 0x2398e
movq 0x8(%rbx), %rdi
leaq 0x1b249(%rip), %rsi     # 0x3621a
jmp 0x1af77
movq 0x8(%rbx), %rdi
leaq 0x1b217(%rip), %rsi     # 0x361f5
xorl %eax, %eax
callq 0x139d2