// File: /workspace/github_c_makefile_star2_O3/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 0xe8b2b
movq %rax, %r14
movl $0x1, (%rax)
movq $0x2, 0x18(%rax)
movq $0x4, 0x20(%rax)
movq %rbx, %rdi
xorl %esi, %esi
movl $0x11, %edx
callq 0xeb220
movl %eax, 0x8(%r14)
movb $0x1, 0x14(%r14)
movl $0x18, %esi
movq %rbx, %rdi
callq 0xe8b2b
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 0xeef43
movl %eax, 0x28(%r14)
leaq 0x8f823(%rip), %rsi     # 0x134b6f
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
movl $0x4, %esi
callq 0xeeff3
movl 0x28(%r14), %edx
cmpq $0x3842494d, %rax       # imm = 0x3842494D
jne 0xa53ec
cmpl $0x3, %edx
jl 0xa53f5
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
movl $0x2, %esi
callq 0xeef43
movl %eax, 0x2c(%r14)
leaq 0x8f8a7(%rip), %rsi     # 0x134c3f
movq %rbx, %rdi
callq 0xeb125
movq (%r15), %rsi
addq $0x4, %rsi
movq %rsi, (%r15)
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
callq 0xeeff3
cmpl $0x3842494d, %eax       # imm = 0x3842494D
jne 0xa54f7
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 0xa8d66
jmp 0xa5508
cmpl $0x5, %edx
jg 0xa54e4
leaq 0x8f860(%rip), %rsi     # 0x134c5c
movq %rbx, %rdi
callq 0xeb125
movq (%r15), %rsi
addq $0x2, %rsi
movq %rsi, (%r15)
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
callq 0xeef43
movq %rax, %r12
addq $0x2, (%r15)
leaq 0x8f8aa(%rip), %rsi     # 0x134cd3
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xe8617
testq %r12, %r12
jle 0xa5508
xorl %ebp, %ebp
movq (%r15), %rcx
cmpq 0x10(%r15), %rcx
jge 0xa5508
movq %rbx, %rdi
leaq 0x8f891(%rip), %rsi     # 0x134ce9
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
movq (%r15), %rsi
callq 0xeef43
addq $0x2, (%r15)
movq %rbx, %rdi
leaq 0x8f878(%rip), %rsi     # 0x134d04
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %edx
movq (%r15), %rsi
callq 0xeeff3
movq %rax, %r13
movq (%r15), %rdx
addq $0x4, %rdx
movq %rdx, (%r15)
movq %rbx, %rdi
leaq 0x8f857(%rip), %rsi     # 0x134d13
movl %r13d, %ecx
xorl %eax, %eax
callq 0xe8617
addq %r13, (%r15)
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
incq %rbp
cmpq %rbp, %r12
jne 0xa5441
jmp 0xa5508
leaq 0x8f78e(%rip), %rsi     # 0x134c79
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
jmp 0xa5508
leaq 0x8f7ab(%rip), %rsi     # 0x134ca9
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe8be2
movq %rbx, %rdi
movq %r14, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe8be2