// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/psd.c
// Function: hrsrc_pluginresource
static void hrsrc_pluginresource(deark *c, lctx *d, zztype *zz, const struct rsrc_info *ri)
{
	struct de_fourcc fourcc;
	zztype czz;

	// Plug-in resources seem to start with a fourcc.
	if(zz_avail(zz)<4) return;
	psd_read_fourcc_zz(c, d, zz, &fourcc);
	de_dbg(c, "id: '%s'", fourcc.id_dbgstr);
	zz_init(&czz, zz);
	switch(fourcc.id) {
	case CODE_mani:
		do_pluginrsrc_mani(c, d, &czz);
		break;
	case CODE_mopt:
		do_pluginrsrc_mopt(c, d, &czz);
		break;
	case CODE_mset:
		do_pluginrsrc_descriptor(c, d, &czz);
		break;
	default:
		if(zz_avail(&czz)>0) {
			de_dbg(c, "[%d more bytes of plug-in resource data at %d]",
				(int)zz_avail(&czz), (int)czz.startpos);
			if(c->debug_level>=2) {
				de_dbg_indent(c, 1);
				de_dbg_hexdump(c, c->infile, czz.startpos, zz_avail(&czz), 256, NULL, 0x1);
				de_dbg_indent(c, -1);
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %rbp
movq (%rdx), %rsi
movq 0x10(%rdx), %rax
cmpq %rax, %rsi
jge 0xa6097
movq %rdx, %r15
movq 0x8(%rdx), %rcx
cmpq %rcx, %rsi
cmovgq %rsi, %rcx
subq %rcx, %rax
cmpq $0x4, %rax
jge 0xa60a9
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
xorl %r8d, %r8d
cmpl $0x0, 0x4(%rbp)
setne %r8b
leaq 0x78(%rsp), %rdx
movl $0x4, %ecx
callq 0xf1762
addq $0x4, (%r15)
leaq 0x88(%rsp), %r14
leaq 0x6e475(%rip), %rsi     # 0x114552
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0xe8617
movq (%r15), %r12
movq 0x10(%r15), %r15
movq %r12, 0x38(%rsp)
movq %r15, 0x40(%rsp)
movl -0xc(%r14), %eax
cmpl $0x6d736574, %eax       # imm = 0x6D736574
je 0xa63f9
cmpl $0x6d6f7074, %eax       # imm = 0x6D6F7074
je 0xa61f6
cmpl $0x6d616e69, %eax       # imm = 0x6D616E69
jne 0xa6425
movq %r15, %rax
subq %r12, %rax
setle %cl
cmpq $0x4, %rax
setl %al
orb %cl, %al
jne 0xa6097
movq 0x18(%rbx), %rdi
xorl %r8d, %r8d
cmpl $0x0, 0x4(%rbp)
setne %r8b
leaq 0x48(%rsp), %rdx
movq %r12, %rsi
movl $0x4, %ecx
callq 0xf1762
leaq 0x4(%r12), %r14
leaq 0x58(%rsp), %r13
leaq 0x6e3e8(%rip), %rsi     # 0x114552
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xe8617
cmpl $0x49524652, -0xc(%r13) # imm = 0x49524652
setne %al
movq %r15, %rcx
subq %r14, %rcx
setle %dl
orb %al, %dl
cmpq $0x4, %rcx
setl %al
orb %dl, %al
jne 0xa6097
movq 0x18(%rbx), %rdi
movl 0x4(%rbp), %edx
movq %r14, %rsi
callq 0xeeff3
addq $0x8, %r12
movq %r12, 0x30(%rsp)
leaq 0x852ca(%rip), %rsi     # 0x12b485
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
subq %r12, %r15
setle %al
cmpq $0xc, %r15
setl %cl
orb %al, %cl
jne 0xa6097
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
movq %rbp, %rsi
movl $0x1, %ecx
callq 0xa8d66
jmp 0xa6097
leaq 0x14(%rsp), %rsi
movq %rbx, %rdi
callq 0xe8a1c
movq 0x18(%rbx), %rdi
movl 0x4(%rbp), %edx
movq %r12, %rsi
callq 0xeeff3
leaq 0x4(%r12), %r14
leaq 0x8e544(%rip), %rsi     # 0x134762
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movl 0x4(%rbp), %edx
movq %r14, %rsi
callq 0xeeff3
movq %rax, %r14
leaq 0x8e52f(%rip), %rsi     # 0x134772
movq %rbx, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0xe8617
movq %r14, 0x28(%rsp)
testq %r14, %r14
jle 0xa63e8
leaq 0x8(%r12), %r14
xorl %r13d, %r13d
movq %rbp, 0x18(%rsp)
movq %r12, 0x20(%rsp)
cmpq %r15, %r14
jge 0xa63e8
cmpq %r12, %r14
movq %r12, %rax
cmovgq %r14, %rax
movq %r15, %rcx
subq %rax, %rcx
cmpq $0x472, %rcx            # imm = 0x472
jl 0xa63e8
movq %rbx, %rdi
leaq 0x8e4eb(%rip), %rsi     # 0x13478b
movl %r13d, %edx
movl %r14d, %ecx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq %rbx, %rdi
leaq 0x8e15d(%rip), %rsi     # 0x134421
movl $0x472, %edx            # imm = 0x472
movl %r14d, %ecx
xorl %eax, %eax
callq 0xe8617
cmpl $0x2, (%rbx)
jl 0xa6316
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rsi
movl $0x1, (%rsp)
movl $0x472, %ecx            # imm = 0x472
movl $0x100, %r8d            # imm = 0x100
movq %rbx, %rdi
movq %r14, %rdx
xorl %r9d, %r9d
callq 0xe8bea
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
leaq 0x472(%r14), %rsi
cmpq %r15, %rsi
jge 0xa63e8
cmpq %r12, %rsi
movq %r12, %rax
cmovgq %rsi, %rax
movq %r15, %rcx
subq %rax, %rcx
cmpq $0x4, %rcx
jl 0xa63e8
cmpq %r12, %r15
setg %r12b
movq 0x18(%rbx), %rdi
movl 0x4(%rbp), %edx
callq 0xeeff3
movq %rax, %rbp
addq $0x476, %r14            # imm = 0x476
movq %rbx, %rdi
leaq 0x8e438(%rip), %rsi     # 0x13479f
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
testq %rbp, %rbp
setg %al
cmpq %r15, %r14
setl %cl
andb %r12b, %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xa63c3
addq %r14, %rbp
cmpq %r15, %rbp
movq %r15, %rax
cmovlq %rbp, %rax
movq %r14, 0x50(%rsp)
movq %r14, 0x48(%rsp)
movq %rax, 0x58(%rsp)
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
leaq 0x48(%rsp), %rdx
movl $0x1, %ecx
leaq 0x9ecf5(%rip), %r8      # 0x1450b0
callq 0xa7748
movq %rbp, %r14
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
incq %r13
cmpq %r13, 0x28(%rsp)
movq 0x18(%rsp), %rbp
movq 0x20(%rsp), %r12
jne 0xa6270
movl 0x14(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
jmp 0xa6097
leaq 0x48(%rsp), %rdx
movq %r12, 0x8(%rdx)
movq %r12, (%rdx)
movq %r15, 0x10(%rdx)
leaq 0x9eca0(%rip), %r8      # 0x1450b0
movq %rbx, %rdi
movq %rbp, %rsi
movl $0x1, %ecx
callq 0xa7748
jmp 0xa6097
subq %r12, %r15
jle 0xa6097
leaq 0x8da73(%rip), %rsi     # 0x133ea8
movq %rbx, %rdi
movl %r15d, %edx
movl %r12d, %ecx
xorl %eax, %eax
callq 0xe8617
cmpl $0x2, (%rbx)
jl 0xa6097
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rsi
movl $0x1, (%rsp)
movl $0x100, %r8d            # imm = 0x100
movq %rbx, %rdi
movq %r12, %rdx
movq %r15, %rcx
xorl %r9d, %r9d
callq 0xe8bea
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
jmp 0xa6097