// File: /workspace/github_c_makefile_star2_O0/michaelforney[P]cproc/init.c
// Function: parseinit
struct init *
parseinit(struct scope *s, struct type *t)
{
	struct initparser p;
	struct expr *expr;
	struct type *base;
	struct bitfield bits;

	p.cur = NULL;
	p.sub = p.obj;
	p.sub->offset = 0;
	p.sub->type = t;
	p.sub->iscur = false;
	p.init = NULL;
	p.last = &p.init;
	if (t->incomplete && t->kind != TYPEARRAY)
		error(&tok.loc, "initializer specified for incomplete type");
	if (t->kind == TYPEARRAY && t->base->size == 0)
		error(&tok.loc, "initializer specified for variable length array type");
	for (;;) {
		if (p.cur) {
			if (tok.kind == TLBRACK || tok.kind == TPERIOD)
				designator(s, &p);
			else if (p.sub != p.cur)
				advance(&p);
			else if (p.cur->type->kind == TYPESTRUCT || p.cur->type->kind == TYPEUNION)
				focus(&p);
		}
		if (consume(TLBRACE)) {
			if (consume(TRBRACE)){
				if (p.sub->type->incomplete)
					error(&tok.loc, "array of unknown size has empty initializer");
				goto next;
			}
			if (p.cur == p.sub) {
				if (p.cur->type->prop & PROPSCALAR)
					error(&tok.loc, "nested braces around scalar initializer");
				assert(p.cur->type->kind == TYPEARRAY);
				focus(&p);
			}
			p.cur = p.sub;
			p.cur->iscur = true;
			continue;
		}
		expr = assignexpr(s);
		for (;;) {
			t = p.sub->type;
			switch (t->kind) {
			case TYPEARRAY:
				if (!expr->decayed || expr->base->kind != EXPRSTRING || !(t->base->prop & PROPINT))
					break;
				base = t->base;
				expr = expr->base;
				if (!(base->prop & PROPCHAR && expr->type->base->prop & PROPCHAR) && !typecompatible(base, expr->type->base))
					error(&tok.loc, "cannot initialize array with string literal of different width");
				if (t->incomplete)
					t->size = expr->type->size;
				goto add;
			case TYPESTRUCT:
			case TYPEUNION:
				if (typecompatible(expr->type, t))
					goto add;
				break;
			default:  /* scalar type */
				assert(t->prop & PROPSCALAR);
				expr = exprassign(expr, t);
				goto add;
			}
			focus(&p);
		}
	add:
		if (p.sub > p.obj && (p.sub[-1].type->kind == TYPESTRUCT || p.sub[-1].type->kind == TYPEUNION))
			bits = p.sub[-1].u.mem->bits;
		else
			bits = (struct bitfield){0};
		initadd(&p, mkinit(p.sub->offset, p.sub->offset + p.sub->type->size, bits, expr));
		for (;;) {
			if (p.sub->type->incomplete)
				p.sub->type->incomplete = false;
		next:
			if (!p.cur)
				return p.init;
			if (tok.kind == TCOMMA) {
				next();
				if (tok.kind != TRBRACE)
					break;
			} else if (tok.kind != TRBRACE) {
				error(&tok.loc, "expected ',' or '}' after initializer");
			}
			next();
			p.sub = p.cur;
			do p.cur = p.cur == p.obj ? NULL : p.cur - 1;
			while (p.cur && !p.cur->iscur);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x460, %rsp            # imm = 0x460
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x30(%rbp)
leaq -0x430(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rax
movb $0x0, 0x18(%rax)
movq $0x0, -0x20(%rbp)
leaq -0x430(%rbp), %rax
addq $0x410, %rax            # imm = 0x410
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
testb $0x1, 0x3c(%rax)
je 0xbf6a
movq -0x10(%rbp), %rax
cmpl $0xd, (%rax)
je 0xbf6a
leaq 0x16250(%rip), %rdi     # 0x221a8
addq $0x8, %rdi
leaq 0xe8d3(%rip), %rsi      # 0x1a836
movb $0x0, %al
callq 0x11190
movq -0x10(%rbp), %rax
cmpl $0xd, (%rax)
jne 0xbf9b
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
cmpq $0x0, 0x10(%rax)
jne 0xbf9b
leaq 0x1621f(%rip), %rdi     # 0x221a8
addq $0x8, %rdi
leaq 0xe8cc(%rip), %rsi      # 0x1a860
movb $0x0, %al
callq 0x11190
jmp 0xbf9d
cmpq $0x0, -0x30(%rbp)
je 0xc012
leaq 0x161fd(%rip), %rax     # 0x221a8
cmpl $0x40, (%rax)
je 0xbfbc
leaq 0x161f1(%rip), %rax     # 0x221a8
cmpl $0x46, (%rax)
jne 0xbfce
movq -0x8(%rbp), %rdi
leaq -0x430(%rbp), %rsi
callq 0xc410
jmp 0xc010
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
je 0xbfe6
leaq -0x430(%rbp), %rdi
callq 0xc620
jmp 0xc00e
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0xf, (%rax)
je 0xc000
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x10, (%rax)
jne 0xc00c
leaq -0x430(%rbp), %rdi
callq 0xc7a0
jmp 0xc00e
jmp 0xc010
jmp 0xc012
movl $0x44, %edi
callq 0xd910
testb $0x1, %al
jne 0xc025
jmp 0xc0e6
movl $0x45, %edi
callq 0xd910
testb $0x1, %al
jne 0xc035
jmp 0xc061
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
testb $0x1, 0x3c(%rax)
je 0xc05c
leaq 0x1615e(%rip), %rdi     # 0x221a8
addq $0x8, %rdi
leaq 0xe840(%rip), %rsi      # 0x1a895
movb $0x0, %al
callq 0x11190
jmp 0xc333
movq -0x30(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0xc0d1
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x4(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0xc097
leaq 0x16123(%rip), %rdi     # 0x221a8
addq $0x8, %rdi
leaq 0xe831(%rip), %rsi      # 0x1a8c1
movb $0x0, %al
callq 0x11190
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0xd, (%rax)
jne 0xc0a6
jmp 0xc0c5
leaq 0xe83c(%rip), %rdi      # 0x1a8e9
leaq 0xe854(%rip), %rsi      # 0x1a908
movl $0xe7, %edx
leaq 0xe84f(%rip), %rcx      # 0x1a90f
callq 0x30f0
leaq -0x430(%rbp), %rdi
callq 0xc7a0
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movb $0x1, 0x18(%rax)
jmp 0xbf9d
movq -0x8(%rbp), %rdi
callq 0x9170
movq %rax, -0x438(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x44c(%rbp)
subl $0xd, %eax
je 0xc12c
jmp 0xc115
movl -0x44c(%rbp), %eax
addl $-0xf, %eax
subl $0x2, %eax
jb 0xc209
jmp 0xc227
movq -0x438(%rbp), %rax
testb $0x1, 0x5(%rax)
je 0xc15c
movq -0x438(%rbp), %rax
movq 0x18(%rax), %rax
cmpl $0x2, (%rax)
jne 0xc15c
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x4(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0xc161
jmp 0xc270
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x440(%rbp)
movq -0x438(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x438(%rbp)
movq -0x440(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xc1ae
movq -0x438(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rax
movl 0x4(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0xc1e6
movq -0x440(%rbp), %rdi
movq -0x438(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rsi
callq 0x11890
testb $0x1, %al
jne 0xc1e6
leaq 0x15fd4(%rip), %rdi     # 0x221a8
addq $0x8, %rdi
leaq 0xe766(%rip), %rsi      # 0x1a945
movb $0x0, %al
callq 0x11190
movq -0x10(%rbp), %rax
testb $0x1, 0x3c(%rax)
je 0xc207
movq -0x438(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0xc281
movq -0x438(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x11890
testb $0x1, %al
jne 0xc223
jmp 0xc225
jmp 0xc281
jmp 0xc270
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0xc238
jmp 0xc257
leaq 0xe745(%rip), %rdi      # 0x1a984
leaq 0xe6c2(%rip), %rsi      # 0x1a908
movl $0x102, %edx            # imm = 0x102
leaq 0xe6bd(%rip), %rcx      # 0x1a90f
callq 0x30f0
movq -0x438(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x7ff0
movq %rax, -0x438(%rbp)
jmp 0xc281
leaq -0x430(%rbp), %rdi
callq 0xc7a0
jmp 0xc0f6
movq -0x28(%rbp), %rax
leaq -0x430(%rbp), %rcx
cmpq %rcx, %rax
jbe 0xc2be
movq -0x28(%rbp), %rax
movq -0x18(%rax), %rax
cmpl $0xf, (%rax)
je 0xc2ab
movq -0x28(%rbp), %rax
movq -0x18(%rax), %rax
cmpl $0x10, (%rax)
jne 0xc2be
movq -0x28(%rbp), %rax
movq -0x10(%rax), %rax
movl 0x20(%rax), %eax
movl %eax, -0x444(%rbp)
jmp 0xc2dc
movw $0x0, -0x448(%rbp)
movw $0x0, -0x446(%rbp)
movl -0x448(%rbp), %eax
movl %eax, -0x444(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
addq 0x10(%rax), %rsi
movq -0x438(%rbp), %rcx
movl -0x444(%rbp), %edx
callq 0xbe70
movq %rax, %rsi
leaq -0x430(%rbp), %rdi
callq 0xc8a0
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
testb $0x1, 0x3c(%rax)
je 0xc331
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movb $0x0, 0x3c(%rax)
jmp 0xc333
cmpq $0x0, -0x30(%rbp)
jne 0xc347
movq -0x20(%rbp), %rax
addq $0x460, %rsp            # imm = 0x460
popq %rbp
retq
leaq 0x15e5a(%rip), %rax     # 0x221a8
cmpl $0x6e, (%rax)
jne 0xc36b
callq 0xd540
leaq 0x15e49(%rip), %rax     # 0x221a8
cmpl $0x45, (%rax)
je 0xc369
jmp 0xc401
jmp 0xc392
leaq 0x15e36(%rip), %rax     # 0x221a8
cmpl $0x45, (%rax)
je 0xc390
leaq 0x15e2a(%rip), %rdi     # 0x221a8
addq $0x8, %rdi
leaq 0xe610(%rip), %rsi      # 0x1a999
movb $0x0, %al
callq 0x11190
jmp 0xc392
callq 0xd540
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
leaq -0x430(%rbp), %rcx
cmpq %rcx, %rax
jne 0xc3ba
xorl %eax, %eax
movq %rax, -0x458(%rbp)
jmp 0xc3c9
movq -0x30(%rbp), %rax
addq $-0x20, %rax
movq %rax, -0x458(%rbp)
movq -0x458(%rbp), %rax
movq %rax, -0x30(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x30(%rbp)
movb %al, -0x459(%rbp)
je 0xc3f2
movq -0x30(%rbp), %rax
movb 0x18(%rax), %al
xorb $-0x1, %al
movb %al, -0x459(%rbp)
movb -0x459(%rbp), %al
testb $0x1, %al
jne 0xc39f
jmp 0xc317
jmp 0xbf9d
nopw %cs:(%rax,%rax)