// File: /workspace/github_c_makefile_star2_O2/oridb[P]mc/6/typeinfo.c
// Function: classify_recursive
static void
classify_recursive(Type *t, PassIn *p, size_t *total_offset)
{
	size_t i = 0, sz = tysize(t);
	size_t cur_offset = *total_offset;
	PassIn *cur = 0;

	if (!t)
		die("cannot pass empty type.");
	if (cur_offset + sz > 16) {
		p[0] = PassInMemory;
		p[1] = PassInMemory;
		return;
	}
	cur = &p[cur_offset / 8];

	switch(t->type) {
	case Tyvoid: break;
	case Tybool:
	case Tybyte:
	case Tychar:
	case Tyint:
	case Tyint16:
	case Tyint32:
	case Tyint64:
	case Tyint8:
	case Typtr:
	case Tyuint:
	case Tyuint16:
	case Tyuint32:
	case Tyuint64:
	case Tyuint8:
		join_classification(cur, PassInInt);
		break;
	case Tyslice:
		/* Slices are too myrddin-specific, they go on the stack. */
		join_classification(&p[0], PassInMemory);
		join_classification(&p[1], PassInMemory);
		break;
	case Tyflt32:
	case Tyflt64:
		join_classification(cur, PassInSSE);
		break;
	case Tyname:
		classify_recursive(t->sub[0], p, total_offset);
		break;
	case Tybad:
	case Tycode:
	case Tyfunc:
	case Tygeneric:
	case Typaram:
	case Tyunres:
	case Tyvalist:
	case Tyvar:
	case Ntypes:
		/* We shouldn't even be in this function */
		join_classification(cur, PassInMemory);
		break;
	case Tytuple:
		for (i = 0; i < t->nsub; ++i) {
			*total_offset = alignto(*total_offset, t->sub[i]);
			classify_recursive(t->sub[i], p, total_offset);
		}
		*total_offset = alignto(*total_offset, t);
		break;
	case Tystruct:
		for (i = 0; i < t->nmemb; ++i) {
			Type *fieldt = decltype(t->sdecls[i]);
			*total_offset = alignto(*total_offset, fieldt);
			classify_recursive(fieldt, p, total_offset);
		}
		*total_offset = alignto(*total_offset, t);
		break;
	case Tyunion:
		/*
		 * General enums are too complicated to interop with C, which is the only
		 * reason for anything other than PassInMemory.
		 */
		if (isenum(t))
			join_classification(cur, PassInInt);
		else
			join_classification(cur, PassInMemory);
		break;
	case Tyarray:
		if (t->asize) {
			t->asize = fold(t->asize, 1);
			assert(exprop(t->asize) == Olit);
			for (i = 0; i < t->asize->expr.args[0]->lit.intval; ++i) {
				classify_recursive(t->sub[0], p, total_offset);
			}
		}
	}

	*total_offset = align(cur_offset + sz, tyalign(t));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r15
callq 0x10d64
testq %r15, %r15
je 0x11590
movq %rax, %r14
movq (%rbx), %r13
addq %r13, %r14
cmpq $0x11, %r14
jb 0x113bd
movabsq $0x300000003, %rax      # imm = 0x300000003
movq %rax, (%r12)
jmp 0x114ad
movl (%r15), %eax
cmpq $0x1f, %rax
ja 0x11497
shrq $0x3, %r13
leaq 0x1d473(%rip), %rcx     # 0x2e848
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x2, (%r12,%r13,4)
jmp 0x11497
movl (%r12,%r13,4), %eax
testl %eax, %eax
je 0x1155e
cmpl $0x1, %eax
jne 0x11487
jmp 0x11497
movl (%r12), %eax
cmpl $0x3, %eax
je 0x1156c
cmpl $0x2, %eax
jne 0x11565
pushq $0x2
jmp 0x11567
xorl %ebp, %ebp
cmpq 0x78(%r15), %rbp
jae 0x1145e
movq 0x88(%r15), %rax
movq (%rax,%rbp,8), %rdi
callq 0x1bf2d
movq %rax, %r13
movq (%rbx), %rdi
movq %rax, %rsi
callq 0xd890
movq %rax, (%rbx)
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x11379
incq %rbp
jmp 0x11424
movq (%rbx), %rdi
movq %r15, %rsi
callq 0xd890
movq %rax, (%rbx)
jmp 0x11497
movq %r15, %rdi
callq 0x1fd13
testl %eax, %eax
jne 0x113de
movl (%r12,%r13,4), %eax
cmpl $0x3, %eax
je 0x11497
cmpl $0x2, %eax
jne 0x11490
pushq $0x2
jmp 0x11492
pushq $0x3
popq %rax
movl %eax, (%r12,%r13,4)
movq %r15, %rdi
callq 0x10f67
movq %r14, %rdi
movq %rax, %rsi
callq 0x2ac13
movq %rax, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x68(%r15), %rax
movq (%rax), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x11379
jmp 0x11497
xorl %r13d, %r13d
movq (%rbx), %rdi
cmpq 0x70(%r15), %r13
jae 0x11461
movq 0x68(%r15), %rax
movq (%rax,%r13,8), %rsi
callq 0xd890
movq %rax, (%rbx)
movq 0x68(%r15), %rax
movq (%rax,%r13,8), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x11379
incq %r13
jmp 0x114d3
movq 0x88(%r15), %rdi
testq %rdi, %rdi
je 0x11497
pushq $0x1
popq %rsi
callq 0x12bd3
movq %rax, 0x88(%r15)
movq %rax, %rdi
callq 0x1b5e6
cmpl $0x35, %eax
jne 0x1159e
xorl %r13d, %r13d
movq 0x88(%r15), %rax
movq 0x50(%rax), %rax
movq (%rax), %rax
cmpq 0x30(%rax), %r13
jae 0x11497
movq 0x68(%r15), %rax
movq (%rax), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x11379
incq %r13
jmp 0x1152f
pushq $0x1
jmp 0x11492
pushq $0x3
popq %rax
movl %eax, (%r12)
movl 0x4(%r12), %eax
cmpl $0x3, %eax
je 0x11497
cmpl $0x2, %eax
jne 0x11583
pushq $0x2
jmp 0x11585
pushq $0x3
popq %rax
movl %eax, 0x4(%r12)
jmp 0x11497
leaq 0x1d51d(%rip), %rdi     # 0x2eab4
xorl %eax, %eax
callq 0x1205c
leaq 0x1d3f7(%rip), %rdi     # 0x2e99c
leaq 0x1d380(%rip), %rsi     # 0x2e92c
leaq 0x1d519(%rip), %rcx     # 0x2eacc
movl $0x20c, %edx            # imm = 0x20C
callq 0x4180
nopl (%rax)