// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/printshop.c
// Function: do_printshop_etc
static void do_printshop_etc(deark *c, lctx *d)
{
	i64 headersize = 0;
	const char *namefile_fn = NULL;
	i64 bytes_consumed;
	i64 pos;
	i64 img_count;
	i64 num_images = 0;
	int num_images_is_known = 0;

	namefile_fn = de_get_ext_option(c, "namefile");
	if(!namefile_fn) namefile_fn = de_get_ext_option(c, "file2");

	if(namefile_fn) {
		d->namefile = dbuf_open_input_file(c, namefile_fn);
	}
	if(d->namefile) {
		de_dbg(c, "Using name file: %s", namefile_fn);
	}

	if(d->fmt == PRINTSHOP_FMT_POG) {
		num_images = de_getu16le(8);
		de_dbg(c, "number of images: %d", (int)num_images);
		num_images_is_known = 1;
		headersize = 10;
	}
	else {
		headersize = 0;
	}

	pos = headersize;
	img_count = 0;
	while(1) {
		if(num_images_is_known && (img_count >= num_images)) break;
		if(pos >= c->infile->len) break;
		do_printshop_etc_image(c, d, img_count, pos, &bytes_consumed);
		if(bytes_consumed<1) break;
		pos += bytes_consumed;
		img_count++;
	}

	if(num_images_is_known && (c->infile->len - pos)>=128) {
		de_warn(c, "%d bytes of data were ignored. This file may not have "
			"been fully decoded.", (int)(c->infile->len - pos));
	}

	dbuf_close(d->namefile);
	d->namefile = NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movq -0x8(%rbp), %rdi
leaq 0xabe91(%rip), %rsi     # 0x1c4dbb
callq 0x15cb30
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x118f4e
movq -0x8(%rbp), %rdi
leaq 0x83633(%rip), %rsi     # 0x19c578
callq 0x15cb30
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x118f6d
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x168de0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x118f8e
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq 0xabe3d(%rip), %rsi     # 0x1c4dc4
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x118fd6
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0x8, %esi
callq 0x165280
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
leaq 0xabe1a(%rip), %rsi     # 0x1c4dd8
movb $0x0, %al
callq 0x15b0d0
movl $0x1, -0x44(%rbp)
movq $0xa, -0x18(%rbp)
jmp 0x118fde
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x119000
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jl 0x119000
jmp 0x119050
movq -0x30(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jl 0x119014
jmp 0x119050
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x30(%rbp), %rcx
leaq -0x28(%rbp), %r8
callq 0x1190c0
cmpq $0x1, -0x28(%rbp)
jge 0x119036
jmp 0x119050
movq -0x28(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x118fee
cmpl $0x0, -0x44(%rbp)
je 0x119092
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
subq -0x30(%rbp), %rax
cmpq $0x80, %rax
jl 0x119092
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
subq -0x30(%rbp), %rax
movl %eax, %edx
leaq 0xabd62(%rip), %rsi     # 0x1c4ded
movb $0x0, %al
callq 0x15bc10
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x1676a0
movq -0x10(%rbp), %rax
movq $0x0, 0x8(%rax)
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)