// File: /workspace/github_c_makefile_star2_O3/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
movl $0x18, %esi
callq 0xe8b2b
movq %rax, %r12
movq %rbx, %rdi
xorl %esi, %esi
movl $0x9, %edx
callq 0xeb220
movl %eax, (%r12)
leaq 0xb980d(%rip), %rsi     # 0x125a2b
movq %rbx, %rdi
xorl %edx, %edx
callq 0xe9bd0
movb %al, 0x4(%r12)
movq %rbx, %rdi
callq 0xf6410
movq %rax, 0x10(%r12)
cmpb $0x0, 0x5(%r12)
jne 0x6c729
xorl %r14d, %r14d
xorl %r15d, %r15d
movq %r12, 0x8(%rsp)
leaq 0x175(%r14), %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jg 0x6c70d
testq %r15, %r15
je 0x6c282
movq 0x10(%r15), %rsi
movq %rbx, %rdi
callq 0xefaca
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe8be2
movl $0xc0, %esi
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, %r15
movq %r14, (%rax)
movq %rbx, %rdi
leaq 0x24(%rsp), %rsi
callq 0xe8a1c
movq (%r15), %rdx
movq %rbx, %rdi
leaq 0xc492c(%rip), %rsi     # 0x130bdb
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq %rbx, %rdi
callq 0xea504
movq %rax, %r13
movq 0x18(%rbx), %rdi
movq (%r15), %rsi
movl (%r12), %r9d
movl $0xc, %edx
movl $0xc, %ecx
movl $0x1, %r8d
callq 0xef87c
movq %rax, 0x10(%r15)
movq 0x18(%rax), %rdi
callq 0xf70f6
movq %rbx, %rdi
leaq 0xb6476(%rip), %rsi     # 0x12277b
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x10(%r15), %rax
testq %rax, %rax
je 0x6c339
cmpq $0xc, 0x10(%rax)
jne 0x6c339
movq 0x8(%rax), %rax
xorl %ecx, %ecx
cmpb $0x20, (%rax,%rcx)
jne 0x6c339
incq %rcx
cmpq $0xc, %rcx
jne 0x6c325
movb $0x1, 0x18(%r15)
movq %r13, 0x18(%rsp)
movq %r14, 0x30(%rsp)
movq 0x10(%r12), %rdi
callq 0xf6423
movq 0x18(%rbx), %rdi
movq (%r15), %rsi
addq $0x19, %rsi
movq 0x10(%r12), %rcx
movl (%r12), %r9d
movl $0x40, %edx
movl $0x1, %r8d
callq 0xefbd7
movq 0x10(%r12), %rdi
callq 0xf70f6
movq %rbx, %rdi
leaq 0xd7fa4(%rip), %rsi     # 0x144329
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
callq 0xf6410
movq %rax, %r12
movq %rbx, %rdi
callq 0xf6410
movq %rax, %r13
movq 0x18(%rbx), %rdi
movq (%r15), %rsi
movl $0x157, %eax            # imm = 0x157
addq %rax, %rsi
movl $0xa, %edx
movq %r12, %rcx
movl $0x1, %r8d
movl $0x5, %r9d
callq 0xefbd7
movq 0x18(%rbx), %rdi
movq (%r15), %rsi
movl $0x162, %eax            # imm = 0x162
addq %rax, %rsi
movl $0x8, %edx
movq %r13, %rcx
movl $0x1, %r8d
movl $0x5, %r9d
callq 0xefbd7
movq %r12, %rdi
callq 0xf70f6
movq %rax, %rbp
movq %r13, %rdi
callq 0xf70f6
movq %rbx, %rdi
leaq 0xb96e2(%rip), %rsi     # 0x125af4
movq %rbp, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xe8617
movq %r13, %rdi
callq 0xf6753
movq %r12, %rdi
callq 0xf6753
movq (%r15), %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 0xeed83
movq %rax, %rbp
movq %rbx, %rdi
leaq 0xb9629(%rip), %rsi     # 0x125a86
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xeebeb
movq %rax, %r12
movq %rbx, %rdi
leaq 0xb9614(%rip), %rsi     # 0x125a94
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
testq %r12, %r12
je 0x6c4b1
testq %rbp, %rbp
je 0x6c4b1
cmpq %r12, %rbp
je 0x6c4b1
movq 0x8(%rsp), %r12
movw $0x101, 0x5(%r12)       # imm = 0x101
movb $0x1, %r14b
xorl %r13d, %r13d
jmp 0x6c633
testq %r12, %r12
cmovneq %r12, %rbp
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %r13
movq %r13, %rsi
callq 0xeebeb
movq %rax, %r12
xorl %r14d, %r14d
movq %rbx, %rdi
leaq 0xb95c9(%rip), %rsi     # 0x125aa2
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeebeb
movq %rax, %r13
movq %rbx, %rdi
leaq 0xb95b5(%rip), %rsi     # 0x125ab1
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
leaq (%r12,%rbp), %rax
addq %r13, %rax
addq $0x176, %rax            # imm = 0x176
movq %rax, 0x8(%r15)
movq 0x10(%rsp), %rax
leaq (%r12,%rax), %r13
leaq 0x1(%r12,%rax), %r12
movq %r12, 0x10(%rsp)
movq %rbx, %rdi
leaq 0xb958b(%rip), %rsi     # 0x125abf
movq %r12, %rdx
xorl %eax, %eax
callq 0xe8617
leaq 0x1(,%r13), %rax
addq %rbp, %rax
movq 0x18(%rbx), %rdi
cmpq 0x18(%rdi), %rax
jg 0x6c62b
testq %rbp, %rbp
je 0x6c617
cmpb $0x0, 0x18(%r15)
je 0x6c58e
movq %rbx, %rdi
leaq 0xb62c6(%rip), %rsi     # 0x122837
xorl %eax, %eax
callq 0xe8617
movq 0x8(%rsp), %rax
incl 0x8(%rax)
cmpb $0x0, 0x4(%rax)
je 0x6c628
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeed61
cmpl $0x28, %eax
jne 0x6c499
movq 0x18(%rbx), %rsi
movq %r15, %r14
addq $0x20, %r14
movq 0x18(%rsi), %r8
subq %r12, %r8
xorl %r13d, %r13d
movq %rbx, %rdi
movq %r14, %rdx
movq %r12, %rcx
xorl %r9d, %r9d
callq 0xf7425
testl %eax, %eax
je 0x6c69d
movq %r14, 0x28(%rsp)
movq 0x60(%r15), %rsi
addq 0xa8(%r15), %rsi
movq %rbp, %rdi
callq 0xe9c3b
movq %rax, %rbp
cmpb $0x0, 0x18(%r15)
je 0x6c6a2
movq %rbx, %rdi
movq 0x18(%rsp), %r14
movq %r14, %rsi
leaq 0xaa06b(%rip), %rdx     # 0x116670
xorl %ecx, %ecx
movl $0x5, %r8d
callq 0xea78f
jmp 0x6c6c5
movq %rbx, %rdi
leaq 0xb94ab(%rip), %rsi     # 0x125acc
xorl %eax, %eax
callq 0xe8617
movb $0x1, %r14b
xorl %r13d, %r13d
movq 0x8(%rsp), %r12
cmpq $0x0, 0x8(%r15)
jg 0x6c640
movb $0x1, 0x5(%r12)
testb %r14b, %r14b
jne 0x6c659
movq (%r15), %rdx
movq %rbx, %rdi
leaq 0xb9485(%rip), %rsi     # 0x125ad7
xorl %eax, %eax
callq 0xe9295
movq %r13, %rdi
callq 0xf052b
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0xea50e
movl 0x24(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
movq 0x8(%r15), %rax
testq %rax, %rax
jle 0x6c712
movq 0x30(%rsp), %r14
addq %rax, %r14
cmpb $0x0, 0x5(%r12)
je 0x6c251
jmp 0x6c712
xorl %r14d, %r14d
jmp 0x6c62e
cmpb $0x0, 0xd0(%rbx)
movq 0x18(%rsp), %r14
je 0x6c6c5
movq 0x10(%r15), %rax
movq 0x18(%rax), %rdx
movq %rbx, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0xea53f
movq %rbx, %rdi
leaq 0xb4a93(%rip), %rsi     # 0x121162
movq %r14, %rdx
xorl %ecx, %ecx
callq 0xefda1
movq %rax, %r13
movq %rbp, %rcx
addq $0xe, %rcx
movq %rbx, %rdi
movq %rax, %rsi
movq 0x28(%rsp), %rdx
callq 0xf78fa
movq 0x18(%rbx), %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq 0xef481
movb $0x1, %r14b
jmp 0x6c62e
testq %r15, %r15
je 0x6c729
movq 0x10(%r15), %rsi
movq %rbx, %rdi
callq 0xefaca
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe8be2
cmpl $0x0, 0x8(%r12)
je 0x6c74a
cmpb $0x0, 0x4(%r12)
jne 0x6c74a
leaq 0xb92fd(%rip), %rsi     # 0x125a3d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9393
cmpb $0x0, 0x6(%r12)
je 0x6c763
leaq 0xac836(%rip), %rsi     # 0x118f8f
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movq 0x10(%r12), %rdi
callq 0xf6753
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe8be2
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq