// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
pushq $0x1
popq %r12
leaq 0x1da37(%rip), %r15     # 0x2e7b4
xorl %r14d, %r14d
pushq $0x1
popq %rbp
testq %rbx, %rbx
je 0x10f27
movl (%rbx), %eax
cmpq $0x1f, %rax
ja 0x10ef4
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movq 0x68(%rbx), %rax
movq (%rax), %rbx
jmp 0x10d83
movq 0x88(%rbx), %rdi
testq %rdi, %rdi
je 0x10ef8
movl %ebp, %esi
callq 0x12bd3
movq %rax, 0x88(%rbx)
movq %rax, %rdi
callq 0x1b5e6
cmpl $0x35, %eax
jne 0x10f35
movq 0x68(%rbx), %rax
movq 0x88(%rbx), %rcx
movq 0x50(%rcx), %rcx
movq (%rcx), %rcx
movq (%rax), %rbx
imulq 0x30(%rcx), %r12
jmp 0x10d83
pushq $0x8
jmp 0x10ef6
pushq $0x4
jmp 0x10ef6
pushq $0x1
jmp 0x10ef6
pushq $0x10
jmp 0x10ef6
pushq $0x2
jmp 0x10ef6
xorl %r14d, %r14d
xorl %r13d, %r13d
cmpq 0x78(%rbx), %r13
jae 0x10e5d
movq 0x88(%rbx), %rax
movq (%rax,%r13,8), %rdi
callq 0x1bf2d
movq %r14, %rdi
movq %rax, %rsi
callq 0xd890
movq %rax, %r15
movq 0x88(%rbx), %rax
movq (%rax,%r13,8), %rdi
callq 0x10f54
movq %rax, %r14
addq %r15, %r14
incq %r13
jmp 0x10e1e
movq %r14, %rdi
movq %rbx, %rsi
callq 0xd890
jmp 0x10eb7
pushq $0x4
popq %r14
xorl %r15d, %r15d
cmpq 0x78(%rbx), %r15
jae 0x10ea4
movq 0x88(%rbx), %rax
movq (%rax,%r15,8), %rax
movq 0x28(%rax), %rdi
testq %rdi, %rdi
je 0x10e9f
callq 0x10d64
leaq 0x4(%rax), %rsi
movq %r14, %rdi
callq 0x2abfd
movq %rax, %r14
incq %r15
jmp 0x10e71
movq %rbx, %rdi
callq 0x10f67
movq %r14, %rdi
movq %rax, %rsi
callq 0x2ac13
movq %rax, %r14
jmp 0x10ef8
xorl %r14d, %r14d
jmp 0x10ef8
xorl %edi, %edi
xorl %r15d, %r15d
cmpq 0x70(%rbx), %r15
jae 0x10e60
movq 0x68(%rbx), %rax
movq (%rax,%r15,8), %rsi
callq 0xd890
movq %rax, %r14
movq 0x68(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x10d64
movq %rax, %rdi
addq %r14, %rdi
incq %r15
jmp 0x10ec6
pushq $-0x1
popq %r14
imulq %r12, %r14
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x21009
leaq 0x1daae(%rip), %rdi     # 0x2e9cb
movq %rax, %rsi
xorl %eax, %eax
callq 0x1205c
leaq 0x1da4f(%rip), %rdi     # 0x2e97d
xorl %eax, %eax
callq 0x1205c
leaq 0x1da60(%rip), %rdi     # 0x2e99c
leaq 0x1d9e9(%rip), %rsi     # 0x2e92c
leaq 0x1da6b(%rip), %rcx     # 0x2e9b5
movl $0x120, %edx            # imm = 0x120
callq 0x4180