// File: /workspace/github_c_makefile_star2_O1/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 0xef475
movl %eax, 0x1c(%r14)
leaq 0xa6653(%rip), %rsi     # 0x13ece3
leaq 0x97e71(%rip), %rdx     # 0x130508
movq %rbx, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %r15d, %r15d
movq %r13, %rcx
xorl %r8d, %r8d
callq 0x98866
addq %r12, %rbp
subq (%r13), %rbp
movl $0x0, %r13d
movl $0x0, %r12d
cmpq $0x44, %rbp
jl 0x9883c
movq %rbx, %rdi
callq 0xea9a9
movq %rax, %r12
movl $0x10, %esi
movl $0x10, %edx
movq %rbx, %rdi
movl $0x2, %ecx
callq 0xf2cab
movq %rax, %r15
movl $0x10, %esi
movl $0x10, %edx
movq %rbx, %rdi
movl $0x1, %ecx
callq 0xf2cab
movq %rax, %r13
movq %rsp, %rbp
movq (%rbp), %rdx
leaq 0x964b5(%rip), %rsi     # 0x12ebd9
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq (%rbp), %rsi
movl $0x2, %edx
movq %r15, %rcx
movl $0x1, %r8d
callq 0xf3081
movq (%rbp), %rdx
addq $0x20, %rdx
movq %rdx, (%rbp)
leaq 0xa1e6d(%rip), %rsi     # 0x13a5c9
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq (%rbp), %rsi
movl $0x2, %edx
movq %r13, %rcx
xorl %r8d, %r8d
callq 0xf3081
addq $0x20, (%rbp)
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xf3e1c
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xef295
movl %eax, 0x9c(%r12)
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xef295
movl %eax, 0x98(%r12)
movb $0x1, 0xe(%r12)
movl 0x9c(%r12), %ecx
leaq 0x9641e(%rip), %rsi     # 0x12ebeb
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
cmpb $0x0, 0xd0(%rbx)
jne 0x987eb
movq 0x28(%r14), %rdi
callq 0xf6883
movq 0x28(%r14), %rdi
callq 0xf6c00
testl %eax, %eax
je 0x98806
movq 0x28(%r14), %rdi
movl $0x2e, %esi
callq 0xf69a2
movq 0x28(%r14), %rdi
leaq 0x97db1(%rip), %rsi     # 0x1305c2
movl $0x5, %edx
callq 0xf6a40
movq 0x28(%r14), %rdx
movq %rbx, %rdi
movq %r12, %rsi
xorl %ecx, %ecx
callq 0xea9e4
movq %r15, %rdi
movq %r12, %rsi
movl $0x2, %edx
callq 0xf2917
movq %r15, %rdi
callq 0xf28d4
movq %r13, %rdi
callq 0xf28d4
movq %rbx, %rdi
movq %r12, %rsi
callq 0xea9b3
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq