// File: /workspace/github_c_makefile_star2_O3/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, %rbp
movl $0x4, %esi
callq 0xe8b2b
movq %rax, 0x48(%rsp)
movq 0x18(%rbp), %rdi
leaq 0x50(%rsp), %r14
movl $0xff, %ecx
movq %r14, %rsi
xorl %edx, %edx
callq 0xee8d4
movb $0x0, 0xff(%r14)
movq %r14, %rdi
movl $0x1a, %esi
callq 0xe82ee
testq %rax, %rax
je 0xb8481
movq %rax, %r12
subq %r14, %r12
leaq 0x800a6(%rip), %rsi     # 0x1380b4
movq %rbp, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbp), %rax
movq 0x18(%rax), %rax
addq $-0x18, %rax
cmpq %rax, %r12
jge 0xb8492
incq %r12
leaq 0x80094(%rip), %r14     # 0x1380ce
xorl %r15d, %r15d
movq %rbp, 0x28(%rsp)
movl $0x28, %esi
movq %rbp, %rdi
callq 0xe8b2b
movq %rax, %r13
movq %rbp, %rdi
movq %r14, %rsi
movl %r15d, %edx
movl %r12d, %ecx
xorl %eax, %eax
callq 0xe8617
movq %rbp, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbp), %rdi
movq %r12, %rsi
callq 0xeead3
cmpb $0x15, %al
jb 0xb80a3
movq $0x0, 0x18(%rsp)
movq %rbp, %rdi
leaq 0x80049(%rip), %rsi     # 0x1380de
xorl %eax, %eax
callq 0xe9295
xorl %ebx, %ebx
jmp 0xb83f4
movl %r15d, 0x14(%rsp)
movzbl %al, %r14d
leaq 0x1(%r12), %r15
movq %rbp, %rdi
callq 0xf6410
movq %rax, 0x20(%r13)
movq 0x18(%rbp), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rax, %rcx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0xefbd7
movq 0x20(%r13), %rdi
callq 0xf705c
movq %rbp, %rdi
leaq 0x6a690(%rip), %rsi     # 0x12277b
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
leaq 0x15(%r12), %rsi
movq 0x18(%rbp), %rdi
leaq 0x16(%r12), %r14
callq 0xeead3
movb %al, 0x18(%r13)
movzbl %al, %edx
movq %rbp, %rdi
leaq 0x7ffd3(%rip), %rsi     # 0x1380ec
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbp), %rdi
movq %r12, %rbx
addq $0x17, %r12
movq %r14, %rsi
callq 0xeead3
movzbl %al, %eax
movq %rax, 0x8(%r13)
movq 0x18(%rbp), %rdi
movq %rbx, 0x20(%rsp)
leaq 0x18(%rbx), %r15
movq %r12, %rsi
callq 0xeead3
movzbl %al, %esi
movq %rsi, 0x10(%r13)
shll $0x3, %esi
movq %rsi, (%r13)
movq 0x8(%r13), %rdx
movq %rbp, %rdi
callq 0xe8f88
movzbl 0x18(%r13), %edx
cmpl $0x3, %edx
je 0xb8292
cmpl $0x2, %edx
je 0xb81b6
cmpl $0x1, %edx
jne 0xb8445
movq 0x8(%r13), %rbx
imulq 0x10(%r13), %rbx
movq 0x18(%rbp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0xf1388
movq %rax, %r14
movq %rbp, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0xb84ee
movq %r14, %rdi
jmp 0xb8288
movq 0x18(%rbp), %rdi
movq %r15, %rsi
callq 0xeebc8
movq %rax, %rbx
movq %rbp, %rdi
leaq 0x7ff2b(%rip), %rsi     # 0x1380fa
movl %ebx, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x8(%r13), %rsi
imulq 0x10(%r13), %rsi
movq %rbp, %rdi
movl $0x1, %edx
callq 0xf09c5
movq %rax, %r15
movq %rbx, 0x18(%rsp)
testq %rbx, %rbx
jle 0xb826e
movq 0x20(%rsp), %rax
leaq 0x1a(%rax), %r14
movq 0x18(%rsp), %rcx
leaq (%rcx,%rax), %rbx
addq $0x1a, %rbx
movq 0x18(%rbp), %rdi
leaq 0x1(%r14), %r12
movq %r14, %rsi
callq 0xeead3
movl %eax, %ecx
andb $0x7f, %cl
movq %rbp, %rdx
movzbl %cl, %ebp
movq 0x18(%rdx), %rdi
testb %al, %al
js 0xb824a
movq %r12, %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0xef481
addq %rbp, %r12
movq %r12, %r14
jmp 0xb8264
movq %r12, %rsi
callq 0xeead3
addq $0x2, %r14
movzbl %al, %esi
movq %r15, %rdi
movq %rbp, %rdx
callq 0xf0eba
cmpq %rbx, %r14
movq 0x28(%rsp), %rbp
jl 0xb8211
movq 0x18(%rsp), %rbx
addq $0x2, %rbx
movq %rbp, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0xb84ee
movq %r15, %rdi
callq 0xf052b
jmp 0xb83d5
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %rbp, %rdi
movl $0x1, %ecx
callq 0xf266a
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 0xf3654
movq 0x18(%rbp), %rdi
movq %r15, %rsi
callq 0xeebc8
movq %rax, %rbx
movq %rbp, %rdi
leaq 0x7fe2e(%rip), %rsi     # 0x138112
movl %ebx, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, 0x40(%rsp)
testq %rbx, %rbx
jle 0xb839f
movq 0x20(%rsp), %rax
addq $0x1a, %rax
movq %rax, 0x38(%rsp)
movq $0x0, 0x30(%rsp)
xorl %ebp, %ebp
xorl %ebx, %ebx
testb $0x1, %bl
jne 0xb8345
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x38(%rsp), %rsi
leaq 0x1(%rsi), %r14
callq 0xeead3
movq %rax, 0x30(%rsp)
movl %eax, %r15d
shrb $0x4, %r15b
movq %r14, 0x38(%rsp)
jmp 0xb8351
movq 0x30(%rsp), %rax
movl %eax, %r15d
andb $0xf, %r15b
movl %r15d, %eax
andb $0x7, %al
je 0xb8391
movzbl %al, %r14d
leaq (%r14,%rbp), %rax
movq %rax, 0x18(%rsp)
cmpb $0x8, %r15b
jb 0xb8384
movq %rbp, %rax
cqto
idivq (%r13)
movq %r12, %rdi
movq %rdx, %rsi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0xf2405
incq %rbp
decq %r14
jne 0xb8365
movq 0x18(%rsp), %rbp
incq %rbx
cmpq 0x40(%rsp), %rbx
jne 0xb8316
movq 0x40(%rsp), %rcx
leaq 0x1(%rcx), %rax
shrq $0x3f, %rax
leaq (%rcx,%rax), %rbx
incq %rbx
sarq %rbx
addq $0x2, %rbx
movq 0x28(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0xb854b
movq %r12, %rdi
callq 0xf228d
movq 0x20(%rsp), %r12
leaq 0x7fced(%rip), %r14     # 0x1380ce
movl 0x14(%rsp), %r15d
addq $0x18, %rbx
movq %rbx, 0x18(%rsp)
movl $0x1, %ebx
movq %rbp, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
testq %r13, %r13
je 0xb841a
movq 0x20(%r13), %rdi
callq 0xf6753
movq %rbp, %rdi
movq %r13, %rsi
callq 0xe8be2
testl %ebx, %ebx
movq 0x18(%rsp), %rax
je 0xb8492
testq %rax, %rax
jle 0xb8492
addq %rax, %r12
incl %r15d
movq 0x18(%rbp), %rax
movq 0x18(%rax), %rax
addq $-0x18, %rax
cmpq %rax, %r12
jle 0xb8042
jmp 0xb8492
movq $0x0, 0x18(%rsp)
movq %rbp, %rdi
leaq 0x63f73(%rip), %rsi     # 0x11c3cb
xorl %eax, %eax
callq 0xe9295
movq %rbp, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
xorl %ebx, %ebx
movq 0x20(%rsp), %r12
leaq 0x7fc54(%rip), %r14     # 0x1380ce
movl 0x14(%rsp), %r15d
jmp 0xb8406
leaq 0x7fc03(%rip), %rsi     # 0x13808b
movq %rbp, %rdi
xorl %eax, %eax
callq 0xe9295
movq %rbp, %rdi
movq 0x48(%rsp), %rsi
callq 0xe8be2
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq