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

	// This function is based on reverse engineering, and may not be correct.

	de_dbg_indent_save(c, &saved_indent_level);

	x = psd_getu32zz(zz);
	de_dbg(c, "unknown int: %d", (int)x);
	num_items = psd_getu32zz(zz);
	de_dbg(c, "number of mopt items: %d", (int)num_items);

	for(i=0; i<num_items; i++) {
		i64 dlen;
		i64 something_len;

		something_len = 1138;
		if(zz_avail(zz)<something_len) break;
		de_dbg(c, "mopt item[%d] at %d", (int)i, (int)zz->pos);
		de_dbg_indent(c, 1);

		de_dbg(c, "[%d bytes of data at %d]", (int)something_len, (int)zz->pos);
		if(c->debug_level>=2) {
			de_dbg_indent(c, 1);
			de_dbg_hexdump(c, c->infile, zz->pos, something_len, 256, NULL, 0x1);
			de_dbg_indent(c, -1);
		}
		zz->pos += something_len;

		if(zz_avail(zz)<4) break;

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

		if(dlen>0 && zz_avail(zz)>0) {
			zz_init_with_len(&czz, zz, dlen);
			read_descriptor(c, d, &czz, 1, "");
			zz->pos += dlen;
		}

		de_dbg_indent(c, -1);
	}

	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 -0x8(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x15b580
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 0xc870b(%rip), %rsi     # 0x1c01a9
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
callq 0xf3330
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %edx
leaq 0xc86e7(%rip), %rsi     # 0x1c01b9
movb $0x0, %al
callq 0x15b0d0
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x28(%rbp), %rax
jge 0xf7c75
movq $0x472, -0x60(%rbp)     # imm = 0x472
movq -0x18(%rbp), %rdi
callq 0xf40b0
cmpq -0x60(%rbp), %rax
jge 0xf7b0b
jmp 0xf7c75
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %eax, %edx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl %eax, %ecx
leaq 0xc86ad(%rip), %rsi     # 0x1c01d2
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rax
movl %eax, %edx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl %eax, %ecx
leaq 0xc8314(%rip), %rsi     # 0x1bfe68
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
cmpl $0x2, (%rax)
jl 0xf7bae
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x18(%rbp), %rax
movq (%rax), %rdx
movq -0x60(%rbp), %rcx
movl $0x100, %r8d            # imm = 0x100
xorl %eax, %eax
movl %eax, %r9d
movl $0x1, (%rsp)
callq 0x15b840
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x60(%rbp), %rcx
movq -0x18(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x18(%rbp), %rdi
callq 0xf40b0
cmpq $0x4, %rax
jge 0xf7bd0
jmp 0xf7c75
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 -0x8(%rbp), %rdi
movq -0x58(%rbp), %rax
movl %eax, %edx
leaq 0xc85e9(%rip), %rsi     # 0x1c01e6
movb $0x0, %al
callq 0x15b0d0
cmpq $0x0, -0x58(%rbp)
jle 0xf7c56
movq -0x18(%rbp), %rdi
callq 0xf40b0
cmpq $0x0, %rax
jle 0xf7c56
movq -0x18(%rbp), %rsi
movq -0x58(%rbp), %rdx
leaq -0x50(%rbp), %rdi
callq 0xf3380
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x50(%rbp), %rdx
movl $0x1, %ecx
leaq 0xd8f8d(%rip), %r8      # 0x1d0bd0
callq 0xf5b50
movq -0x58(%rbp), %rcx
movq -0x18(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xf7ae1
movq -0x8(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x15b5a0
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)