// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/grob.c
// Function: de_run_grob
static void de_run_grob(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	u8 buf[4];
	const char *s;

	d = de_malloc(c, sizeof(lctx));

	s = de_get_ext_option(c, "grob:planes");
	if(s) {
		d->num_planes = de_atoi64(s);
	}
	if(d->num_planes<1) d->num_planes=1;
	if(d->num_planes>8) {
		de_err(c, "Unsupported grob:planes option");
		goto done;
	}

	s = de_get_ext_option(c, "grob:planeorder");
	if(s && s[0]=='l') {
		d->grayscale_lsb = 1;
	}

	de_read(buf, 0, 4);

	if(!de_memcmp(buf, "HPHP", 4)) {
		de_run_grob_binary(c, d);
	}
	else {
		de_run_grob_text(c, d);
	}

done:
	de_free(c, d);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
pushq $0x28
popq %rsi
callq 0xdecaf
movq %rax, %r14
leaq 0xc22f9(%rip), %rsi     # 0x11337b
movq %rbx, %rdi
callq 0xdfa87
testq %rax, %rax
je 0x5109d
movq %rax, %rdi
callq 0xdfb3b
movq %rax, 0x18(%r14)
jmp 0x510a1
movq 0x18(%r14), %rax
testq %rax, %rax
jle 0x510b8
cmpq $0x9, %rax
jb 0x510c0
leaq 0xc22d4(%rip), %rsi     # 0x113387
jmp 0x51466
movq $0x1, 0x18(%r14)
leaq 0xc22df(%rip), %rsi     # 0x1133a6
movq %rbx, %rdi
callq 0xdfa87
testq %rax, %rax
je 0x510e1
cmpb $0x6c, (%rax)
jne 0x510e1
movl $0x1, 0x20(%r14)
movq 0x18(%rbx), %rdi
leaq 0x34(%rsp), %r15
pushq $0x4
popq %r13
movq %r15, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0xe3cb7
cmpl $0x50485048, (%r15)     # imm = 0x50485048
je 0x51351
movq %rsp, %rax
andq $0x0, (%rax)
leaq 0xc23c4(%rip), %rsi     # 0x1134da
movq %rbx, %rdi
callq 0xe07f7
xorl %ecx, %ecx
xorl %r15d, %r15d
movq 0x18(%rbx), %rdi
movq 0x18(%rdi), %r8
subq %rcx, %r8
jle 0x5145a
leaq 0xc23b5(%rip), %rsi     # 0x1134f0
movq %r13, %rdx
movq %rsp, %r9
callq 0xe62f1
testl %eax, %eax
je 0x5145a
movl (%rsp), %edx
movq %rbx, %rdi
leaq 0xc239a(%rip), %rsi     # 0x1134f5
xorl %eax, %eax
callq 0xde896
incq %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe6ccb
testl %eax, %eax
je 0x51470
movq %r15, 0x28(%rsp)
movq (%rsp), %r12
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
addq $0x3, %r12
movq %r13, %rcx
movq %r12, %r13
movq %rcx, %r15
incq %r12
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xe3eb4
leaq 0x1(%r15), %rcx
cmpb $0x20, %al
je 0x5118f
jmp 0x511c8
movzbl %al, %eax
imulq $0xa, (%r14), %rcx
addq %rcx, %rax
addq $-0x30, %rax
movq %rax, (%r14)
incq %r12
incq %r13
incq %r15
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xe3eb4
cmpb $0x20, %al
jne 0x511ae
movq %r13, %r12
movq %r15, %rbp
incq %r13
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3eb4
incq %r15
cmpb $0x20, %al
je 0x511d8
jmp 0x51212
movzbl %al, %eax
imulq $0xa, 0x8(%r14), %rcx
addq %rcx, %rax
addq $-0x30, %rax
movq %rax, 0x8(%r14)
incq %r13
incq %r12
incq %rbp
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3eb4
cmpb $0x20, %al
jne 0x511f6
movq %rbp, %r13
incq %r12
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xe3eb4
incq %rbp
cmpb $0x20, %al
je 0x51222
cmpq $0x1, 0x18(%r14)
leaq 0xc2208(%rip), %rdx     # 0x11344f
leaq 0xe6a12(%rip), %rax     # 0x137c60
cmoveq %rax, %rdx
movl (%r14), %ecx
movl 0x8(%r14), %r8d
movq %rbx, %rdi
leaq 0xc21d7(%rip), %rsi     # 0x11343a
xorl %eax, %eax
callq 0xde896
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0xe6be1
testl %eax, %eax
je 0x51327
movq (%r14), %rax
addq $0x7, %rax
imulq 0x8(%r14), %rax
cqto
pushq $0x8
popq %rcx
idivq %rcx
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0xe59cd
movq %rax, 0x20(%rsp)
movq 0x18(%rbx), %rdi
cmpq 0x18(%rdi), %r12
jge 0x5130c
movq %r12, %rsi
callq 0xe3eb4
movl %eax, %r15d
movq 0x18(%rbx), %rdi
incq %r12
movq %r12, %rsi
callq 0xe3eb4
cmpb $0x30, %r15b
jb 0x5130c
movl %eax, %ebp
cmpb $0x30, %al
jb 0x5130c
movzbl %r15b, %edi
xorl %esi, %esi
callq 0xe11c4
movl %eax, %r15d
movzbl %bpl, %edi
xorl %esi, %esi
callq 0xe11c4
shlb $0x4, %al
orb %r15b, %al
movzbl %al, %esi
movq 0x20(%rsp), %rdi
callq 0xe5bc5
addq $0x2, %r13
incq %r12
jmp 0x512a7
movq %r13, 0x10(%r14)
movq %rbx, %rdi
movq %r14, %rsi
movq 0x20(%rsp), %r15
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x51538
jmp 0x5132a
xorl %r15d, %r15d
movq %r15, %rdi
callq 0xe5591
movq 0x10(%r14), %rcx
testq %rcx, %rcx
pushq $0x4
popq %r13
movq 0x28(%rsp), %r15
jle 0x51470
addq (%rsp), %rcx
jmp 0x51123
leaq 0xc2063(%rip), %rsi     # 0x1133bb
movq %rbx, %rdi
callq 0xe07f7
movq 0x18(%rbx), %rdi
movq %rsp, %r12
pushq $0x12
popq %rcx
movq %r12, %rsi
xorl %edx, %edx
callq 0xe3cb7
movzbl 0xa(%r12), %ebp
movl %ebp, %eax
andl $0xf, %eax
shll $0x10, %eax
movzbl 0x9(%r12), %ecx
shll $0x8, %ecx
orl %eax, %ecx
movzbl 0x8(%r12), %r15d
orl %ecx, %r15d
movzwl 0xb(%r12), %r12d
leaq 0xc2030(%rip), %rsi     # 0x1133d3
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xde896
cmpl $0x2b1e, %r15d          # imm = 0x2B1E
je 0x513cd
leaq 0xc2025(%rip), %rsi     # 0x1133e5
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xdf05a
shll $0x4, %r12d
shrl $0x4, %ebp
orl %r12d, %ebp
leaq 0xc203f(%rip), %rsi     # 0x11341d
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xde896
movzbl 0xf(%rsp), %ecx
movl %ecx, %eax
andl $0xf, %eax
shll $0x10, %eax
movzbl 0xe(%rsp), %edx
shll $0x8, %edx
orl %eax, %edx
movzbl 0xd(%rsp), %r8d
orq %rdx, %r8
movq %r8, 0x8(%r14)
movzwl 0x10(%rsp), %eax
shll $0x4, %eax
shrl $0x4, %ecx
orl %eax, %ecx
movq %rcx, (%r14)
cmpq $0x1, 0x18(%r14)
leaq 0xe6836(%rip), %rax     # 0x137c60
leaq 0xc201e(%rip), %rdx     # 0x11344f
cmoveq %rax, %rdx
leaq 0xc1ffe(%rip), %rsi     # 0x11343a
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdx
pushq $0x12
popq %rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x51538
jmp 0x51470
testq %r15, %r15
jne 0x51470
leaq 0xc20a7(%rip), %rsi     # 0x11350d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
movq %rbx, %rdi
movq %r14, %rsi
callq 0xded32
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq