// File: /workspace/github_c_makefile_star2_O3/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
movl $0x28, %esi
callq 0xe8b2b
movq %rax, %r14
leaq 0xcc885(%rip), %rsi     # 0x12046d
movq %rbx, %rdi
callq 0xe9b74
testq %rax, %rax
je 0x53c03
movq %rax, %rdi
callq 0xe9c2f
movq %rax, 0x18(%r14)
jmp 0x53c07
movq 0x18(%r14), %rax
testq %rax, %rax
jle 0x53c1e
cmpq $0x9, %rax
jb 0x53c26
leaq 0xcc860(%rip), %rsi     # 0x120479
jmp 0x5402b
movq $0x1, 0x18(%r14)
leaq 0xcc86b(%rip), %rsi     # 0x120498
movq %rbx, %rdi
callq 0xe9b74
testq %rax, %rax
je 0x53c47
cmpb $0x6c, (%rax)
jne 0x53c47
movl $0x1, 0x20(%r14)
movq 0x18(%rbx), %rdi
leaq 0x34(%rsp), %r15
movl $0x4, %ecx
movq %r15, %rsi
xorl %edx, %edx
callq 0xee8d4
cmpl $0x50485048, (%r15)     # imm = 0x50485048
je 0x53f12
movq $0x0, (%rsp)
leaq 0xcc951(%rip), %rsi     # 0x1205cc
movq %rbx, %rdi
callq 0xeb125
movq 0x18(%rbx), %rdi
movq 0x18(%rdi), %r8
testq %r8, %r8
jle 0x54024
leaq 0xcc947(%rip), %rbp     # 0x1205e2
xorl %r15d, %r15d
xorl %ecx, %ecx
movq %r14, 0x18(%rsp)
subq %rcx, %r8
movl $0x4, %edx
movq %rbp, %rsi
movq %rsp, %r9
callq 0xf149c
testl %eax, %eax
je 0x5401f
movl (%rsp), %edx
movq %rbx, %rdi
leaq 0xcc91a(%rip), %rsi     # 0x1205e7
xorl %eax, %eax
callq 0xe8617
incq %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0xf1e9d
testl %eax, %eax
je 0x54035
movq %r15, 0x28(%rsp)
movq (%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq %rax, 0x20(%rsp)
leaq 0x3(%rax), %r15
incq %r15
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeead3
cmpb $0x20, %al
je 0x53d03
jmp 0x53d30
movzbl %al, %eax
movq (%r14), %rcx
leaq (%rcx,%rcx,4), %rcx
leaq (%rax,%rcx,2), %rax
addq $-0x30, %rax
movq %rax, (%r14)
incq %r15
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeead3
cmpb $0x20, %al
jne 0x53d18
leaq 0x1(%r15), %rcx
movq %r15, %r12
movq %rcx, %r13
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeead3
incq %r15
leaq 0x1(%r13), %rcx
cmpb $0x20, %al
je 0x53d44
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeead3
cmpb $0x20, %al
je 0x53d9c
movq %r13, %r12
movzbl %al, %eax
movq 0x8(%r14), %rcx
leaq (%rcx,%rcx,4), %rcx
leaq (%rax,%rcx,2), %rax
addq $-0x30, %rax
movq %rax, 0x8(%r14)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeead3
incq %r13
jmp 0x53d6d
leaq 0x1(%r12), %rcx
movq %r12, %r13
movq %rcx, %r15
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeead3
incq %r12
leaq 0x1(%r15), %rcx
cmpb $0x20, %al
je 0x53da1
cmpq $0x1, 0x18(%r14)
leaq 0xcc777(%rip), %rdx     # 0x120541
leaq 0xf12df(%rip), %rax     # 0x1450b0
cmoveq %rax, %rdx
movl (%r14), %ecx
movl 0x8(%r14), %r8d
movq %rbx, %rdi
leaq 0xcc746(%rip), %rsi     # 0x12052c
xorl %eax, %eax
callq 0xe8617
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0xf1db1
testl %eax, %eax
je 0x53eb1
movq (%r14), %rax
addq $0x7, %rax
imulq 0x8(%r14), %rax
leaq 0x7(%rax), %rsi
testq %rax, %rax
cmovnsq %rax, %rsi
sarq $0x3, %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xf09c5
movq %rax, %r12
movq 0x18(%rbx), %rdi
cmpq 0x18(%rdi), %r13
jge 0x53ec5
movq %r12, %r14
leaq -0x1(%r15), %r13
movq %r13, %rsi
callq 0xeead3
movl %eax, %r12d
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeead3
cmpb $0x30, %r12b
jb 0x53eb6
movl %eax, %ebp
cmpb $0x30, %al
jb 0x53eb6
movzbl %r12b, %edi
xorl %esi, %esi
callq 0xebbbc
movl %eax, %r12d
movzbl %bpl, %edi
xorl %esi, %esi
callq 0xebbbc
shlb $0x4, %al
orb %r12b, %al
movzbl %al, %esi
movq %r14, %r12
movq %r14, %rdi
callq 0xf0bd6
movq 0x18(%rbx), %rdi
leaq 0x2(%r15), %r13
incq %r15
cmpq 0x18(%rdi), %r15
movq %r13, %r15
jl 0x53e3a
decq %r13
leaq 0xcc733(%rip), %rbp     # 0x1205e2
jmp 0x53ec0
xorl %r12d, %r12d
jmp 0x53ede
leaq 0xcc725(%rip), %rbp     # 0x1205e2
movq %r14, %r12
movq 0x18(%rsp), %r14
subq 0x20(%rsp), %r13
movq %r13, 0x10(%r14)
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x54101
movq %r12, %rdi
callq 0xf052b
movq 0x10(%r14), %rcx
testq %rcx, %rcx
movq 0x28(%rsp), %r15
jle 0x54035
addq (%rsp), %rcx
movq 0x18(%rbx), %rdi
movq 0x18(%rdi), %r8
cmpq %r8, %rcx
jl 0x53ca5
jmp 0x54035
leaq 0xcc594(%rip), %rsi     # 0x1204ad
movq %rbx, %rdi
callq 0xeb125
movq 0x18(%rbx), %rdi
movq %rsp, %r12
movl $0x12, %ecx
movq %r12, %rsi
xorl %edx, %edx
callq 0xee8d4
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 0xcc55f(%rip), %rsi     # 0x1204c5
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe8617
cmpl $0x2b1e, %r15d          # imm = 0x2B1E
je 0x53f90
leaq 0xcc554(%rip), %rsi     # 0x1204d7
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe8faa
shll $0x4, %r12d
shrl $0x4, %ebp
orl %r12d, %ebp
leaq 0xcc56e(%rip), %rsi     # 0x12050f
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
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 0xf10c3(%rip), %rax     # 0x1450b0
leaq 0xcc54d(%rip), %rdx     # 0x120541
cmoveq %rax, %rdx
leaq 0xcc52d(%rip), %rsi     # 0x12052c
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdx
movl $0x12, %ecx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x54101
jmp 0x54035
testq %r15, %r15
jne 0x54035
leaq 0xcc5d4(%rip), %rsi     # 0x1205ff
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe8be2
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq