// File: /workspace/github_c_makefile_star2_O0/michaelforney[P]cproc/qbe.c
// Function: emittype
static void
emittype(struct type *t)
{
	static unsigned id;
	struct member *m, *other;
	struct type *sub;
	unsigned long long off;

	if (t->value || t->kind != TYPESTRUCT && t->kind != TYPEUNION)
		return;
	t->value = xmalloc(sizeof(*t->value));
	t->value->kind = VALUE_TYPE;
	t->value->u.name = t->u.structunion.tag;
	t->value->id = ++id;
	for (m = t->u.structunion.members; m; m = m->next) {
		for (sub = m->type; sub->kind == TYPEARRAY; sub = sub->base)
			;
		emittype(sub);
	}
	fputs("type ", stdout);
	emitname(t->value);
	if (t == targ->typevalist) {
		printf(" = align %d { %llu }\n", t->align, t->size);
		return;
	}
	fputs(" = { ", stdout);
	for (m = t->u.structunion.members, off = 0; m;) {
		if (t->kind == TYPESTRUCT) {
			/* look for a subsequent member with a larger storage unit */
			for (other = m->next; other; other = other->next) {
				if (other->offset >= ALIGNUP(m->offset + 1, 8))
					break;
				if (other->offset <= m->offset)
					m = other;
			}
			off = m->offset + m->type->size;
		} else {
			fputs("{ ", stdout);
		}
		for (sub = m->type; sub->kind == TYPEARRAY; sub = sub->base)
			;
		emitclass(qbetype(sub).data, sub->value);
		if (m->type->size > sub->size)
			printf(" %llu", m->type->size / sub->size);
		if (t->kind == TYPESTRUCT) {
			fputs(", ", stdout);
			/* skip subsequent members contained within the same storage unit */
			do m = m->next;
			while (m && m->offset < off);
		} else {
			fputs(" } ", stdout);
			m = m->next;
		}
	}
	puts("}");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x12f69
movq -0x8(%rbp), %rax
cmpl $0xf, (%rax)
je 0x12f6e
movq -0x8(%rbp), %rax
cmpl $0x10, (%rax)
je 0x12f6e
jmp 0x1324f
movl $0x10, %edi
callq 0x127c0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl $0x6, (%rax)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rcx, 0x8(%rax)
movl 0xf23d(%rip), %ecx      # 0x221e8
addl $0x1, %ecx
movl %ecx, 0xf234(%rip)      # 0x221e8
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1300e
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpl $0xd, (%rax)
jne 0x12ff7
jmp 0x12fe9
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x12fde
movq -0x20(%rbp), %rdi
callq 0x12f40
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x12fcb
movq 0xdfbb(%rip), %rax      # 0x20fd0
movq (%rax), %rsi
leaq 0x9748(%rip), %rdi      # 0x1c767
callq 0x3100
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x164a0
movq -0x8(%rbp), %rax
leaq 0xf164(%rip), %rcx      # 0x221a0
movq (%rcx), %rcx
cmpq 0x8(%rcx), %rax
jne 0x13067
movq -0x8(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x9712(%rip), %rdi      # 0x1c76d
movb $0x0, %al
callq 0x30c0
jmp 0x1324f
movq 0xdf62(%rip), %rax      # 0x20fd0
movq (%rax), %rsi
leaq 0x970b(%rip), %rdi      # 0x1c783
callq 0x3100
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x10(%rbp)
movq $0x0, -0x28(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x13243
movq -0x8(%rbp), %rax
cmpl $0xf, (%rax)
jne 0x13123
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x13109
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
addq $0x1, %rcx
addq $0x8, %rcx
subq $0x1, %rcx
andq $-0x8, %rcx
cmpq %rcx, %rax
jb 0x130df
jmp 0x13109
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x18(%rcx), %rax
ja 0x130f9
movq -0x18(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0x130fb
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x130b1
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
addq 0x10(%rcx), %rax
movq %rax, -0x28(%rbp)
jmp 0x13139
movq 0xdea6(%rip), %rax      # 0x20fd0
movq (%rax), %rsi
leaq 0x9652(%rip), %rdi      # 0x1c786
callq 0x3100
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpl $0xd, (%rax)
jne 0x1315e
jmp 0x13150
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x13145
movq -0x20(%rbp), %rdi
callq 0x158f0
movl %edx, -0x40(%rbp)
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x34(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x2c(%rbp)
movsbl -0x33(%rbp), %edi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x16450
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jbe 0x131ca
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rcx
xorl %edx, %edx
divq 0x10(%rcx)
movq %rax, %rsi
leaq 0x5607(%rip), %rdi      # 0x187ca
movb $0x0, %al
callq 0x30c0
movq -0x8(%rbp), %rax
cmpl $0xf, (%rax)
jne 0x1321c
movq 0xddf6(%rip), %rax      # 0x20fd0
movq (%rax), %rsi
leaq 0x912a(%rip), %rdi      # 0x1c30e
callq 0x3100
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x10(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x10(%rbp)
movb %al, -0x49(%rbp)
je 0x13213
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
cmpq -0x28(%rbp), %rax
setb %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x131e9
jmp 0x1323e
movq 0xddad(%rip), %rax      # 0x20fd0
movq (%rax), %rsi
leaq 0x955c(%rip), %rdi      # 0x1c789
callq 0x3100
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x13091
leaq 0x878c(%rip), %rdi      # 0x1b9d6
callq 0x3060
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)