// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
leaq 0x8(%rsp), %rbx
andq $0x0, 0x400(%rbx)
movq %rbx, 0x408(%rbx)
andq $0x0, (%rbx)
movq %rsi, %r15
movq %rsi, 0x8(%rbx)
movb $0x0, 0x18(%rbx)
leaq 0x418(%rsp), %rax
andq $0x0, (%rax)
movq %rdi, %r14
movq %rax, 0x8(%rax)
cmpb $0x1, 0x3c(%rsi)
jne 0x8fb0
cmpl $0xd, (%r15)
je 0x8fb6
leaq 0x1316a(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xa4af(%rip), %rsi      # 0x13458
xorl %eax, %eax
callq 0xc536
cmpl $0xd, (%r15)
jne 0x8fda
movq 0x20(%r15), %rax
cmpq $0x0, 0x10(%rax)
jne 0x8fda
leaq 0x13140(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xa4af(%rip), %rsi      # 0x13482
xorl %eax, %eax
callq 0xc536
pushq $0x44
popq %rbp
leaq 0x13124(%rip), %r13     # 0x1c108
leaq 0x8(%r13), %r12
movq 0x408(%rsp), %rax
testq %rax, %rax
je 0x9255
movl (%r13), %ecx
cmpl $0x46, %ecx
je 0x900b
cmpl $0x40, %ecx
jne 0x917a
leaq 0x418(%rsp), %rdx
movq %rdx, 0x420(%rsp)
movq %rax, 0x410(%rsp)
movq 0x8(%rax), %rbp
cmpl $0x46, %ecx
je 0x90de
cmpl $0x40, %ecx
jne 0x9163
cmpl $0xd, (%rbp)
je 0x9050
movq %r12, %rdi
leaq 0x9e32(%rip), %rsi      # 0x12e7b
xorl %eax, %eax
callq 0xc536
callq 0x9c1e
movq %r14, %rdi
xorl %esi, %esi
callq 0x6f2d
movq 0x20(%rbp), %rcx
imulq 0x10(%rcx), %rax
movq 0x410(%rsp), %rcx
movq %rax, 0x10(%rcx)
movq 0x410(%rsp), %rax
movq 0x10(%rax), %rax
cmpq 0x10(%rbp), %rax
jb 0x90b5
cmpb $0x0, 0x3c(%rbp)
jne 0x90a9
movq %r12, %rdi
leaq 0xa54b(%rip), %rsi      # 0x135e1
xorl %eax, %eax
callq 0xc536
movq 0x410(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rbp), %rcx
addq 0x10(%rcx), %rax
movq %rax, 0x10(%rbp)
pushq $0x41
popq %rdi
leaq 0x9deb(%rip), %rsi      # 0x12eaa
callq 0xa26e
movq 0x20(%rbp), %rsi
movq 0x410(%rsp), %rax
movq 0x10(%rax), %rdx
movq %rbx, %rdi
callq 0x95fc
jmp 0x9152
movl (%rbp), %eax
addl $-0xf, %eax
cmpl $0x2, %eax
jb 0x90fa
movq %r12, %rdi
leaq 0x9dcc(%rip), %rsi      # 0x12ebf
xorl %eax, %eax
callq 0xc536
callq 0x9c1e
pushq $0x4
popq %rdi
leaq 0x9dea(%rip), %rsi      # 0x12ef3
callq 0xa26e
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
callq 0x965d
testb %al, %al
jne 0x914a
cmpl $0x10, (%rbp)
leaq 0x9dfa(%rip), %rdx      # 0x12f25
leaq 0x9851(%rip), %rax      # 0x12983
cmoveq %rax, %rdx
movq %r12, %rdi
leaq 0x9dc9(%rip), %rsi      # 0x12f09
movq %r15, %rcx
xorl %eax, %eax
callq 0xc536
movq %r15, %rdi
callq 0x3250
movq 0x410(%rsp), %rax
movl (%r13), %ecx
jmp 0x9023
pushq $0x63
popq %rdi
leaq 0xa4a1(%rip), %rsi      # 0x1360e
callq 0xa26e
pushq $0x44
popq %rbp
jmp 0x9255
movq 0x410(%rsp), %rcx
cmpq %rax, %rcx
je 0x9215
leaq -0x20(%rcx), %rax
movq %rax, 0x410(%rsp)
movq -0x18(%rcx), %rdi
movl (%rdi), %edx
cmpl $0xf, %edx
je 0x91cd
cmpl $0xd, %edx
jne 0x91ea
movq 0x20(%rdi), %rax
movq 0x10(%rax), %rax
addq %rax, -0x10(%rcx)
movq 0x410(%rsp), %rax
movq 0x10(%rax), %rdx
cmpq 0x10(%rdi), %rdx
jne 0x9237
cmpb $0x1, 0x3c(%rdi)
jne 0x91ea
jmp 0x923d
movq -0x10(%rcx), %rax
movq 0x28(%rax), %rax
movq %rax, -0x10(%rcx)
movq 0x410(%rsp), %rax
movq 0x10(%rax), %rcx
testq %rcx, %rcx
jne 0x922d
movq %rax, %rcx
cmpq 0x408(%rsp), %rax
jne 0x918b
movq %r12, %rdi
leaq 0xa443(%rip), %rsi      # 0x13644
xorl %eax, %eax
callq 0xc536
movq 0x410(%rsp), %rcx
jmp 0x918b
movq 0x8(%rax), %rax
movl (%rax), %eax
addl $-0xf, %eax
cmpl $0x1, %eax
ja 0x9255
movq %rbx, %rdi
callq 0x9595
jmp 0x9255
movq 0x8(%rcx), %rsi
movq 0x18(%rcx), %rdx
jmp 0x924d
movq 0x20(%rdi), %rsi
jmp 0x924d
movq 0x20(%rdi), %rsi
addq 0x10(%rsi), %rdx
movq %rdx, 0x10(%rdi)
movq 0x10(%rax), %rdx
movq %rbx, %rdi
callq 0x95fc
movl %ebp, %edi
callq 0xa28d
testb %al, %al
je 0x92d6
pushq $0x45
popq %rdi
callq 0xa28d
testb %al, %al
jne 0x9337
movq 0x408(%rsp), %rcx
movq 0x410(%rsp), %rax
cmpq %rax, %rcx
jne 0x92c5
movq 0x8(%rcx), %rax
testb $0x10, 0x4(%rax)
je 0x92ac
movq %r12, %rdi
leaq 0xa24a(%rip), %rsi      # 0x134e3
xorl %eax, %eax
callq 0xc536
movq 0x408(%rsp), %rax
movq 0x8(%rax), %rax
cmpl $0xd, (%rax)
jne 0x9557
movq %rbx, %rdi
callq 0x9595
movq 0x410(%rsp), %rax
movq %rax, 0x408(%rsp)
movb $0x1, 0x18(%rax)
jmp 0x8ff0
movq %r14, %rdi
callq 0x6fa4
movq %rax, %rbp
movq 0x410(%rsp), %rax
movq 0x8(%rax), %r15
movl (%r15), %eax
leal -0xf(%rax), %ecx
cmpl $0x2, %ecx
jae 0x930a
movq 0x8(%rbp), %rdi
movq %r15, %rsi
callq 0xc85a
testb %al, %al
je 0x932d
jmp 0x9363
cmpl $0xd, %eax
jne 0x9368
cmpb $0x1, 0x5(%rbp)
jne 0x932d
movq 0x18(%rbp), %rcx
cmpl $0x2, (%rcx)
jne 0x932d
movq 0x20(%r15), %rdi
movl 0x4(%rdi), %eax
testb $0x2, %al
jne 0x9460
movq %rbx, %rdi
callq 0x9595
jmp 0x92e1
movq 0x410(%rsp), %rax
movq 0x8(%rax), %rax
cmpb $0x1, 0x3c(%rax)
jne 0x94b8
movq %r12, %rdi
leaq 0xa160(%rip), %rsi      # 0x134b7
xorl %eax, %eax
callq 0xc536
jmp 0x94b8
movq %rbp, %rcx
jmp 0x9381
testb $0x10, 0x4(%r15)
je 0x9576
movq %rbp, %rdi
movq %r15, %rsi
callq 0x6441
movq %rax, %rcx
pushq $0x44
popq %rbp
movq 0x410(%rsp), %rax
xorl %edx, %edx
cmpq %rbx, %rax
jbe 0x93a8
movq -0x18(%rax), %rsi
movl (%rsi), %esi
addl $-0xf, %esi
cmpl $0x1, %esi
ja 0x93a8
movq -0x10(%rax), %rdx
movl 0x20(%rdx), %edx
movq (%rax), %rdi
movq 0x8(%rax), %rax
movq 0x10(%rax), %rsi
addq %rdi, %rsi
callq 0x8f0c
movq 0x420(%rsp), %rcx
movq (%rcx), %rdx
testq %rdx, %rdx
je 0x943b
movq 0x8(%rdx), %rdi
shlq $0x3, %rdi
movswq 0x1a(%rdx), %rsi
subq %rsi, %rdi
movq (%rax), %rsi
movswq 0x18(%rax), %r8
leaq (%r8,%rsi,8), %rsi
cmpq %rsi, %rdi
jbe 0x9412
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
movswq 0x1a(%rax), %r8
subq %r8, %rsi
movq (%rdx), %r8
movswq 0x18(%rdx), %r9
leaq (%r9,%r8,8), %r8
cmpq %r8, %rsi
jbe 0x943d
cmpq %rsi, %rdi
jbe 0x941b
addq $0x20, %rdx
movq %rdx, %rcx
jmp 0x93c3
movq 0x20(%rdx), %rdx
testq %rdx, %rdx
je 0x943b
movq 0x8(%rdx), %rdi
shlq $0x3, %rdi
movswq 0x1a(%rdx), %r8
subq %r8, %rdi
cmpq %rsi, %rdi
jbe 0x941b
jmp 0x943d
xorl %edx, %edx
movq %rax, %rsi
addq $0x20, %rsi
movq %rdx, 0x20(%rax)
movq %rax, (%rcx)
movq %rsi, 0x420(%rsp)
movq 0x410(%rsp), %rax
jmp 0x952a
movq %rcx, (%rsp)
movq 0x8(%rcx), %rcx
movq 0x20(%rcx), %rsi
testb $0x1, %al
je 0x9476
testb $0x1, 0x4(%rsi)
jne 0x9490
callq 0xc85a
testb %al, %al
jne 0x9490
movq %r12, %rdi
leaq 0xa0de(%rip), %rsi      # 0x13567
xorl %eax, %eax
callq 0xc536
cmpb $0x1, 0x3c(%r15)
pushq $0x44
popq %rbp
jne 0x94af
movq (%rsp), %rcx
movq 0x8(%rcx), %rax
movq 0x10(%rax), %rax
movq %rax, 0x10(%r15)
jmp 0x9384
movq (%rsp), %rcx
jmp 0x9384
cmpq $0x0, 0x408(%rsp)
je 0x953d
movl (%r13), %eax
cmpl $0x45, %eax
je 0x94f4
cmpl $0x6e, %eax
jne 0x94e3
callq 0x9c1e
cmpl $0x45, (%r13)
jne 0x8fe8
jmp 0x94f4
movq %r12, %rdi
leaq 0xa0ce(%rip), %rsi      # 0x135bb
xorl %eax, %eax
callq 0xc536
callq 0x9c1e
movq 0x408(%rsp), %rax
movq %rax, 0x410(%rsp)
movq %rax, %rcx
cmpq %rbx, %rcx
je 0x9520
leaq -0x20(%rcx), %rdx
cmpb $0x1, -0x8(%rcx)
movq %rdx, %rcx
jne 0x950c
jmp 0x9522
xorl %edx, %edx
movq %rdx, 0x408(%rsp)
movq 0x8(%rax), %rax
cmpb $0x1, 0x3c(%rax)
jne 0x94b8
movb $0x0, 0x3c(%rax)
jmp 0x94b8
movq 0x418(%rsp), %rax
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9fad(%rip), %rdi      # 0x1350b
leaq 0x9fc5(%rip), %rsi      # 0x1352a
leaq 0x9fc5(%rip), %rcx      # 0x13531
movl $0xe7, %edx
callq 0x30e0
leaq 0xa029(%rip), %rdi      # 0x135a6
leaq 0x9fa6(%rip), %rsi      # 0x1352a
leaq 0x9fa6(%rip), %rcx      # 0x13531
movl $0x102, %edx            # imm = 0x102
callq 0x30e0