// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/psd.c
// Function: de_run_ps_brush
static void de_run_ps_brush(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	zztype *zz = NULL;
	int has_8bim_sig;

	d = de_malloc(c, sizeof(lctx));
	d->version = 1;
	init_version_specific_info(c, d);

	zz = de_malloc(c, sizeof(zztype));
	zz_init_absolute(zz, 0, c->infile->len);

	d->abr_major_ver = (int)psd_getu16(0);
	de_dbg(c, "file version: %d", (int)d->abr_major_ver);

	has_8bim_sig = (psd_getu32(4) == CODE_8BIM);

	if(has_8bim_sig && d->abr_major_ver>=3) {
		d->abr_minor_ver = (int)psd_getu16(2);
		de_declare_fmt(c, "Photoshop Brush (new format)");
		do_abr_v6(c, d, zz);
	}
	else if(d->abr_major_ver<=5) {
		de_declare_fmt(c, "Photoshop Brush (old format)");
		do_abr_v1(c, d, zz);
	}
	else {
		de_err(c, "Unsupported Photoshop Brush format (version=%d)", (int)d->abr_major_ver);
		goto done;
	}

done:
	de_free(c, zz);
	de_free(c, d);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl $0x58, %esi
callq 0xe969b
movq %rax, %r14
movl $0x1, (%rax)
movq %rbx, %rdi
movq %rax, %rsi
callq 0xa64c0
movl $0x18, %esi
movq %rbx, %rdi
callq 0xe969b
movq %rax, %r15
movq 0x18(%rbx), %rdi
movq 0x18(%rdi), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
movq %rax, 0x10(%r15)
movl 0x4(%r14), %edx
xorl %esi, %esi
callq 0xef570
movl %eax, 0x28(%r14)
leaq 0x8eab9(%rip), %rsi     # 0x134777
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
movl $0x4, %esi
callq 0xef614
cmpq $0x3842494d, %rax       # imm = 0x3842494D
jne 0xa5d5c
cmpl $0x3, 0x28(%r14)
jl 0xa5d5c
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
movl $0x2, %esi
callq 0xef570
movl %eax, 0x2c(%r14)
leaq 0x8eb3f(%rip), %rsi     # 0x134847
movq %rbx, %rdi
callq 0xeb6d6
movq (%r15), %rsi
addq $0x4, %rsi
movq %rsi, (%r15)
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
callq 0xef614
cmpl $0x3842494d, %eax       # imm = 0x3842494D
jne 0xa5e6b
movq (%r15), %rax
movq 0x10(%r15), %rcx
movq %rsp, %rdx
movq %rax, 0x8(%rdx)
movq %rax, (%rdx)
movq %rcx, 0x10(%rdx)
movq %rbx, %rdi
movq %r14, %rsi
movl $0x2, %ecx
callq 0xa9600
jmp 0xa5e7c
movl 0x28(%r14), %edx
cmpl $0x5, %edx
jg 0xa5e58
leaq 0x8eaf4(%rip), %rsi     # 0x134864
movq %rbx, %rdi
callq 0xeb6d6
movq (%r15), %rsi
addq $0x2, %rsi
movq %rsi, (%r15)
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
callq 0xef570
movq %rax, %r12
addq $0x2, (%r15)
leaq 0x8eb3e(%rip), %rsi     # 0x1348db
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xe9226
testq %r12, %r12
jle 0xa5e7c
xorl %ebp, %ebp
movq (%r15), %rcx
cmpq 0x10(%r15), %rcx
jge 0xa5e7c
movq %rbx, %rdi
leaq 0x8eb25(%rip), %rsi     # 0x1348f1
movl %ebp, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
movq (%r15), %rsi
callq 0xef570
addq $0x2, (%r15)
movq %rbx, %rdi
leaq 0x8eb0c(%rip), %rsi     # 0x13490c
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
movq (%r15), %rsi
callq 0xef614
movq %rax, %r13
movq (%r15), %rdx
addq $0x4, %rdx
movq %rdx, (%r15)
movq %rbx, %rdi
leaq 0x8eaeb(%rip), %rsi     # 0x13491b
movl %r13d, %ecx
xorl %eax, %eax
callq 0xe9226
addq %r13, (%r15)
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
incq %rbp
cmpq %rbp, %r12
jne 0xa5db5
jmp 0xa5e7c
leaq 0x8ea22(%rip), %rsi     # 0x134881
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
jmp 0xa5e7c
leaq 0x8ea3f(%rip), %rsi     # 0x1348b1
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe9752
movq %rbx, %rdi
movq %r14, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe9752