// File: /workspace/github_c_makefile_star2_O1/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 0xe969b
movq %rax, %rbp
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %esi, %esi
movl $0x9, %edx
callq 0xeb7d1
movl %eax, 0x4(%rbp)
leaq 0x18(%rsp), %r14
movq $0x4, (%r14)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef3a0
movq %rax, 0x8(%rbp)
leaq 0xc3a1e(%rip), %rsi     # 0x12f1d8
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef3a0
movq %rax, 0x10(%rbp)
leaq 0x18(%rbp), %rsi
leaq 0xb925e(%rip), %rdi     # 0x124a40
movl $0xec, %edx
movq %rsi, 0x28(%rsp)
callq 0xecc60
movq $0x10, (%r14)
movq 0x18(%rbx), %rax
cmpq $0x11, 0x18(%rax)
jl 0x6bb9f
movl $0x10, %eax
xorl %r15d, %r15d
movq %rbp, 0x30(%rsp)
cmpq 0x10(%rbp), %rax
jge 0x6bb9f
testq %r15, %r15
je 0x6b82e
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6d539
movl $0x38, %esi
movq %rbx, %rdi
callq 0xe969b
movq %rax, %r15
movq 0x18(%rsp), %rax
movq %rax, (%r15)
movq %rbx, %rdi
leaq 0x24(%rsp), %rsi
callq 0xe958c
movq (%r15), %rdx
movq %rbx, %rdi
leaq 0xb9e25(%rip), %rsi     # 0x125685
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq (%r15), %rax
addq $0x2, %rax
movq %rax, 0x10(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %r12
movq %r12, %rsi
callq 0xef1ed
movq %rax, %r14
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xef1ed
leaq 0x28(%r15), %r13
movq %r13, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0xeae33
movb $0x2, 0x29(%r15)
movl $0x40, %edx
movq %r13, %rdi
leaq 0x40(%rsp), %r14
movq %r14, %rsi
xorl %ecx, %ecx
callq 0xeb4f8
movq %rbx, %rdi
leaq 0xdd512(%rip), %rsi     # 0x148dea
leaq 0xc247d(%rip), %rdx     # 0x12dd5c
movq %r14, %rcx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xef1ed
movq %rax, 0x8(%r15)
movq %rbx, %rdi
leaq 0xded32(%rip), %rsi     # 0x14a635
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
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 0xefe67
movq %rax, 0x18(%r15)
cmpl $0x0, 0x34(%rax)
je 0x6bb37
movq %r13, 0x38(%rsp)
movq 0x18(%rax), %rdi
callq 0xf7557
movq %rbx, %rdi
leaq 0xb6c15(%rip), %rsi     # 0x122573
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%r15), %rax
movq (%rax), %rax
addq %rax, 0x10(%rsp)
movq %rbx, %rdi
callq 0xf6870
movq %rax, %r14
movq %rax, 0x20(%r15)
movq 0x18(%r15), %rax
movq 0x18(%rax), %r12
movq %r14, %rdi
callq 0xf6883
movq 0x10(%r12), %r13
testq %r13, %r13
jle 0x6b9cb
xorl %ebp, %ebp
movq 0x8(%r12), %rax
movl (%rax,%rbp,4), %esi
cmpl $0x5c, %esi
je 0x6b9b1
cmpl $0x2f, %esi
jne 0x6b9bb
movq %r14, %rdi
callq 0xf6883
jmp 0x6b9c3
movq %r14, %rdi
callq 0xf69a2
incq %rbp
cmpq %rbp, %r13
jne 0x6b99f
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
leaq 0xca7e8(%rip), %rsi     # 0x1361c2
xorl %eax, %eax
callq 0xe9226
movl $0x1b02, %esi           # imm = 0x1B02
movq %rbx, %rdi
movl $0x1, %edx
callq 0xf0faf
movq %rax, %r13
movq %rax, %rdi
callq 0xf0e3f
movq 0x10(%rsp), %rax
movq 0x8(%r15), %r12
movq %rax, 0x40(%rsp)
testq %r12, %r12
leaq 0x40(%rsp), %rbp
jle 0x6ba78
addq %rax, %r12
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xef14d
cmpb $-0x14, %al
jb 0x6ba3a
cmpb $-0x1, %al
je 0x6ba47
movzbl %al, %r14d
addq $-0xe9, %r14
jmp 0x6ba57
movzbl %al, %esi
movq %r13, %rdi
callq 0xf11be
jmp 0x6ba71
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xef14d
movzbl %al, %r14d
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xef14d
movzbl %al, %esi
movq %r13, %rdi
movq %r14, %rdx
callq 0xf14bd
cmpq %r12, 0x40(%rsp)
jl 0x6ba19
movq %r13, %rdi
callq 0xf0ea4
cmpq $0x1b00, 0x18(%r13)     # imm = 0x1B00
movq 0x30(%rsp), %rbp
jne 0x6bb40
movl $0x60, %esi
movl $0x48, %edx
movq %rbx, %rdi
movl $0x3, %ecx
callq 0xf2cab
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 0xf35b8
movq %rbx, %rdi
callq 0xea9a9
movq %rax, %r12
cmpb $0x0, 0xd0(%rbx)
je 0x6bb02
movq 0x20(%r15), %rdi
callq 0xf6c00
testl %eax, %eax
je 0x6bb02
movq 0x20(%r15), %rdx
movq %rbx, %rdi
movq %r12, %rsi
xorl %ecx, %ecx
callq 0xea9e4
movq 0x38(%rsp), %rax
movups (%rax), %xmm0
movups %xmm0, 0x18(%r12)
movq %r14, %rdi
movq %r12, %rsi
movl $0x6, %edx
callq 0xf2917
movq 0x10(%rsp), %rax
addq 0x8(%r15), %rax
movq %rax, 0x10(%rsp)
subq (%r15), %rax
movq %rax, 0x10(%r15)
jmp 0x6bb57
movb $0x1, 0x1(%rbp)
xorl %r13d, %r13d
jmp 0x6bb51
movq %rbx, %rdi
leaq 0xa7213(%rip), %rsi     # 0x112d5d
xorl %eax, %eax
callq 0xe9df7
xorl %r12d, %r12d
xorl %r14d, %r14d
movq %r13, %rdi
callq 0xf0b13
movq %r14, %rdi
callq 0xf28d4
movq %rbx, %rdi
movq %r12, %rsi
callq 0xea9b3
movl 0x24(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
movq 0x10(%r15), %rax
testq %rax, %rax
jle 0x6bb9f
addq 0x18(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jl 0x6b814
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6d539
testq %rbp, %rbp
je 0x6bbd1
cmpb $0x0, 0x1(%rbp)
je 0x6bbc6
leaq 0xad2b3(%rip), %rsi     # 0x118e6f
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xe9752
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq