// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/mmm.c
// Function: do_mmm_CURS
static void do_mmm_CURS(deark *c, struct mmm_ctx *d, struct de_iffctx *ictx, i64 pos1, i64 len)
{
	i64 pos = pos1;
	de_bitmap *img_fg = NULL;
	de_bitmap *img_mask = NULL;
	de_finfo *fi = NULL;

	mmm_read_rsrcid_p(c, d, ictx, &pos, NULL);
	mmm_read_name_p(c, d, ictx, &pos, NULL);
	if(pos1+len-pos < 68) goto done;

	fi = de_finfo_create(c);

	img_fg = de_bitmap_create(c, 16, 16, 2);
	img_mask = de_bitmap_create(c, 16, 16, 1);

	de_dbg(c, "foreground at %"I64_FMT, pos);
	de_convert_image_bilevel(c->infile, pos, 2, img_fg, DE_CVTF_WHITEISZERO);
	pos += 32;
	de_dbg(c, "mask at %"I64_FMT, pos);
	de_convert_image_bilevel(c->infile, pos, 2, img_mask, 0);
	pos += 32;
	de_bitmap_apply_mask(img_fg, img_mask, 0);

	fi->hotspot_y = (int)de_geti16be_p(&pos);
	fi->hotspot_x = (int)de_geti16be_p(&pos);
	fi->has_hotspot = 1;
	de_dbg(c, "hotspot: (%d,%d)", fi->hotspot_x, fi->hotspot_y);

	if(!c->filenames_from_file) ucstring_empty(d->tmp_namestr);
	if(ucstring_isnonempty(d->tmp_namestr)) {
		ucstring_append_char(d->tmp_namestr, '.');
	}
	ucstring_append_sz(d->tmp_namestr, "CURS", DE_ENCODING_LATIN1);
	de_finfo_set_name_from_ucstring(c, fi, d->tmp_namestr, 0);
	de_bitmap_write_to_file_finfo(img_fg, fi, DE_CREATEFLAG_OPT_IMAGE);

done:
	de_bitmap_destroy(img_fg);
	de_bitmap_destroy(img_mask);
	de_finfo_destroy(c, fi);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %rbp
movq %rcx, %r12
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq %rsp, %r13
movq %rcx, (%r13)
movq 0x18(%rdx), %rdi
movq %r13, %rsi
callq 0xeee2f
movl %eax, 0x1c(%r14)
leaq 0xa72e2(%rip), %rsi     # 0x13f0e3
leaq 0x98a3b(%rip), %rdx     # 0x130843
movq %rbx, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %r15d, %r15d
movq %r13, %rcx
xorl %r8d, %r8d
callq 0x97fd7
addq %r12, %rbp
subq (%r13), %rbp
movl $0x0, %r13d
movl $0x0, %r12d
cmpq $0x44, %rbp
jl 0x97fad
movq %rbx, %rdi
callq 0xea504
movq %rax, %r12
movl $0x10, %esi
movl $0x10, %edx
movq %rbx, %rdi
movl $0x2, %ecx
callq 0xf266a
movq %rax, %r15
movl $0x10, %esi
movl $0x10, %edx
movq %rbx, %rdi
movl $0x1, %ecx
callq 0xf266a
movq %rax, %r13
movq %rsp, %rbp
movq (%rbp), %rdx
leaq 0x97054(%rip), %rsi     # 0x12eee9
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq (%rbp), %rsi
movl $0x2, %edx
movq %r15, %rcx
movl $0x1, %r8d
callq 0xf2a40
movq (%rbp), %rdx
addq $0x20, %rdx
movq %rdx, (%rbp)
leaq 0xa2a7c(%rip), %rsi     # 0x13a949
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq (%rbp), %rsi
movl $0x2, %edx
movq %r13, %rcx
xorl %r8d, %r8d
callq 0xf2a40
addq $0x20, (%rbp)
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xf37bd
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeec86
movl %eax, 0x9c(%r12)
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeec86
movl %eax, 0x98(%r12)
movb $0x1, 0xe(%r12)
movl 0x9c(%r12), %ecx
leaq 0x96fbd(%rip), %rsi     # 0x12eefb
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
cmpb $0x0, 0xd0(%rbx)
jne 0x97f5c
movq 0x28(%r14), %rdi
callq 0xf6423
movq 0x28(%r14), %rdi
callq 0xf67a3
testl %eax, %eax
je 0x97f77
movq 0x28(%r14), %rdi
movl $0x2e, %esi
callq 0xf6542
movq 0x28(%r14), %rdi
leaq 0x9897b(%rip), %rsi     # 0x1308fd
movl $0x5, %edx
callq 0xf65e3
movq 0x28(%r14), %rdx
movq %rbx, %rdi
movq %r12, %rsi
xorl %ecx, %ecx
callq 0xea53f
movq %r15, %rdi
movq %r12, %rsi
movl $0x2, %edx
callq 0xf22d0
movq %r15, %rdi
callq 0xf228d
movq %r13, %rdi
callq 0xf228d
movq %rbx, %rdi
movq %r12, %rsi
callq 0xea50e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq