// File: /workspace/github_c_makefile_star2_O3/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, (%rsp)
movl 0x10(%r14), %eax
movl %eax, %edi
movl %r12d, %ebx
subl %r12d, %edi
jle 0xd47d
movq 0x1d446(%rip), %rsi     # 0x2a8b8
callq 0xd984
movl 0x10(%r14), %eax
movl %eax, %ebx
cmpw $0x0, 0x16(%r14)
je 0xd62c
movq %r14, %r15
movq %r15, %rcx
movq 0x18(%r15), %r15
testq %r15, %r15
je 0xd49e
cmpl %eax, 0x10(%r15)
je 0xd48c
movq %rcx, 0x8(%rsp)
movl %ebx, 0x4(%rsp)
cmpq $0x0, 0x1d409(%rip)     # 0x2a8b8
leaq 0x1f52a(%rip), %rbp     # 0x2c9e0
je 0xd65d
leaq 0x25b15(%rip), %rax     # 0x32fd8
movq (%rax), %rsi
xorl %edi, %edi
callq 0x908f
movq %rax, %r13
xorl %edi, %edi
callq 0xae91
movq %rax, %r12
movswl 0x16(%r14), %ecx
movswl 0x14(%r14), %edi
subl %edi, %ecx
movq 0x8(%r14), %rax
movl 0x8(%rax), %eax
shll $0x3, %eax
cmpl %eax, %ecx
leaq 0x1bc67(%rip), %rbp     # 0x29160
jge 0xd52f
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
shll %cl, %edi
movq 0x130(%rbp), %rbx
notl %edi
leaq 0x25ac6(%rip), %rax     # 0x32fd8
movq (%rax), %rsi
callq 0x908f
movl $0x180, %edi            # imm = 0x180
movq %r12, %rsi
movq %rax, %rdx
callq *%rbx
movq %rax, %r12
movswl 0x14(%r14), %edi
movq 0x3e0(%rbp), %rbx
movq 0x1c8(%rbp), %rbp
leaq 0x25a54(%rip), %rax     # 0x32f98
movq (%rax), %rsi
callq 0x908f
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 0x1f465(%rip), %rbx     # 0x2c9e0
je 0xd591
cmpl $0x2c, (%rbx)
jne 0xd591
callq 0xe195
movl %eax, (%rbx)
testl %eax, %eax
jne 0xd4d0
testq %r15, %r15
je 0xd646
movl 0x10(%r15), %r12d
subl 0x10(%r14), %r12d
leaq 0x25a2f(%rip), %rax     # 0x32fd8
movq (%rax), %rax
cmpl 0x8(%rax), %r12d
jge 0xd646
testl %r12d, %r12d
jle 0xd7a8
movl %r12d, %ebx
leaq 0x1bb97(%rip), %r15     # 0x29160
leaq 0x259b0(%rip), %rbp     # 0x32f80
movq (%rbp), %rsi
movq %r13, %rdi
callq 0x17b29
movq 0x1d2d5(%rip), %rsi     # 0x2a8b8
movq %rax, %rdi
callq 0xd33c
movq 0x1c0(%r15), %r14
leaq 0x2599f(%rip), %rax     # 0x32f98
movq (%rax), %rsi
movl $0x8, %edi
callq 0x908f
movl $0x170, %edi            # imm = 0x170
movq %r13, %rsi
movq %rax, %rdx
callq *%r14
movq %rax, %r13
decl %ebx
jne 0xd5d0
movl 0x4(%rsp), %ebx
movq 0x8(%rsp), %r14
movl (%rsp), %ebp
jmp 0xd7b4
movq 0x8(%r14), %rdi
movl 0x1c(%rsp), %esi
callq 0xcd17
movq 0x8(%r14), %rax
movl 0x8(%rax), %r12d
jmp 0xd7b4
movq 0x1d26b(%rip), %rsi     # 0x2a8b8
movq %r13, %rdi
callq 0xd33c
movl %eax, %r12d
jmp 0xd7a8
xorl %r13d, %r13d
xorl %r12d, %r12d
movq %r12, 0x10(%rsp)
movq %rbp, %r12
leaq 0x25926(%rip), %rbp     # 0x32f98
movq (%rbp), %rdi
callq 0xdaf3
movl 0x28(%rax), %ebx
movswl 0x16(%r14), %edx
movswl 0x14(%r14), %eax
movl %edx, %ecx
subl %eax, %ecx
movq 0x8(%r14), %rsi
movl 0x8(%rsi), %edi
shll $0x3, %edi
cmpl %edi, %ecx
jge 0xd6cb
movq (%rbp), %rdi
cmpq %rdi, %rsi
sete %r8b
testl %ebx, %ebx
setns %r9b
andb %r8b, %r9b
cmpb $0x1, %r9b
jne 0xd6d5
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
shll %cl, %edi
shrl %edi
testl %ebx, %edi
movq %r12, %rbp
movq 0x10(%rsp), %r12
jne 0xd719
jmp 0xd705
movq %r12, %rbp
movq 0x10(%rsp), %r12
jmp 0xd740
cmpq %rdi, %rsi
sete %dil
testl %ebx, %ebx
sets %r8b
andb %dil, %r8b
cmpb $0x1, %r8b
movq %r12, %rbp
movq 0x10(%rsp), %r12
jne 0xd705
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
shll %cl, %edi
notl %edi
shrl %edi
orl %ebx, %edi
cmpl $-0x1, %edi
jne 0xd719
movl %ebx, %edi
shrl %cl, %edi
leaq 0x258c8(%rip), %r8      # 0x32fd8
cmpq (%r8), %rsi
jne 0xd735
testl %edi, %edi
je 0xd735
leaq 0x11f6c(%rip), %rdi     # 0x1f68c
xorl %eax, %eax
callq 0x9bfd
movswl 0x16(%r14), %edx
movswl 0x14(%r14), %eax
movl %edx, %ecx
subl %eax, %ecx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
shll %cl, %esi
notl %esi
andl %esi, %ebx
movl %eax, %ecx
shll %cl, %ebx
orl %ebx, %r13d
cmpl %edx, %r12d
cmovlel %edx, %r12d
movq 0x18(%r14), %r14
cmpq %r15, %r14
je 0xd76d
cmpl $0x2c, (%rbp)
jne 0xd76d
callq 0xe195
movl %eax, (%rbp)
testl %eax, %eax
jne 0xd663
testl %r12d, %r12d
je 0xd7a5
addl $0x7, %r12d
shrl $0x3, %r12d
cmpl $0x1, %r12d
movl %r12d, %ebx
adcl $0x0, %ebx
movl %r13d, %r14d
movl (%rsp), %ebp
shrl $0x8, %r14d
movzbl %r13b, %esi
movl $0x3, %edi
callq 0x1a672
movl %r14d, %r13d
decl %ebx
jne 0xd78a
jmp 0xd7ab
xorl %r12d, %r12d
movl (%rsp), %ebp
movl 0x4(%rsp), %ebx
movq 0x8(%rsp), %r14
movq 0x18(%r14), %rcx
movq 0x20(%rsp), %rax
testq %rcx, %rcx
je 0xd7c9
movq 0x8(%rcx), %rax
movq %rcx, %r14
addl %ebx, %r12d
movswl 0x4(%rax), %ebx
testl %ebx, %ebx
je 0xd7fb
movl %r12d, %eax
cltd
idivl %ebx
testl %edx, %edx
je 0xd7fb
movl %ebx, %edi
subl %edx, %edi
movq 0x1d0cf(%rip), %rsi     # 0x2a8b8
callq 0xd984
leal (%r12,%rbx), %eax
decl %eax
negl %ebx
andl %eax, %ebx
movl %ebx, %r12d
testl %ebp, %ebp
jle 0xd80d
cmpl %ebp, %r12d
leaq 0x1f1d7(%rip), %rbx     # 0x2c9e0
jl 0xd814
jmp 0xd829
leaq 0x1f1cc(%rip), %rbx     # 0x2c9e0
cmpl $0x2c, (%rbx)
jne 0xd829
callq 0xe195
movl %eax, (%rbx)
cmpl $0x7d, %eax
jne 0xd45d
movl %r12d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq