// File: /workspace/github_c_makefile_star2_O3/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 0x12421
testq %r15, %r15
je 0x12d3a
movq %rax, %r14
movq (%rbx), %rdi
addq %rdi, %r14
cmpq $0x11, %r14
jb 0x12b2f
movabsq $0x300000003, %rax      # imm = 0x300000003
movq %rax, (%r12)
jmp 0x12cb1
movl (%r15), %eax
cmpq $0x1f, %rax
ja 0x12c9b
movq %rdi, %r13
shrq $0x3, %r13
leaq 0x1fd2e(%rip), %rcx     # 0x32878
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x2, (%r12,%r13,4)
jmp 0x12c9b
movl (%r12,%r13,4), %eax
testl %eax, %eax
je 0x12d30
cmpl $0x1, %eax
je 0x12c9b
cmpl $0x2, %eax
je 0x12c35
movl $0x3, %eax
jmp 0x12c3a
movl (%r12), %ecx
cmpl $0x3, %ecx
je 0x12ba4
movl $0x3, %eax
cmpl $0x2, %ecx
jne 0x12ba0
movl $0x2, %eax
movl %eax, (%r12)
movl 0x4(%r12), %ecx
cmpl $0x3, %ecx
je 0x12c9b
movl $0x3, %eax
cmpl $0x2, %ecx
jne 0x12bc1
movl $0x2, %eax
movl %eax, 0x4(%r12)
jmp 0x12c9b
cmpq $0x0, 0x78(%r15)
je 0x12c90
xorl %ebp, %ebp
movq 0x88(%r15), %rax
movq (%rax,%rbp,8), %rdi
callq 0x1e31c
movq %rax, %r13
movq (%rbx), %rdi
movq %rax, %rsi
callq 0xec3c
movq %rax, (%rbx)
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x12aeb
incq %rbp
cmpq 0x78(%r15), %rbp
jb 0x12bd8
jmp 0x12c8d
movq %r15, %rdi
callq 0x227e7
testl %eax, %eax
jne 0x12b53
movl (%r12,%r13,4), %ecx
cmpl $0x3, %ecx
je 0x12c9b
movl $0x3, %eax
cmpl $0x2, %ecx
jne 0x12c3a
movl $0x2, %eax
movl %eax, (%r12,%r13,4)
jmp 0x12c9b
movq 0x68(%r15), %rax
movq (%rax), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x12aeb
jmp 0x12c9b
cmpq $0x0, 0x70(%r15)
je 0x12c90
xorl %r13d, %r13d
movq (%rbx), %rdi
movq 0x68(%r15), %rax
movq (%rax,%r13,8), %rsi
callq 0xec3c
movq %rax, (%rbx)
movq 0x68(%r15), %rax
movq (%rax,%r13,8), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x12aeb
incq %r13
cmpq 0x70(%r15), %r13
jb 0x12c5e
movq (%rbx), %rdi
movq %r15, %rsi
callq 0xec3c
movq %rax, (%rbx)
movq %r15, %rdi
callq 0x12677
movq %r14, %rdi
movq %rax, %rsi
callq 0x2e217
movq %rax, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x88(%r15), %rdi
testq %rdi, %rdi
je 0x12c9b
movl $0x1, %esi
callq 0x144db
movq %rax, 0x88(%r15)
movq %rax, %rdi
callq 0x1d422
cmpl $0x35, %eax
jne 0x12d48
movq 0x88(%r15), %rax
movq 0x50(%rax), %rax
movq (%rax), %rax
cmpq $0x0, 0x30(%rax)
je 0x12c9b
xorl %r13d, %r13d
movq 0x68(%r15), %rax
movq (%rax), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x12aeb
incq %r13
movq 0x88(%r15), %rax
movq 0x50(%rax), %rax
movq (%rax), %rax
cmpq 0x30(%rax), %r13
jb 0x12d02
jmp 0x12c9b
movl $0x1, %eax
jmp 0x12c3a
leaq 0x1fda3(%rip), %rdi     # 0x32ae4
xorl %eax, %eax
callq 0x13844
leaq 0x1fc7d(%rip), %rdi     # 0x329cc
leaq 0x1fc06(%rip), %rsi     # 0x3295c
leaq 0x1fd9f(%rip), %rcx     # 0x32afc
movl $0x20c, %edx            # imm = 0x20C
callq 0x4180
nop