// File: /workspace/github_c_makefile_star2_O2/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 $0x28, %rsp
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %rbx
movl (%rdx), %ebp
movq %rdx, %rdi
callq 0x9ff2f
leaq 0x823a6(%rip), %rsi     # 0x1270f6
movq %rbx, %rdi
movl %ebp, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x18(%rbx), %rdi
movl 0x4(%r13), %edx
movq %r14, %rsi
callq 0x9fe70
leaq 0x82770(%rip), %rsi     # 0x1274f1
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movl 0x4(%r13), %edx
movq %r14, %rsi
callq 0x9fe70
leaq 0x79471(%rip), %rsi     # 0x11e215
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
leaq 0x6d6f6(%rip), %rcx     # 0x1124ad
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0xa1409
movq 0x18(%rbx), %rdi
movl 0x4(%r13), %edx
movq %r14, %rsi
callq 0x9fe70
movq %rax, %r12
leaq 0x6ce51(%rip), %rsi     # 0x111c30
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xde896
movq %r14, %rdx
cmpq $-0x1, %r12
pushq $-0x2
popq %rax
cmovgeq %r12, %rax
addq $0x2, %rax
movq %rax, 0x18(%rsp)
movq %rsp, %r15
xorl %ebp, %ebp
cmpq %rbp, 0x18(%rsp)
je 0xa4fac
movq 0x18(%rbx), %rdi
movq %rdx, %r12
movq (%rdx), %rsi
movl 0x4(%r13), %edx
callq 0xe41cb
movq %r13, %r14
movq %rax, %r13
movl (%r12), %ecx
testq %rax, %rax
leaq 0x92e26(%rip), %r8      # 0x137c60
leaq 0x822ff(%rip), %rax     # 0x127140
cmoveq %rax, %r8
movq %rbx, %rdi
leaq 0x822d0(%rip), %rsi     # 0x12711f
movq %rbp, 0x20(%rsp)
movl %ebp, %edx
xorl %eax, %eax
callq 0xde896
movq %r12, %rdx
movq (%r12), %rbp
testq %r13, %r13
je 0xa4f88
movq 0x10(%rdx), %rax
movq %rbp, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
addq $0x4, %rbp
movq %rbp, (%rsp)
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
movq %r15, %rbp
movq %r15, %rsi
callq 0x9fe70
movq %rax, %r13
movq %rbx, %rdi
leaq 0x79367(%rip), %rsi     # 0x11e215
movl %r13d, %edx
xorl %eax, %eax
callq 0xde896
testq %r13, %r13
je 0xa4f54
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
addq (%rsp), %r13
movq %rbp, %rsi
callq 0x9fe70
movq %rbx, %rdi
leaq 0x701e8(%rip), %rsi     # 0x1150c7
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
movq %r14, %rsi
movq %rbp, %rdx
leaq 0x6d5b5(%rip), %rcx     # 0x1124ad
callq 0xa1409
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
movq %rbp, %rsi
callq 0x9feb0
movq %rbx, %rdi
leaq 0x701b0(%rip), %rsi     # 0x1150c7
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0x9ff51
movzbl %al, %esi
movq %rbx, %rdi
callq 0xa4fc5
movl (%rsp), %ecx
movl %r13d, %edx
subl %ecx, %edx
movq %rbx, %rdi
leaq 0x82200(%rip), %rsi     # 0x127149
xorl %eax, %eax
callq 0xde896
movq %r13, (%rsp)
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rdx
movq %rdx, %rbp
subq %rax, %rbp
jle 0xa4f91
movq (%rsp), %rcx
cmpq %rdx, %rcx
movq %r14, %r13
movq %r12, %rdx
jg 0xa4f99
subq %rax, %rcx
movq %rcx, %rbp
jmp 0xa4f99
addq $0x4, %rbp
movq %r14, %r13
jmp 0xa4f9c
xorl %ebp, %ebp
movq %r14, %r13
movq %r12, %rdx
addq (%rdx), %rbp
movq %rbp, (%rdx)
movq 0x20(%rsp), %rbp
incq %rbp
jmp 0xa4e08
pushq $-0x1
popq %rsi
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xdeba7