// File: /workspace/github_c_makefile_star2_O1/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 0x1b109
movq %rdi, %rbx
incl 0x46a67(%rip)           # 0x618f0
movb $0x1, 0x97(%rdi)
movq 0x60(%rdi), %rdi
callq 0x20159
movl (%rbx), %eax
addl $-0x15, %eax
cmpl $0x5, %eax
ja 0x1afc3
leaq 0x1ac06(%rip), %rcx     # 0x35ab4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x0, 0x46a1a(%rip)     # 0x618d8
jne 0x1aece
cmpq $0x0, 0x88(%rbx)
je 0x1b193
leaq 0x88(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x188e1
jmp 0x1afc3
incl 0x469ef(%rip)           # 0x618d8
cmpq $0x0, 0x78(%rbx)
je 0x1afaa
xorl %r14d, %r14d
movq 0x88(%rbx), %rax
movq (%rax,%r14,8), %rax
cmpq $0x0, 0x20(%rax)
jne 0x1af0d
movq %rbx, 0x20(%rax)
movq 0x88(%rbx), %rax
movq (%rax,%r14,8), %rax
movq 0x20(%rax), %rdi
callq 0x196c0
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 0x1af6c
callq 0x1ae68
movq 0x88(%rbx), %rax
movq (%rax,%r14,8), %rax
movq 0x28(%rax), %rdi
callq 0x196c0
movq 0x88(%rbx), %rcx
movq (%rcx,%r14,8), %rcx
movq %rax, 0x28(%rcx)
incq %r14
cmpq 0x78(%rbx), %r14
jb 0x1aef7
jmp 0x1afaa
incl 0x4695b(%rip)           # 0x618d8
cmpq $0x0, 0x78(%rbx)
je 0x1afaa
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x88(%rbx), %rdi
addq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x188e1
incq %r15
addq $0x8, %r14
cmpq 0x78(%rbx), %r15
jb 0x1af8a
decl 0x46928(%rip)           # 0x618d8
jmp 0x1afc3
movq %rbx, %rdi
callq 0x21297
testq %rax, %rax
je 0x1b17e
cmpq $0x0, 0x20(%rbx)
je 0x1b0a4
xorl %r15d, %r15d
leaq 0x47220(%rip), %r12     # 0x621f8
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rax
cmpq $0x0, 0x8(%rax)
je 0x1b097
xorl %r13d, %r13d
callq 0x20037
movq 0x18(%rbx), %rcx
movq (%rcx,%r15,8), %rcx
movq (%rcx), %rcx
movq (%rcx,%r13,8), %rsi
movq %rax, %rdi
callq 0x20669
testq %rax, %rax
je 0x1b118
movq %rax, %r14
cmpq $0x0, 0x80(%rbx)
jne 0x1b02c
callq 0x2d63c
movq %rax, 0x80(%rbx)
movq 0x80(%rbx), %rdi
movslq (%r14), %rsi
callq 0x2d816
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 0x1e773
testl %eax, %eax
je 0x1b06f
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rax
movq 0x18(%rax), %rax
movq %rax, 0x28(%rbx)
movq 0x10(%r14), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%r15,8), %rcx
movq (%rcx), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rax
cmpq 0x8(%rax), %r13
jb 0x1afee
incq %r15
cmpq 0x20(%rbx), %r15
jb 0x1afd8
cmpq $0x0, 0x70(%rbx)
je 0x1b0d9
xorl %r14d, %r14d
movq 0x68(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x196c0
movq 0x68(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
movq 0x68(%rbx), %rax
movq (%rax,%r14,8), %rdi
cmpq %rbx, %rdi
je 0x1b141
incq %r14
cmpq 0x70(%rbx), %r14
jb 0x1b0ae
callq 0x2d63c
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1b54d
movl %eax, %ebp
movq %r14, %rdi
callq 0x2d664
testl %ebp, %ebp
jne 0x1b169
movq 0x60(%rbx), %rdi
callq 0x201a4
decl 0x467e7(%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 0x19a6f
movq 0x8(%rbx), %rdi
leaq 0x1b105(%rip), %rsi     # 0x3623c
movq %rax, %rdx
xorl %eax, %eax
callq 0x13b8e
callq 0x23e44
movq %rax, %r14
movq %rbx, %rdi
callq 0x23e44
movq 0x8(%rbx), %rdi
leaq 0x1b0f8(%rip), %rsi     # 0x36254
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x13b8e
movq %rbx, %rdi
callq 0x23e44
movq 0x8(%rbx), %rdi
leaq 0x1b107(%rip), %rsi     # 0x36283
jmp 0x1b137
movq %rbx, %rdi
callq 0x23e44
movq 0x8(%rbx), %rdi
leaq 0x1b079(%rip), %rsi     # 0x3620a
jmp 0x1b137
movq 0x8(%rbx), %rdi
leaq 0x1b047(%rip), %rsi     # 0x361e5
xorl %eax, %eax
callq 0x13b8e