// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/misc2.c
// Function: de_run_deskmate_pnt
static void de_run_deskmate_pnt(deark *c, de_module_params *mparams)
{
	i64 w, h;
	i64 rowspan;
	i64 pos = 0;
	int is_compressed;
	de_bitmap *img = NULL;
	dbuf *unc_pixels = NULL;
	i64 unc_pixels_size;
	de_color pal[16];

	pos += 22;
	de_dbg(c, "image at %"I64_FMT, pos);
	w = 312;
	h = 176;
	rowspan = w/2;
	unc_pixels_size = rowspan * h;

	de_copy_std_palette(DE_PALID_PC16, 0, 0, pal, 16, 0);

	is_compressed = (pos+unc_pixels_size != c->infile->len);
	de_dbg(c, "compressed: %d", is_compressed);

	if(is_compressed) {
		unc_pixels = dbuf_create_membuf(c, unc_pixels_size, 0x1);
		while(1) {
			i64 count;
			u8 val;

			if(pos >= c->infile->len) break; // out of source data
			if(unc_pixels->len >= unc_pixels_size) break; // enough dst data
			val = de_getbyte_p(&pos);
			count = (i64)de_getbyte_p(&pos);
			dbuf_write_run(unc_pixels, val, count);
		}
	}
	else {
		unc_pixels = dbuf_open_input_subfile(c->infile, pos, unc_pixels_size);
	}

	img = de_bitmap_create(c, w, h, 3);
	de_convert_image_paletted(unc_pixels, 0, 4, rowspan, pal, img, 0);
	de_bitmap_write_to_file(img, NULL, 0);

	dbuf_close(unc_pixels);
	de_bitmap_destroy(img);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x30(%rbp), %rax
addq $0x16, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq 0x121f38(%rip), %rsi    # 0x1ba32e
movb $0x0, %al
callq 0x15b0d0
movq $0x138, -0x18(%rbp)     # imm = 0x138
movq $0xb0, -0x20(%rbp)
movq -0x18(%rbp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
imulq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq -0x90(%rbp), %rcx
movl $0x14, %edi
xorl %r9d, %r9d
xorl %eax, %eax
movl %eax, %edx
movl $0x10, %r8d
movl %r9d, %esi
callq 0x161320
movq -0x30(%rbp), %rax
addq -0x50(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rdi
movl -0x34(%rbp), %edx
leaq 0x12b606(%rip), %rsi    # 0x1c3a80
movb $0x0, %al
callq 0x15b0d0
cmpl $0x0, -0x34(%rbp)
je 0x98514
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
movl $0x1, %edx
callq 0x168020
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jl 0x984b5
jmp 0x98512
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
cmpq -0x50(%rbp), %rax
jl 0x984c5
jmp 0x98512
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x165170
movb %al, -0x99(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x165170
movzbl %al, %eax
movq %rax, -0x98(%rbp)
movq -0x48(%rbp), %rdi
movb -0x99(%rbp), %al
movq -0x98(%rbp), %rdx
movzbl %al, %esi
callq 0x168800
jmp 0x984a1
jmp 0x9852d
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x1691b0
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl $0x3, %ecx
callq 0x16b750
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rcx
leaq -0x90(%rbp), %r8
movq -0x40(%rbp), %r9
xorl %eax, %eax
movl %eax, %esi
movl $0x4, %edx
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0x16c520
movq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x16afd0
movq -0x48(%rbp), %rdi
callq 0x1676a0
movq -0x40(%rbp), %rdi
callq 0x16af60
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax,%rax)