// File: /workspace/github_c_makefile_star2_O3/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
movl $0x40, %esi
callq 0xe8b2b
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 %r14, 0x8(%rsp)
movq %r12, 0x18(%r14)
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0xe8f88
xorl %r12d, %r12d
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeead3
movl %eax, %ebp
movq 0x18(%rbx), %rdi
leaq 0x1(%r15), %rsi
callq 0xeead3
movl %eax, %r13d
movq 0x18(%rbx), %rdi
leaq 0x3(%r15), %rsi
callq 0xeead3
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, 0x20(%rsp,%r12,4)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe91fc
incq %r12
addq $0x4, %r15
cmpq $0x100, %r12            # imm = 0x100
jne 0x23c62
movq 0x8(%rsp), %r14
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
movq %rbx, %rdi
movl $0x3, %ecx
callq 0xf266a
movq %rax, 0x38(%r14)
movq %rbx, %rdi
callq 0xea504
movq 0x10(%r14), %rdi
movq 0x18(%r14), %rcx
movq %rdi, %rdx
xorq $0x140, %rdx            # imm = 0x140
movq %rcx, %rsi
xorq $0xc8, %rsi
orq %rdx, %rsi
movq %rax, 0x10(%rsp)
jne 0x23d2b
movl $0x1, 0x78(%rax)
movaps 0xef5be(%rip), %xmm0    # 0x1132e0
movups %xmm0, 0x80(%rax)
jmp 0x23d34
testq %rcx, %rcx
jle 0x23df0
xorl %r12d, %r12d
testq %rdi, %rdi
jle 0x23de4
movq %rbx, %r14
xorl %ebx, %ebx
movq %rbx, %r13
movq %rbx, 0x18(%rsp)
movl %ebx, %ecx
notb %cl
andb $0xf, %cl
movl $0x1, %r15d
shll %cl, %r15d
andq $-0x10, %r13
addq $0x400, %r13            # imm = 0x400
xorl %ebx, %ebx
xorl %ebp, %ebp
movq 0x18(%r14), %rdi
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rsi
imulq %r12, %rsi
addq %r13, %rsi
callq 0xeeb67
andl %r15d, %eax
movl $0x1, %edx
movl %ebp, %ecx
shll %cl, %edx
testl %eax, %eax
je 0x23d97
movl %edx, %eax
orl %eax, %ebx
incq %rbp
addq $0x2, %r13
cmpq $0x8, %rbp
jne 0x23d6c
movq 0x8(%rsp), %r15
movq 0x30(%r15), %rax
movq 0x38(%r15), %rdi
movl %ebx, %ecx
movl (%rax,%rcx,4), %ecx
movq 0x18(%rsp), %rbx
movq %rbx, %rsi
movq %r12, %rdx
callq 0xf24ba
incq %rbx
movq 0x10(%r15), %rdi
cmpq %rdi, %rbx
jl 0x23d45
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq %r14, %rbx
incq %r12
cmpq %rcx, %r12
jl 0x23d37
movq 0x8(%rsp), %r14
movq 0x38(%r14), %rdi
movq 0x10(%rsp), %r15
movq %r15, %rsi
xorl %edx, %edx
callq 0xf22d0
movq 0x38(%r14), %rdi
callq 0xf228d
movq $0x0, 0x38(%r14)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xea50e
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe8be2
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)