// File: /workspace/github_c_makefile_star2_O1/oridb[P]mc/6/typeinfo.c
// Function: tysize
size_t
tysize(Type *t)
{
	size_t sz;
	size_t i;

	sz = 0;
	if (!t)
		die("size of empty type => bailing.");
	switch (t->type) {
	case Tyvoid:
		return 0;
	case Tybool: case Tyint8:
	case Tybyte: case Tyuint8:
		return 1;
	case Tyint16: case Tyuint16:
		return 2;
	case Tyint: case Tyint32:
	case Tyuint: case Tyuint32:
	case Tychar:  /* utf32 */
		return 4;

	case Typtr:
	case Tyvalist: /* ptr to first element of valist */
		return Ptrsz;

	case Tyint64:
	case Tyuint64:
		return 8;

		/*end integer types*/
	case Tyflt32:
		return 4;
	case Tyflt64:
		return 8;

	case Tycode:
		return Ptrsz;
	case Tyfunc:
		return 2*Ptrsz;
	case Tyslice:
		return 2*Ptrsz; /* len; ptr */
	case Tyname:
		return tysize(t->sub[0]);
	case Tyarray:
		if (!t->asize)
			return 0;
		t->asize = fold(t->asize, 1);
		assert(exprop(t->asize) == Olit);
		return t->asize->expr.args[0]->lit.intval * tysize(t->sub[0]);
	case Tytuple:
		for (i = 0; i < t->nsub; i++) {
			sz = alignto(sz, t->sub[i]);
			sz += tysize(t->sub[i]);
		}
		sz = alignto(sz, t);
		return sz;
		break;
	case Tystruct:
		for (i = 0; i < t->nmemb; i++) {
			sz = alignto(sz, decltype(t->sdecls[i]));
			sz += size(t->sdecls[i]);
		}
		sz = alignto(sz, t);
		return sz;
		break;
	case Tyunion:
		sz = Wordsz;
		for (i = 0; i < t->nmemb; i++)
			if (t->udecls[i]->etype)
				sz = max(sz, tysize(t->udecls[i]->etype) + Wordsz);
		return align(sz, tyalign(t));
		break;
	case Tygeneric: case Tybad: case Tyvar:
	case Typaram: case Tyunres: case Ntypes:
		die("Type %s does not have size; why did it get down to here?", tystr(t));
		break;
	}
	return -1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %r14
movl $0x1, %ebx
xorl %r15d, %r15d
leaq 0x201dc(%rip), %r12     # 0x327d4
testq %r14, %r14
je 0x127ed
movl (%r14), %eax
cmpq $0x1f, %rax
ja 0x12787
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movq 0x68(%r14), %rax
movq (%rax), %r14
jmp 0x125f8
movq 0x88(%r14), %rdi
testq %rdi, %rdi
je 0x127c3
movl $0x1, %esi
callq 0x14703
movq %rax, 0x88(%r14)
movq %rax, %rdi
callq 0x1d672
cmpl $0x35, %eax
jne 0x127fb
movq 0x68(%r14), %rax
movq 0x88(%r14), %rcx
movq 0x50(%rcx), %rcx
movq (%rcx), %rcx
movq (%rax), %r14
imulq 0x30(%rcx), %rbx
jmp 0x125f8
movl $0x8, %r15d
jmp 0x127c3
movl $0x4, %r15d
jmp 0x127c3
movl $0x1, %r15d
jmp 0x127c3
movl $0x10, %r15d
jmp 0x127c3
movl $0x2, %r15d
jmp 0x127c3
cmpq $0x0, 0x78(%r14)
je 0x12790
xorl %r13d, %r13d
xorl %r15d, %r15d
movq 0x88(%r14), %rax
movq (%rax,%r13,8), %rdi
callq 0x1e56c
movq %r15, %rdi
movq %rax, %rsi
callq 0xee68
movq %rax, %r12
movq 0x88(%r14), %rax
movq (%rax,%r13,8), %rax
xorl %ecx, %ecx
cmpl $0x8, 0x8(%rax)
setne %cl
movq 0x20(%rax,%rcx,8), %rdi
callq 0x125dd
movq %rax, %r15
addq %r12, %r15
incq %r13
cmpq 0x78(%r14), %r13
jb 0x126b6
jmp 0x12793
cmpq $0x0, 0x78(%r14)
je 0x12798
movl $0x4, %r15d
xorl %r12d, %r12d
movq 0x88(%r14), %rax
movq (%rax,%r12,8), %rax
movq 0x28(%rax), %rdi
testq %rdi, %rdi
je 0x12742
callq 0x125dd
leaq 0x4(%rax), %rsi
movq %r15, %rdi
callq 0x2e681
movq %rax, %r15
incq %r12
cmpq 0x78(%r14), %r12
jb 0x1271a
jmp 0x1279e
cmpq $0x0, 0x70(%r14)
je 0x127b3
xorl %r12d, %r12d
xorl %eax, %eax
movq 0x68(%r14), %rcx
movq (%rcx,%r12,8), %rsi
movq %rax, %rdi
callq 0xee68
movq %rax, %r15
movq 0x68(%r14), %rax
movq (%rax,%r12,8), %rdi
callq 0x125dd
addq %r15, %rax
incq %r12
cmpq 0x70(%r14), %r12
jb 0x12759
jmp 0x127b5
movq $-0x1, %r15
jmp 0x127c3
xorl %r15d, %r15d
movq %r15, %rdi
jmp 0x127b8
movl $0x4, %r15d
movq %r14, %rdi
callq 0x1282d
movq %r15, %rdi
movq %rax, %rsi
callq 0x2e697
jmp 0x127c0
xorl %eax, %eax
movq %rax, %rdi
movq %r14, %rsi
callq 0xee68
movq %rax, %r15
imulq %r15, %rbx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %r14, %rdi
callq 0x23e44
leaq 0x20208(%rip), %rdi     # 0x329eb
movq %rax, %rsi
xorl %eax, %eax
callq 0x13a00
leaq 0x201a9(%rip), %rdi     # 0x3299d
xorl %eax, %eax
callq 0x13a00
leaq 0x201ba(%rip), %rdi     # 0x329bc
leaq 0x20143(%rip), %rsi     # 0x3294c
leaq 0x201c5(%rip), %rcx     # 0x329d5
movl $0x120, %edx            # imm = 0x120
callq 0x4180