// File: /workspace/github_c_makefile_star2_O1/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 0xe969b
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 0xe9b05
xorl %r12d, %r12d
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef0d5
movl %eax, %ebp
movq 0x18(%rbx), %rdi
leaq 0x1(%r15), %rsi
callq 0xef0d5
movl %eax, %r13d
movq 0x18(%rbx), %rdi
leaq 0x3(%r15), %rsi
callq 0xef0d5
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 0xe9d68
incq %r12
addq $0x4, %r15
cmpq $0x100, %r12            # imm = 0x100
jne 0x23c7e
movq 0x8(%rsp), %r15
movq 0x10(%r15), %rsi
movq 0x18(%r15), %rdx
movq %rbx, %rdi
movl $0x3, %ecx
callq 0xf2cab
movq %rax, 0x38(%r15)
movq %rbx, %r14
movq %rbx, %rdi
callq 0xea9a9
cmpq $0x140, 0x10(%r15)      # imm = 0x140
jne 0x23d4a
cmpq $0xc8, 0x18(%r15)
jne 0x23d4a
movl $0x1, 0x78(%rax)
movabsq $0x406e000000000000, %rcx # imm = 0x406E000000000000
movq %rcx, 0x80(%rax)
movabsq $0x4069000000000000, %rcx # imm = 0x4069000000000000
movq %rcx, 0x88(%rax)
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x18(%r15)
jle 0x23e07
xorl %r12d, %r12d
cmpq $0x0, 0x10(%r15)
jle 0x23dfa
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 0xef169
andl %r15d, %eax
movl $0x1, %edx
movl %ebp, %ecx
shll %cl, %edx
testl %eax, %eax
je 0x23dbc
movl %edx, %eax
orl %eax, %ebx
incq %rbp
addq $0x2, %r13
cmpq $0x8, %rbp
jne 0x23d91
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 0xf2afd
incq %rbx
cmpq 0x10(%r15), %rbx
jl 0x23d6a
incq %r12
cmpq 0x18(%r15), %r12
jl 0x23d5d
movq 0x38(%r15), %rdi
movq 0x10(%rsp), %r12
movq %r12, %rsi
xorl %edx, %edx
callq 0xf2917
movq 0x38(%r15), %rdi
callq 0xf28d4
movq $0x0, 0x38(%r15)
movq %r14, %rdi
movq %r12, %rsi
callq 0xea9b3
movq %r14, %rdi
movq %r15, %rsi
callq 0xe9752
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop