// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/psd.c
// Function: do_slices_v6
static void do_slices_v6(deark *c, lctx *d, zztype *zz)
{
	i64 num_slices;
	i64 i;
	de_ucstring *name_of_group_of_slices = NULL;
	zztype czz;
	int ret;

	zz->pos += 4; // version (already read)
	read_rectangle_tlbr(c, d, zz, "bounding rectangle");
	if(zz->pos >= zz->endpos) goto done;

	name_of_group_of_slices = ucstring_create(c);
	read_unicode_string(c, d, name_of_group_of_slices, zz);
	de_dbg(c, "name of group of slices: \"%s\"",
		ucstring_getpsz_d(name_of_group_of_slices));
	if(zz->pos >= zz->endpos) goto done;

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

	for(i=0; i<num_slices; i++) {
		if(zz->pos >= zz->endpos) {
			de_dbg(c, "[Expected %d slices, only found %d]", (int)num_slices, (int)i);
			goto done;
		}
		de_dbg(c, "slice[%d] at %d", (int)i, (int)zz->pos);
		de_dbg_indent(c, 1);
		zz_init(&czz, zz);
		do_slices_resource_block(c, d, i, &czz);
		de_dbg_indent(c, -1);
		zz->pos += zz_used(&czz);
	}

	// The PSD spec seems to show that a Descriptor can (optionally) appear after
	// every slice resource block.
	// But if that were true, there would seem to be no way to tell whether a slice
	// is followed by a descriptor, or immediately by the next slice.
	// Fortunately, evidence suggests that a Descriptor can only appear after the
	// last slice in the array.

	if(zz->pos >= zz->endpos) goto done;

	ret = read_descriptor(c, d, zz, 1, " (for slices)");
	if(!ret) goto done;

done:
	ucstring_destroy(name_of_group_of_slices);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq 0xc9d23(%rip), %rcx     # 0x1bf320
callq 0xf5820
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jl 0xf5618
jmp 0xf57b7
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0xf54d0
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rdi
callq 0x172650
movq -0x58(%rbp), %rdi
movq %rax, %rdx
leaq 0xc9cda(%rip), %rsi     # 0x1bf333
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jl 0xf5676
jmp 0xf57b7
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
callq 0xf3330
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %edx
leaq 0xc9cae(%rip), %rsi     # 0x1bf351
movb $0x0, %al
callq 0x15b0d0
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x20(%rbp), %rax
jge 0xf577a
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jl 0xf56f4
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %edx
movq -0x28(%rbp), %rax
movl %eax, %ecx
leaq 0xc9c7e(%rip), %rsi     # 0x1bf366
movb $0x0, %al
callq 0x15b0d0
jmp 0xf57b7
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %edx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl %eax, %ecx
leaq 0xc9c7c(%rip), %rsi     # 0x1bf38a
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x18(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0xf3580
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x48(%rbp), %rcx
callq 0xf58b0
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
leaq -0x48(%rbp), %rdi
callq 0xf3820
movq %rax, %rcx
movq -0x18(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xf56b2
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jl 0xf578d
jmp 0xf57b7
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl $0x1, %ecx
leaq 0xc9bf5(%rip), %r8      # 0x1bf39a
callq 0xf5b50
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jne 0xf57b5
jmp 0xf57b7
jmp 0xf57b7
movq -0x30(%rbp), %rdi
callq 0x171750
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)