// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/png.c
// Function: handler_sPLT
static void handler_sPLT(deark *c, lctx *d, struct handler_params *hp)
{
	struct de_stringreaderdata *srd = NULL;
	i64 pos = hp->dpos;
	i64 nbytes_to_scan;
	u8 depth;
	i64 nentries;
	i64 stride;
	i64 i;

	nbytes_to_scan = hp->dlen;
	if(nbytes_to_scan>80) nbytes_to_scan=80;
	srd = dbuf_read_string(c->infile, pos, nbytes_to_scan, 79, DE_CONVFLAG_STOP_AT_NUL,
		DE_ENCODING_LATIN1);
	if(!srd->found_nul) goto done;
	de_dbg(c, "palette name: \"%s\"", ucstring_getpsz(srd->str));
	pos += srd->bytes_consumed;

	if(pos >= hp->dpos+hp->dlen) goto done;
	depth = de_getbyte(pos++);
	de_dbg(c, "depth: %d", (int)depth);
	if(depth!=8 && depth!=16) goto done;

	stride = (depth==8) ? 6 : 10;
	nentries = (hp->dpos+hp->dlen-pos)/stride;
	de_dbg(c, "number of entries: %d", (int)nentries);

	if(c->debug_level<2) goto done;
	for(i=0; i<nentries; i++) {
		unsigned int cr, cg, cb, ca, cf;
		if(depth==8) {
			cr = (unsigned int)de_getbyte(pos);
			cg = (unsigned int)de_getbyte(pos+1);
			cb = (unsigned int)de_getbyte(pos+2);
			ca = (unsigned int)de_getbyte(pos+3);
			cf = (unsigned int)de_getu16be(pos+4);
			de_dbg2(c, "pal[%3d] = (%3u,%3u,%3u,A=%u) F=%u",
				(int)i, cr, cg, cb, ca, cf);
		}
		else {
			cr = (unsigned int)de_getu16be(pos);
			cg = (unsigned int)de_getu16be(pos+2);
			cb = (unsigned int)de_getu16be(pos+4);
			ca = (unsigned int)de_getu16be(pos+6);
			cf = (unsigned int)de_getu16be(pos+8);
			de_dbg2(c, "pal[%3d] = (%5u,%5u,%5u,A=%u) F=%u",
				(int)i, cr, cg, cb, ca, cf);
		}
		pos += stride;
	}

done:
	de_destroy_stringreaderdata(c, srd);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x50, -0x30(%rbp)
jle 0x10c715
movq $0x50, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
movl $0x4f, %ecx
movl $0x1, %r8d
movl $0x5, %r9d
callq 0x1664c0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, 0x34(%rax)
jne 0x10c74e
jmp 0x10c9ec
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x172500
movq -0x70(%rbp), %rdi
movq %rax, %rdx
leaq 0xb6d07(%rip), %rsi     # 0x1c3478
movb $0x0, %al
callq 0x15b0d0
movq -0x20(%rbp), %rax
movq (%rax), %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
movq -0x18(%rbp), %rdx
addq 0x8(%rdx), %rcx
cmpq %rcx, %rax
jl 0x10c7a4
jmp 0x10c9ec
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
movq %rsi, %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
callq 0x165060
movb %al, -0x31(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x31(%rbp), %edx
leaq 0xa151d(%rip), %rsi     # 0x1adcef
movb $0x0, %al
callq 0x15b0d0
movzbl -0x31(%rbp), %eax
cmpl $0x8, %eax
je 0x10c7f0
movzbl -0x31(%rbp), %eax
cmpl $0x10, %eax
je 0x10c7f0
jmp 0x10c9ec
movzbl -0x31(%rbp), %edx
movl $0xa, %eax
movl $0x6, %ecx
cmpl $0x8, %edx
cmovel %ecx, %eax
cltq
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
addq 0x8(%rcx), %rax
subq -0x28(%rbp), %rax
cqto
idivq -0x48(%rbp)
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
leaq 0x96062(%rip), %rsi     # 0x1a289a
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
cmpl $0x2, (%rax)
jge 0x10c84d
jmp 0x10c9ec
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x40(%rbp), %rax
jge 0x10c9ea
movzbl -0x31(%rbp), %eax
cmpl $0x8, %eax
jne 0x10c927
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x165060
movzbl %al, %eax
movl %eax, -0x54(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
addq $0x1, %rsi
callq 0x165060
movzbl %al, %eax
movl %eax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
addq $0x2, %rsi
callq 0x165060
movzbl %al, %eax
movl %eax, -0x5c(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
addq $0x3, %rsi
callq 0x165060
movzbl %al, %eax
movl %eax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
addq $0x4, %rsi
callq 0x1651d0
movl %eax, -0x64(%rbp)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rax
movl %eax, %edx
movl -0x54(%rbp), %ecx
movl -0x58(%rbp), %r8d
movl -0x5c(%rbp), %r9d
movl -0x60(%rbp), %r10d
movl -0x64(%rbp), %eax
leaq 0xb6b78(%rip), %rsi     # 0x1c348b
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x15b350
jmp 0x10c9cd
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x1651d0
movl %eax, -0x54(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
addq $0x2, %rsi
callq 0x1651d0
movl %eax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
addq $0x4, %rsi
callq 0x1651d0
movl %eax, -0x5c(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
addq $0x6, %rsi
callq 0x1651d0
movl %eax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
addq $0x8, %rsi
callq 0x1651d0
movl %eax, -0x64(%rbp)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rax
movl %eax, %edx
movl -0x54(%rbp), %ecx
movl -0x58(%rbp), %r8d
movl -0x5c(%rbp), %r9d
movl -0x60(%rbp), %r10d
movl -0x64(%rbp), %eax
leaq 0xb6af0(%rip), %rsi     # 0x1c34ae
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x15b350
movq -0x48(%rbp), %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x10c855
jmp 0x10c9ec
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x166830
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)