// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/psd.c
// Function: do_vm_array_list
static void do_vm_array_list(deark *c, lctx *d, zztype *zz)
{
	i64 ver;
	i64 dlen;
	i64 num_channels;
	zztype czz;
	i64 i;

	de_dbg(c, "virtual memory array list at %d, len=%"I64_FMT"", (int)zz->pos,
		zz_avail(zz));
	de_dbg_indent(c, 1);

	ver = psd_getu32zz(zz);
	de_dbg(c, "version: %d", (int)ver);

	dlen = psd_getu32zz(zz);
	de_dbg(c, "length: %d", (int)dlen);

	read_rectangle_tlbr(c, d, zz, "rectangle");

	num_channels = psd_getu32zz(zz);
	de_dbg(c, "number of channels: %d", (int)num_channels);

	for(i=0; i<num_channels+2; i++) {
		i64 is_written;

		// Look ahead at the array-is-written flag.
		is_written = psd_getu32(zz->pos);

		de_dbg(c, "virtual memory array[%d] at %d%s", (int)i, (int)zz->pos,
			is_written?"":" (empty)");
		if(is_written) {
			zz_init(&czz, zz);
			de_dbg_indent(c, 1);
			do_vm_array(c, d, &czz);
			de_dbg_indent(c, -1);
			zz->pos += zz_used(&czz);
		}
		else {
			zz->pos += 4;
		}
	}

	de_dbg_indent(c, -1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %r14
movq (%rdx), %rdx
movq 0x10(%r12), %rax
movq %rax, %rcx
subq %rdx, %rcx
jle 0xab496
movq 0x8(%r12), %rsi
cmpq %rsi, %rdx
jge 0xab498
subq %rsi, %rax
movq %rax, %rcx
jmp 0xab498
xorl %ecx, %ecx
leaq 0x88f2f(%rip), %rsi     # 0x1343ce
movq %r14, %rdi
xorl %eax, %eax
callq 0xe8617
movq %r14, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%r14), %rdi
movl 0x4(%r13), %edx
movq (%r12), %rsi
callq 0xeeff3
addq $0x4, (%r12)
leaq 0x892f6(%rip), %rsi     # 0x1347c9
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r14), %rdi
movl 0x4(%r13), %edx
movq (%r12), %rsi
callq 0xeeff3
addq $0x4, (%r12)
leaq 0x7ff89(%rip), %rsi     # 0x12b485
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
leaq 0x7406e(%rip), %rcx     # 0x11f57d
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0xa76cc
movq 0x18(%r14), %rdi
movl 0x4(%r13), %edx
movq (%r12), %rsi
callq 0xeeff3
movq %rax, %rbx
addq $0x4, (%r12)
leaq 0x737c3(%rip), %rsi     # 0x11ed00
movq %r14, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, 0x8(%rsp)
cmpq $-0x1, %rbx
jl 0xab722
movq (%r12), %rsi
addq $0x2, 0x8(%rsp)
xorl %ebp, %ebp
movq %r13, (%rsp)
movq %r12, 0x28(%rsp)
movq 0x18(%r14), %rdi
movl 0x4(%r13), %edx
callq 0xeeff3
movq %rax, %r15
movl (%r12), %ecx
testq %rax, %rax
leaq 0x99b25(%rip), %r8      # 0x1450b0
leaq 0x88e86(%rip), %rax     # 0x134418
cmoveq %rax, %r8
movq %r14, %rdi
leaq 0x88e57(%rip), %rsi     # 0x1343f7
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
movq (%r12), %rbx
testq %r15, %r15
je 0xab6fd
movq 0x10(%r12), %r15
movq %rbx, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movq %r14, %rdi
movl $0x1, %esi
callq 0xe8a15
leaq 0x4(%rbx), %rsi
movq 0x18(%r14), %rdi
movl 0x4(%r13), %edx
callq 0xeeff3
movq %r14, %r12
movq %rax, %r14
leaq 0x8(%rbx), %r13
movq %r13, 0x10(%rsp)
movq %r12, %rdi
leaq 0x7fe89(%rip), %rsi     # 0x12b485
movl %r14d, %edx
xorl %eax, %eax
callq 0xe8617
movq %r14, 0x30(%rsp)
testq %r14, %r14
je 0xab6d3
movq 0x18(%r12), %rdi
movq (%rsp), %r14
movl 0x4(%r14), %edx
movq %r13, %rsi
callq 0xeeff3
addq $0xc, %rbx
movq %rbx, 0x10(%rsp)
movq %r12, %rdi
leaq 0x76c4b(%rip), %rsi     # 0x122287
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq %r12, %rdi
movq %r14, %rsi
leaq 0x10(%rsp), %rdx
leaq 0x73f26(%rip), %rcx     # 0x11f57d
callq 0xa76cc
movq 0x18(%r12), %rdi
movl 0x4(%r14), %edx
movq 0x10(%rsp), %r15
movq %r15, %rsi
callq 0xeef43
leaq 0x2(%r15), %rbx
movq %r12, %rdi
leaq 0x76c07(%rip), %rsi     # 0x122287
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r12), %rdi
movq %rbx, %rsi
callq 0xeead3
addl $0x3, %r15d
movzbl %al, %esi
movq %r12, %rdi
callq 0xab73d
addq 0x30(%rsp), %r13
movl %r13d, %edx
subl %r15d, %edx
movq %r12, %rdi
leaq 0x88d67(%rip), %rsi     # 0x134421
movl %r15d, %ecx
xorl %eax, %eax
callq 0xe8617
movq %r13, 0x10(%rsp)
movq 0x18(%rsp), %rbx
movq 0x20(%rsp), %r15
movq %r12, %r14
movq %r12, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq %r15, %rsi
subq %rbx, %rsi
movq 0x28(%rsp), %r12
jle 0xab706
cmpq %r15, %r13
jg 0xab708
subq %rbx, %r13
movq %r13, %rsi
jmp 0xab708
addq $0x4, %rbx
movq %rbx, %rsi
jmp 0xab710
xorl %esi, %esi
addq (%r12), %rsi
movq (%rsp), %r13
movq %rsi, (%r12)
incq %rbp
cmpq %rbp, 0x8(%rsp)
jne 0xab56d
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe8a15