// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x8
popq %rsi
callq 0xe404f
movq %rax, %r14
movq 0x18(%rbx), %rdi
pushq $0xc
popq %rsi
callq 0xe404f
movq %rax, %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0xdf038
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xe6be1
testl %eax, %eax
je 0x658b6
pushq $0x4
popq %rbp
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movl %ebp, %ecx
callq 0xe7437
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movl %ebp, %ecx
callq 0xe7437
movq %rax, 0x8(%rsp)
xorl %ebp, %ebp
testq %r14, %r14
movl $0x0, %eax
cmovgq %r14, %rax
movq %rax, 0x30(%rsp)
testq %r15, %r15
cmovleq %rbp, %r15
shlq $0x3, %r14
pushq $0x11
popq %r13
movq %r14, 0x20(%rsp)
movq %r15, 0x18(%rsp)
cmpq %r15, %rbp
je 0x6587e
movq %r13, 0x28(%rsp)
xorl %r14d, %r14d
cmpq 0x30(%rsp), %r14
je 0x65864
movq %r13, %r15
xorl %r12d, %r12d
cmpq $0x4, %r12
je 0x657f3
movq 0x18(%rbx), %rdi
leaq -0x1(%r15), %rsi
callq 0xe3eb4
movb %al, 0x4(%rsp,%r12)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3eb4
movb %al, (%rsp,%r12)
incq %r12
addq $0x2, %r15
jmp 0x657c2
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 0x10(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0xe728c
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 0x8(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0xe728c
incq %r14
addq $0x8, %r13
jmp 0x657b1
incq %rbp
movq 0x20(%rsp), %r14
movq 0x28(%rsp), %r13
addq %r14, %r13
movq 0x18(%rsp), %r15
jmp 0x657a0
pushq $0x2
popq %rcx
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq 0x8(%rsp), %r14
movq %r14, %rsi
xorl %edx, %edx
callq 0xe6d4b
movq %rbx, %rdi
callq 0xe7084
movq %r14, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe7084
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq