// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/misc2.c
// Function: de_run_thumbsplus
static void de_run_thumbsplus(deark *c, de_module_params *mparams)
{
	struct thumbsplus_ctx *d = NULL;
	struct thumbsplus_icon_ctx *md = NULL;
	i64 pos;

	d = de_malloc(c, sizeof(struct thumbsplus_ctx));
	d->input_encoding = de_get_input_encoding(c, NULL, DE_ENCODING_WINDOWS1252);

	pos = 4;
	d->icon_count = de_getu32le_p(&pos);
	de_dbg(c, "count: %"I64_FMT, d->icon_count);
	d->reported_file_size = de_getu32le_p(&pos);

	make_thumbsplus_pal(c, d);

	pos = 16;
	while(1) {
		if(pos>=c->infile->len || pos>=d->reported_file_size) goto done;
		if(md) {
			thumbsplus_icon_destroy(c, md);
			md = NULL;
		}
		md = de_malloc(c, sizeof(struct thumbsplus_icon_ctx));
		md->icon_pos = pos;
		do_thumbsplus_icon(c, d, md);
		if(md->total_len<=0) goto done;
		pos += md->total_len;
	}

done:
	thumbsplus_icon_destroy(c, md);
	if(d) {
		if(d->need_errmsg) {
			de_err(c, "Bad or unsupported file");
		}
		de_free(c, d);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
movl $0x418, %esi            # imm = 0x418
callq 0xe8b2b
movq %rax, %rbp
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %esi, %esi
movl $0x9, %edx
callq 0xeb220
movl %eax, 0x4(%rbp)
leaq 0x18(%rsp), %r14
movq $0x4, (%r14)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xeed83
movq %rax, 0x8(%rbp)
leaq 0xc3f71(%rip), %rsi     # 0x12f4bb
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xeed83
movq %rax, 0x10(%rbp)
leaq 0x18(%rbp), %rsi
leaq 0xb96ee(%rip), %rdi     # 0x124c60
movl $0xec, %edx
movq %rsi, 0x28(%rsp)
callq 0xec5fe
movq $0x10, (%r14)
movq 0x18(%rbx), %rax
cmpq $0x11, 0x18(%rax)
jl 0x6b941
movl $0x10, %eax
xorl %r15d, %r15d
movq %rbp, 0x30(%rsp)
cmpq 0x10(%rbp), %rax
jge 0x6b941
testq %r15, %r15
je 0x6b5be
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6d308
movl $0x38, %esi
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, %r15
movq 0x18(%rsp), %rax
movq %rax, (%r15)
movq %rbx, %rdi
leaq 0x24(%rsp), %rsi
callq 0xe8a1c
movq (%r15), %rdx
movq %rbx, %rdi
leaq 0xba2c5(%rip), %rsi     # 0x1258b5
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq (%r15), %rax
addq $0x2, %rax
movq %rax, 0x10(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %r12
movq %r12, %rsi
callq 0xeebeb
movq %rax, %r14
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeebeb
leaq 0x28(%r15), %r13
movq %r13, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0xea92a
movb $0x2, 0x29(%r15)
movl $0x40, %edx
movq %r13, %rdi
leaq 0x40(%rsp), %r14
movq %r14, %rsi
xorl %ecx, %ecx
callq 0xeaf46
movq %rbx, %rdi
leaq 0xddd1a(%rip), %rsi     # 0x149382
leaq 0xc29e5(%rip), %rdx     # 0x12e054
movq %r14, %rcx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeebeb
movq %rax, 0x8(%r15)
movq %rbx, %rdi
leaq 0xdf552(%rip), %rsi     # 0x14abe5
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x10(%rsp), %rsi
addq $0xc, %rsi
movq %rsi, 0x10(%rsp)
movq 0x18(%rbx), %rdi
movl 0x4(%rbp), %r9d
movl $0x104, %edx            # imm = 0x104
movl $0x104, %ecx            # imm = 0x104
movl $0x1, %r8d
callq 0xef87c
movq %rax, 0x18(%r15)
cmpl $0x0, 0x34(%rax)
je 0x6b8c7
movq %r13, 0x38(%rsp)
movq 0x18(%rax), %rdi
callq 0xf70f6
movq %rbx, %rdi
leaq 0xb708d(%rip), %rsi     # 0x12277b
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r15), %rax
movq (%rax), %rax
addq %rax, 0x10(%rsp)
movq %rbx, %rdi
callq 0xf6410
movq %rax, %r14
movq %rax, 0x20(%r15)
movq 0x18(%r15), %rax
movq 0x18(%rax), %r12
movq %r14, %rdi
callq 0xf6423
movq 0x10(%r12), %r13
testq %r13, %r13
jle 0x6b75b
xorl %ebp, %ebp
movq 0x8(%r12), %rax
movl (%rax,%rbp,4), %esi
cmpl $0x5c, %esi
je 0x6b741
cmpl $0x2f, %esi
jne 0x6b74b
movq %r14, %rdi
callq 0xf6423
jmp 0x6b753
movq %r14, %rdi
callq 0xf6542
incq %rbp
cmpq %rbp, %r13
jne 0x6b72f
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
leaq 0xcae9b(%rip), %rsi     # 0x136605
xorl %eax, %eax
callq 0xe8617
movl $0x1b02, %esi           # imm = 0x1B02
movq %rbx, %rdi
movl $0x1, %edx
callq 0xf09c5
movq %rax, %r13
movq %rax, %rdi
callq 0xf0855
movq 0x10(%rsp), %rax
movq 0x8(%r15), %r12
movq %rax, 0x40(%rsp)
testq %r12, %r12
leaq 0x40(%rsp), %rbp
jle 0x6b808
addq %rax, %r12
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeeb4b
cmpb $-0x14, %al
jb 0x6b7ca
cmpb $-0x1, %al
je 0x6b7d7
movzbl %al, %r14d
addq $-0xe9, %r14
jmp 0x6b7e7
movzbl %al, %esi
movq %r13, %rdi
callq 0xf0bd6
jmp 0x6b801
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeeb4b
movzbl %al, %r14d
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeeb4b
movzbl %al, %esi
movq %r13, %rdi
movq %r14, %rdx
callq 0xf0eba
cmpq %r12, 0x40(%rsp)
jl 0x6b7a9
movq %r13, %rdi
callq 0xf08ba
cmpq $0x1b00, 0x18(%r13)     # imm = 0x1B00
movq 0x30(%rsp), %rbp
jne 0x6b8d0
movl $0x60, %esi
movl $0x48, %edx
movq %rbx, %rdi
movl $0x3, %ecx
callq 0xf266a
movq %rax, %r14
movl $0x0, (%rsp)
movl $0x8, %edx
movl $0x60, %ecx
movq %r13, %rdi
xorl %esi, %esi
movq 0x28(%rsp), %r8
movq %rax, %r9
callq 0xf2f79
movq %rbx, %rdi
callq 0xea504
movq %rax, %r12
cmpb $0x0, 0xd0(%rbx)
je 0x6b892
movq 0x20(%r15), %rdi
callq 0xf67a3
testl %eax, %eax
je 0x6b892
movq 0x20(%r15), %rdx
movq %rbx, %rdi
movq %r12, %rsi
xorl %ecx, %ecx
callq 0xea53f
movq 0x38(%rsp), %rax
movups (%rax), %xmm0
movups %xmm0, 0x18(%r12)
movq %r14, %rdi
movq %r12, %rsi
movl $0x6, %edx
callq 0xf22d0
movq 0x10(%rsp), %rax
addq 0x8(%r15), %rax
movq %rax, 0x10(%rsp)
subq (%r15), %rax
movq %rax, 0x10(%r15)
jmp 0x6b8e7
movb $0x1, 0x1(%rbp)
xorl %r13d, %r13d
jmp 0x6b8e1
movq %rbx, %rdi
leaq 0xa7493(%rip), %rsi     # 0x112d6d
xorl %eax, %eax
callq 0xe9295
xorl %r12d, %r12d
xorl %r14d, %r14d
movq %r13, %rdi
callq 0xf052b
movq %r14, %rdi
callq 0xf228d
movq %rbx, %rdi
movq %r12, %rsi
callq 0xea50e
movl 0x24(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
movq 0x10(%r15), %rax
testq %rax, %rax
jle 0x6b92f
addq 0x18(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jl 0x6b5a4
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6d308
testq %rbp, %rbp
jne 0x6b94c
jmp 0x6b96e
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6d308
cmpb $0x0, 0x1(%rbp)
je 0x6b963
leaq 0xad636(%rip), %rsi     # 0x118f8f
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xe8be2
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq