// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/printptnr.c
// Function: de_run_pp_gph
static void de_run_pp_gph(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	i64 pos;
	i64 bytes_consumed;
	int img_idx = 0;
	u8 *bufptr;
	u8 buf[256];

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

	de_read(buf, 0, sizeof(buf)-1);
	buf[sizeof(buf)-1] = '\0';
	bufptr = (u8*)de_strchr((const char*)buf, 0x1a);
	if(!bufptr) {
		de_err(c, "This doesn't look like a valid .GPH file");
		goto done;
	}

	pos = (bufptr - buf);
	de_dbg(c, "end of header found at %d", (int)pos);

	pos++;

	while(1) {
		if(pos > (c->infile->len - 24)) break;
		bytes_consumed = 0;
		if(!do_one_image(c, d, pos, img_idx, &bytes_consumed)) goto done;
		if(bytes_consumed<1) goto done;
		pos += bytes_consumed;
		img_idx++;
	}

done:
	de_free(c, d);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rdi, %r15
pushq $0x4
popq %rsi
callq 0xdecaf
movq %rax, 0x40(%rsp)
movq 0x18(%r15), %rdi
leaq 0x50(%rsp), %r14
movl $0xff, %ecx
movq %r14, %rsi
xorl %edx, %edx
callq 0xe3cb7
movb $0x0, 0xff(%r14)
pushq $0x1a
popq %rsi
movq %r14, %rdi
callq 0xde55b
testq %rax, %rax
je 0xb12a2
movq %rax, %rbp
subq %r14, %rbp
leaq 0x79f4e(%rip), %rsi     # 0x12adb4
movq %r15, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xde896
incq %rbp
pushq $0x1
popq %r12
movl $0x0, 0x1c(%rsp)
movq %r15, 0x8(%rsp)
movq 0x18(%r15), %rax
movq 0x18(%rax), %rax
addq $-0x18, %rax
cmpq %rax, %rbp
jg 0xb12b3
movq %r15, %rdi
pushq $0x28
popq %rsi
callq 0xdecaf
movq %rax, %r13
movq %r15, %rdi
leaq 0x79f1b(%rip), %rsi     # 0x12adce
movl 0x1c(%rsp), %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0xde896
movq %r15, %rdi
movl %r12d, %esi
callq 0xdeba7
movq 0x18(%r15), %rdi
movq %rbp, %rsi
callq 0xe3eb4
cmpb $0x15, %al
movq %rbp, 0x20(%rsp)
jb 0xb0efb
movq %r15, %rdi
leaq 0x79ef4(%rip), %rsi     # 0x12adde
xorl %eax, %eax
callq 0xdf2a5
movb $0x1, %bl
xorl %r14d, %r14d
jmp 0xb1244
movzbl %al, %r14d
movq %r15, %rbx
leaq 0x1(%rbp), %r15
movq %rbx, %rdi
callq 0xeac74
movq %rax, 0x20(%r13)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rax, %rcx
xorl %r8d, %r8d
movl %r12d, %r9d
callq 0xe4c9a
movq 0x20(%r13), %rdi
callq 0xeb7e4
movq %rbx, %rdi
leaq 0x6467e(%rip), %rsi     # 0x1155bb
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
leaq 0x15(%rbp), %rsi
movq 0x18(%rbx), %rdi
leaq 0x16(%rbp), %r14
callq 0xe3eb4
movb %al, 0x18(%r13)
movzbl %al, %edx
movq %rbx, %rdi
leaq 0x79e83(%rip), %rsi     # 0x12adec
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
leaq 0x17(%rbp), %r12
movq %r14, %rsi
callq 0xe3eb4
movzbl %al, %eax
movq %rax, 0x8(%r13)
movq 0x18(%rbx), %rdi
leaq 0x18(%rbp), %r15
movq %r12, %rsi
callq 0xe3eb4
movzbl %al, %esi
movq %rsi, 0x10(%r13)
shll $0x3, %esi
movq %rsi, (%r13)
movq 0x8(%r13), %rdx
movq %rbx, %rdi
callq 0xdf038
movzbl 0x18(%r13), %edx
cmpl $0x3, %edx
je 0xb10f1
cmpl $0x2, %edx
je 0xb1009
cmpl $0x1, %edx
jne 0xb1287
movq 0x8(%r13), %rbx
imulq 0x10(%r13), %rbx
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rdi
movq %r15, %rsi
movq %rax, %r15
movq %rbx, %rdx
callq 0xe6248
movq %rax, %r14
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0xb130b
movq %r14, %rdi
movq %rbx, %r14
jmp 0xb10e7
movq 0x8(%rsp), %rbx
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3fa3
movq %rax, %r12
movq %rbx, %rdi
leaq 0x79dd3(%rip), %rsi     # 0x12adfa
movl %r12d, %edx
xorl %eax, %eax
callq 0xde896
movq 0x20(%rsp), %r15
leaq 0x1a(%r15), %r14
movq 0x8(%r13), %rsi
imulq 0x10(%r13), %rsi
movq %rbx, %rdi
pushq $0x1
popq %rdx
callq 0xe59cd
movq %rax, 0x10(%rsp)
movq %r12, 0x28(%rsp)
leaq (%r12,%r15), %rbx
addq $0x1a, %rbx
cmpq %rbx, %r14
jge 0xb10c0
movq 0x8(%rsp), %r15
movq 0x18(%r15), %rdi
leaq 0x1(%r14), %r12
movq %r14, %rsi
callq 0xe3eb4
movl %eax, %ecx
andb $0x7f, %cl
movzbl %cl, %ebp
movq 0x18(%r15), %rdi
testb %al, %al
js 0xb10a2
movq %r12, %rsi
movq %rbp, %rdx
movq 0x10(%rsp), %rcx
callq 0xe45f4
addq %rbp, %r12
movq %r12, %r14
jmp 0xb1060
movq %r12, %rsi
callq 0xe3eb4
addq $0x2, %r14
movzbl %al, %esi
movq 0x10(%rsp), %rdi
movq %rbp, %rdx
callq 0xe5e40
jmp 0xb1060
movq 0x28(%rsp), %r14
addq $0x2, %r14
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
movq 0x10(%rsp), %r15
movq %r15, %rdx
callq 0xb130b
movq %r15, %rdi
movq %rbx, %r15
callq 0xe5591
jmp 0xb123e
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
pushq $0x1
popq %rcx
callq 0xe7437
movq %rax, %rbp
movq (%r13), %rcx
movq 0x8(%r13), %r8
andl $0x0, (%rsp)
xorl %r12d, %r12d
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
pushq $-0x1
popq %r9
callq 0xe8292
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3fa3
movq %rax, %r14
movq %rbx, %rdi
leaq 0x79cce(%rip), %rsi     # 0x12ae12
movl %r14d, %edx
xorl %eax, %eax
callq 0xde896
movq 0x20(%rsp), %rax
addq $0x1a, %rax
movq %rax, 0x38(%rsp)
leaq 0x1(%r14), %rax
movq %rax, 0x48(%rsp)
testq %r14, %r14
cmovleq %r12, %r14
movq %r14, 0x28(%rsp)
xorl %r15d, %r15d
movq $0x0, 0x30(%rsp)
cmpq 0x28(%rsp), %r12
je 0xb120f
movq %r12, 0x10(%rsp)
testb $0x1, %r12b
jne 0xb11bd
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x38(%rsp), %rsi
leaq 0x1(%rsi), %rbx
callq 0xe3eb4
movq %rax, 0x30(%rsp)
movl %eax, %r12d
shrb $0x4, %r12b
movq %rbx, 0x38(%rsp)
jmp 0xb11c9
movq 0x30(%rsp), %rax
movl %eax, %r12d
andb $0xf, %r12b
movl %r12d, %eax
andb $0x7, %al
movzbl %al, %ebx
leaq (%r15,%rbx), %r14
subq $0x1, %rbx
jb 0xb11ff
cmpb $0x8, %r12b
jb 0xb11fa
movq %r15, %rax
cqto
idivq (%r13)
movq %rbp, %rdi
movq %rdx, %rsi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0xe71da
incq %r15
jmp 0xb11d5
movq 0x10(%rsp), %r12
incq %r12
movq %r14, %r15
jmp 0xb117d
movq 0x48(%rsp), %rax
cqto
pushq $0x2
popq %rcx
idivq %rcx
movq %rax, %r14
addq $0x2, %r14
movq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0xb1362
movq %rbp, %rdi
callq 0xe7084
addq $0x18, %r14
xorl %ebx, %ebx
movq %r15, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
testq %r13, %r13
je 0xb1268
movq 0x20(%r13), %rdi
callq 0xeaf3c
movq %r15, %rdi
movq %r13, %rsi
callq 0xded32
testq %r14, %r14
setle %al
orb %al, %bl
movq 0x20(%rsp), %rbp
pushq $0x1
popq %r12
jne 0xb12b3
addq %r14, %rbp
incl 0x1c(%rsp)
jmp 0xb0e86
movq 0x8(%rsp), %r15
movq %r15, %rdi
leaq 0x5e045(%rip), %rsi     # 0x10f2db
xorl %eax, %eax
callq 0xdf2a5
jmp 0xb0ef1
leaq 0x79ae2(%rip), %rsi     # 0x12ad8b
movq %r15, %rdi
xorl %eax, %eax
callq 0xdf2a5
movq %r15, %rdi
movq 0x40(%rsp), %rsi
callq 0xded32
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq