// File: /workspace/github_c_makefile_star2_O1/Oric4ever[P]lcc65/6502/build/../src/init.c
// Function: initstruct
static int initstruct(int len, Type ty, int lev) {
	int a, n = 0;
	Field p = ty->u.sym->u.s.flist;

	do {
		if (p->offset > n) {
			genspace(p->offset - n, current);
			n += p->offset - n;
		}
		if (p->to) {
			Field q = p;
			while (q->link && q->link->offset == p->offset)
				q = q->link;
			n += initfields(p, q->link);
			p = q;
		} else {
			initializer(p->type, lev);
			n += p->type->size;
		}
		if (p->link) {
			p = p->link;
			a = p->type->align;
		} else
			a = ty->align;
		if (a && n%a) {
			genspace(a - n%a, current);
			n = roundup(n, a);
		}
		if ((len > 0 && n >= len) || t != ',')
			break;
		t = gettok();
	} while (t != '}');
	return n;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, 0x1c(%rsp)
movl %edi, %ebp
movq %rsi, 0x20(%rsp)
movq 0x18(%rsi), %rax
movq 0x58(%rax), %r14
xorl %r12d, %r12d
movl %edi, 0x8(%rsp)
movl 0x10(%r14), %edi
movl %r12d, %ebx
subl %r12d, %edi
jle 0xd4c9
movq 0x1c3f8(%rip), %rsi     # 0x298b8
callq 0xd9b7
movl 0x10(%r14), %ebx
cmpw $0x0, 0x16(%r14)
je 0xd676
movq %r14, %r15
movq %r15, %rcx
movq 0x18(%r15), %r15
testq %r15, %r15
je 0xd4ee
movl 0x10(%r15), %eax
cmpl 0x10(%r14), %eax
je 0xd4d8
movq %rcx, 0x10(%rsp)
movl %ebx, 0xc(%rsp)
cmpq $0x0, 0x1c3b9(%rip)     # 0x298b8
je 0xd6a7
leaq 0x24acc(%rip), %rax     # 0x31fd8
movq (%rax), %rsi
xorl %edi, %edi
callq 0x9044
movq %rax, %r13
xorl %edi, %edi
callq 0xaeb9
movq %rax, %r12
movswl 0x16(%r14), %ecx
movswl 0x14(%r14), %eax
subl %eax, %ecx
movq 0x8(%r14), %rax
movl 0x8(%rax), %eax
shll $0x3, %eax
cmpl %eax, %ecx
leaq 0x1ac1e(%rip), %rbp     # 0x28160
jge 0xd573
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
shll %cl, %edi
movq 0x130(%rbp), %rbx
notl %edi
leaq 0x24a7d(%rip), %rax     # 0x31fd8
movq (%rax), %rsi
callq 0x9044
movl $0x180, %edi            # imm = 0x180
movq %r12, %rsi
movq %rax, %rdx
callq *%rbx
movq %rax, %r12
movq 0x3e0(%rbp), %rbx
movq 0x1c8(%rbp), %rbp
movswl 0x14(%r14), %edi
leaq 0x24a0b(%rip), %rax     # 0x31f98
movq (%rax), %rsi
callq 0x9044
movl $0x150, %edi            # imm = 0x150
movq %r12, %rsi
movq %rax, %rdx
callq *%rbp
movl $0x1a0, %edi            # imm = 0x1A0
movq %r13, %rsi
movq %rax, %rdx
callq *%rbx
movq %rax, %r13
movq 0x18(%r14), %rax
cmpq %r15, %rax
cmovneq %rax, %r14
leaq 0x1e41c(%rip), %rbx     # 0x2b9e0
je 0xd5da
cmpl $0x2c, (%rbx)
jne 0xd5da
callq 0xe1c6
movl %eax, (%rbx)
testl %eax, %eax
jne 0xd519
testq %r15, %r15
je 0xd690
movl 0x10(%r15), %r12d
subl 0x10(%r14), %r12d
leaq 0x249e6(%rip), %rax     # 0x31fd8
movq (%rax), %rax
cmpl 0x8(%rax), %r12d
jge 0xd690
testl %r12d, %r12d
jle 0xd7da
movl %r12d, %ebx
leaq 0x1ab4e(%rip), %r15     # 0x28160
leaq 0x24967(%rip), %rbp     # 0x31f80
movq (%rbp), %rsi
movq %r13, %rdi
callq 0x17ca2
movq 0x1c28c(%rip), %rsi     # 0x298b8
movq %rax, %rdi
callq 0xd38c
movq 0x1c0(%r15), %r14
leaq 0x24956(%rip), %rax     # 0x31f98
movq (%rax), %rsi
movl $0x8, %edi
callq 0x9044
movl $0x170, %edi            # imm = 0x170
movq %r13, %rsi
movq %rax, %rdx
callq *%r14
movq %rax, %r13
decl %ebx
jne 0xd619
movl 0xc(%rsp), %ebx
movq 0x10(%rsp), %r14
movl 0x8(%rsp), %ebp
jmp 0xd7e7
movq 0x8(%r14), %rdi
movl 0x1c(%rsp), %esi
callq 0xcd39
movq 0x8(%r14), %rax
movl 0x8(%rax), %r12d
jmp 0xd7e7
movq 0x1c221(%rip), %rsi     # 0x298b8
movq %r13, %rdi
callq 0xd38c
movl %eax, %r12d
jmp 0xd7da
xorl %r13d, %r13d
xorl %ebx, %ebx
leaq 0x248e5(%rip), %rbp     # 0x31f98
movq (%rbp), %rdi
callq 0xdb2b
movl 0x28(%rax), %r12d
movswl 0x16(%r14), %ecx
movswl 0x14(%r14), %eax
subl %eax, %ecx
movq 0x8(%r14), %rax
movl 0x8(%rax), %edx
shll $0x3, %edx
cmpl %edx, %ecx
jge 0xd768
movq (%rbp), %rdx
cmpq %rdx, %rax
sete %sil
testl %r12d, %r12d
setns %dil
andb %sil, %dil
cmpb $0x1, %dil
jne 0xd707
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
shll %cl, %esi
shrl %esi
testl %r12d, %esi
jne 0xd745
cmpq %rdx, %rax
sete %dl
testl %r12d, %r12d
sets %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0xd730
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
shll %cl, %edx
notl %edx
shrl %edx
orl %r12d, %edx
cmpl $-0x1, %edx
jne 0xd745
movl %r12d, %edx
shrl %cl, %edx
leaq 0x2489c(%rip), %rcx     # 0x31fd8
cmpq (%rcx), %rax
jne 0xd753
testl %edx, %edx
je 0xd753
leaq 0x11ef0(%rip), %rdi     # 0x1f63c
xorl %eax, %eax
callq 0x9be3
movzwl 0x16(%r14), %ecx
subl 0x14(%r14), %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
shll %cl, %eax
notl %eax
andl %eax, %r12d
leaq 0x1e271(%rip), %rbp     # 0x2b9e0
movb 0x14(%r14), %cl
shll %cl, %r12d
orl %r12d, %r13d
movswl 0x16(%r14), %eax
cmpl %eax, %ebx
cmovlel %eax, %ebx
movq 0x18(%r14), %r14
cmpq %r15, %r14
je 0xd7a2
cmpl $0x2c, (%rbp)
jne 0xd7a2
callq 0xe1c6
movl %eax, (%rbp)
testl %eax, %eax
jne 0xd6ac
leal 0x7(%rbx), %r12d
shrl $0x3, %r12d
testl %ebx, %ebx
je 0xd7da
cmpl $0x1, %r12d
movl %r12d, %ebx
adcl $0x0, %ebx
movl %r13d, %r14d
movl 0x8(%rsp), %ebp
shrl $0x8, %r14d
movzbl %r13b, %esi
movl $0x3, %edi
callq 0x1a8a1
movl %r14d, %r13d
decl %ebx
jne 0xd7bf
jmp 0xd7de
movl 0x8(%rsp), %ebp
movl 0xc(%rsp), %ebx
movq 0x10(%rsp), %r14
movq 0x18(%r14), %rcx
movq 0x20(%rsp), %rax
testq %rcx, %rcx
je 0xd7fc
movq 0x8(%rcx), %rax
movq %rcx, %r14
addl %ebx, %r12d
movswl 0x4(%rax), %ebx
testl %ebx, %ebx
je 0xd82e
movl %r12d, %eax
cltd
idivl %ebx
testl %edx, %edx
je 0xd82e
movl %ebx, %edi
subl %edx, %edi
movq 0x1c09c(%rip), %rsi     # 0x298b8
callq 0xd9b7
leal (%r12,%rbx), %eax
decl %eax
negl %ebx
andl %eax, %ebx
movl %ebx, %r12d
testl %ebp, %ebp
jle 0xd840
cmpl %ebp, %r12d
leaq 0x1e1a4(%rip), %rbx     # 0x2b9e0
jl 0xd847
jmp 0xd85c
leaq 0x1e199(%rip), %rbx     # 0x2b9e0
cmpl $0x2c, (%rbx)
jne 0xd85c
callq 0xe1c6
movl %eax, (%rbx)
cmpl $0x7d, %eax
jne 0xd4ad
movl %r12d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq