// File: /workspace/github_c_makefile_star2_O3/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
testq %rdi, %rdi
je 0x12637
movq %rdi, %rbx
movl $0x1, %r12d
leaq 0x203a1(%rip), %r15     # 0x327e4
xorl %r14d, %r14d
movl (%rbx), %eax
cmpq $0x1f, %rax
ja 0x125ec
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movq 0x68(%rbx), %rax
movq (%rax), %rbx
testq %rbx, %rbx
jne 0x12446
jmp 0x12637
movq 0x88(%rbx), %rdi
testq %rdi, %rdi
je 0x1260d
movl $0x1, %esi
callq 0x144db
movq %rax, 0x88(%rbx)
movq %rax, %rdi
callq 0x1d422
cmpl $0x35, %eax
jne 0x12645
movq 0x68(%rbx), %rax
movq 0x88(%rbx), %rcx
movq 0x50(%rcx), %rcx
movq (%rcx), %rcx
movq (%rax), %rbx
imulq 0x30(%rcx), %r12
jmp 0x12462
movl $0x4, %r14d
jmp 0x1260d
movl $0x8, %r14d
jmp 0x1260d
movl $0x1, %r14d
jmp 0x1260d
movl $0x2, %r14d
jmp 0x1260d
movl $0x10, %r14d
jmp 0x1260d
cmpq $0x0, 0x78(%rbx)
je 0x125f5
xorl %r13d, %r13d
xorl %r14d, %r14d
movq 0x88(%rbx), %rax
movq (%rax,%r13,8), %rdi
callq 0x1e31c
movq %r14, %rdi
movq %rax, %rsi
callq 0xec3c
movq %rax, %r15
movq 0x88(%rbx), %rax
movq (%rax,%r13,8), %rax
xorl %ecx, %ecx
cmpl $0x8, 0x8(%rax)
setne %cl
movq 0x20(%rax,%rcx,8), %rdi
callq 0x12421
movq %rax, %r14
addq %r15, %r14
incq %r13
cmpq 0x78(%rbx), %r13
jb 0x12502
jmp 0x125f8
movq 0x78(%rbx), %rax
movl $0x4, %r14d
testq %rax, %rax
je 0x12598
xorl %r15d, %r15d
movq 0x88(%rbx), %rcx
movq (%rcx,%r15,8), %rcx
movq 0x28(%rcx), %rdi
testq %rdi, %rdi
je 0x12590
callq 0x12421
leaq 0x4(%rax), %rsi
movq %r14, %rdi
callq 0x2e201
movq %rax, %r14
movq 0x78(%rbx), %rax
incq %r15
cmpq %rax, %r15
jb 0x12564
movq %rbx, %rdi
callq 0x12677
movq %r14, %rdi
movq %rax, %rsi
callq 0x2e217
jmp 0x1260a
cmpq $0x0, 0x70(%rbx)
je 0x125fd
xorl %r15d, %r15d
xorl %eax, %eax
movq 0x68(%rbx), %rcx
movq (%rcx,%r15,8), %rsi
movq %rax, %rdi
callq 0xec3c
movq %rax, %r14
movq 0x68(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x12421
addq %r14, %rax
incq %r15
cmpq 0x70(%rbx), %r15
jb 0x125b9
jmp 0x125ff
xorl %r14d, %r14d
jmp 0x1260d
movq $-0x1, %r14
jmp 0x1260d
xorl %r14d, %r14d
movq %r14, %rdi
jmp 0x12602
xorl %eax, %eax
movq %rax, %rdi
movq %rbx, %rsi
callq 0xec3c
movq %rax, %r14
imulq %r12, %r14
movq %r14, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rbx, %rdi
callq 0x2398e
leaq 0x203ce(%rip), %rdi     # 0x329fb
movq %rax, %rsi
xorl %eax, %eax
callq 0x13844
leaq 0x2036f(%rip), %rdi     # 0x329ad
xorl %eax, %eax
callq 0x13844
leaq 0x20380(%rip), %rdi     # 0x329cc
leaq 0x20309(%rip), %rsi     # 0x3295c
leaq 0x2038b(%rip), %rcx     # 0x329e5
movl $0x120, %edx            # imm = 0x120
callq 0x4180