// File: /workspace/github_c_makefile_star2_O3/oridb[P]mc/parse/infer.c
// Function: tyfix
static Type *
tyfix(Node *ctx, Type *orig, int noerr)
{
	static Type *tyint, *tyflt;
	static Bitset *intset, *fltset;
	Type *t, *d, *base;
	Tyenv *env;
	vlong val;
	size_t i;
	char buf[1024];

	if (!tyint) {
		tyint = mktype(Zloc, Tyint);
		intset = mkbs();
		traitsfor(tyint, intset);
	}
	if (!tyflt) {
		tyflt = mktype(Zloc, Tyflt64);
		fltset = mkbs();
		traitsfor(tyflt, fltset);
	}

	t = tysearch(tf(orig));
	env = t->env;
	if (env)
		pushenv(env);
	base = orig->seqaux;
	/* Process delayed type mappings. */
	if (orig->type == Tyvar && hthas(delayed, orig)) {
		d = htget(delayed, orig);
		if (t->type == Tyvar) {
			/* tyvar is guaranteed to unify error-free */
			unify(ctx, t, d);
			t = tf(t);
		} else if (tybase(t)->type != d->type && !noerr) {
			fatal(ctx, "type %s not compatible with %s near %s\n",
			    tystr(t), tystr(d), ctxstr(ctx));
		}
	}

	/* Default the type */
	if (t->type == Tyvar && t->trneed) {
		if (bsissubset(t->trneed, intset))
			t = tyint;
		else if (bsissubset(t->trneed, fltset))
			t = tyflt;
	}

	if (!t->fixed) {
		t->fixed = 1;
		switch(t->type) {
		case Tyarray:
			if (t->type == Tyarray && t->asize)
				t->asize = fold(t->asize, 1);
			if (t->asize && getintlit(t->asize, &val) && val < 0)
				fatal(t->asize, "negative array size %lld\n", val);
			typesub(t->asize, noerr);
			break;
		case Tystruct:
			inaggr++;
			for (i = 0; i < t->nmemb; i++)
				typesub(t->sdecls[i], noerr);
			inaggr--;
			break;
		case Tyunion:
			for (i = 0; i < t->nmemb; i++) {
				if (t->udecls[i]->etype) {
					tyresolve(t->udecls[i]->etype);
					t->udecls[i]->etype =
						tyfix(ctx, t->udecls[i]->etype, noerr);
				}
			}
			break;
		case Tyname:
			for (i = 0; i < t->narg; i++)
				t->arg[i] = tyfix(ctx, t->arg[i], noerr);
			break;
		default:
			break;
		}
	}

	for (i = 0; i < t->nsub; i++)
		t->sub[i] = tyfix(ctx, t->sub[i], noerr);

	if (t->type == Tyvar && !noerr)
		fatal(ctx, "underconstrained type %s near %s", tyfmt(buf, 1024, t), ctxstr(ctx));
	if (base) {
		if (base != orig)
			base = tyfix(ctx, base, noerr);
		t->seqaux = base;
	}
	if (env)
		popenv(env);
	return t;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
cmpq $0x0, 0x479f8(%rip)     # 0x618b8
jne 0x19ef3
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x6, %esi
callq 0x2289d
movq %rax, 0x479e0(%rip)     # 0x618b8
callq 0x2d13c
movq %rax, 0x479e4(%rip)     # 0x618c8
movq 0x479cd(%rip), %rdi     # 0x618b8
movq %rax, %rsi
callq 0x1a29f
cmpq $0x0, 0x479c5(%rip)     # 0x618c0
jne 0x19f2e
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x10, %esi
callq 0x2289d
movq %rax, 0x479ad(%rip)     # 0x618c0
callq 0x2d13c
movq %rax, 0x479b1(%rip)     # 0x618d0
movq 0x4799a(%rip), %rdi     # 0x618c0
movq %rax, %rsi
callq 0x1a29f
movq %r14, %rdi
callq 0x19640
testq %rax, %rax
je 0x19f56
leaq 0x4828e(%rip), %rcx     # 0x621d0
movq (%rcx), %rcx
movq %rax, %r15
movl 0x4(%rax), %eax
movq (%rcx,%rax,8), %rax
testq %rax, %rax
jne 0x19f45
jmp 0x19f59
xorl %r15d, %r15d
movq 0x60(%r15), %r12
testq %r12, %r12
je 0x19f6a
movq %r12, %rdi
callq 0x1ff19
movq 0x28(%r14), %r13
cmpl $0x19, (%r14)
jne 0x19fd7
movq 0x47825(%rip), %rdi     # 0x617a0
movq %r14, %rsi
callq 0x2da24
testl %eax, %eax
je 0x19fd7
movq 0x47812(%rip), %rdi     # 0x617a0
movq %r14, %rsi
callq 0x2d8fa
cmpl $0x19, (%r15)
jne 0x19fb7
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x1a38c
movq %r15, %rdi
callq 0x19640
movq %rax, %r15
jmp 0x19fd7
movq %rax, 0x8(%rsp)
movq %r15, %rdi
callq 0x227ac
testl %ebp, %ebp
jne 0x19fd7
movq 0x8(%rsp), %rdx
movl (%rdx), %ecx
cmpl %ecx, (%rax)
jne 0x1a264
cmpl $0x19, (%r15)
movq %r12, 0x10(%rsp)
jne 0x1a025
movq 0x80(%r15), %rdi
testq %rdi, %rdi
je 0x1a025
movq 0x478d3(%rip), %rsi     # 0x618c8
callq 0x2d62f
testl %eax, %eax
je 0x1a007
movq 0x478b3(%rip), %r15     # 0x618b8
jmp 0x1a025
movq 0x80(%r15), %rdi
movq 0x478bb(%rip), %rsi     # 0x618d0
callq 0x2d62f
testl %eax, %eax
je 0x1a025
movq 0x4789b(%rip), %r15     # 0x618c0
cmpb $0x0, 0x98(%r15)
je 0x1a0b3
cmpq $0x0, 0x70(%r15)
je 0x1a060
xorl %r12d, %r12d
movq 0x68(%r15), %rax
movq (%rax,%r12,8), %rsi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x19e9f
movq 0x68(%r15), %rcx
movq %rax, (%rcx,%r12,8)
incq %r12
cmpq 0x70(%r15), %r12
jb 0x1a03d
testl %ebp, %ebp
jne 0x1a06e
cmpl $0x19, (%r15)
je 0x1a230
testq %r13, %r13
movq 0x10(%rsp), %r12
je 0x1a091
cmpq %r14, %r13
je 0x1a08d
movq %rbx, %rdi
movq %r13, %rsi
movl %ebp, %edx
callq 0x19e9f
movq %rax, %r13
movq %r13, 0x28(%r15)
testq %r12, %r12
je 0x1a09e
movq %r12, %rdi
callq 0x1ff64
movq %r15, %rax
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, 0x98(%r15)
movl (%r15), %eax
addl $-0x15, %eax
cmpl $0x7, %eax
ja 0x1a033
leaq 0x1b9d3(%rip), %rcx     # 0x35aa4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x88(%r15), %rdi
testq %rdi, %rdi
je 0x1a222
movl $0x1, %esi
callq 0x144db
movq %rax, 0x88(%r15)
testq %rax, %rax
je 0x1a222
leaq 0x18(%rsp), %r12
movq %rax, %rdi
movq %r12, %rsi
callq 0x14410
testl %eax, %eax
setne %al
movq (%r12), %rdx
testq %rdx, %rdx
sets %cl
andb %al, %cl
movq 0x88(%r15), %rdi
cmpb $0x1, %cl
jne 0x1a224
leaq 0x1bead(%rip), %rsi     # 0x35fe9
xorl %eax, %eax
callq 0x138e7
movq 0x78(%r15), %rax
testq %rax, %rax
je 0x1a033
xorl %r12d, %r12d
movq 0x88(%r15), %rcx
movq (%rcx,%r12,8), %rcx
movq 0x28(%rcx), %rdi
testq %rdi, %rdi
je 0x1a198
callq 0x1ac8d
movq 0x88(%r15), %rax
movq (%rax,%r12,8), %rax
movq 0x28(%rax), %rsi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x19e9f
movq 0x88(%r15), %rcx
movq (%rcx,%r12,8), %rcx
movq %rax, 0x28(%rcx)
movq 0x78(%r15), %rax
incq %r12
cmpq %rax, %r12
jb 0x1a153
jmp 0x1a033
movl 0x4772d(%rip), %eax     # 0x618d8
leal 0x1(%rax), %ecx
movl %ecx, 0x47724(%rip)     # 0x618d8
cmpq $0x0, 0x78(%r15)
je 0x1a1e1
xorl %r12d, %r12d
movq 0x88(%r15), %rax
movq (%rax,%r12,8), %rdi
movl %ebp, %esi
callq 0x1907f
incq %r12
cmpq 0x78(%r15), %r12
jb 0x1a1be
movl 0x476f9(%rip), %eax     # 0x618d8
decl %eax
movl %eax, 0x476f1(%rip)     # 0x618d8
jmp 0x1a033
cmpq $0x0, 0x48(%r15)
je 0x1a033
xorl %r12d, %r12d
movq 0x40(%r15), %rax
movq (%rax,%r12,8), %rsi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x19e9f
movq 0x40(%r15), %rcx
movq %rax, (%rcx,%r12,8)
incq %r12
cmpq 0x48(%r15), %r12
jb 0x1a1fa
jmp 0x1a033
xorl %edi, %edi
movl %ebp, %esi
callq 0x1907f
jmp 0x1a033
leaq 0x20(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %r15, %rdx
callq 0x23321
movq %rax, %r14
movq %rbx, %rdi
callq 0x19858
leaq 0x1bdaf(%rip), %rsi     # 0x36003
movq %rbx, %rdi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x138e7
movq %r15, %rdi
movq %rdx, %r15
callq 0x2398e
movq %rax, %r14
movq %r15, %rdi
callq 0x2398e
movq %rax, %r15
movq %rbx, %rdi
callq 0x19858
leaq 0x1bd35(%rip), %rsi     # 0x35fc1
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x138e7