// File: /workspace/github_c_makefile_star2_O1/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 $0x148, %rsp            # imm = 0x148
movq %rdi, %r12
movl $0x4, %esi
callq 0xe969b
movq %rax, 0x38(%rsp)
movq 0x18(%r12), %rdi
leaq 0x40(%rsp), %r14
movl $0xff, %ecx
movq %r14, %rsi
xorl %edx, %edx
callq 0xeeee8
movb $0x0, 0xff(%r14)
movq %r14, %rdi
movl $0x1a, %esi
callq 0xe8ed3
testq %rax, %rax
je 0xb9034
movq %rax, %rbp
subq %r14, %rbp
leaq 0x7f131(%rip), %rsi     # 0x137d28
movq %r12, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%r12), %rax
movq 0x18(%rax), %rax
addq $-0x18, %rax
cmpq %rax, %rbp
jge 0xb9045
incq %rbp
xorl %ebx, %ebx
movq %r12, 0x10(%rsp)
movl $0x28, %esi
movq %r12, %rdi
callq 0xe969b
movq %rax, %r13
movq %r12, %rdi
leaq 0x7f105(%rip), %rsi     # 0x137d42
movl %ebx, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0xe9226
movq %r12, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%r12), %rdi
movq %rbp, %rsi
callq 0xef0d5
cmpb $0x15, %al
movl %ebx, 0x2c(%rsp)
jb 0xb8c85
movq %r12, %rdi
leaq 0x7f0de(%rip), %rsi     # 0x137d52
xorl %eax, %eax
callq 0xe9df7
movb $0x1, %bl
xorl %r14d, %r14d
jmp 0xb8fcd
movzbl %al, %r14d
leaq 0x1(%rbp), %r15
movq %r12, %rdi
callq 0xf6870
movq %rax, 0x20(%r13)
movq 0x18(%r12), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rax, %rcx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0xf01b0
movq 0x20(%r13), %rdi
callq 0xf74bd
movq %r12, %rdi
leaq 0x698ab(%rip), %rsi     # 0x122573
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
leaq 0x15(%rbp), %rsi
movq 0x18(%r12), %rdi
leaq 0x16(%rbp), %r14
callq 0xef0d5
movb %al, 0x18(%r13)
movzbl %al, %edx
movq %r12, %rdi
leaq 0x7f06b(%rip), %rsi     # 0x137d60
xorl %eax, %eax
callq 0xe9226
movq 0x18(%r12), %rdi
leaq 0x17(%rbp), %r12
movq %r14, %rsi
callq 0xef0d5
movzbl %al, %eax
movq %rax, 0x8(%r13)
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
leaq 0x18(%rbp), %r15
movq %r12, %rsi
movq 0x10(%rsp), %r12
callq 0xef0d5
movzbl %al, %esi
movq %rsi, 0x10(%r13)
shll $0x3, %esi
movq %rsi, (%r13)
movq 0x8(%r13), %rdx
movq %r12, %rdi
callq 0xe9b05
movzbl 0x18(%r13), %edx
cmpl $0x3, %edx
je 0xb8e85
cmpl $0x2, %edx
je 0xb8d9b
cmpl $0x1, %edx
jne 0xb901e
movq 0x8(%r13), %r14
imulq 0x10(%r13), %r14
movq 0x18(%r12), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xf1988
movq %rax, %r15
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0xb90a1
movq %r15, %rdi
callq 0xf0b13
jmp 0xb8fc7
movq 0x18(%r12), %rdi
movq %r15, %rsi
callq 0xef1ca
movq %rax, %rbx
movq %r12, %rdi
leaq 0x7efb9(%rip), %rsi     # 0x137d6e
movl %ebx, %edx
xorl %eax, %eax
callq 0xe9226
movq %r12, %rdi
leaq 0x1a(%rbp), %r12
movq 0x8(%r13), %rsi
imulq 0x10(%r13), %rsi
movl $0x1, %edx
callq 0xf0faf
movq %rax, 0x8(%rsp)
movq %rbp, 0x18(%rsp)
movq %rbx, 0x20(%rsp)
addq %rbp, %rbx
addq $0x1a, %rbx
movq %r12, %rbp
cmpq %rbx, %r12
jge 0xb8e4f
movq 0x10(%rsp), %r14
movq 0x18(%r14), %rdi
leaq 0x1(%r12), %rbp
movq %r12, %rsi
callq 0xef0d5
movl %eax, %ecx
andb $0x7f, %cl
movzbl %cl, %r15d
movq 0x18(%r14), %rdi
testb %al, %al
js 0xb8e32
movq %rbp, %rsi
movq %r15, %rdx
movq 0x8(%rsp), %rcx
callq 0xefabc
addq %r15, %rbp
jmp 0xb8e4f
movq %rbp, %rsi
callq 0xef0d5
leaq 0x2(%r12), %rbp
movzbl %al, %esi
movq 0x8(%rsp), %rdi
movq %r15, %rdx
callq 0xf14bd
cmpq %rbx, %r12
movq %rbp, %r12
jl 0xb8df1
movq 0x20(%rsp), %r14
addq $0x2, %r14
movq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
movq 0x8(%rsp), %rbx
movq %rbx, %rdx
callq 0xb90a1
movq %rbx, %rdi
callq 0xf0b13
jmp 0xb8fc2
movq %rbp, 0x18(%rsp)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %r12, %rdi
movl $0x1, %ecx
callq 0xf2cab
movq %r12, %rbx
movq %rax, %r12
movq (%r13), %rcx
movq 0x8(%r13), %r8
movl $0x0, (%rsp)
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
callq 0xf3cb3
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef1ca
movq %rax, %r14
movq %rbx, %rdi
leaq 0x7eea7(%rip), %rsi     # 0x137d86
movl %r14d, %edx
xorl %eax, %eax
callq 0xe9226
movq %r14, 0x8(%rsp)
testq %r14, %r14
jle 0xb8f89
movq 0x18(%rsp), %rax
addq $0x1a, %rax
movq %rax, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
xorl %ebp, %ebp
xorl %ebx, %ebx
testb $0x1, %bl
jne 0xb8f41
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x20(%rsp), %rsi
leaq 0x1(%rsi), %r14
callq 0xef0d5
movq %rax, 0x30(%rsp)
movl %eax, %r15d
shrb $0x4, %r15b
movq %r14, 0x20(%rsp)
jmp 0xb8f4d
movq 0x30(%rsp), %rax
movl %eax, %r15d
andb $0xf, %r15b
movl %r15d, %eax
andb $0x7, %al
je 0xb8f7f
movzbl %al, %r14d
cmpb $0x8, %r15b
jb 0xb8f77
movq %rbp, %rax
cqto
idivq (%r13)
movq %r12, %rdi
movq %rdx, %rsi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0xf2a4a
incq %rbp
decq %r14
jne 0xb8f58
incq %rbx
cmpq 0x8(%rsp), %rbx
jne 0xb8f12
movq 0x8(%rsp), %rcx
leaq 0x1(%rcx), %rax
shrq $0x3f, %rax
leaq (%rcx,%rax), %r14
incq %r14
sarq %r14
addq $0x2, %r14
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0xb90fe
movq %r12, %rdi
movq %rbx, %r12
callq 0xf28d4
movq 0x18(%rsp), %rbp
addq $0x18, %r14
xorl %ebx, %ebx
movq %r12, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
testq %r13, %r13
je 0xb8ff3
movq 0x20(%r13), %rdi
callq 0xf6bb0
movq %r12, %rdi
movq %r13, %rsi
callq 0xe9752
testq %r14, %r14
setle %al
orb %al, %bl
movl 0x2c(%rsp), %ebx
jne 0xb9045
addq %r14, %rbp
incl %ebx
movq 0x18(%r12), %rax
movq 0x18(%rax), %rax
addq $-0x18, %rax
cmpq %rax, %rbp
jle 0xb8c23
jmp 0xb9045
movq %r12, %rdi
leaq 0x63293(%rip), %rsi     # 0x11c2bb
xorl %eax, %eax
callq 0xe9df7
jmp 0xb8c7b
leaq 0x7ecc4(%rip), %rsi     # 0x137cff
movq %r12, %rdi
xorl %eax, %eax
callq 0xe9df7
movq %r12, %rdi
movq 0x38(%rsp), %rsi
callq 0xe9752
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq