// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/atari-img.c
// Function: do_atari_falcon_8bit_img
static void do_atari_falcon_8bit_img(deark *c, i64 width, i64 height)
{
	struct atari_img_decode_data *adata = NULL;
	i64 k;
	u8 cr, cg, cb;
	u32 pal[256];

	adata = de_malloc(c, sizeof(struct atari_img_decode_data));
	de_zeromem(pal, sizeof(pal));
	adata->pal = pal;
	adata->bpp = 8;
	adata->ncolors = 256;
	adata->w = width;
	adata->h = height;
	de_dbg_dimensions(c, adata->w, adata->h);

	for(k=0; k<256; k++) {
		cr = de_getbyte(k*4+0);
		cg = de_getbyte(k*4+1);
		cb = de_getbyte(k*4+3);
		pal[k] = DE_MAKE_RGB(cr, cg, cb);
		de_dbg_pal_entry(c, k, pal[k]);
	}

	decode_falcon_8bit_image(c, adata, 1024);

	de_free(c, adata);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
pushq $0x40
popq %rsi
callq 0xdecaf
movq %rax, %r14
leaq 0x20(%rsp), %rbp
xorl %r15d, %r15d
movl $0x400, %edx            # imm = 0x400
movq %rbp, %rdi
xorl %esi, %esi
callq 0x18140
movq %rbp, 0x30(%r14)
movq $0x8, (%r14)
movq $0x100, 0x8(%r14)       # imm = 0x100
movq %r13, 0x10(%r14)
movq %r12, 0x18(%r14)
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0xdf038
pushq $0x3
popq %r12
movq 0x8(%rsp), %rbx
cmpq $0x403, %r12            # imm = 0x403
je 0x23548
movq 0x18(%rbx), %rdi
leaq -0x3(%r12), %rsi
callq 0xe3eb4
movl %eax, %ebp
movq 0x18(%rbx), %rdi
leaq -0x2(%r12), %rsi
callq 0xe3eb4
movl %eax, %r13d
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xe3eb4
movzbl %bpl, %ecx
shll $0x10, %ecx
movzbl %r13b, %esi
shll $0x8, %esi
orl %ecx, %esi
movzbl %al, %edx
orl %esi, %edx
orl $0xff000000, %edx       # imm = 0xFF000000
movl %edx, 0x1d(%rsp,%r12)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xdf23b
incq %r15
addq $0x4, %r12
jmp 0x234de
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
pushq $0x3
popq %rcx
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xe7437
movq %rax, 0x38(%r14)
movq %rbx, %rdi
callq 0xdfd1a
movq 0x10(%r14), %rcx
cmpq $0x140, %rcx            # imm = 0x140
jne 0x23598
cmpq $0xc8, 0x18(%r14)
jne 0x23598
movl $0x1, 0x78(%rax)
movaps 0xe2cef(%rip), %xmm0    # 0x106280
movups %xmm0, 0x80(%rax)
movq %rax, 0x10(%rsp)
xorl %r12d, %r12d
cmpq 0x18(%r14), %r12
jge 0x23647
xorl %ebx, %ebx
cmpq %rcx, %rbx
jge 0x2363f
movq %rbx, %r13
movq %rbx, 0x18(%rsp)
movl %ebx, %ecx
notb %cl
andb $0xf, %cl
pushq $0x1
popq %r15
shll %cl, %r15d
andq $-0x10, %r13
addq $0x400, %r13            # imm = 0x400
xorl %ebp, %ebp
xorl %ebx, %ebx
cmpq $0x8, %rbp
je 0x23616
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x10(%r14), %rsi
imulq %r12, %rsi
addq %r13, %rsi
callq 0xe3f46
andl %r15d, %eax
pushq $0x1
popq %rdx
movl %ebp, %ecx
shll %cl, %edx
testl %eax, %eax
je 0x23609
movl %edx, %eax
orl %ebx, %eax
incq %rbp
addq $0x2, %r13
movl %eax, %ebx
jmp 0x235da
movq 0x30(%r14), %rax
movq 0x38(%r14), %rdi
movl %ebx, %ecx
movl (%rax,%rcx,4), %ecx
movq 0x18(%rsp), %rbx
movq %rbx, %rsi
movq %r12, %rdx
callq 0xe7287
incq %rbx
movq 0x10(%r14), %rcx
jmp 0x235ac
incq %r12
jmp 0x235a0
movq 0x38(%r14), %rdi
movq 0x10(%rsp), %r15
movq %r15, %rsi
xorl %edx, %edx
callq 0xe70ab
movq 0x38(%r14), %rdi
callq 0xe7084
andq $0x0, 0x38(%r14)
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xdfd24
movq %rbx, %rdi
movq %r14, %rsi
callq 0xded32
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)