// File: /workspace/github_c_makefile_star2_O1/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 0xabf81
movq 0x8(%r12), %rsi
cmpq %rsi, %rdx
jge 0xabf83
subq %rsi, %rax
movq %rax, %rcx
jmp 0xabf83
xorl %ecx, %ecx
leaq 0x8804c(%rip), %rsi     # 0x133fd6
movq %r14, %rdi
xorl %eax, %eax
callq 0xe9226
movq %r14, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%r14), %rdi
movl 0x4(%r13), %edx
movq (%r12), %rsi
callq 0xef614
addq $0x4, (%r12)
leaq 0x88413(%rip), %rsi     # 0x1343d1
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%r14), %rdi
movl 0x4(%r13), %edx
movq (%r12), %rsi
callq 0xef614
addq $0x4, (%r12)
leaq 0x7f1ce(%rip), %rsi     # 0x12b1b5
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
leaq 0x7347b(%rip), %rcx     # 0x11f475
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0xa80fd
movq 0x18(%r14), %rdi
movl 0x4(%r13), %edx
movq (%r12), %rsi
callq 0xef614
movq %rax, %rbx
addq $0x4, (%r12)
leaq 0x72bd0(%rip), %rsi     # 0x11ebf8
movq %r14, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, 0x28(%rsp)
cmpq $-0x1, %rbx
jl 0xac21b
addq $0x2, 0x28(%rsp)
xorl %ebp, %ebp
movq %r12, 0x20(%rsp)
movq 0x18(%r14), %rdi
movq (%r12), %rsi
movl 0x4(%r13), %edx
callq 0xef614
movq %rax, %r15
movl (%r12), %ecx
testq %rax, %rax
leaq 0x98b5e(%rip), %r8      # 0x144bd0
leaq 0x87fa7(%rip), %rax     # 0x134020
cmoveq %rax, %r8
movq %r14, %rdi
leaq 0x87f78(%rip), %rsi     # 0x133fff
movl %ebp, %edx
xorl %eax, %eax
callq 0xe9226
movq (%r12), %rbx
testq %r15, %r15
je 0xac1f8
movq 0x10(%r12), %rax
movq %rbx, 0x10(%rsp)
movq %rbx, 0x8(%rsp)
movq %rax, 0x18(%rsp)
movq %r14, %rdi
movl $0x1, %esi
callq 0xe9585
leaq 0x4(%rbx), %rsi
movq %rsi, 0x8(%rsp)
movq 0x18(%r14), %rdi
movl 0x4(%r13), %edx
callq 0xef614
movq %r13, %r12
movq %rax, %r13
leaq 0x8(%rbx), %r15
movq %r15, 0x8(%rsp)
movq %r14, %rdi
leaq 0x7f0c8(%rip), %rsi     # 0x12b1b5
movl %r13d, %edx
xorl %eax, %eax
callq 0xe9226
testq %r13, %r13
je 0xac1bf
movq 0x18(%r14), %rdi
movl 0x4(%r12), %edx
movq %r15, %rsi
callq 0xef614
addq $0xc, %rbx
movq %rbx, 0x8(%rsp)
movq %r14, %rdi
leaq 0x75f5b(%rip), %rsi     # 0x12207f
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq %r14, %rdi
movq %r12, %rsi
leaq 0x8(%rsp), %rdx
leaq 0x73336(%rip), %rcx     # 0x11f475
callq 0xa80fd
movq 0x18(%r14), %rdi
movl 0x4(%r12), %edx
movq %r15, 0x30(%rsp)
movq 0x8(%rsp), %r15
movq %r15, %rsi
callq 0xef570
leaq 0x2(%r15), %rbx
movq %rbx, 0x8(%rsp)
movq %r14, %rdi
leaq 0x75f0d(%rip), %rsi     # 0x12207f
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%r14), %rdi
movq %rbx, %rsi
callq 0xef0d5
addq $0x3, %r15
movq %r15, 0x8(%rsp)
movzbl %al, %esi
movq %r14, %rdi
callq 0xac236
addq 0x30(%rsp), %r13
movl %r13d, %edx
subl %r15d, %edx
movq %r14, %rdi
leaq 0x87e79(%rip), %rsi     # 0x134029
movl %r15d, %ecx
xorl %eax, %eax
callq 0xe9226
movq %r13, 0x8(%rsp)
movq %r12, %r13
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rdx
movq %rdx, %rbx
subq %rax, %rbx
jle 0xac1fe
movq 0x8(%rsp), %rcx
cmpq %rdx, %rcx
movq 0x20(%rsp), %r12
jg 0xac205
subq %rax, %rcx
movq %rcx, %rbx
jmp 0xac205
addq $0x4, %rbx
jmp 0xac209
xorl %ebx, %ebx
movq 0x20(%rsp), %r12
addq (%r12), %rbx
movq %rbx, (%r12)
incq %rbp
cmpq %rbp, 0x28(%rsp)
jne 0xac050
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe9585