// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x58
popq %rsi
callq 0xdecaf
movq %rax, %r14
movl $0x1, (%rax)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x9f9fe
pushq $0x18
popq %rsi
movq %rbx, %rdi
callq 0xdecaf
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 0xe41b1
movl %eax, 0x28(%r14)
leaq 0x88612(%rip), %rsi     # 0x127897
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
pushq $0x4
popq %rsi
callq 0xe41cb
movl 0x28(%r14), %edx
cmpq $0x3842494d, %rax       # imm = 0x3842494D
jne 0x9f31f
cmpl $0x3, %edx
jl 0x9f328
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
pushq $0x2
popq %rsi
callq 0xe41b1
movl %eax, 0x2c(%r14)
leaq 0x8869a(%rip), %rsi     # 0x127967
movq %rbx, %rdi
callq 0xe07f7
movq (%r15), %rsi
addq $0x4, %rsi
movq %rsi, (%r15)
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
callq 0xe41cb
cmpl $0x3842494d, %eax       # imm = 0x3842494D
jne 0x9f418
movq (%r15), %rax
movq 0x10(%r15), %rcx
movq %rsp, %rdx
movq %rax, 0x8(%rdx)
movq %rax, (%rdx)
movq %rcx, 0x10(%rdx)
pushq $0x2
popq %rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa2803
jmp 0x9f429
cmpl $0x5, %edx
jg 0x9f405
leaq 0x88655(%rip), %rsi     # 0x127984
movq %rbx, %rdi
callq 0xe07f7
addq $0x2, (%r15)
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
movq %r15, %rsi
callq 0x9feb0
movq %rax, %r12
leaq 0x886a6(%rip), %rsi     # 0x1279fb
xorl %r13d, %r13d
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xde896
testq %r12, %r12
cmovleq %r13, %r12
xorl %ebp, %ebp
cmpq %rbp, %r12
je 0x9f429
movq (%r15), %rcx
cmpq 0x10(%r15), %rcx
jge 0x9f429
movq %rbx, %rdi
leaq 0x88683(%rip), %rsi     # 0x127a11
movl %ebp, %edx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
movq %r15, %rsi
callq 0x9feb0
movq %rbx, %rdi
leaq 0x88670(%rip), %rsi     # 0x127a2c
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
movq %r15, %rsi
callq 0x9fe70
movq %rax, %r13
movl (%r15), %edx
movq %rbx, %rdi
leaq 0x88656(%rip), %rsi     # 0x127a3b
movl %r13d, %ecx
xorl %eax, %eax
callq 0xde896
addq %r13, (%r15)
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
incq %rbp
jmp 0x9f36e
leaq 0x88595(%rip), %rsi     # 0x1279a1
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
jmp 0x9f429
leaq 0x885b2(%rip), %rsi     # 0x1279d1
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
movq %rbx, %rdi
movq %r15, %rsi
callq 0xded32
movq %rbx, %rdi
movq %r14, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xded32