// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/psd.c
// Function: do_samp_block
static void do_samp_block(deark *c, lctx *d, zztype *zz)
{
	i64 item_idx;
	int saved_indent_level;
	de_ucstring *tmps = NULL;
	zztype czz;

	// Note: This code is based on guesswork, and may be incorrect.

	de_dbg_indent_save(c, &saved_indent_level);
	tmps = ucstring_create(c);

	item_idx = 0;
	while(1) {
		i64 item_data_len2;
		zztype datazz; // zz for the item data (minus the length field)

		if(zz->pos+16 > zz->endpos) break;

		de_dbg(c, "item[%d] at %d", (int)item_idx, (int)zz->pos);
		de_dbg_indent(c, 1);

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

		zz_init_with_len(&datazz, zz, item_data_len2);

		ucstring_empty(tmps);
		read_pascal_string_to_ucstring(c, d, tmps, &datazz);
		de_dbg(c, "id: \"%s\"", ucstring_getpsz_d(tmps));

		if(d->abr_major_ver==6 && d->abr_minor_ver<=1) {
			zz_init(&czz, &datazz);
			do_samp_block_v61stuff(c, d, &czz);
		}
		else if(d->abr_major_ver>6 || (d->abr_major_ver==6 && d->abr_minor_ver>=2)) {
			zz_init(&czz, &datazz);
			do_samp_block_v62stuff(c, d, &czz);
		}

		zz->pos += de_pad_to_4(item_data_len2);

		de_dbg_indent(c, -1);
		item_idx++;
	}

	ucstring_destroy(tmps);
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, -0x30(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
addq $0x10, %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jle 0xf97b8
jmp 0xf9917
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %edx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl %eax, %ecx
leaq 0xc6a05(%rip), %rsi     # 0x1c01d7
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
callq 0xf3330
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rax
movl %eax, %edx
leaq 0xbd696(%rip), %rsi     # 0x1b6eaa
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rsi
movq -0x50(%rbp), %rdx
leaq -0x68(%rbp), %rdi
callq 0xf3380
movq -0x30(%rbp), %rdi
callq 0x171210
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
leaq -0x68(%rbp), %rcx
callq 0xf3e30
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x30(%rbp), %rdi
callq 0x172650
movq -0x70(%rbp), %rdi
movq %rax, %rdx
leaq 0xbfee6(%rip), %rsi     # 0x1b974f
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
cmpl $0x6, 0x28(%rax)
jne 0xf98a4
movq -0x10(%rbp), %rax
cmpl $0x1, 0x2c(%rax)
jg 0xf98a4
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xf3580
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0xfb2d0
jmp 0xf98e2
movq -0x10(%rbp), %rax
cmpl $0x6, 0x28(%rax)
jg 0xf98c2
movq -0x10(%rbp), %rax
cmpl $0x6, 0x28(%rax)
jne 0xf98e0
movq -0x10(%rbp), %rax
cmpl $0x2, 0x2c(%rax)
jl 0xf98e0
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xf3580
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0xfb3d0
jmp 0xf98e2
movq -0x50(%rbp), %rdi
callq 0x15ce30
movq %rax, %rcx
movq -0x18(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0xf979e
movq -0x30(%rbp), %rdi
callq 0x171750
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x15b5a0
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)