// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/misc2.c
// Function: de_run_alias_pix
static void de_run_alias_pix(deark *c, de_module_params *mparams)
{
	de_bitmap *img = NULL;
	i64 w, h;
	i64 i;
	i64 pos;
	i64 firstline;
	i64 depth;
	i64 xpos, ypos;
	i64 runlen;
	u32 clr;

	w = de_getu16be(0);
	h = de_getu16be(2);
	firstline = de_getu16be(4);
	depth = de_getu16be(8);

	if(!de_good_image_dimensions(c, w, h)) goto done;
	if(firstline >= h) goto done;
	if(depth!=24) {
		de_err(c, "Unsupported image type");
		goto done;
	}

	img = de_bitmap_create(c, w, h, 3);

	pos = 10;
	xpos = 0;
	// I don't know for sure what to do with the "first scanline" field, in the
	// unlikely event it is not 0. The documentation doesn't say.
	ypos = firstline;
	while(1) {
		if(pos+4 > c->infile->len) {
			break; // EOF
		}
		runlen = (i64)de_getbyte(pos);
		clr = dbuf_getRGB(c->infile, pos+1, DE_GETRGBFLAG_BGR);
		pos+=4;

		for(i=0; i<runlen; i++) {
			de_bitmap_setpixel_rgb(img, xpos, ypos, clr);
			xpos++; // Runs are not allowed to span rows
		}

		if(xpos >= w) {
			xpos=0;
			ypos++;
		}
	}

	de_bitmap_write_to_file(img, NULL, 0);
done:
	de_bitmap_destroy(img);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1651d0
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0x2, %esi
callq 0x1651d0
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0x4, %esi
callq 0x1651d0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0x8, %esi
callq 0x1651d0
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x16a850
cmpl $0x0, %eax
jne 0x955ba
jmp 0x956e7
movq -0x40(%rbp), %rax
cmpq -0x28(%rbp), %rax
jl 0x955c9
jmp 0x956e7
cmpq $0x18, -0x48(%rbp)
je 0x955e7
movq -0x8(%rbp), %rdi
leaq 0x10dee5(%rip), %rsi    # 0x1a34c0
movb $0x0, %al
callq 0x15bfb0
jmp 0x956e7
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl $0x3, %ecx
callq 0x16b750
movq %rax, -0x18(%rbp)
movq $0xa, -0x38(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rax
addq $0x4, %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jle 0x95634
jmp 0x956d8
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x38(%rbp), %rsi
callq 0x165060
movzbl %al, %eax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x38(%rbp), %rsi
addq $0x1, %rsi
movl $0x1, %edx
callq 0x165ff0
movl %eax, -0x64(%rbp)
movq -0x38(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x60(%rbp), %rax
jge 0x956b5
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdx
movl -0x64(%rbp), %ecx
callq 0x16b310
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x9567d
movq -0x50(%rbp), %rax
cmpq -0x20(%rbp), %rax
jl 0x956d3
movq $0x0, -0x50(%rbp)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x95619
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x16afd0
movq -0x18(%rbp), %rdi
callq 0x16af60
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)