// File: /workspace/github_c_makefile_star2_O2/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 $0x228, %rsp            # imm = 0x228
andq $0x0, 0x10(%rsp)
andq $0x0, 0x8(%rsp)
movl (%rdi), %ebx
cmpl $0x19, %ebx
jne 0x10807
xorl %r14d, %r14d
jmp 0x10b5c
callq 0x1fd76
movq %rax, %r14
movl %ebx, %ebp
orl $0x80, %ebp
cmpl $0x1c, (%rax)
cmovnel %ebx, %ebp
pushq $0x4
popq %rdi
xorl %esi, %esi
callq 0x449c
movq %rax, 0x18(%rsp)
movzbl %bpl, %esi
xorl %edi, %edi
callq 0x449c
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movq %rax, %rdx
callq 0x29b2d
movl (%r14), %eax
cmpq $0x1f, %rax
ja 0x10b27
leaq 0x1ded7(%rip), %rcx     # 0x2e734
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x70(%r14), %rsi
pushq $0x4
popq %rdi
callq 0x449c
leaq 0x10(%rsp), %r15
leaq 0x8(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x29b2d
xorl %ebx, %ebx
cmpq 0x70(%r14), %rbx
jae 0x10b27
movq 0x68(%r14), %rax
movq (%rax,%rbx,8), %rdi
callq 0x107db
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x29b2d
incq %rbx
jmp 0x1088c
leaq 0x10(%rsp), %r15
leaq 0x8(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x10bbd
movq 0x78(%r14), %rsi
pushq $0x4
popq %rdi
callq 0x449c
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x29b2d
xorl %ebx, %ebx
pushq $0x1
popq %r13
cmpq 0x78(%r14), %rbx
jae 0x10b27
movq 0x88(%r14), %rax
movq (%rax,%rbx,8), %rbp
movq 0x18(%rbp), %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x10707
movq 0x28(%rbp), %rdi
testq %rdi, %rdi
je 0x10922
callq 0x107db
jmp 0x10944
pushq $0x4
popq %rdi
movq %r13, %rsi
callq 0x449c
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x29b2d
xorl %edi, %edi
xorl %esi, %esi
callq 0x449c
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x29b2d
incq %rbx
jmp 0x108ee
leaq 0x10(%rsp), %r15
leaq 0x8(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x10bbd
movq 0x78(%r14), %rsi
pushq $0x4
popq %rdi
callq 0x449c
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x29b2d
xorl %ebx, %ebx
cmpq 0x78(%r14), %rbx
jae 0x10b27
movq 0x88(%r14), %rax
movq (%rax,%rbx,8), %r13
movq 0x20(%r13), %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x10707
movq 0x28(%r13), %rdi
callq 0x107db
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x29b2d
incq %rbx
jmp 0x1098b
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movq %r14, %rdx
callq 0x10bbd
movq 0x88(%r14), %rdi
pushq $0x1
popq %rsi
callq 0x12bd3
movq %rax, 0x88(%r14)
testq %rax, %rax
je 0x10ad5
cmpl $0x8, 0x8(%rax)
jne 0x10b9e
movq 0x50(%rax), %rax
movq (%rax), %rax
cmpl $0x9, 0x8(%rax)
jne 0x10b7f
cmpl $0x2, 0x18(%rax)
jne 0x10b7f
movq 0x30(%rax), %rsi
jmp 0x10ad7
leaq 0x2206c(%rip), %rdx     # 0x32a9d
leaq 0x1d412(%rip), %rcx     # 0x2de4a
leaq 0x20(%rsp), %rdi
movl $0x200, %r15d           # imm = 0x200
movl $0x200, %esi            # imm = 0x200
xorl %eax, %eax
callq 0x2a9bf
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
subq %rax, %r15
movq %r15, %rsi
movq %r14, %rdx
callq 0x5125
cmpb $0x0, 0x94(%r14)
je 0x10aff
pushq $0x1
popq %rdx
jmp 0x10b09
leaq 0x10(%rsp), %r15
leaq 0x8(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x10bbd
movq 0x70(%r14), %rsi
pushq $0x4
popq %rdi
callq 0x449c
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x29b2d
xorl %ebx, %ebx
cmpq 0x70(%r14), %rbx
jae 0x10b27
movq 0x68(%r14), %rax
movq (%rax,%rbx,8), %rdi
callq 0x107db
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x29b2d
incq %rbx
jmp 0x10aaf
xorl %esi, %esi
pushq $0x4
popq %rdi
callq 0x449c
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movq %rax, %rdx
callq 0x29b2d
movq 0x68(%r14), %rax
movq (%rax), %rdi
callq 0x107db
jmp 0x10b15
xorl %edx, %edx
cmpl $0x0, 0x10(%r14)
setne %dl
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0x4521
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movq %rax, %rdx
callq 0x29b2d
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x44f9
movq %rax, %r14
movq %rax, %rdi
callq 0x10658
movq 0x18(%rsp), %rcx
movq %rax, 0x20(%rcx)
leaq 0x20(%r14), %rsi
movq %r14, %rdi
addq $0x28, %rdi
xorl %edx, %edx
callq 0x29b98
movq %r14, %rax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1dd8a(%rip), %rdi     # 0x2e902
xorl %eax, %eax
callq 0x1205c
leaq 0x1ddc9(%rip), %rdi     # 0x2e94f
leaq 0x1dd9f(%rip), %rsi     # 0x2e92c
leaq 0x1dda3(%rip), %rcx     # 0x2e937
movl $0x9c, %edx
callq 0x4180
leaq 0x1dd74(%rip), %rdi     # 0x2e919
leaq 0x1dd80(%rip), %rsi     # 0x2e92c
leaq 0x1dd84(%rip), %rcx     # 0x2e937
movl $0x9a, %edx
callq 0x4180