// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/atari-img.c
// Function: decode_falcon_8bit_image
static void decode_falcon_8bit_image(deark *c, struct atari_img_decode_data *adata, i64 pos)
{
	i64 i, j, k;
	unsigned int v;
	unsigned int n;
	de_finfo *fi = NULL;

	adata->img = de_bitmap_create(c, adata->w, adata->h, 3);

	fi = de_finfo_create(c);
	if(adata->w==320 && adata->h==200) {
		fi->density.code = DE_DENSITY_UNK_UNITS;
		fi->density.xdens = 240.0;
		fi->density.ydens = 200.0;
	}

	for(j=0; j<adata->h; j++) {
		for(i=0; i<adata->w; i++) {
			v = 0;
			for(k=0; k<8; k++) {
				n = (u32)de_getu16be(pos+j*adata->w + (i-i%16) +2*k);
				if(n&(1<<(15-i%16))) v |= 1<<k;
			}
			de_bitmap_setpixel_rgb(adata->img, i, j, adata->pal[v]);
		}
	}

	de_bitmap_write_to_file_finfo(adata->img, fi, 0);
	de_bitmap_destroy(adata->img);
	adata->img = NULL;
	de_finfo_destroy(c, fi);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
movl $0x3, %ecx
callq 0x16b750
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x8(%rbp), %rdi
callq 0x15d230
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x140, 0x10(%rax)      # imm = 0x140
jne 0x2bbb1
movq -0x10(%rbp), %rax
cmpq $0xc8, 0x18(%rax)
jne 0x2bbb1
movq -0x40(%rbp), %rax
movl $0x1, 0x78(%rax)
movq -0x40(%rbp), %rax
movsd 0x173763(%rip), %xmm0   # 0x19f2f8
movsd %xmm0, 0x80(%rax)
movq -0x40(%rbp), %rax
movsd 0x17376f(%rip), %xmm0   # 0x19f318
movsd %xmm0, 0x88(%rax)
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jge 0x2bce9
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jge 0x2bcd6
movl $0x0, -0x34(%rbp)
movq $0x0, -0x30(%rbp)
cmpq $0x8, -0x30(%rbp)
jge 0x2bca2
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
imulq 0x10(%rcx), %rax
addq %rax, %rsi
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movl $0x10, %ecx
cqto
idivq %rcx
movq -0x50(%rbp), %rax
subq %rdx, %rax
addq %rax, %rsi
movq -0x30(%rbp), %rax
shlq %rax
addq %rax, %rsi
callq 0x1651d0
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x20(%rbp), %rax
movl $0x10, %ecx
cqto
idivq %rcx
movl -0x44(%rbp), %eax
movl $0xf, %ecx
subq %rdx, %rcx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x2bc8f
movq -0x30(%rbp), %rax
movl %eax, %ecx
movl $0x1, %eax
shll %cl, %eax
orl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x2bc91
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x2bbf4
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x34(%rbp), %ecx
movl (%rax,%rcx,4), %ecx
callq 0x16b310
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x2bbd3
jmp 0x2bcd8
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x2bbb9
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x40(%rbp), %rsi
xorl %edx, %edx
callq 0x16afa0
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x16af60
movq -0x10(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x15d260
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)