// File: /workspace/github_c_makefile_star2_O3/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 0xcd4b
movq 0x10(%rbx), %rbx
movl (%rbx), %eax
cmpl $0xf, %eax
jb 0xcd4b
movq 0x10(%rbx), %rax
cmpl $0x8, (%rax)
jb 0xcd59
movq 0x10(%rbx), %rax
movl (%rax), %eax
jmp 0xcd50
cmpl $0x8, %eax
jb 0xcd59
cmpl $0xd, %eax
jne 0xce21
cmpq $0x0, 0x1db57(%rip)     # 0x2a8b8
jne 0xcd6c
leaq 0x20f8e(%rip), %rax     # 0x2dcf8
incl (%rax)
leaq 0x1fc6d(%rip), %r15     # 0x2c9e0
cmpl $0x7b, (%r15)
jne 0xcd95
callq 0xe195
movl %eax, (%r15)
xorl %edi, %edi
callq 0xae91
movq %rax, %r15
movl %r14d, %edi
callq 0xd312
jmp 0xcd9f
xorl %edi, %edi
callq 0xae91
movq %rax, %r15
movq %r15, %rdi
callq 0xac23
movq %rax, %r12
movq %rbx, %rdi
movq %rax, %rsi
callq 0x9ff1
movq %rax, %r15
testq %rax, %rax
je 0xcdcd
movq %r12, %rdi
movq %r15, %rsi
callq 0xa2f7
movq %rax, %r12
jmp 0xcde3
movq 0x8(%r12), %rsi
leaq 0x127e7(%rip), %rdi     # 0x1f5c0
movq %rbx, %rdx
xorl %eax, %eax
callq 0x974c
movq 0x1dace(%rip), %rsi     # 0x2a8b8
movq %r12, %rdi
testq %rsi, %rsi
je 0xcdfc
callq 0xd33c
movl %eax, %r12d
jmp 0xce24
movl $0x1, %esi
callq 0xcaa9
movl %eax, %r12d
leaq 0x22f68(%rip), %rax     # 0x2fd78
movl $0x0, (%rax)
leaq 0x20edb(%rip), %rax     # 0x2dcf8
decl (%rax)
jmp 0xce24
xorl %r12d, %r12d
movl (%rbx), %eax
cmpl $0xf, %eax
jb 0xce3b
movq 0x10(%rbx), %rcx
movl (%rcx), %ecx
addl $-0x9, %ecx
cmpl $0x2, %ecx
jb 0xce47
jmp 0xce52
leal -0x9(%rax), %ecx
cmpl $0x1, %ecx
ja 0xcfc2
cmpl $0x0, 0x8(%rbx)
je 0xce6b
cmpl $0xf, %eax
jb 0xce92
movq 0x10(%rbx), %rax
movl (%rax), %eax
cmpl $0x9, %eax
je 0xcee2
cmpl $0xa, %eax
je 0xcea0
jmp 0xcfb1
leaq 0x12785(%rip), %rdi     # 0x1f5f7
movq %rbx, %rsi
xorl %eax, %eax
callq 0x974c
leaq 0x1c6ec(%rip), %rsi     # 0x2956f
movl $0x3b, %edi
callq 0x9aa0
jmp 0xd300
cmpl $0x9, %eax
je 0xcee2
cmpl $0xa, %eax
jne 0xcfc2
leaq 0x1fb39(%rip), %r12     # 0x2c9e0
cmpl $0x7b, (%r12)
jne 0xcf20
callq 0xe195
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 0xd436
movl %eax, %r12d
movl %r14d, %edi
callq 0xd312
jmp 0xcfb1
leaq 0x1faf7(%rip), %r12     # 0x2c9e0
cmpl $0x7b, (%r12)
jne 0xcf27
callq 0xe195
movl %eax, (%r12)
leal 0x1(%r14), %edx
xorl %edi, %edi
movq %rbx, %rsi
callq 0xd436
movl %eax, %r12d
leaq 0x1c65a(%rip), %rsi     # 0x2956b
movl $0x7d, %edi
callq 0x9bc5
jmp 0xcfb1
testl %r14d, %r14d
jne 0xcf77
jmp 0xcf66
cmpq $0x0, 0x1d989(%rip)     # 0x2a8b8
je 0xcf5c
xorl %edi, %edi
callq 0xae91
movq %rax, %r12
movq %rbx, %rdi
movq %rax, %rsi
callq 0x9ff1
testq %rax, %rax
je 0xcf97
movq 0x1d966(%rip), %rsi     # 0x2a8b8
movq %r12, %rdi
callq 0xd33c
jmp 0xcfad
testl %r14d, %r14d
jle 0xcf66
movl 0x8(%rbx), %edi
jmp 0xcf86
leaq 0x126ac(%rip), %rdi     # 0x1f619
movq %rbx, %rsi
xorl %eax, %eax
callq 0x974c
movq 0x18(%rbx), %rax
movq 0x58(%rax), %rax
movq 0x8(%rax), %rax
movl 0x8(%rax), %edi
leal 0x1(%r14), %edx
movq %rbx, %rsi
callq 0xd436
movl %eax, %r12d
jmp 0xcfb1
movq 0x8(%r12), %rsi
leaq 0x1261d(%rip), %rdi     # 0x1f5c0
movq %rbx, %rdx
xorl %eax, %eax
callq 0x974c
movl 0x8(%rbx), %r12d
movl (%rbx), %eax
cmpl $0xf, %eax
jb 0xcfc2
movq 0x10(%rbx), %rcx
movl (%rcx), %edx
movb $0x1, %cl
jmp 0xcfc6
xorl %ecx, %ecx
movl %eax, %edx
cmpl $0xc, %edx
jne 0xcfd9
movq 0x10(%rbx), %r15
cmpl $0xf, (%r15)
jb 0xcfd9
movq 0x10(%r15), %r15
movl %eax, %edx
testb %cl, %cl
je 0xcfe5
movq 0x10(%rbx), %rdx
movl (%rdx), %edx
cmpl $0xc, %edx
jne 0xd0db
movl (%r15), %edx
cmpl $0xf, %edx
jb 0xcffc
movq 0x10(%r15), %rdx
movl (%rdx), %edx
cmpl $0x3, %edx
jne 0xd0db
leaq 0x1f9d4(%rip), %r12     # 0x2c9e0
movl (%r12), %eax
cmpl $0x7b, %eax
je 0xd15f
cmpl $0x24, %eax
jne 0xd189
movl 0x8(%rbx), %esi
leaq 0x1f924(%rip), %r14     # 0x2c950
movq (%r14), %rdx
movq 0x20(%rdx), %rax
testl %esi, %esi
jle 0xd05b
movl 0x8(%rax), %ecx
decl %ecx
cmpl %ecx, %esi
jne 0xd05b
leaq 0x25f39(%rip), %rax     # 0x32f80
movq (%rax), %rdi
movl $0x1, %edx
callq 0x188ea
movq (%r14), %rdx
movq %rax, 0x20(%rdx)
movl 0x8(%rax), %r12d
movq 0x1d852(%rip), %r14     # 0x2a8b8
testq %r14, %r14
je 0xd1ca
movq %rdx, (%rsp)
testl %r12d, %r12d
jle 0xd288
movq (%rsp), %rax
movq 0x48(%rax), %r15
leal 0x1(%r12), %r13d
movq %r15, %rbp
movl 0x8(%r14), %eax
leaq 0x25f01(%rip), %rcx     # 0x32f98
movq (%rcx), %rcx
movswl 0x4(%rcx), %ecx
cltd
idivl %ecx
testl %edx, %edx
je 0xd1db
movzbl (%rbp), %edi
incq %rbp
leaq 0x25ec9(%rip), %rax     # 0x32f80
movq (%rax), %rsi
callq 0x908f
movq %rax, %rdi
movq %r14, %rsi
callq 0xd33c
decl %r13d
incl %r15d
cmpl $0x1, %r13d
jg 0xd08c
jmp 0xd288
testb %cl, %cl
je 0xd0e5
movq 0x10(%rbx), %rax
movl (%rax), %eax
cmpl $0xc, %eax
jne 0xd296
leaq 0x1f8eb(%rip), %r12     # 0x2c9e0
cmpl $0x7b, (%r12)
jne 0xd12e
callq 0xe195
movl %eax, (%r12)
incl %r14d
xorl %edi, %edi
movq %r15, %rsi
movl %r14d, %edx
callq 0xd933
movl %eax, %r12d
leaq 0x1c44c(%rip), %rsi     # 0x2956b
movl $0x7d, %edi
callq 0x9bc5
jmp 0xd296
testl %r14d, %r14d
jle 0xd13a
movl 0x8(%rbx), %edi
testl %edi, %edi
jg 0xd14f
leaq 0x124d8(%rip), %rdi     # 0x1f619
movq %rbx, %rsi
xorl %eax, %eax
callq 0x974c
movl 0x8(%r15), %edi
incl %r14d
movq %r15, %rsi
movl %r14d, %edx
callq 0xd933
jmp 0xd1b3
callq 0xe195
movl %eax, (%r12)
cmpl $0x24, %eax
jne 0xd1bb
leal 0x1(%r14), %esi
movq %rbx, %rdi
callq 0xcd17
movq %rax, %rbx
movl %r14d, %edi
callq 0xd312
jmp 0xd300
testl %r14d, %r14d
jle 0xd195
movl 0x8(%rbx), %edi
testl %edi, %edi
jg 0xd1ab
leaq 0x1247d(%rip), %rdi     # 0x1f619
movq %rbx, %rsi
xorl %eax, %eax
callq 0x974c
movl $0x1, %edi
movq %r15, %rsi
callq 0xd83b
movl %eax, %r12d
jmp 0xd296
xorl %edi, %edi
movq %r15, %rsi
callq 0xd83b
jmp 0xd115
movq 0x48(%rdx), %rsi
movl %r12d, %edi
callq 0x1a6f4
jmp 0xd288
leaq 0x25d9e(%rip), %rax     # 0x32f80
movq (%rax), %rdi
movq (%rsp), %rcx
movq 0x20(%rcx), %rax
movl 0x8(%rax), %esi
addl 0x48(%rcx), %esi
subl %r15d, %esi
xorl %edx, %edx
callq 0x188ea
movq %rax, %r13
movq %rax, %rdi
callq 0x18a0a
movl $0x107, %edi            # imm = 0x107
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x179e5
movq %rax, (%rsp)
movl 0x8(%r13), %esi
movq %rbp, %rdi
callq 0x16b50
movq %r13, %rdi
movq %rax, %rsi
callq 0x16dcc
movq %rax, %r15
movq 0x50(%rax), %rax
testq %rax, %rax
jne 0xd256
movl $0x51, %edi
movq %r13, %rsi
movl $0x3, %edx
callq 0x17456
movq %rax, 0x50(%r15)
movq (%rsp), %rdx
movq %rax, 0x28(%rdx)
movl $0x49, %edi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x179e5
movq %rax, %r15
movl 0x8(%r13), %edi
callq 0x175d3
movq %rax, 0x28(%r15)
movq %r15, %rdi
movq %r14, %rsi
callq 0xd33c
callq 0xe195
leaq 0x1f74c(%rip), %rcx     # 0x2c9e0
movl %eax, (%rcx)
movl 0x8(%rbx), %edi
testl %edi, %edi
je 0xd2b2
subl %r12d, %edi
jge 0xd2ec
leaq 0x12395(%rip), %rdi     # 0x1f63e
xorl %eax, %eax
callq 0x974c
jmp 0xd300
movl (%rbx), %eax
cmpl $0xf, %eax
jb 0xd2bf
movq 0x10(%rbx), %rax
movl (%rax), %eax
cmpl $0xc, %eax
jne 0xd2fc
movq 0x10(%rbx), %rdi
movl 0x8(%rdi), %ecx
testl %ecx, %ecx
jle 0xd2fc
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 0x188ea
jle 0xd300
movq 0x1d5c3(%rip), %rsi     # 0x2a8b8
callq 0xd984
jmp 0xd300
movl %r12d, 0x8(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq