// File: /workspace/github_c_makefile_star2_O2/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 0xdecaf
movq %rax, %r15
pushq $0x9
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe08d2
movl %eax, 0x4(%r15)
leaq 0x20(%rsp), %r14
movq $0x4, (%r14)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xe40bf
movq %rax, 0x8(%r15)
leaq 0xba90d(%rip), %rsi     # 0x122233
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xe40bf
movq %rax, 0x10(%r15)
leaq 0x18(%r15), %rsi
leaq 0xb0112(%rip), %rdi     # 0x117a60
movl $0xec, %edx
movq %rsi, 0x30(%rsp)
callq 0xe1b9f
pushq $0x10
popq %rax
leaq 0x40(%rsp), %r13
xorl %esi, %esi
movq %r15, 0x10(%rsp)
movq %rax, 0x20(%rsp)
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jge 0x67d03
cmpq 0x10(%r15), %rax
jge 0x67d03
testq %rsi, %rsi
je 0x67996
movq %rbx, %rdi
callq 0x6965c
movq %rbx, %rdi
pushq $0x38
popq %rsi
callq 0xdecaf
movq %rax, %rbp
movq 0x20(%rsp), %rax
movq %rax, (%rbp)
movq %rbx, %rdi
leaq 0x2c(%rsp), %rsi
callq 0xdebae
movq (%rbp), %rdx
movq %rbx, %rdi
leaq 0xb0ced(%rip), %rsi     # 0x1186b5
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq (%rbp), %rax
addq $0x2, %rax
movq %rax, 0x8(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x8(%rsp), %r12
movq %r12, %rsi
callq 0xe3fc4
movq %rax, %r14
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xe3fc4
leaq 0x28(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0xe0110
movb $0x2, 0x29(%rbp)
movq %r15, 0x38(%rsp)
movq %r15, %rdi
movq %r13, %rsi
pushq $0x40
popq %rdx
xorl %ecx, %ecx
callq 0xe0644
movq %rbx, %rdi
leaq 0xd4476(%rip), %rsi     # 0x13beb2
leaq 0xb93a1(%rip), %rdx     # 0x120de4
movq %r13, %rcx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xe3fc4
movq %rax, 0x8(%rbp)
movq %rbx, %rdi
leaq 0xd5cae(%rip), %rsi     # 0x13d715
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x8(%rsp), %rsi
addq $0xc, %rsi
movq %rsi, 0x8(%rsp)
movq 0x18(%rbx), %rdi
movq 0x10(%rsp), %r14
movl 0x4(%r14), %r9d
movl $0x104, %edx            # imm = 0x104
movl $0x104, %ecx            # imm = 0x104
pushq $0x1
popq %r8
callq 0xe495c
movq %rax, 0x18(%rbp)
cmpl $0x0, 0x34(%rax)
movq %rbp, 0x18(%rsp)
je 0x67c99
movq 0x18(%rax), %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0xadaf6(%rip), %rsi     # 0x1155bb
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbp), %rax
movq (%rax), %rax
addq %rax, 0x8(%rsp)
movq %rbx, %rdi
callq 0xeac74
movq %rax, %r14
movq %rax, 0x20(%rbp)
movq 0x18(%rbp), %rax
movq 0x18(%rax), %r15
movq %r14, %rdi
callq 0xeac85
movq 0x10(%r15), %r12
testq %r12, %r12
movl $0x0, %eax
cmovleq %rax, %r12
xorl %ebp, %ebp
cmpq %rbp, %r12
je 0x67b39
movq 0x8(%r15), %rax
movl (%rax,%rbp,4), %esi
cmpl $0x5c, %esi
je 0x67b22
cmpl $0x2f, %esi
jne 0x67b2c
movq %r14, %rdi
callq 0xeac85
jmp 0x67b34
movq %r14, %rdi
callq 0xeada5
incq %rbp
jmp 0x67b0c
movq 0x8(%rsp), %rdx
movq %rbx, %rdi
leaq 0xc17bd(%rip), %rsi     # 0x129305
xorl %eax, %eax
callq 0xde896
movl $0x1b02, %esi           # imm = 0x1B02
movq %rbx, %rdi
pushq $0x1
popq %rdx
callq 0xe59cd
movq %rax, %r12
movq %rax, %rdi
callq 0xe589c
movq 0x8(%rsp), %rax
movq 0x18(%rsp), %rcx
movq 0x8(%rcx), %r15
addq %rax, %r15
movq %rax, 0x40(%rsp)
cmpq %r15, %rax
jge 0x67be4
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3f2a
movzbl %al, %r14d
cmpb $-0x14, %al
jb 0x67ba6
cmpb $-0x1, %al
je 0x67bb3
addq $-0xe9, %r14
jmp 0x67bc3
movq %r12, %rdi
movl %r14d, %esi
callq 0xe5bc5
jmp 0x67bdd
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3f2a
movzbl %al, %r14d
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3f2a
movzbl %al, %esi
movq %r12, %rdi
movq %r14, %rdx
callq 0xe5e40
movq 0x40(%rsp), %rax
jmp 0x67b80
movq %r12, %rdi
callq 0xe58e8
cmpq $0x1b00, 0x18(%r12)     # imm = 0x1B00
jne 0x67ca3
movq %rbx, %rdi
pushq $0x60
popq %r15
movq %r15, %rsi
pushq $0x48
popq %rdx
pushq $0x3
popq %rcx
callq 0xe7437
movq %rax, %r14
andl $0x0, (%rsp)
movq %r12, %rdi
xorl %esi, %esi
pushq $0x8
popq %rdx
movq %r15, %rcx
movq 0x30(%rsp), %r8
movq %rax, %r9
callq 0xe7cbc
movq %rbx, %rdi
callq 0xdfd1a
movq %rax, %r15
cmpb $0x0, 0xd0(%rbx)
movq 0x18(%rsp), %rbp
je 0x67c66
movq 0x20(%rbp), %rdi
callq 0xeaf8a
testl %eax, %eax
je 0x67c66
movq 0x20(%rbp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0xdfd55
movq 0x38(%rsp), %rax
movups (%rax), %xmm0
movups %xmm0, 0x18(%r15)
movq %r14, %rdi
movq %r15, %rsi
pushq $0x6
popq %rdx
callq 0xe70ab
movq 0x8(%rsp), %rax
addq 0x8(%rbp), %rax
movq %rax, 0x8(%rsp)
subq (%rbp), %rax
movq %rax, 0x10(%rbp)
jmp 0x67cba
movb $0x1, 0x1(%r14)
xorl %r12d, %r12d
jmp 0x67cb4
movq %rbx, %rdi
leaq 0x9e0a0(%rip), %rsi     # 0x105d4d
xorl %eax, %eax
callq 0xdf2a5
xorl %r15d, %r15d
xorl %r14d, %r14d
movq %r12, %rdi
callq 0xe5591
movq %r14, %rdi
callq 0xe7084
movq %rbx, %rdi
movq %r15, %rsi
callq 0xdfd24
movl 0x2c(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
movq 0x18(%rsp), %rsi
movq 0x10(%rsi), %rax
testq %rax, %rax
jle 0x67cfe
addq 0x20(%rsp), %rax
movq 0x10(%rsp), %r15
jmp 0x6796c
movq 0x10(%rsp), %r15
movq %rbx, %rdi
callq 0x6965c
testq %r15, %r15
je 0x67d33
cmpb $0x0, 0x1(%r15)
je 0x67d28
leaq 0xa4181(%rip), %rsi     # 0x10be9f
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
movq %rbx, %rdi
movq %r15, %rsi
callq 0xded32
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq