// File: /workspace/github_c_makefile_star2_O1/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
cmpl $0xf, (%rdi)
jb 0xcd53
movq 0x10(%rbx), %rbx
movl (%rbx), %eax
movq %rbx, %rcx
cmpl $0xf, %eax
jb 0xcd61
movq 0x10(%rbx), %rcx
cmpl $0x8, (%rcx)
jb 0xcd7b
movq %rbx, %rcx
cmpl $0xf, %eax
jb 0xcd72
movq 0x10(%rbx), %rcx
cmpl $0xd, (%rcx)
jne 0xce43
cmpq $0x0, 0x1cb35(%rip)     # 0x298b8
jne 0xcd8e
leaq 0x1ff6c(%rip), %rax     # 0x2ccf8
incl (%rax)
leaq 0x1ec4b(%rip), %r15     # 0x2b9e0
cmpl $0x7b, (%r15)
jne 0xcdb7
callq 0xe1c6
movl %eax, (%r15)
xorl %edi, %edi
callq 0xaeb9
movq %rax, %r15
movl %r14d, %edi
callq 0xd362
jmp 0xcdc1
xorl %edi, %edi
callq 0xaeb9
movq %rax, %r15
movq %r15, %rdi
callq 0xac81
movq %rax, %r12
movq %rbx, %rdi
movq %rax, %rsi
callq 0x9fe1
movq %rax, %r15
testq %rax, %rax
je 0xcdef
movq %r12, %rdi
movq %r15, %rsi
callq 0xa341
movq %rax, %r12
jmp 0xce05
movq 0x8(%r12), %rsi
leaq 0x12775(%rip), %rdi     # 0x1f570
movq %rbx, %rdx
xorl %eax, %eax
callq 0x9720
movq 0x1caac(%rip), %rsi     # 0x298b8
movq %r12, %rdi
testq %rsi, %rsi
je 0xce1e
callq 0xd38c
movl %eax, %r12d
jmp 0xce46
movl $0x1, %esi
callq 0xcadc
movl %eax, %r12d
leaq 0x21f46(%rip), %rax     # 0x2ed78
movl $0x0, (%rax)
leaq 0x1feb9(%rip), %rax     # 0x2ccf8
decl (%rax)
jmp 0xce46
xorl %r12d, %r12d
movl (%rbx), %eax
movq %rbx, %rcx
cmpl $0xf, %eax
jb 0xce54
movq 0x10(%rbx), %rcx
cmpl $0xa, (%rcx)
je 0xce7b
movq %rbx, %rcx
cmpl $0xf, %eax
jb 0xce65
movq 0x10(%rbx), %rcx
cmpl $0x9, (%rcx)
je 0xce7b
movq %rbx, %rcx
cmpl $0xf, %eax
jb 0xce76
movq 0x10(%rbx), %rcx
cmpl $0xa, (%rcx)
jne 0xce85
cmpl $0x0, 0x8(%rbx)
je 0xcf40
movq %rbx, %rcx
cmpl $0xf, %eax
jb 0xce91
movq 0x10(%rbx), %rcx
cmpl $0xa, (%rcx)
jne 0xcedc
leaq 0x1eb43(%rip), %r12     # 0x2b9e0
cmpl $0x7b, (%r12)
jne 0xcf67
callq 0xe1c6
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 0xd485
movl %eax, %r12d
movl %r14d, %edi
callq 0xd362
jmp 0xcff8
movq %rbx, %rcx
cmpl $0xf, %eax
jb 0xcee8
movq 0x10(%rbx), %rcx
cmpl $0x9, (%rcx)
je 0xcf02
movq %rbx, %rcx
cmpl $0xf, %eax
jb 0xcef9
movq 0x10(%rbx), %rcx
cmpl $0xa, (%rcx)
jne 0xcff8
leaq 0x1ead7(%rip), %r12     # 0x2b9e0
cmpl $0x7b, (%r12)
jne 0xcf6e
callq 0xe1c6
movl %eax, (%r12)
leal 0x1(%r14), %edx
xorl %edi, %edi
movq %rbx, %rsi
callq 0xd485
movl %eax, %r12d
leaq 0x1b63a(%rip), %rsi     # 0x2856b
movl $0x7d, %edi
callq 0x9bab
jmp 0xcff8
leaq 0x12660(%rip), %rdi     # 0x1f5a7
movq %rbx, %rsi
xorl %eax, %eax
callq 0x9720
leaq 0x1b617(%rip), %rsi     # 0x2856f
movl $0x3b, %edi
callq 0x9a79
jmp 0xd350
testl %r14d, %r14d
jne 0xcfbe
jmp 0xcfad
cmpq $0x0, 0x1c942(%rip)     # 0x298b8
je 0xcfa3
xorl %edi, %edi
callq 0xaeb9
movq %rax, %r12
movq %rbx, %rdi
movq %rax, %rsi
callq 0x9fe1
testq %rax, %rax
je 0xcfde
movq 0x1c91f(%rip), %rsi     # 0x298b8
movq %r12, %rdi
callq 0xd38c
jmp 0xcff4
testl %r14d, %r14d
jle 0xcfad
movl 0x8(%rbx), %edi
jmp 0xcfcd
leaq 0x12615(%rip), %rdi     # 0x1f5c9
movq %rbx, %rsi
xorl %eax, %eax
callq 0x9720
movq 0x18(%rbx), %rax
movq 0x58(%rax), %rax
movq 0x8(%rax), %rax
movl 0x8(%rax), %edi
leal 0x1(%r14), %edx
movq %rbx, %rsi
callq 0xd485
movl %eax, %r12d
jmp 0xcff8
movq 0x8(%r12), %rsi
leaq 0x12586(%rip), %rdi     # 0x1f570
movq %rbx, %rdx
xorl %eax, %eax
callq 0x9720
movl 0x8(%rbx), %r12d
movl (%rbx), %eax
movq %rbx, %rcx
cmpl $0xf, %eax
jb 0xd006
movq 0x10(%rbx), %rcx
cmpl $0xc, (%rcx)
jne 0xd019
movq 0x10(%rbx), %r15
cmpl $0xf, (%r15)
jb 0xd019
movq 0x10(%r15), %r15
movq %rbx, %rcx
cmpl $0xf, %eax
jb 0xd025
movq 0x10(%rbx), %rcx
cmpl $0xc, (%rcx)
jne 0xd128
cmpl $0xf, (%r15)
movq %r15, %rcx
jb 0xd03b
movq 0x10(%r15), %rcx
cmpl $0x3, (%rcx)
jne 0xd128
leaq 0x1e995(%rip), %r12     # 0x2b9e0
movl (%r12), %eax
cmpl $0x7b, %eax
je 0xd1ae
cmpl $0x24, %eax
jne 0xd1d8
movl 0x8(%rbx), %esi
testl %esi, %esi
jle 0xd09a
leaq 0x1e8e1(%rip), %r14     # 0x2b950
movq (%r14), %rax
movq 0x20(%rax), %rax
movl 0x8(%rax), %eax
decl %eax
cmpl %eax, %esi
jne 0xd09a
leaq 0x24efa(%rip), %rax     # 0x31f80
movq (%rax), %rdi
movl $0x1, %edx
callq 0x18a62
movq (%r14), %rcx
movq %rax, 0x20(%rcx)
leaq 0x1e8af(%rip), %rax     # 0x2b950
movq (%rax), %rcx
movq 0x20(%rcx), %rax
movl 0x8(%rax), %r12d
movq 0x1c805(%rip), %r14     # 0x298b8
testq %r14, %r14
je 0xd219
movq %rcx, (%rsp)
testl %r12d, %r12d
jle 0xd2d9
movq (%rsp), %rax
movq 0x48(%rax), %r15
leal 0x1(%r12), %r13d
movq %r15, %rbp
movl 0x8(%r14), %eax
leaq 0x24eb4(%rip), %rcx     # 0x31f98
movq (%rcx), %rcx
movswl 0x4(%rcx), %ecx
cltd
idivl %ecx
testl %edx, %edx
je 0xd22a
movzbl (%rbp), %edi
incq %rbp
leaq 0x24e7c(%rip), %rax     # 0x31f80
movq (%rax), %rsi
callq 0x9044
movq %rax, %rdi
movq %r14, %rsi
callq 0xd38c
decl %r13d
incl %r15d
cmpl $0x1, %r13d
jg 0xd0d9
jmp 0xd2d9
movq %rbx, %rcx
cmpl $0xf, %eax
jb 0xd134
movq 0x10(%rbx), %rcx
cmpl $0xc, (%rcx)
jne 0xd2e7
leaq 0x1e89c(%rip), %r12     # 0x2b9e0
cmpl $0x7b, (%r12)
jne 0xd17d
callq 0xe1c6
movl %eax, (%r12)
incl %r14d
xorl %edi, %edi
movq %r15, %rsi
movl %r14d, %edx
callq 0xd966
movl %eax, %r12d
leaq 0x1b3fd(%rip), %rsi     # 0x2856b
movl $0x7d, %edi
callq 0x9bab
jmp 0xd2e7
testl %r14d, %r14d
jle 0xd189
movl 0x8(%rbx), %edi
testl %edi, %edi
jg 0xd19e
leaq 0x12439(%rip), %rdi     # 0x1f5c9
movq %rbx, %rsi
xorl %eax, %eax
callq 0x9720
movl 0x8(%r15), %edi
incl %r14d
movq %r15, %rsi
movl %r14d, %edx
callq 0xd966
jmp 0xd202
callq 0xe1c6
movl %eax, (%r12)
cmpl $0x24, %eax
jne 0xd20a
leal 0x1(%r14), %esi
movq %rbx, %rdi
callq 0xcd39
movq %rax, %rbx
movl %r14d, %edi
callq 0xd362
jmp 0xd350
testl %r14d, %r14d
jle 0xd1e4
movl 0x8(%rbx), %edi
testl %edi, %edi
jg 0xd1fa
leaq 0x123de(%rip), %rdi     # 0x1f5c9
movq %rbx, %rsi
xorl %eax, %eax
callq 0x9720
movl $0x1, %edi
movq %r15, %rsi
callq 0xd86e
movl %eax, %r12d
jmp 0xd2e7
xorl %edi, %edi
movq %r15, %rsi
callq 0xd86e
jmp 0xd164
movq 0x48(%rcx), %rsi
movl %r12d, %edi
callq 0x1a936
jmp 0xd2d9
leaq 0x24d4f(%rip), %rax     # 0x31f80
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 0x18a62
movq %rax, %r13
movq %rax, %rdi
callq 0x18b7d
movl $0x107, %edi            # imm = 0x107
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x17b61
movq %rax, (%rsp)
movl 0x8(%r13), %esi
movq %rbp, %rdi
callq 0x16c24
movq %r13, %rdi
movq %rax, %rsi
callq 0x16eac
movq %rax, %r15
cmpq $0x0, 0x50(%rax)
jne 0xd2a3
movl $0x51, %edi
movq %r13, %rsi
movl $0x3, %edx
callq 0x175a8
movq %rax, 0x50(%r15)
movq 0x50(%r15), %rax
movq (%rsp), %rdx
movq %rax, 0x28(%rdx)
movl $0x49, %edi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x17b61
movq %rax, %r15
movl 0x8(%r13), %edi
callq 0x1774b
movq %rax, 0x28(%r15)
movq %r15, %rdi
movq %r14, %rsi
callq 0xd38c
callq 0xe1c6
leaq 0x1e6fb(%rip), %rcx     # 0x2b9e0
movl %eax, (%rcx)
movl 0x8(%rbx), %edi
testl %edi, %edi
je 0xd303
subl %r12d, %edi
jge 0xd33c
leaq 0x122f4(%rip), %rdi     # 0x1f5ee
xorl %eax, %eax
callq 0x9720
jmp 0xd350
cmpl $0xf, (%rbx)
movq %rbx, %rax
jb 0xd30f
movq 0x10(%rbx), %rax
cmpl $0xc, (%rax)
jne 0xd34c
movq 0x10(%rbx), %rdi
movl 0x8(%rdi), %ecx
testl %ecx, %ecx
jle 0xd34c
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 0x18a62
jle 0xd350
movq 0x1c573(%rip), %rsi     # 0x298b8
callq 0xd9b7
jmp 0xd350
movl %r12d, 0x8(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq