// File: /workspace/github_c_makefile_star2_O1/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 $0x98, %rsp
movq %rdx, %r15
movq %rsi, %rbp
movq %rdi, %rbx
movq (%rdx), %rsi
movq 0x10(%rdx), %rcx
movq %rcx, %rax
subq %rsi, %rax
jle 0xa6a3b
movq 0x8(%r15), %rdx
cmpq %rdx, %rsi
jge 0xa6a3d
subq %rdx, %rcx
movq %rcx, %rax
jmp 0xa6a3d
xorl %eax, %eax
cmpq $0x4, %rax
jge 0xa6a55
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rbx), %rdi
xorl %r8d, %r8d
cmpl $0x0, 0x4(%rbp)
setne %r8b
leaq 0x68(%rsp), %rdx
movl $0x4, %ecx
callq 0xf1d74
addq $0x4, (%r15)
leaq 0x78(%rsp), %r14
leaq 0x6da1f(%rip), %rsi     # 0x1144a2
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0xe9226
movq (%r15), %r12
movq 0x10(%r15), %r15
movq %r12, 0x18(%rsp)
movq %r12, 0x10(%rsp)
movq %r15, 0x20(%rsp)
movl -0xc(%r14), %eax
cmpl $0x6d736574, %eax       # imm = 0x6D736574
je 0xa6da2
cmpl $0x6d6f7074, %eax       # imm = 0x6D6F7074
je 0xa6ba7
cmpl $0x6d616e69, %eax       # imm = 0x6D616E69
jne 0xa6dce
movq %r15, %rax
subq %r12, %rax
setle %cl
cmpq $0x4, %rax
setl %al
orb %cl, %al
jne 0xa6a43
movq 0x18(%rbx), %rdi
xorl %r8d, %r8d
cmpl $0x0, 0x4(%rbp)
setne %r8b
leaq 0x38(%rsp), %rdx
movq %r12, %rsi
movl $0x4, %ecx
callq 0xf1d74
leaq 0x4(%r12), %r14
movq %r14, 0x10(%rsp)
leaq 0x48(%rsp), %r13
leaq 0x6d988(%rip), %rsi     # 0x1144a2
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xe9226
cmpl $0x49524652, -0xc(%r13) # imm = 0x49524652
jne 0xa6a43
movq %r15, %rax
subq %r14, %rax
setle %cl
cmpq $0x4, %rax
setl %al
orb %cl, %al
jne 0xa6a43
movq 0x18(%rbx), %rdi
movl 0x4(%rbp), %edx
movq %r14, %rsi
callq 0xef614
addq $0x8, %r12
movq %r12, 0x10(%rsp)
leaq 0x84649(%rip), %rsi     # 0x12b1b5
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
subq %r12, %r15
setle %al
cmpq $0xc, %r15
setl %cl
orb %al, %cl
jne 0xa6a43
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
movq %rbp, %rsi
movl $0x1, %ecx
callq 0xa9600
jmp 0xa6a43
leaq 0xc(%rsp), %rsi
movq %rbx, %rdi
callq 0xe958c
movq 0x18(%rbx), %rdi
movl 0x4(%rbp), %edx
movq %r12, %rsi
callq 0xef614
leaq 0x4(%r12), %r14
movq %r14, 0x10(%rsp)
leaq 0x8d796(%rip), %rsi     # 0x13436a
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movl 0x4(%rbp), %edx
movq %r14, %rsi
callq 0xef614
movq %rax, %r14
leaq 0x8(%r12), %rax
movq %rax, 0x10(%rsp)
leaq 0x8d777(%rip), %rsi     # 0x13437a
movq %rbx, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0xe9226
movq %r14, 0x30(%rsp)
testq %r14, %r14
jle 0xa6e4c
movq 0x10(%rsp), %r14
xorl %r13d, %r13d
movq %rbp, 0x28(%rsp)
cmpq %r12, %r14
movq %r12, %rax
cmovgq %r14, %rax
cmpq %r15, %r14
jge 0xa6e47
movq %r15, %rcx
subq %rax, %rcx
cmpq $0x472, %rcx            # imm = 0x472
jl 0xa6e47
movq %rbx, %rdi
leaq 0x8d738(%rip), %rsi     # 0x134393
movl %r13d, %edx
movl %r14d, %ecx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq %rbx, %rdi
leaq 0x8d3aa(%rip), %rsi     # 0x134029
movl $0x472, %edx            # imm = 0x472
movl %r14d, %ecx
xorl %eax, %eax
callq 0xe9226
cmpl $0x2, (%rbx)
jl 0xa6cd1
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
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 0xe975a
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
leaq 0x472(%r14), %rsi
cmpq %r12, %rsi
movq %r12, %rax
cmovgq %rsi, %rax
cmpq %r15, %rsi
jge 0xa6e44
movq %r15, %rcx
subq %rax, %rcx
cmpq $0x4, %rcx
jl 0xa6e44
movq 0x18(%rbx), %rdi
movl 0x4(%rbp), %edx
callq 0xef614
movq %rax, %rbp
addq $0x476, %r14            # imm = 0x476
movq %rbx, %rdi
leaq 0x8d68c(%rip), %rsi     # 0x1343a7
movl %ebp, %edx
xorl %eax, %eax
callq 0xe9226
testq %rbp, %rbp
jle 0xa6d7d
movq %r12, %rax
cmpq %r12, %r14
cmovgq %r14, %rax
cmpq %r15, %r14
jge 0xa6d7d
movq %r15, %rcx
cmpq %rax, %r15
jle 0xa6d7d
addq %r14, %rbp
cmpq %rcx, %rbp
movq %rcx, %rax
cmovlq %rbp, %rax
movq %r14, 0x40(%rsp)
movq %r14, 0x38(%rsp)
movq %rax, 0x48(%rsp)
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movl $0x1, %ecx
leaq 0x9de5b(%rip), %r8      # 0x144bd0
callq 0xa8173
movq %rbp, %r14
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
incq %r13
cmpq %r13, 0x30(%rsp)
movq 0x28(%rsp), %rbp
jne 0xa6c2b
jmp 0xa6e47
leaq 0x38(%rsp), %rdx
movq %r12, 0x8(%rdx)
movq %r12, (%rdx)
movq %r15, 0x10(%rdx)
leaq 0x9de17(%rip), %r8      # 0x144bd0
movq %rbx, %rdi
movq %rbp, %rsi
movl $0x1, %ecx
callq 0xa8173
jmp 0xa6a43
cmpq %r12, %r15
jle 0xa6a43
movl %r15d, %edx
subl %r12d, %edx
leaq 0x8cccc(%rip), %rsi     # 0x133ab0
movq %rbx, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0xe9226
cmpl $0x2, (%rbx)
jl 0xa6a43
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
xorl %eax, %eax
subq %r12, %r15
movq 0x18(%rbx), %rsi
cmovleq %rax, %r15
movl $0x1, (%rsp)
movl $0x100, %r8d            # imm = 0x100
movq %rbx, %rdi
movq %r12, %rdx
movq %r15, %rcx
xorl %r9d, %r9d
callq 0xe975a
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
jmp 0xa6a43
movq %rsi, %r14
movq %r14, 0x10(%rsp)
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
jmp 0xa6a43