// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/ico.c
// Function: de_run_ico
static void de_run_ico(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	i64 x;
	i64 num_images;
	i64 i;

	d = de_malloc(c, sizeof(lctx));
	d->extract_unused_masks = (c->extract_level>=2);

	x = de_getu16le(2);
	if(x==1) {
		d->is_cur=0;
		de_declare_fmt(c, "Windows Icon");
	}
	else if(x==2) {
		d->is_cur=1;
		de_declare_fmt(c, "Windows Cursor");
	}
	else {
		de_dbg(c, "Not an ICO/CUR file");
		goto done;
	}

	num_images = de_getu16le(4);
	de_dbg(c, "images in file: %d", (int)num_images);
	if(!de_good_image_count(c, num_images)) {
		goto done;
	}

	for(i=0; i<num_images; i++) {
		do_image_dir_entry(c, d, i, 6+16*i);
	}

done:
	de_free(c, d);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %rbx
movl $0x8, %esi
callq 0xe969b
xorl %ecx, %ecx
cmpl $0x2, 0x90(%rbx)
movq %rax, %r13
setge %cl
movl %ecx, 0x4(%rax)
movq 0x18(%rbx), %rdi
movl $0x2, %esi
callq 0xef1ca
cmpq $0x1, %rax
je 0x76d24
cmpq $0x2, %rax
jne 0x774c3
leaq 0xb16f6(%rip), %rsi     # 0x128413
movl $0x1, %eax
jmp 0x76d2d
leaq 0xb16db(%rip), %rsi     # 0x128406
xorl %eax, %eax
movl %eax, (%r13)
movq %rbx, %rdi
callq 0xeb6d6
movq 0x18(%rbx), %rdi
movl $0x4, %esi
callq 0xef1ca
movq %rax, %r14
leaq 0xb16e5(%rip), %rsi     # 0x128436
movq %rbx, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movq %r14, %rsi
callq 0xf2509
testl %eax, %eax
sete %al
movq %r14, 0x30(%rsp)
testq %r14, %r14
setle %cl
orb %al, %cl
jne 0x774d4
xorl %r12d, %r12d
movq %rbx, 0x28(%rsp)
movq %r13, 0x20(%rsp)
movq %r12, %r14
shlq $0x4, %r14
movl $0x500, %esi            # imm = 0x500
movq %rbx, %rdi
callq 0xe969b
movq %rax, %rbp
movq %r12, (%rax)
leal 0x6(%r14), %ecx
movq %rbx, %rdi
leaq 0xb1693(%rip), %rsi     # 0x128449
movl %r12d, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
cmpl $0x0, (%r13)
je 0x76e10
movq 0x18(%rbx), %rdi
movq %r14, %rsi
orq $0xa, %rsi
callq 0xef1ca
movl %eax, 0x18(%rbp)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
orq $0xc, %rsi
callq 0xef1ca
movl %eax, 0x1c(%rbp)
movl 0x18(%rbp), %edx
movq %rbx, %rdi
leaq 0xa6480(%rip), %rsi     # 0x11d287
movl %eax, %ecx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r14, %rsi
orq $0xe, %rsi
callq 0xef37e
movq %rax, 0x8(%rbp)
movq 0x18(%rbx), %rdi
addq $0x12, %r14
movq %r14, %rsi
callq 0xef37e
movq %rax, 0x10(%rbp)
movq 0x8(%rbp), %rcx
movq %rbx, %rdi
leaq 0xa6254(%rip), %rsi     # 0x11d09a
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x8(%rbp), %r14
movq 0x10(%rbp), %r15
leaq (%r14,%r15), %rax
movq 0x18(%rbx), %rsi
cmpq 0x18(%rsi), %rax
movq %rbp, 0x8(%rsp)
jle 0x76e73
xorl %r15d, %r15d
jmp 0x76f25
movq %r12, 0x18(%rsp)
leaq 0x50(%rbp), %r12
movq %rbx, %rdi
movq %r12, %rdx
movq %r15, %rcx
movq %r14, %r8
movl $0x2, %r9d
callq 0xf7881
testl %eax, %eax
je 0x76f07
cmpl $0x1, (%r12)
jne 0x76f98
movq 0x28(%rsp), %rbx
movq 0x18(%rbx), %rdi
leaq 0x10(%r15), %rsi
callq 0xef32a
movq %rax, %r12
movq 0x18(%rbx), %rdi
leaq 0x14(%r15), %rsi
callq 0xef32a
movl $0x40, %esi
leaq 0x60(%rsp), %rbp
movq %rbp, %rdi
leaq 0xb1622(%rip), %rdx     # 0x1284fa
movl %r12d, %ecx
movl %eax, %r8d
xorl %eax, %eax
callq 0xe8d67
movq 0x18(%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbp, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xf0321
xorl %r15d, %r15d
movq 0x20(%rsp), %r13
jmp 0x76f1b
movq %rbx, %rdi
leaq 0xa4e6e(%rip), %rsi     # 0x11bd7f
xorl %eax, %eax
callq 0xe9df7
xorl %r15d, %r15d
movq 0x18(%rsp), %r12
movq 0x8(%rsp), %rbp
testq %rbp, %rbp
je 0x76f62
movq 0xf0(%rbp), %rdi
callq 0xf28d4
xorl %r14d, %r14d
movq 0x8(%rsp), %rax
movq %r14, 0xf0(%rax)
movq 0x8(%rsp), %rax
movq 0xf8(%rax), %rdi
callq 0xf28d4
movq 0x8(%rsp), %rbp
movq %r14, 0xf8(%rbp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xea9b3
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xe9752
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
incq %r12
cmpq 0x30(%rsp), %r12
jne 0x76d8e
jmp 0x774d4
movq 0x8(%rsp), %rcx
movq 0x80(%rcx), %r9
cmpq $0x20, %r9
movq 0x28(%rsp), %rbx
ja 0x7727b
movabsq $0x101000116, %rax      # imm = 0x101000116
btq %r9, %rax
jae 0x77007
cmpl $0x0, 0x88(%rcx)
movq 0x20(%rsp), %r13
movq 0x18(%rsp), %r12
je 0x76ff1
movq %rbx, %rdi
leaq 0xb14ca(%rip), %rsi     # 0x1284aa
xorl %eax, %eax
callq 0xe9df7
movq 0x8(%rsp), %rbp
jmp 0x76e6b
cmpq $0x20, %r9
jne 0x77027
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x40(%rcx)
jmp 0x7702e
cmpq $0x10, %r9
jne 0x7727b
movl (%rcx), %edx
movq %rbx, %rdi
leaq 0xb1443(%rip), %rsi     # 0x128460
movl $0x10, %ecx
jmp 0x7728a
movl $0x1, 0x40(%rcx)
movl 0x70(%rcx), %ecx
movq 0x8(%rsp), %rax
movl 0x78(%rax), %r8d
movl $0x20, %esi
leaq 0x60(%rsp), %rdi
leaq 0xb0524(%rip), %rdx     # 0x12756f
xorl %eax, %eax
callq 0xe8d67
movq 0x8(%rsp), %rax
movq 0xb0(%rax), %rax
shlq $0x3, %rax
cqto
movq 0x8(%rsp), %rcx
idivq 0x80(%rcx)
movq 0x8(%rsp), %rcx
movq %rax, 0x30(%rcx)
movq 0x8(%rsp), %rcx
movq 0xc0(%rcx), %rcx
shlq $0x3, %rcx
movq 0x8(%rsp), %rdx
movq %rcx, 0x38(%rdx)
movq 0x8(%rsp), %rcx
movq 0x70(%rcx), %rsi
movq 0x8(%rsp), %rcx
movq 0x78(%rcx), %rcx
movq %rbx, %rdi
movq %rax, %rdx
movl $0x4, %r8d
callq 0xf2ce6
movq 0x8(%rsp), %rbp
movq %rax, 0xf0(%rbp)
movq 0xa0(%rbp), %rdx
testq %rdx, %rdx
jle 0x7710f
cmpq $0x100, %rdx            # imm = 0x100
jg 0x76e6b
movq 0x18(%rbx), %rdi
movq 0x68(%rbp), %rsi
addq %r15, %rsi
movq 0x98(%rbp), %rcx
movq 0x8(%rsp), %rax
leaq 0x100(%rax), %r8
movl $0x1, (%rsp)
movl $0x100, %r9d            # imm = 0x100
callq 0xf328f
movq 0x8(%rsp), %rbp
addq 0xd8(%rbp), %r15
movq %r15, 0x20(%rbp)
movq 0xb8(%rbp), %rcx
addq %r15, %rcx
movq %rcx, 0x28(%rbp)
movq %rbx, %rdi
leaq 0xb139e(%rip), %rsi     # 0x1284d0
movl %r15d, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x8(%rsp), %rax
movq 0x38(%rax), %rdx
movq 0x8(%rsp), %rax
movq 0x70(%rax), %rsi
movq 0x8(%rsp), %rax
movq 0x78(%rax), %rcx
movq %rbx, %rdi
movl $0x1, %r8d
callq 0xf2ce6
movq 0x8(%rsp), %rcx
movq %rax, 0xf8(%rcx)
movq 0x18(%rbx), %rdi
movq 0x8(%rsp), %rcx
movq 0x28(%rcx), %rsi
movq 0x8(%rsp), %rcx
movq 0xc0(%rcx), %rdx
movq %rax, %rcx
xorl %r8d, %r8d
callq 0xf3081
movq 0x8(%rsp), %r8
movq 0x80(%r8), %rdx
cmpq $0x20, %rdx
jne 0x772a8
movq 0xf0(%r8), %rbx
cmpq $0x0, 0x10(%rbx)
jle 0x77271
xorl %ebp, %ebp
movq %rbx, 0x38(%rsp)
movq 0xb0(%r8), %rax
imulq %rbp, %rax
addq 0x20(%r8), %rax
movq %rax, 0x40(%rsp)
cmpq $0x0, 0x30(%r8)
movq 0x28(%rsp), %r15
leaq 0x40(%rsp), %r14
jle 0x77264
xorl %r12d, %r12d
movq 0x18(%r15), %rdi
movq %r14, %rsi
callq 0xef14d
movb %al, 0x17(%rsp)
movq 0x18(%r15), %rdi
movq %r14, %rsi
callq 0xef14d
movl %eax, %ebx
movq 0x18(%r15), %rdi
movq %r14, %rsi
callq 0xef14d
movl %eax, %r13d
movq 0x18(%r15), %rdi
movq %r14, %rsi
callq 0xef14d
movzbl %al, %eax
shll $0x18, %eax
movzbl %r13b, %ecx
shll $0x10, %ecx
orl %eax, %ecx
movzbl %bl, %eax
movq 0x38(%rsp), %rbx
shll $0x8, %eax
orl %ecx, %eax
movzbl 0x17(%rsp), %ecx
orl %eax, %ecx
movq %rbx, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0xf2b02
movq 0x8(%rsp), %r8
incq %r12
cmpq 0x30(%r8), %r12
jl 0x771ec
incq %rbp
cmpq 0x10(%rbx), %rbp
jl 0x771c4
movq 0x20(%rsp), %r13
jmp 0x773a9
movl (%rcx), %edx
movq %rbx, %rdi
leaq 0xb1200(%rip), %rsi     # 0x128487
movl %r9d, %ecx
xorl %eax, %eax
callq 0xe9df7
movq 0x8(%rsp), %rbp
xorl %r15d, %r15d
movq 0x20(%rsp), %r13
movq 0x18(%rsp), %r12
jmp 0x76f25
movq 0xf0(%r8), %r15
cmpq $0x18, %rdx
jne 0x772de
movq 0x18(%rbx), %rdi
movq 0x20(%r8), %rsi
movq 0xb0(%r8), %rdx
movl $0x3, %ecx
movq %r15, %r8
movl $0x1, %r9d
callq 0xf38d9
movl $0x808000ff, %ebx       # imm = 0x808000FF
jmp 0x77317
cmpq $0x8, %rdx
movl $0x808000ff, %ebx       # imm = 0x808000FF
jg 0x773a9
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x20(%r8), %rsi
movq 0xb0(%r8), %rcx
addq $0x100, %r8             # imm = 0x100
movl $0x0, (%rsp)
movq %r15, %r9
callq 0xf35b8
cmpq $0x0, 0x10(%r15)
movq 0x8(%rsp), %r8
jle 0x773a9
xorl %r14d, %r14d
cmpq $0x0, 0x70(%r8)
jle 0x773a0
xorl %r12d, %r12d
movq 0xf8(%r8), %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %r8, %rbp
callq 0xf2bd3
testl $0xff0000, %eax         # imm = 0xFF0000
je 0x77394
movq 0xf0(%rbp), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0xf2bd3
testl $0xffffff, %eax         # imm = 0xFFFFFF
je 0x77380
movl $0x1, 0x48(%rbp)
leal (%r14,%r12), %eax
testb $0x1, %al
movl $0x80ff0080, %ecx       # imm = 0x80FF0080
cmovel %ebx, %ecx
jmp 0x77382
xorl %ecx, %ecx
movq 0xf0(%rbp), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0xf2b02
incq %r12
cmpq 0x70(%rbp), %r12
movq %rbp, %r8
jl 0x77334
incq %r14
cmpq 0x10(%r15), %r14
jl 0x7732a
cmpl $0x0, 0x48(%r8)
movq 0x28(%rsp), %rbx
je 0x773cb
movq %rbx, %rdi
leaq 0xb1145(%rip), %rsi     # 0x128504
xorl %eax, %eax
callq 0xe9b27
movq 0x8(%rsp), %r8
movq 0xf0(%r8), %rdi
xorl %esi, %esi
cmpq $0x20, 0x80(%r8)
sete %sil
callq 0xf3f11
movq %rbx, %rdi
callq 0xea9a9
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
leaq 0x60(%rsp), %rdx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0xeac7c
movq 0x8(%rsp), %rbp
cmpl $0x0, (%r13)
movq 0x18(%rsp), %r12
je 0x77432
movb $0x1, 0xe(%r15)
movl 0x18(%rbp), %eax
movl %eax, 0x98(%r15)
movl 0x1c(%rbp), %eax
movl %eax, 0x9c(%r15)
movq 0xf0(%rbp), %rdi
movq %r15, %rsi
movl $0x4, %edx
callq 0xf2917
cmpl $0x0, 0x4(%r13)
je 0x76f25
cmpl $0x0, 0x40(%rbp)
leaq 0x40(%rsp), %r14
je 0x77477
cmpb $0x0, 0xd6(%rbx)
je 0x76f25
movq 0x38(%rbp), %rax
cmpq 0x70(%rbp), %rax
jle 0x76f25
movl 0x70(%rbp), %ecx
movq 0x8(%rsp), %rax
movl 0x78(%rax), %r8d
movq 0x8(%rsp), %rax
movl 0x80(%rax), %r9d
movl $0x20, %esi
movq %r14, %rdi
leaq 0xb104f(%rip), %rdx     # 0x1284ed
xorl %eax, %eax
callq 0xe8d67
movq 0x8(%rsp), %rax
movq 0xf8(%rax), %rdi
movq %r14, %rsi
movl $0x5, %edx
callq 0xf2923
jmp 0x76f20
leaq 0xb0f58(%rip), %rsi     # 0x128422
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe9752
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq