// File: /workspace/github_c_makefile_star2_O2/Oric4ever[P]lcc65/6502/build/../src/init.c
// Function: initializer
Type initializer(Type ty, int lev) {
	int n = 0;
	Tree e;
	Type aty;
	static char follow[] = { IF, CHAR, STATIC, 0 };

	ty = unqual(ty);
	if (isscalar(ty)) {
		if (!current)
			needconst++;
		if (t == '{') {
			t = gettok();
			e = expr1(0);
			initend(lev, follow);
		} else
			e = expr1(0);
		e = pointer(e);
		aty = assign(ty, e);
		if (aty)
			e = cast(e, aty);
		else
			error("invalid initialization type; found `%t' expected `%t'\n",
				e->type, ty);
		if (current)
			n = genasgn(e, current);
		else {
			n = genconst(e, 1);
			ntree = 0;
			needconst--;
		}
	}
	if ((isunion(ty) || isstruct(ty)) && ty->size == 0) {
		static char follow[] = { CHAR, STATIC, 0 };
		error("cannot initialize undefined `%t'\n", ty);
		skipto(';', follow);
		return ty;
	} else if (isunion(ty)) {
		if (t == '{') {
			t = gettok();
			n = initstruct(ty->u.sym->u.s.flist->type->size, ty, lev + 1);
			initend(lev, follow);
		} else {
			if (lev == 0)
				error("missing { in initialization of `%t'\n", ty);
			n = initstruct(ty->u.sym->u.s.flist->type->size, ty, lev + 1);
		}
	} else if (isstruct(ty)) {
		if (t == '{') {
			t = gettok();
			n = initstruct(0, ty, lev + 1);
			test('}', follow);
		} else if (current) {
			e = expr1(0);
			if (assign(ty, e))
				genasgn(e, current);
			else
				error("invalid initialization type; found `%t' expected `%t'\n",
					e->type, ty);
			n = ty->size;
		} else if (lev > 0)
			n = initstruct(ty->size, ty, lev + 1);
		else {
			error("missing { in initialization of `%t'\n", ty);
			n = initstruct(ty->u.sym->u.s.flist->type->size, ty, lev + 1);
		}
	}
	if (isarray(ty))
		aty = unqual(ty->type);
	if (isarray(ty) && ischar(aty)) {
		if (t == SCON) {
			if (ty->size > 0 && ty->size == tsym->type->size - 1)
				tsym->type = array(chartype, ty->size, STRUCT_ALIGN);
			n = tsym->type->size;
			if (current)
				genchar(tsym, current);
			else
				defstring(tsym->type->size, tsym->u.c.v.p);
			t = gettok();
		} else if (t == '{') {
			t = gettok();
			if (t == SCON) {
				ty = initializer(ty, lev + 1);
				initend(lev, follow);
				return ty;
			}
			n = initchar(0, aty);
			test('}', follow);
		} else if (lev > 0 && ty->size > 0)
			n = initchar(ty->size, aty);
		else {	/* eg, char c[] = 0; */
			error("missing { in initialization of `%t'\n", ty);
			n = initchar(1, aty);
		}
	} else if (isarray(ty)) {
		if (t == '{') {
			t = gettok();
			n = initarray(0, aty, lev + 1);
			test('}', follow);
		} else if (lev > 0 && ty->size > 0)
			n = initarray(ty->size, aty, lev + 1);
		else {
			error("missing { in initialization of `%t'\n", ty);
			n = initarray(aty->size, aty, lev + 1);
		}
	}
	if (ty->size) {
		if (n > ty->size)
			error("too many initializers\n");
		else if (n < ty->size)
			genspace(ty->size - n, current);
	} else if (isarray(ty) && ty->type->size > 0)
		ty = array(ty->type, n/ty->type->size, 0);
	else
		ty->size = n;
	return ty;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
movl (%rdi), %eax
cmpl $0xf, %eax
jb 0xc041
movq 0x10(%rbx), %rbx
movl (%rbx), %eax
cmpl $0xf, %eax
jb 0xc041
movq 0x10(%rbx), %rax
cmpl $0x8, (%rax)
jb 0xc04f
movq 0x10(%rbx), %rax
movl (%rax), %eax
jmp 0xc046
cmpl $0x8, %eax
jb 0xc04f
cmpl $0xd, %eax
jne 0xc115
cmpq $0x0, 0x1d861(%rip)     # 0x298b8
jne 0xc062
leaq 0x20c98(%rip), %rax     # 0x2ccf8
incl (%rax)
leaq 0x1f977(%rip), %r15     # 0x2b9e0
cmpl $0x7b, (%r15)
jne 0xc08b
callq 0xd3c9
movl %eax, (%r15)
xorl %edi, %edi
callq 0xa439
movq %rax, %r15
movl %r14d, %edi
callq 0xc5de
jmp 0xc095
xorl %edi, %edi
callq 0xa439
movq %rax, %r15
movq %r15, %rdi
callq 0xa22f
movq %rax, %r12
movq %rbx, %rdi
movq %rax, %rsi
callq 0x9610
movq %rax, %r15
testq %rax, %rax
je 0xc0c3
movq %r12, %rdi
movq %r15, %rsi
callq 0x9912
movq %rax, %r12
jmp 0xc0d9
movq 0x8(%r12), %rsi
leaq 0x114f1(%rip), %rdi     # 0x1d5c0
movq %rbx, %rdx
xorl %eax, %eax
callq 0x8dd4
movq 0x1d7d8(%rip), %rsi     # 0x298b8
testq %rsi, %rsi
je 0xc0f2
movq %r12, %rdi
callq 0xc606
movl %eax, %r12d
jmp 0xc118
pushq $0x1
popq %rsi
movq %r12, %rdi
callq 0xbdcb
movl %eax, %r12d
leaq 0x22c71(%rip), %rax     # 0x2ed78
andl $0x0, (%rax)
leaq 0x20be7(%rip), %rax     # 0x2ccf8
decl (%rax)
jmp 0xc118
xorl %r12d, %r12d
movl (%rbx), %eax
cmpl $0xf, %eax
jb 0xc12f
movq 0x10(%rbx), %rcx
movl (%rcx), %ecx
addl $-0x9, %ecx
cmpl $0x2, %ecx
jb 0xc13b
jmp 0xc146
leal -0x9(%rax), %ecx
cmpl $0x1, %ecx
ja 0xc2ae
cmpl $0x0, 0x8(%rbx)
je 0xc15b
cmpl $0xf, %eax
jb 0xc180
movq 0x10(%rbx), %rax
movl (%rax), %eax
cmpl $0x9, %eax
je 0xc1d0
cmpl $0xa, %eax
je 0xc18e
jmp 0xc29d
leaq 0x11495(%rip), %rdi     # 0x1d5f7
movq %rbx, %rsi
xorl %eax, %eax
callq 0x8dd4
leaq 0x1c3fc(%rip), %rsi     # 0x2856f
pushq $0x3b
popq %rdi
callq 0x90fc
jmp 0xc5cc
cmpl $0x9, %eax
je 0xc1d0
cmpl $0xa, %eax
jne 0xc2ae
leaq 0x1f84b(%rip), %r12     # 0x2b9e0
cmpl $0x7b, (%r12)
jne 0xc20c
callq 0xd3c9
movl %eax, (%r12)
movq 0x18(%rbx), %rax
movq 0x58(%rax), %rax
movq 0x8(%rax), %rax
movl 0x8(%rax), %edi
leal 0x1(%r14), %edx
movq %rbx, %rsi
callq 0xc6fc
movl %eax, %r12d
movl %r14d, %edi
callq 0xc5de
jmp 0xc29d
leaq 0x1f809(%rip), %r12     # 0x2b9e0
cmpl $0x7b, (%r12)
jne 0xc213
callq 0xd3c9
movl %eax, (%r12)
leal 0x1(%r14), %edx
xorl %edi, %edi
movq %rbx, %rsi
callq 0xc6fc
movl %eax, %r12d
leaq 0x1c36c(%rip), %rsi     # 0x2856b
pushq $0x7d
popq %rdi
callq 0x9201
jmp 0xc29d
testl %r14d, %r14d
jne 0xc263
jmp 0xc252
cmpq $0x0, 0x1d69d(%rip)     # 0x298b8
je 0xc248
xorl %edi, %edi
callq 0xa439
movq %rax, %r12
movq %rbx, %rdi
movq %rax, %rsi
callq 0x9610
testq %rax, %rax
je 0xc283
movq 0x1d67a(%rip), %rsi     # 0x298b8
movq %r12, %rdi
callq 0xc606
jmp 0xc299
testl %r14d, %r14d
jle 0xc252
movl 0x8(%rbx), %edi
jmp 0xc272
leaq 0x113c0(%rip), %rdi     # 0x1d619
movq %rbx, %rsi
xorl %eax, %eax
callq 0x8dd4
movq 0x18(%rbx), %rax
movq 0x58(%rax), %rax
movq 0x8(%rax), %rax
movl 0x8(%rax), %edi
leal 0x1(%r14), %edx
movq %rbx, %rsi
callq 0xc6fc
movl %eax, %r12d
jmp 0xc29d
movq 0x8(%r12), %rsi
leaq 0x11331(%rip), %rdi     # 0x1d5c0
movq %rbx, %rdx
xorl %eax, %eax
callq 0x8dd4
movl 0x8(%rbx), %r12d
movl (%rbx), %eax
cmpl $0xf, %eax
jb 0xc2ae
movq 0x10(%rbx), %rcx
movl (%rcx), %edx
movb $0x1, %cl
jmp 0xc2b2
xorl %ecx, %ecx
movl %eax, %edx
cmpl $0xc, %edx
jne 0xc2c5
movq 0x10(%rbx), %r15
cmpl $0xf, (%r15)
jb 0xc2c5
movq 0x10(%r15), %r15
movl %eax, %edx
testb %cl, %cl
je 0xc2d1
movq 0x10(%rbx), %rdx
movl (%rdx), %edx
cmpl $0xc, %edx
jne 0xc3b4
movl (%r15), %edx
cmpl $0xf, %edx
jb 0xc2e8
movq 0x10(%r15), %rdx
movl (%rdx), %edx
cmpl $0x3, %edx
jne 0xc3b4
leaq 0x1f6e8(%rip), %r12     # 0x2b9e0
movl (%r12), %eax
cmpl $0x7b, %eax
je 0xc436
cmpl $0x24, %eax
jne 0xc460
movl 0x8(%rbx), %esi
leaq 0x1f638(%rip), %r14     # 0x2b950
movq (%r14), %rdx
movq 0x20(%rdx), %rax
testl %esi, %esi
jle 0xc345
movl 0x8(%rax), %ecx
decl %ecx
cmpl %ecx, %esi
jne 0xc345
leaq 0x25c4d(%rip), %rax     # 0x31f80
movq (%rax), %rdi
pushq $0x1
popq %rdx
callq 0x17382
movq (%r14), %rdx
movq %rax, 0x20(%rdx)
movl 0x8(%rax), %r12d
movq 0x1d568(%rip), %r14     # 0x298b8
movq 0x48(%rdx), %r15
testq %r14, %r14
je 0xc49f
movq %rdx, (%rsp)
movl %r15d, %r13d
movl %r12d, %ebp
testl %ebp, %ebp
jle 0xc554
movl 0x8(%r14), %eax
leaq 0x25c1e(%rip), %rcx     # 0x31f98
movq (%rcx), %rcx
movswl 0x4(%rcx), %ecx
cltd
idivl %ecx
testl %edx, %edx
je 0xc4af
movzbl (%r15), %edi
incq %r15
leaq 0x25be6(%rip), %rax     # 0x31f80
movq (%rax), %rsi
callq 0x8726
movq %rax, %rdi
movq %r14, %rsi
callq 0xc606
decl %ebp
incl %r13d
jmp 0xc367
testb %cl, %cl
je 0xc3be
movq 0x10(%rbx), %rax
movl (%rax), %eax
cmpl $0xc, %eax
jne 0xc562
leaq 0x1f612(%rip), %r12     # 0x2b9e0
cmpl $0x7b, (%r12)
jne 0xc405
callq 0xd3c9
movl %eax, (%r12)
incl %r14d
xorl %edi, %edi
movq %r15, %rsi
movl %r14d, %edx
callq 0xcbef
movl %eax, %r12d
leaq 0x1c173(%rip), %rsi     # 0x2856b
pushq $0x7d
popq %rdi
callq 0x9201
jmp 0xc562
testl %r14d, %r14d
jle 0xc411
movl 0x8(%rbx), %edi
testl %edi, %edi
jg 0xc426
leaq 0x11201(%rip), %rdi     # 0x1d619
movq %rbx, %rsi
xorl %eax, %eax
callq 0x8dd4
movl 0x8(%r15), %edi
incl %r14d
movq %r15, %rsi
movl %r14d, %edx
callq 0xcbef
jmp 0xc488
callq 0xd3c9
movl %eax, (%r12)
cmpl $0x24, %eax
jne 0xc490
leal 0x1(%r14), %esi
movq %rbx, %rdi
callq 0xc00d
movq %rax, %rbx
movl %r14d, %edi
callq 0xc5de
jmp 0xc5cc
testl %r14d, %r14d
jle 0xc46c
movl 0x8(%rbx), %edi
testl %edi, %edi
jg 0xc480
leaq 0x111a6(%rip), %rdi     # 0x1d619
movq %rbx, %rsi
xorl %eax, %eax
callq 0x8dd4
pushq $0x1
popq %rdi
movq %r15, %rsi
callq 0xcaf7
movl %eax, %r12d
jmp 0xc562
xorl %edi, %edi
movq %r15, %rsi
callq 0xcaf7
jmp 0xc3ee
movl %r12d, %edi
movq %r15, %rsi
callq 0x191ff
jmp 0xc554
leaq 0x25aca(%rip), %rax     # 0x31f80
movq (%rax), %rdi
movq (%rsp), %rcx
movq 0x20(%rcx), %rax
movl 0x8(%rax), %esi
addl 0x48(%rcx), %esi
subl %r13d, %esi
xorl %edx, %edx
callq 0x17382
movq %rax, %r13
movq %rax, %rdi
callq 0x1749b
movl $0x107, %edi            # imm = 0x107
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x165eb
movq %rax, %rbp
movl 0x8(%r13), %esi
movq %r15, %rdi
callq 0x157c9
movq %r13, %rdi
movq %rax, %rsi
callq 0x15a24
movq %rax, %r15
movq 0x50(%rax), %rax
testq %rax, %rax
jne 0xc525
pushq $0x51
popq %rdi
pushq $0x3
popq %rdx
movq %r13, %rsi
callq 0x16090
movq %rax, 0x50(%r15)
movq %rax, 0x28(%rbp)
pushq $0x49
popq %rdi
movq %r13, %rsi
movq %rbp, %rdx
xorl %ecx, %ecx
callq 0x165eb
movq %rax, %r15
movl 0x8(%r13), %edi
callq 0x16220
movq %rax, 0x28(%r15)
movq %r15, %rdi
movq %r14, %rsi
callq 0xc606
callq 0xd3c9
leaq 0x1f480(%rip), %rcx     # 0x2b9e0
movl %eax, (%rcx)
movl 0x8(%rbx), %edi
testl %edi, %edi
je 0xc57e
subl %r12d, %edi
jge 0xc5b8
leaq 0x110c9(%rip), %rdi     # 0x1d63e
xorl %eax, %eax
callq 0x8dd4
jmp 0xc5cc
movl (%rbx), %eax
cmpl $0xf, %eax
jb 0xc58b
movq 0x10(%rbx), %rax
movl (%rax), %eax
cmpl $0xc, %eax
jne 0xc5c8
movq 0x10(%rbx), %rdi
movl 0x8(%rdi), %ecx
testl %ecx, %ecx
jle 0xc5c8
movl %r12d, %eax
cltd
idivl %ecx
movl %eax, %esi
xorl %edx, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x17382
jle 0xc5cc
movq 0x1d2f7(%rip), %rsi     # 0x298b8
callq 0xcc40
jmp 0xc5cc
movl %r12d, 0x8(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq