// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/misc2.c
// Function: de_run_farbfeld
static void de_run_farbfeld(deark *c, de_module_params *mparams)
{
	de_bitmap *imghi = NULL; // high 8 bits of each sample
	de_bitmap *imglo = NULL; // low 8 bits of each sample
	i64 width, height;
	i64 i, j, k;
	i64 ppos;
	u8 sh[4];
	u8 sl[4];

	width = de_getu32be(8);
	height = de_getu32be(12);
	de_dbg_dimensions(c, width, height);
	if(!de_good_image_dimensions(c, width, height)) return;

	imghi = de_bitmap_create(c, width, height, 4);
	imglo = de_bitmap_create(c, width, height, 4);

	for(j=0; j<height; j++) {
		for(i=0; i<width; i++) {
			ppos = 16 + 8*(width*j + i);
			for(k=0; k<4; k++) {
				sh[k] = de_getbyte(ppos+2*k);
				sl[k] = de_getbyte(ppos+2*k+1);
			}
			de_bitmap_setpixel_rgba(imghi, i, j,
				DE_MAKE_RGBA(sh[0],sh[1],sh[2],sh[3]));
			de_bitmap_setpixel_rgba(imglo, i, j,
				DE_MAKE_RGBA(sl[0],sl[1],sl[2],sl[3]));
		}
	}
	de_bitmap16_write_to_file_finfo(imghi, imglo, NULL, DE_CREATEFLAG_OPT_IMAGE);
	de_bitmap_destroy(imghi);
	de_bitmap_destroy(imglo);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
movl $0x8, %esi
callq 0xef32a
movq %rax, %rbp
movq 0x18(%rbx), %rdi
movl $0xc, %esi
callq 0xef32a
movq %rax, %r15
movq %rbx, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0xe9b05
movq %rbx, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0xf241d
testl %eax, %eax
je 0x694e3
movq %rbx, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movl $0x4, %ecx
callq 0xf2cab
movq %rax, 0x20(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movl $0x4, %ecx
callq 0xf2cab
movq %rax, 0x18(%rsp)
testq %r15, %r15
jle 0x694a9
leaq (,%rbp,8), %rax
movq %rax, 0x28(%rsp)
movl $0x10, %eax
movq %rax, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq %r15, 0x30(%rsp)
testq %rbp, %rbp
jle 0x6947f
movq 0x8(%rsp), %r12
xorl %r15d, %r15d
movq %r12, %r14
xorl %r13d, %r13d
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef0d5
movb %al, 0x4(%rsp,%r13)
movq 0x18(%rbx), %rdi
leaq 0x1(%r14), %rsi
callq 0xef0d5
movb %al, (%rsp,%r13)
incq %r13
addq $0x2, %r14
cmpq $0x4, %r13
jne 0x693d6
movzbl 0x7(%rsp), %eax
shll $0x18, %eax
movzbl 0x4(%rsp), %ecx
shll $0x10, %ecx
orl %eax, %ecx
movzbl 0x5(%rsp), %eax
shll $0x8, %eax
orl %ecx, %eax
movzbl 0x6(%rsp), %ecx
orl %eax, %ecx
movq 0x20(%rsp), %rdi
movq %r15, %rsi
movq 0x10(%rsp), %r14
movq %r14, %rdx
callq 0xf2b02
movzbl 0x3(%rsp), %eax
shll $0x18, %eax
movzbl (%rsp), %ecx
shll $0x10, %ecx
orl %eax, %ecx
movzbl 0x1(%rsp), %eax
shll $0x8, %eax
orl %ecx, %eax
movzbl 0x2(%rsp), %ecx
orl %eax, %ecx
movq 0x18(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xf2b02
incq %r15
addq $0x8, %r12
cmpq %rbp, %r15
jne 0x693d0
movq 0x10(%rsp), %rcx
incq %rcx
movq 0x8(%rsp), %rax
addq 0x28(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %r15
movq %rcx, 0x10(%rsp)
cmpq %r15, %rcx
jne 0x693bf
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
movq 0x18(%rsp), %r14
movq %r14, %rsi
xorl %edx, %edx
movl $0x2, %ecx
callq 0xf2586
movq %rbx, %rdi
callq 0xf28d4
movq %r14, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xf28d4
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq