// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/atari-img.c
// Function: do_prism_read_palette
static void do_prism_read_palette(deark *c, prismctx *d, struct atari_img_decode_data *adata)
{
	i64 i;
	i64 r1, g1, b1;
	u8 r, g, b;
	u32 pal1[256];
	u32 clr;
	i64 num_entries_to_read;
	char tmps[32];

	de_zeromem(pal1, sizeof(pal1));
	num_entries_to_read = de_min_int(d->pal_size, 256);

	for(i=0; i<num_entries_to_read; i++) {
		r1 = de_getu16be(128+6*i+0);
		g1 = de_getu16be(128+6*i+2);
		b1 = de_getu16be(128+6*i+4);
		r = de_scale_1000_to_255(r1);
		g = de_scale_1000_to_255(g1);
		b = de_scale_1000_to_255(b1);
		clr = DE_MAKE_RGB(r,g,b);
		de_snprintf(tmps, sizeof(tmps), "(%4d,%4d,%4d) "DE_CHAR_RIGHTARROW" ",
			(int)r1, (int)g1, (int)b1);
		de_dbg_pal_entry2(c, i, clr, tmps, NULL, NULL);
		pal1[i] = clr;
	}

	for(i=0; i<num_entries_to_read; i++) {
		d->pal[i] = pal1[map_vdi_pal(adata->bpp, (unsigned int)i)];
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x470, %rsp            # imm = 0x470
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x440(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x19140
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x15ccf0
movq %rax, -0x450(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x450(%rbp), %rax
jge 0x2afc5
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
imulq $0x6, -0x20(%rbp), %rsi
addq $0x80, %rsi
addq $0x0, %rsi
callq 0x1651d0
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
imulq $0x6, -0x20(%rbp), %rsi
addq $0x80, %rsi
addq $0x2, %rsi
callq 0x1651d0
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
imulq $0x6, -0x20(%rbp), %rsi
addq $0x80, %rsi
addq $0x4, %rsi
callq 0x1651d0
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rdi
callq 0x161760
movb %al, -0x39(%rbp)
movq -0x30(%rbp), %rdi
callq 0x161760
movb %al, -0x3a(%rbp)
movq -0x38(%rbp), %rdi
callq 0x161760
movb %al, -0x3b(%rbp)
movzbl -0x39(%rbp), %eax
shll $0x10, %eax
orl $0xff000000, %eax       # imm = 0xFF000000
movzbl -0x3a(%rbp), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movzbl -0x3b(%rbp), %ecx
orl %ecx, %eax
movl %eax, -0x444(%rbp)
leaq -0x470(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %eax, %r8d
movq -0x38(%rbp), %rax
movl %eax, %r9d
movl $0x20, %esi
leaq 0x174896(%rip), %rdx    # 0x19f810
movb $0x0, %al
callq 0x15a980
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x444(%rbp), %edx
leaq -0x470(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %r8
callq 0x15bdb0
movl -0x444(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, -0x440(%rbp,%rax,4)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x2ae9a
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x450(%rbp), %rax
jge 0x2b00f
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movl %eax, %esi
callq 0x2b020
movl %eax, %eax
movl -0x440(%rbp,%rax,4), %edx
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movl %edx, 0x18(%rax,%rcx,4)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x2afcd
addq $0x470, %rsp            # imm = 0x470
popq %rbp
retq
nopl (%rax,%rax)