// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/psd.c
// Function: do_shmd_block
static void do_shmd_block(deark *c, lctx *d, zztype *zz)
{
	i64 count;
	i64 i;
	zztype czz;

	if(zz_avail(zz)<4) return;

	count = psd_getu32zz(zz);
	de_dbg(c, "number of metadata items: %d", (int)count);

	for(i=0; i<count; i++) {
		i64 itempos, dpos, dlen;
		struct de_fourcc key4cc;

		if(zz->pos >= zz->endpos) break;
		itempos = zz->pos;

		zz->pos += 4; // signature ("8BIM", presumably)

		psd_read_fourcc_zz(c, d, zz, &key4cc);

		zz->pos += 1; // flag
		zz->pos += 3; // padding

		dlen = psd_getu32zz(zz);

		dpos = zz->pos;
		de_dbg(c, "metadata item[%d] '%s' at %d, dpos=%d, dlen=%d",
			(int)i, key4cc.id_dbgstr, (int)itempos, (int)dpos, (int)dlen);

		de_dbg_indent(c, 1);

		switch(key4cc.id) {
		case CODE_cust: // Undocumented, but seems to be a versioned Descriptor
		case CODE_mlst: // Undocumented, but seems to be a versioned Descriptor
			zz_init_with_len(&czz, zz, dlen);
			read_descriptor(c, d, &czz, 1, "");
			break;
		}

		de_dbg_indent(c, -1);

		zz->pos += dlen;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0xf40b0
cmpq $0x4, %rax
jge 0xf95cb
jmp 0xf9754
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 0xc6b65(%rip), %rsi     # 0x1c015d
movb $0x0, %al
callq 0x15b0d0
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x20(%rbp), %rax
jge 0xf9754
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jl 0xf962b
jmp 0xf9754
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%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 -0x88(%rbp), %rcx
callq 0xf3d80
movq -0x18(%rbp), %rax
movq (%rax), %rcx
incq %rcx
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rcx
addq $0x3, %rcx
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
callq 0xf3330
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movl -0x28(%rbp), %edx
leaq -0x78(%rbp), %rcx
movl -0x48(%rbp), %r8d
movl -0x50(%rbp), %r9d
movl -0x58(%rbp), %esi
movq %rsp, %rax
movl %esi, (%rax)
leaq 0xc6aba(%rip), %rsi     # 0x1c017a
xorl %eax, %eax
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movl -0x84(%rbp), %eax
movl %eax, -0x8c(%rbp)
subl $0x63757374, %eax       # imm = 0x63757374
je 0xf96f9
jmp 0xf96ea
movl -0x8c(%rbp), %eax
subl $0x6d6c7374, %eax       # imm = 0x6D6C7374
jne 0xf9727
jmp 0xf96f9
movq -0x18(%rbp), %rsi
movq -0x58(%rbp), %rdx
leaq -0x40(%rbp), %rdi
callq 0xf3380
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x40(%rbp), %rdx
movl $0x1, %ecx
leaq 0xd74ae(%rip), %r8      # 0x1d0bd0
callq 0xf5b50
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x58(%rbp), %rcx
movq -0x18(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xf9607
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)