// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/misc2.c
// Function: de_run_pixfolio
static void de_run_pixfolio(deark *c, de_module_params *mparams)
{
	struct pixfolio_ctx *d = NULL;
	struct pixfolio_item_ctx *md = NULL;
	i64 pos;

	d = de_malloc(c, sizeof(struct pixfolio_ctx));
	d->input_encoding = de_get_input_encoding(c, NULL, DE_ENCODING_WINDOWS1252);
	d->opt_undelete = (u8)de_get_ext_option_bool(c, "pixfolio:undelete", 0);
	d->tmpstr = ucstring_create(c);

	pos = 0;
	while(1) {
		if(d->fatalerrflag) goto done;
		if(pos+373 > c->infile->len) goto done;
		if(md) {
			pixfolio_item_destroy(c, md);
			md = NULL;
		}
		md = de_malloc(c, sizeof(struct pixfolio_item_ctx));
		md->pos = pos;
		do_pixfolio_item(c, d, md);
		if(md->total_len<=0) goto done;
		pos += md->total_len;
	}

done:
	pixfolio_item_destroy(c, md);
	if(d) {
		if(d->deleted_count!=0 && !d->opt_undelete) {
			de_info(c, "Note: Deleted items found. Use \"-opt pixfolio:undelete\" "
				"to extract them.");
		}
		if(d->need_errmsg) {
			de_err(c, "Bad or unsupported file");
		}
		ucstring_destroy(d->tmpstr);
		de_free(c, d);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
pushq $0x18
popq %rsi
callq 0xdecaf
movq %rax, %r15
pushq $0x9
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe08d2
movl %eax, (%r15)
leaq 0xb02ce(%rip), %rsi     # 0x11882b
movq %rbx, %rdi
xorl %edx, %edx
callq 0xdfae5
movb %al, 0x4(%r15)
movq %rbx, %rdi
callq 0xeac74
movq %rax, 0x10(%r15)
pushq $0x1
popq %rbp
xorl %r13d, %r13d
xorl %r14d, %r14d
movq %r15, 0x8(%rsp)
cmpb $0x0, 0x5(%r15)
jne 0x68a13
leaq 0x175(%r14), %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jg 0x68a13
testq %r13, %r13
je 0x685b5
movq %rbx, %rdi
movq %r13, %rsi
callq 0x69875
movl $0xc0, %esi
movq %rbx, %rdi
callq 0xdecaf
movq %rax, %r13
movq %r14, (%rax)
movq %rbx, %rdi
leaq 0x24(%rsp), %rsi
callq 0xdebae
movq (%r13), %rdx
movq %rbx, %rdi
leaq 0xbb315(%rip), %rsi     # 0x1238f8
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
movl %ebp, %esi
callq 0xdeba7
movq %rbx, %rdi
callq 0xdfd1a
movq %rax, 0x18(%rsp)
movq 0x18(%rbx), %rdi
movq (%r13), %rsi
movl (%r15), %r9d
pushq $0xc
popq %rcx
movq %rcx, %rdx
movl %ebp, %r8d
callq 0xe495c
movq %rax, 0x10(%r13)
movq 0x18(%rax), %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0xacf8a(%rip), %rsi     # 0x1155bb
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x10(%r13), %rax
testq %rax, %rax
je 0x68668
cmpq $0xc, 0x10(%rax)
jne 0x68668
movq 0x8(%rax), %rax
xorl %ecx, %ecx
cmpq $0xc, %rcx
je 0x68663
cmpb $0x20, (%rax,%rcx)
leaq 0x1(%rcx), %rcx
je 0x68651
jmp 0x68668
movb $0x1, 0x18(%r13)
movq %r14, 0x30(%rsp)
movq 0x10(%r15), %rdi
callq 0xeac85
movq 0x18(%rbx), %rdi
movq (%r13), %rsi
addq $0x19, %rsi
movq 0x10(%r15), %rcx
movl (%r15), %r9d
pushq $0x40
popq %rdx
movl %ebp, %r8d
callq 0xe4c9a
movq 0x10(%r15), %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0xce832(%rip), %rsi     # 0x136ed9
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
callq 0xeac74
movq %rax, %r15
movq %rbx, %rdi
callq 0xeac74
movq %rax, %r12
movq 0x18(%rbx), %rdi
movq (%r13), %rsi
movl $0x157, %eax            # imm = 0x157
addq %rax, %rsi
pushq $0xa
popq %rdx
movq %r15, %rcx
movl %ebp, %r8d
pushq $0x5
popq %r14
movl %r14d, %r9d
callq 0xe4c9a
movq 0x18(%rbx), %rdi
movq (%r13), %rsi
movl $0x162, %eax            # imm = 0x162
addq %rax, %rsi
pushq $0x8
popq %rdx
movq %r12, %rcx
movl %ebp, %r8d
movl %r14d, %r9d
callq 0xe4c9a
movq %r15, %rdi
callq 0xeb877
movq %rax, %rbp
movq %r12, %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0xb01ca(%rip), %rsi     # 0x1188f4
movq %rbp, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xde896
movq %r12, %rdi
callq 0xeaf3c
movq %r15, %rdi
callq 0xeaf3c
movq (%r13), %rax
movl $0x16b, %ecx            # imm = 0x16B
addq %rcx, %rax
movq %rax, 0x10(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0xe40bf
movq %rax, %r12
movq %rbx, %rdi
leaq 0xb0110(%rip), %rsi     # 0x118886
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xe3fc4
movq %rax, %r15
movq %rbx, %rdi
leaq 0xb00fb(%rip), %rsi     # 0x118894
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
testq %r15, %r15
je 0x687c8
testq %r12, %r12
je 0x687c8
cmpq %r15, %r12
je 0x687c8
movq 0x8(%rsp), %r15
movw $0x101, 0x5(%r15)       # imm = 0x101
movb $0x1, %r14b
xorl %ebp, %ebp
jmp 0x68942
testq %r15, %r15
cmovneq %r15, %r12
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %rbp
movq %rbp, %rsi
callq 0xe3fc4
movq %rax, %r15
xorl %r14d, %r14d
movq %rbx, %rdi
leaq 0xb00b2(%rip), %rsi     # 0x1188a2
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xe3fc4
movq %rax, %rbp
movq %rbx, %rdi
leaq 0xb009e(%rip), %rsi     # 0x1188b1
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
leaq (%r12,%r15), %rax
addq %rbp, %rax
addq $0x176, %rax            # imm = 0x176
movq %rax, 0x8(%r13)
movq 0x10(%rsp), %rax
leaq (%r15,%rax), %rbp
leaq 0x1(%r15,%rax), %r15
movq %r15, 0x10(%rsp)
movq %rbx, %rdi
leaq 0xb0074(%rip), %rsi     # 0x1188bf
movq %r15, %rdx
xorl %eax, %eax
callq 0xde896
leaq (%r12,%rbp), %rax
incq %rax
movq 0x18(%rbx), %rdi
cmpq 0x18(%rdi), %rax
jg 0x6893b
testq %r12, %r12
je 0x68927
cmpb $0x0, 0x18(%r13)
je 0x688a1
movq %rbx, %rdi
leaq 0xacdf3(%rip), %rsi     # 0x115677
xorl %eax, %eax
callq 0xde896
movq 0x8(%rsp), %rax
incl 0x8(%rax)
cmpb $0x0, 0x4(%rax)
je 0x68938
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe409f
cmpl $0x28, %eax
jne 0x687b2
movq 0x18(%rbx), %rsi
movq %r13, %r14
addq $0x20, %r14
movq 0x18(%rsi), %r8
subq %r15, %r8
xorl %ebp, %ebp
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
xorl %r9d, %r9d
callq 0xebba5
testl %eax, %eax
je 0x689a3
movq %r14, 0x28(%rsp)
movq 0x60(%r13), %rsi
addq 0xa8(%r13), %rsi
movq %r12, %rdi
callq 0xdfb45
movq %rax, %r12
cmpb $0x0, 0x18(%r13)
je 0x689a8
movq %rbx, %rdi
movq 0x18(%rsp), %r14
movq %r14, %rsi
leaq 0xa0cc9(%rip), %rdx     # 0x1095e0
xorl %ecx, %ecx
pushq $0x5
popq %r8
callq 0xdffbd
jmp 0x689cb
movq %rbx, %rdi
leaq 0xaff9b(%rip), %rsi     # 0x1188cc
xorl %eax, %eax
callq 0xde896
movb $0x1, %r14b
xorl %ebp, %ebp
movq 0x8(%rsp), %r15
cmpq $0x0, 0x8(%r13)
jg 0x6894e
movb $0x1, 0x5(%r15)
testb %r14b, %r14b
jne 0x68968
movq (%r13), %rdx
movq %rbx, %rdi
leaq 0xaff76(%rip), %rsi     # 0x1188d7
xorl %eax, %eax
callq 0xdf2a5
movq %rbp, %rdi
callq 0xe5591
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0xdfd24
movl 0x24(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
movq 0x8(%r13), %rax
movq 0x30(%rsp), %r14
addq %rax, %r14
testq %rax, %rax
pushq $0x1
popq %rbp
jg 0x68585
jmp 0x68a13
xorl %r14d, %r14d
jmp 0x6893d
cmpb $0x0, 0xd0(%rbx)
movq 0x18(%rsp), %r14
je 0x689cb
movq 0x10(%r13), %rax
movq 0x18(%rax), %rdx
movq %rbx, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0xdfd55
movq %rbx, %rdi
leaq 0xab69d(%rip), %rsi     # 0x114072
movq %r14, %rdx
xorl %ecx, %ecx
callq 0xe4e62
movq %rax, %rbp
movq %r12, %rcx
addq $0xe, %rcx
movq %rbx, %rdi
movq %rax, %rsi
movq 0x28(%rsp), %rdx
callq 0xec053
movq 0x18(%rbx), %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rbp, %rcx
callq 0xe45f4
movb $0x1, %r14b
jmp 0x6893d
movq %rbx, %rdi
movq %r13, %rsi
callq 0x69875
cmpl $0x0, 0x8(%r15)
je 0x68a3d
cmpb $0x0, 0x4(%r15)
jne 0x68a3d
leaq 0xafe0a(%rip), %rsi     # 0x11883d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf37f
cmpb $0x0, 0x6(%r15)
je 0x68a55
leaq 0xa3454(%rip), %rsi     # 0x10be9f
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
movq 0x10(%r15), %rdi
callq 0xeaf3c
movq %rbx, %rdi
movq %r15, %rsi
callq 0xded32
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq