// File: /workspace/github_c_makefile_star2_O1/oridb[P]mc/6/typeinfo.c
// Function: tydescsub
Blob *
tydescsub(Type *ty)
{
	Blob **sub, *sz, *bt, *b;
	size_t i, nsub;
	char buf[512];
	uint8_t tt;
	Node *len;
	int isextern;

	sub = NULL;
	nsub = 0;
	/* names are pulled out of line */
	tt = ty->type;
	/* tyvars can get tagged, but aren't desired */
	if (ty->type == Tyvar)
		return NULL;

	ty = tydedup(ty);
	if (ty->type == Tyname)
		tt |= Tdindirect;
	sz = mkblobi(Btimin, 0);
	bt = mkblobi(Bti8, tt);
	lappend(&sub, &nsub, bt);
	switch (ty->type) {
	case Ntypes: case Tyvar: case Tybad: case Typaram:
	case Tygeneric: case Tycode: case Tyunres:
		die("invalid type in tydesc");
		break;

		/* atomic types -- nothing else to do */
	case Tyvoid: case Tychar: case Tybool: case Tyint8:
	case Tyint16: case Tyint: case Tyint32: case Tyint64:
	case Tybyte: case Tyuint8: case Tyuint16:
	case Tyuint: case Tyuint32: case Tyuint64:
	case Tyflt32: case Tyflt64: case Tyvalist:
		break;

	case Typtr:
		lappend(&sub, &nsub, tydescsub(ty->sub[0]));
		break;
	case Tyslice:
		lappend(&sub, &nsub, tydescsub(ty->sub[0]));
		break;
	case Tyarray:
		encodetypeinfo(&sub, &nsub, ty);
		ty->asize = fold(ty->asize, 1);
		len = ty->asize;
		if (len) {
			assert(len->type == Nexpr);
			len = len->expr.args[0];
			assert(len->type == Nlit && len->lit.littype == Lint);
			lappend(&sub, &nsub, mkblobi(Btimin, len->lit.intval));
		} else {
			lappend(&sub, &nsub, mkblobi(Btimin, 0));
		}

		lappend(&sub, &nsub, tydescsub(ty->sub[0]));
		break;
	case Tyfunc:
		lappend(&sub, &nsub, mkblobi(Btimin, ty->nsub));
		for (i = 0; i < ty->nsub; i++)
			lappend(&sub, &nsub, tydescsub(ty->sub[i]));
		break;
	case Tytuple:
		encodetypeinfo(&sub, &nsub, ty);
		lappend(&sub, &nsub, mkblobi(Btimin, ty->nsub));
		for (i = 0; i < ty->nsub; i++)
			lappend(&sub, &nsub, tydescsub(ty->sub[i]));
		break;
	case Tystruct:
		encodetypeinfo(&sub, &nsub, ty);
		lappend(&sub, &nsub, mkblobi(Btimin, ty->nmemb));
		for (i = 0; i < ty->nmemb; i++)
			structmemb(&sub, &nsub, ty->sdecls[i]);
		break;
	case Tyunion:
		encodetypeinfo(&sub, &nsub, ty);
		lappend(&sub, &nsub, mkblobi(Btimin, ty->nmemb));
		for (i = 0; i < ty->nmemb; i++)
			unionmemb(&sub, &nsub, ty->udecls[i]);
		break;
	case Tyname:
		i = bprintf(buf, sizeof buf, "%s", Symprefix);
		tydescid(buf + i, sizeof buf - i, ty);
		isextern = ty->isimport || ty->vis != Visintern;
		lappend(&sub, &nsub, mkblobref(buf, 0, isextern));
		break;
	}
	b = mkblobseq(sub, nsub);
	sz->ival = blobsz(b);
	linsert(&b->seq.sub, &b->seq.nsub, 0, sz);
	return b;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
xorl %r14d, %r14d
movq %r14, 0x8(%rsp)
movq %r14, (%rsp)
movl (%rdi), %ebx
cmpl $0x19, %ebx
je 0x123d5
callq 0x22cec
movq %rax, %r14
movl %ebx, %ebp
orl $0x80, %ebp
cmpl $0x1c, (%rax)
cmovnel %ebx, %ebp
movl $0x4, %edi
xorl %esi, %esi
callq 0x49bc
movq %rax, %rbx
movzbl %bpl, %esi
xorl %edi, %edi
callq 0x49bc
leaq 0x8(%rsp), %rdi
movq %rsp, %rsi
movq %rax, %rdx
callq 0x2d3ff
movl (%r14), %eax
cmpq $0x1f, %rax
ja 0x123a3
leaq 0x206b8(%rip), %rcx     # 0x32754
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x70(%r14), %rsi
movl $0x4, %edi
callq 0x49bc
leaq 0x8(%rsp), %rdi
movq %rsp, %rsi
movq %rax, %rdx
callq 0x2d3ff
cmpq $0x0, 0x70(%r14)
je 0x123a3
xorl %r13d, %r13d
leaq 0x8(%rsp), %r15
movq %rsp, %r12
movq 0x68(%r14), %rax
movq (%rax,%r13,8), %rdi
callq 0x12020
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x2d3ff
incq %r13
cmpq 0x70(%r14), %r13
jb 0x120d9
jmp 0x123a3
leaq 0x8(%rsp), %r15
movq %rsp, %r12
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x12436
movq 0x78(%r14), %rsi
movl $0x4, %edi
callq 0x49bc
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x2d3ff
cmpq $0x0, 0x78(%r14)
je 0x123a3
xorl %r13d, %r13d
leaq 0x8(%rsp), %r15
movq %rsp, %r12
movq 0x88(%r14), %rax
movq (%rax,%r13,8), %rbp
movq 0x18(%rbp), %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x11f4a
movq 0x28(%rbp), %rdi
testq %rdi, %rdi
je 0x12174
callq 0x12020
jmp 0x1219a
movl $0x1, %esi
movl $0x4, %edi
callq 0x49bc
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x2d3ff
xorl %edi, %edi
xorl %esi, %esi
callq 0x49bc
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x2d3ff
incq %r13
cmpq 0x78(%r14), %r13
jb 0x1214a
jmp 0x123a3
leaq 0x8(%rsp), %r15
movq %rsp, %r12
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x12436
movq 0x78(%r14), %rsi
movl $0x4, %edi
callq 0x49bc
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x2d3ff
cmpq $0x0, 0x78(%r14)
je 0x123a3
xorl %r13d, %r13d
leaq 0x8(%rsp), %r15
movq %rsp, %r12
movq 0x88(%r14), %rax
movq (%rax,%r13,8), %rbp
movq 0x20(%rbp), %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x11f4a
movq 0x28(%rbp), %rdi
callq 0x12020
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x2d3ff
incq %r13
cmpq 0x78(%r14), %r13
jb 0x121fe
jmp 0x123a3
leaq 0x8(%rsp), %rdi
movq %rsp, %rsi
movq %r14, %rdx
callq 0x12436
movq 0x88(%r14), %rdi
movl $0x1, %esi
callq 0x14703
movq %rax, 0x88(%r14)
testq %rax, %rax
je 0x1236b
cmpl $0x8, 0x8(%rax)
jne 0x12417
movq 0x50(%rax), %rax
movq (%rax), %rax
cmpl $0x9, 0x8(%rax)
jne 0x123f8
cmpl $0x2, 0x18(%rax)
jne 0x123f8
movq 0x30(%rax), %rsi
jmp 0x1236d
leaq 0x2481a(%rip), %rdx     # 0x36abd
leaq 0x1fb90(%rip), %rcx     # 0x31e3a
leaq 0x10(%rsp), %rdi
movl $0x200, %r15d           # imm = 0x200
movl $0x200, %esi            # imm = 0x200
xorl %eax, %eax
callq 0x2e42e
leaq (%rsp,%rax), %rdi
addq $0x10, %rdi
subq %rax, %r15
movq %r15, %rsi
movq %r14, %rdx
callq 0x5855
movl $0x1, %edx
cmpb $0x0, 0x94(%r14)
jne 0x122f0
xorl %edx, %edx
cmpl $0x0, 0x10(%r14)
setne %dl
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x4a49
jmp 0x12393
leaq 0x8(%rsp), %r15
movq %rsp, %r12
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x12436
movq 0x70(%r14), %rsi
movl $0x4, %edi
callq 0x49bc
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x2d3ff
cmpq $0x0, 0x70(%r14)
je 0x123a3
xorl %r13d, %r13d
leaq 0x8(%rsp), %r15
movq %rsp, %r12
movq 0x68(%r14), %rax
movq (%rax,%r13,8), %rdi
callq 0x12020
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x2d3ff
incq %r13
cmpq 0x70(%r14), %r13
jb 0x12345
jmp 0x123a3
xorl %esi, %esi
movl $0x4, %edi
callq 0x49bc
leaq 0x8(%rsp), %rdi
movq %rsp, %rsi
movq %rax, %rdx
callq 0x2d3ff
movq 0x68(%r14), %rax
movq (%rax), %rdi
callq 0x12020
leaq 0x8(%rsp), %rdi
movq %rsp, %rsi
movq %rax, %rdx
callq 0x2d3ff
movq 0x8(%rsp), %rdi
movq (%rsp), %rsi
callq 0x4a1f
movq %rax, %r14
movq %rax, %rdi
callq 0x11e80
movq %rax, 0x20(%rbx)
leaq 0x20(%r14), %rsi
movq %r14, %rdi
addq $0x28, %rdi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x2d46a
movq %r14, %rax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x20531(%rip), %rdi     # 0x32922
xorl %eax, %eax
callq 0x13a00
leaq 0x20570(%rip), %rdi     # 0x3296f
leaq 0x20546(%rip), %rsi     # 0x3294c
leaq 0x2054a(%rip), %rcx     # 0x32957
movl $0x9c, %edx
callq 0x4180
leaq 0x2051b(%rip), %rdi     # 0x32939
leaq 0x20527(%rip), %rsi     # 0x3294c
leaq 0x2052b(%rip), %rcx     # 0x32957
movl $0x9a, %edx
callq 0x4180