// File: /workspace/github_c_makefile_star2_O1/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 $0x48, %rsp
movq %rdi, %rbx
movl $0x28, %esi
callq 0xe969b
movq %rax, %r14
leaq 0xcc69d(%rip), %rsi     # 0x120345
movq %rbx, %rdi
callq 0xea6cb
testq %rax, %rax
je 0x53cc1
movq %rax, %rdi
callq 0xea786
movq %rax, 0x18(%r14)
cmpq $0x0, 0x18(%r14)
jg 0x53cd0
movq $0x1, 0x18(%r14)
cmpq $0x9, 0x18(%r14)
jl 0x53ce3
leaq 0xcc673(%rip), %rsi     # 0x120351
jmp 0x54111
leaq 0xcc686(%rip), %rsi     # 0x120370
movq %rbx, %rdi
callq 0xea6cb
testq %rax, %rax
je 0x53d04
cmpb $0x6c, (%rax)
jne 0x53d04
movl $0x1, 0x20(%r14)
movq 0x18(%rbx), %rdi
leaq 0x44(%rsp), %r15
movl $0x4, %ecx
movq %r15, %rsi
xorl %edx, %edx
callq 0xeeee8
cmpl $0x50485048, (%r15)     # imm = 0x50485048
je 0x53fd9
movq $0x0, (%rsp)
leaq 0xcc76c(%rip), %rsi     # 0x1204a4
movq %rbx, %rdi
callq 0xeb6d6
movq 0x18(%rbx), %rdi
movq 0x18(%rdi), %r8
testq %r8, %r8
jle 0x5410a
leaq 0xcc762(%rip), %rbp     # 0x1204ba
xorl %r15d, %r15d
xorl %ecx, %ecx
movq %r14, 0x20(%rsp)
subq %rcx, %r8
movl $0x4, %edx
movq %rbp, %rsi
movq %rsp, %r9
callq 0xf1a9c
testl %eax, %eax
je 0x540fd
movl (%rsp), %edx
movq %rbx, %rdi
leaq 0xcc735(%rip), %rsi     # 0x1204bf
xorl %eax, %eax
callq 0xe9226
incq %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0xf2509
movl $0x1, %ecx
movq %rcx, 0x28(%rsp)
testl %eax, %eax
je 0x54102
movq %r15, 0x38(%rsp)
movq (%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq %rax, 0x30(%rsp)
leaq 0x3(%rax), %r15
incq %r15
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef0d5
cmpb $0x20, %al
je 0x53dca
jmp 0x53df7
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 0xef0d5
cmpb $0x20, %al
jne 0x53ddf
leaq 0x1(%r15), %rcx
movq %r15, %r12
movq %rcx, %r13
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef0d5
incq %r15
leaq 0x1(%r13), %rcx
cmpb $0x20, %al
je 0x53e0b
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xef0d5
cmpb $0x20, %al
je 0x53e63
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 0xef0d5
incq %r13
jmp 0x53e34
leaq 0x1(%r12), %rcx
movq %r12, %r13
movq %rcx, %r15
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xef0d5
incq %r12
leaq 0x1(%r15), %rcx
cmpb $0x20, %al
je 0x53e68
cmpq $0x1, 0x18(%r14)
leaq 0xcc588(%rip), %rdx     # 0x120419
leaq 0xf0d38(%rip), %rax     # 0x144bd0
cmoveq %rax, %rdx
movl (%r14), %ecx
movl 0x8(%r14), %r8d
movq %rbx, %rdi
leaq 0xcc557(%rip), %rsi     # 0x120404
xorl %eax, %eax
callq 0xe9226
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0xf241d
testl %eax, %eax
je 0x53f78
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 0xf0faf
movq %rax, %r12
movq 0x18(%rbx), %rdi
cmpq 0x18(%rdi), %r13
jge 0x53f8c
movq %r12, %r14
leaq -0x1(%r15), %r13
movq %r13, %rsi
callq 0xef0d5
movl %eax, %r12d
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef0d5
cmpb $0x30, %r12b
jb 0x53f7d
movl %eax, %ebp
cmpb $0x30, %al
jb 0x53f7d
movzbl %r12b, %edi
xorl %esi, %esi
callq 0xec1cc
movl %eax, %r12d
movzbl %bpl, %edi
xorl %esi, %esi
callq 0xec1cc
shlb $0x4, %al
orb %r12b, %al
movzbl %al, %esi
movq %r14, %r12
movq %r14, %rdi
callq 0xf11be
movq 0x18(%rbx), %rdi
leaq 0x2(%r15), %r13
incq %r15
cmpq 0x18(%rdi), %r15
movq %r13, %r15
jl 0x53f01
decq %r13
leaq 0xcc544(%rip), %rbp     # 0x1204ba
jmp 0x53f87
xorl %r12d, %r12d
jmp 0x53fa5
leaq 0xcc536(%rip), %rbp     # 0x1204ba
movq %r14, %r12
movq 0x20(%rsp), %r14
subq 0x30(%rsp), %r13
movq %r13, 0x10(%r14)
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x541ec
movq %r12, %rdi
callq 0xf0b13
movq 0x10(%r14), %rcx
testq %rcx, %rcx
movq 0x38(%rsp), %r15
jle 0x54102
addq (%rsp), %rcx
movq 0x18(%rbx), %rdi
movq 0x18(%rdi), %r8
cmpq %r8, %rcx
jl 0x53d62
jmp 0x54102
leaq 0xcc3a5(%rip), %rsi     # 0x120385
movq %rbx, %rdi
callq 0xeb6d6
movq 0x18(%rbx), %rdi
movq %rsp, %r12
movl $0x12, %ecx
movq %r12, %rsi
xorl %edx, %edx
callq 0xeeee8
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
movzbl 0xc(%r12), %r13d
movzbl 0xb(%r12), %r12d
leaq 0xcc36a(%rip), %rsi     # 0x12039d
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe9226
cmpl $0x2b1e, %r15d          # imm = 0x2B1E
je 0x5405d
leaq 0xcc35f(%rip), %rsi     # 0x1203af
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe9b27
shll $0xc, %r13d
shll $0x4, %r12d
shrl $0x4, %ebp
orl %r13d, %ebp
orl %r12d, %ebp
leaq 0xcc372(%rip), %rsi     # 0x1203e7
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe9226
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)
movzbl 0x11(%rsp), %eax
shll $0xc, %eax
movzbl 0x10(%rsp), %edx
shll $0x4, %edx
shrl $0x4, %ecx
orl %eax, %ecx
orl %edx, %ecx
movq %rcx, (%r14)
cmpq $0x1, 0x18(%r14)
leaq 0xf0b05(%rip), %rax     # 0x144bd0
leaq 0xcc347(%rip), %rdx     # 0x120419
cmoveq %rax, %rdx
leaq 0xcc327(%rip), %rsi     # 0x120404
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdx
movl $0x12, %ecx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x541ec
jmp 0x5411b
movq %r15, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
jne 0x5411b
leaq 0xcc3c6(%rip), %rsi     # 0x1204d7
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe9752
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq