// File: /workspace/github_c_makefile_star2_O3/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 0xe8b2b
xorl %ecx, %ecx
cmpl $0x2, 0x90(%rbx)
setge %cl
movq %rax, 0x30(%rsp)
movl %ecx, 0x4(%rax)
movq 0x18(%rbx), %rdi
movl $0x2, %esi
callq 0xeebc8
cmpq $0x1, %rax
je 0x769a2
cmpq $0x2, %rax
jne 0x77145
leaq 0xb1ca8(%rip), %rsi     # 0x128643
movl $0x1, %eax
jmp 0x769ab
leaq 0xb1c8d(%rip), %rsi     # 0x128636
xorl %eax, %eax
movq 0x30(%rsp), %rcx
movl %eax, (%rcx)
movq %rbx, %rdi
callq 0xeb125
movq 0x18(%rbx), %rdi
movl $0x4, %esi
callq 0xeebc8
movq %rax, %rbp
leaq 0xb1c94(%rip), %rsi     # 0x128666
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xf1e9d
testl %eax, %eax
sete %al
testq %rbp, %rbp
setle %cl
orb %al, %cl
jne 0x77156
xorl %r12d, %r12d
movq %rbp, 0x28(%rsp)
movq %r12, %r14
shlq $0x4, %r14
movl $0x500, %esi            # imm = 0x500
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, %r13
movq %r12, (%rax)
leal 0x6(%r14), %ecx
movq %rbx, %rdi
leaq 0xb1c4d(%rip), %rsi     # 0x128679
movl %r12d, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x30(%rsp), %rax
cmpl $0x0, (%rax)
je 0x76a8c
movq 0x18(%rbx), %rdi
movq %r14, %rsi
orq $0xa, %rsi
callq 0xeebc8
movl %eax, 0x18(%r13)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
orq $0xc, %rsi
callq 0xeebc8
movl %eax, 0x1c(%r13)
movl 0x18(%r13), %edx
movq %rbx, %rdi
leaq 0xa6914(%rip), %rsi     # 0x11d397
movl %eax, %ecx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r14, %rsi
orq $0xe, %rsi
callq 0xeed61
movq %rax, 0x8(%r13)
movq 0x18(%rbx), %rdi
addq $0x12, %r14
movq %r14, %rsi
callq 0xeed61
movq %rax, 0x10(%r13)
movq 0x8(%r13), %rcx
movq %rbx, %rdi
leaq 0xa66e8(%rip), %rsi     # 0x11d1aa
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x8(%r13), %r14
movq 0x10(%r13), %r15
leaq (%r14,%r15), %rax
movq 0x18(%rbx), %rsi
cmpq 0x18(%rsi), %rax
jle 0x76aea
xorl %r15d, %r15d
jmp 0x76ba2
movq %r12, 0x20(%rsp)
movq %r13, 0x10(%rsp)
leaq 0x50(%r13), %r12
movq %rbx, %rdi
movq %r12, %rdx
movq %r15, %rcx
movq %r14, %r8
movl $0x2, %r9d
callq 0xf7425
testl %eax, %eax
je 0x76b84
movq %rbx, %rbp
cmpl $0x1, (%r12)
jne 0x76bff
movq %rbp, %rbx
movq 0x18(%rbp), %rdi
leaq 0x10(%r15), %rsi
callq 0xeed0d
movq %rax, %r12
movq 0x18(%rbp), %rdi
leaq 0x14(%r15), %rsi
callq 0xeed0d
movl $0x40, %esi
leaq 0x60(%rsp), %r13
movq %r13, %rdi
leaq 0xb1bd5(%rip), %rdx     # 0x12872a
movl %r12d, %ecx
movl %eax, %r8d
xorl %eax, %eax
callq 0xe8193
movq 0x18(%rbp), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r13, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xefd48
xorl %r15d, %r15d
movq 0x28(%rsp), %rbp
jmp 0x76b98
movq %rbx, %rdi
leaq 0xa5319(%rip), %rsi     # 0x11bea7
xorl %eax, %eax
callq 0xe9295
xorl %r15d, %r15d
movq 0x20(%rsp), %r12
movq 0x10(%rsp), %r13
movq 0xf0(%r13), %rdi
callq 0xf228d
xorl %r14d, %r14d
movq %r14, 0xf0(%r13)
movq 0xf8(%r13), %rdi
callq 0xf228d
movq %r14, 0xf8(%r13)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xea50e
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe8be2
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
incq %r12
cmpq %rbp, %r12
jne 0x76a04
jmp 0x77156
movq 0x10(%rsp), %rcx
movq 0x80(%rcx), %r9
cmpq $0x20, %r9
movq %rbp, %rbx
ja 0x76eea
movabsq $0x101000116, %rax      # imm = 0x101000116
btq %r9, %rax
jae 0x76ed1
cmpl $0x0, 0x88(%rcx)
movq 0x20(%rsp), %r12
je 0x76c5d
movq %rbx, %rdi
leaq 0xb1a96(%rip), %rsi     # 0x1286da
xorl %eax, %eax
callq 0xe9295
movq 0x10(%rsp), %r13
xorl %r15d, %r15d
movq 0x28(%rsp), %rbp
jmp 0x76ba2
movl $0x1, %eax
cmpq $0x20, %r9
jne 0x76c71
movl $0x1, 0x44(%rcx)
xorl %eax, %eax
movl %eax, 0x40(%rcx)
movl 0x70(%rcx), %ecx
movq 0x10(%rsp), %rax
movl 0x78(%rax), %r8d
movl $0x20, %esi
leaq 0x60(%rsp), %rdi
leaq 0xb0b0e(%rip), %rdx     # 0x12779f
xorl %eax, %eax
callq 0xe8193
movq 0x10(%rsp), %rax
movq 0xb0(%rax), %rax
shlq $0x3, %rax
cqto
movq 0x10(%rsp), %rcx
idivq 0x80(%rcx)
movq 0x10(%rsp), %rcx
movq %rax, 0x30(%rcx)
movq 0x10(%rsp), %rcx
movq 0xc0(%rcx), %rcx
shlq $0x3, %rcx
movq 0x10(%rsp), %rdx
movq %rcx, 0x38(%rdx)
movq 0x10(%rsp), %rcx
movq 0x70(%rcx), %rsi
movq 0x10(%rsp), %rcx
movq 0x78(%rcx), %rcx
movq %rbx, %rdi
movq %rax, %rdx
movl $0x4, %r8d
callq 0xf26a5
movq 0x10(%rsp), %r13
movq %rax, 0xf0(%r13)
movq 0xa0(%r13), %rdx
testq %rdx, %rdx
jle 0x76d55
cmpq $0x100, %rdx            # imm = 0x100
ja 0x76c50
movq 0x18(%rbx), %rdi
movq 0x68(%r13), %rsi
addq %r15, %rsi
movq 0x98(%r13), %rcx
movq 0x10(%rsp), %rax
leaq 0x100(%rax), %r8
movl $0x1, (%rsp)
movl $0x100, %r9d            # imm = 0x100
callq 0xf2c4e
movq 0x10(%rsp), %r13
addq 0xd8(%r13), %r15
movq %r15, 0x20(%r13)
movq 0xb8(%r13), %rcx
addq %r15, %rcx
movq %rcx, 0x28(%r13)
movq %rbx, %rdi
leaq 0xb1988(%rip), %rsi     # 0x128700
movl %r15d, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x10(%rsp), %rax
movq 0x38(%rax), %rdx
movq 0x10(%rsp), %rax
movq 0x70(%rax), %rsi
movq 0x10(%rsp), %rax
movq 0x78(%rax), %rcx
movq %rbx, %rdi
movl $0x1, %r8d
callq 0xf26a5
movq 0x10(%rsp), %rcx
movq %rax, 0xf8(%rcx)
movq 0x18(%rbx), %rdi
movq 0x10(%rsp), %rcx
movq 0x28(%rcx), %rsi
movq 0x10(%rsp), %rcx
movq 0xc0(%rcx), %rdx
movq %rax, %rcx
xorl %r8d, %r8d
callq 0xf2a40
movq 0x10(%rsp), %r8
movq 0x80(%r8), %rdx
cmpq $0x20, %rdx
jne 0x76f17
movq 0xf0(%r8), %r14
movq 0x10(%r14), %rcx
testq %rcx, %rcx
jle 0x77029
movq 0x30(%r8), %rax
xorl %r13d, %r13d
movq 0xb0(%r8), %rdx
imulq %r13, %rdx
addq 0x20(%r8), %rdx
movq %rdx, 0x40(%rsp)
testq %rax, %rax
jle 0x76ec0
xorl %r12d, %r12d
movq %r13, 0x38(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x40(%rsp), %rbp
movq %rbp, %rsi
callq 0xeeb4b
movb %al, 0x1f(%rsp)
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeeb4b
movl %eax, %r13d
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeeb4b
movl %eax, %r15d
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeeb4b
movzbl %al, %eax
shll $0x18, %eax
movzbl %r15b, %ecx
shll $0x10, %ecx
orl %eax, %ecx
movzbl %r13b, %eax
movq 0x38(%rsp), %r13
shll $0x8, %eax
orl %ecx, %eax
movzbl 0x1f(%rsp), %ecx
orl %eax, %ecx
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xf24bf
movq 0x10(%rsp), %r8
incq %r12
movq 0x30(%r8), %rax
cmpq %rax, %r12
jl 0x76e31
movq 0x10(%r14), %rcx
movq 0x20(%rsp), %r12
incq %r13
cmpq %rcx, %r13
jl 0x76e0c
jmp 0x77029
cmpq $0x10, %r9
jne 0x76eea
movl (%rcx), %edx
movq %rbx, %rdi
leaq 0xb17ad(%rip), %rsi     # 0x128690
movl $0x10, %ecx
jmp 0x76ef9
movl (%rcx), %edx
movq %rbx, %rdi
leaq 0xb17c1(%rip), %rsi     # 0x1286b7
movl %r9d, %ecx
xorl %eax, %eax
callq 0xe9295
movq 0x10(%rsp), %r13
xorl %r15d, %r15d
movq 0x28(%rsp), %rbp
movq 0x20(%rsp), %r12
jmp 0x76ba2
movq 0xf0(%r8), %r15
cmpq $0x18, %rdx
jne 0x76f48
movq 0x18(%rbx), %rdi
movq 0x20(%r8), %rsi
movq 0xb0(%r8), %rdx
movl $0x3, %ecx
movq %r15, %r8
movl $0x1, %r9d
callq 0xf3279
jmp 0x76f77
cmpq $0x8, %rdx
jg 0x77029
movq 0x18(%rbx), %rdi
movq 0x20(%r8), %rsi
movq 0xb0(%r8), %rcx
addq $0x100, %r8             # imm = 0x100
movl $0x0, (%rsp)
movq %r15, %r9
callq 0xf2f79
movq 0x10(%r15), %rcx
testq %rcx, %rcx
movq 0x10(%rsp), %r8
jle 0x77029
movq 0x70(%r8), %rax
xorl %r14d, %r14d
testq %rax, %rax
jle 0x7701d
xorl %r12d, %r12d
movl $0x808000ff, %ebx       # imm = 0x808000FF
movq 0xf8(%r8), %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %r8, %r13
callq 0xf2592
testl $0xff0000, %eax         # imm = 0xFF0000
je 0x77002
movq 0xf0(%r13), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0xf2592
testl $0xffffff, %eax         # imm = 0xFFFFFF
je 0x76fee
movl $0x1, 0x48(%r13)
leal (%r14,%r12), %eax
testb $0x1, %al
movl $0x80ff0080, %ecx       # imm = 0x80FF0080
cmovel %ebx, %ecx
jmp 0x76ff0
xorl %ecx, %ecx
movq 0xf0(%r13), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0xf24bf
incq %r12
movq 0x70(%r13), %rax
cmpq %rax, %r12
movq %r13, %r8
jl 0x76fa1
movq 0x10(%r15), %rcx
movq %rbp, %rbx
movq 0x20(%rsp), %r12
incq %r14
cmpq %rcx, %r14
jl 0x76f90
cmpl $0x0, 0x48(%r8)
je 0x77046
movq %rbx, %rdi
leaq 0xb16fa(%rip), %rsi     # 0x128734
xorl %eax, %eax
callq 0xe8faa
movq 0x10(%rsp), %r8
movq 0xf0(%r8), %rdi
xorl %esi, %esi
cmpq $0x20, 0x80(%r8)
sete %sil
callq 0xf38c4
movq %rbx, %rdi
callq 0xea504
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
leaq 0x60(%rsp), %rdx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0xea78f
movq 0x10(%rsp), %r13
movq 0x30(%rsp), %rax
cmpl $0x0, (%rax)
movq 0x28(%rsp), %rbp
je 0x770a7
movb $0x1, 0xe(%r15)
movq 0x18(%r13), %rax
movq %rax, 0x98(%r15)
movq 0xf0(%r13), %rdi
movq %r15, %rsi
movl $0x4, %edx
callq 0xf22d0
movq 0x30(%rsp), %rax
cmpl $0x0, 0x4(%rax)
je 0x76ba2
cmpl $0x0, 0x40(%r13)
je 0x770f3
cmpb $0x0, 0xd6(%rbx)
leaq 0x40(%rsp), %r14
je 0x76ba2
movq 0x70(%r13), %rcx
cmpq %rcx, 0x38(%r13)
jle 0x76ba2
jmp 0x770fc
movq 0x70(%r13), %rcx
leaq 0x40(%rsp), %r14
movq 0x10(%rsp), %rax
movl 0x78(%rax), %r8d
movq 0x10(%rsp), %rax
movl 0x80(%rax), %r9d
movl $0x20, %esi
movq %r14, %rdi
leaq 0xb15fd(%rip), %rdx     # 0x12871d
xorl %eax, %eax
callq 0xe8193
movq 0x10(%rsp), %rax
movq 0xf8(%rax), %rdi
movq %r14, %rsi
movl $0x5, %edx
callq 0xf22dc
jmp 0x76b9d
leaq 0xb1506(%rip), %rsi     # 0x128652
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movq 0x30(%rsp), %rsi
callq 0xe8be2
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq