// File: lvandeve[P]lodepng/pngdetail.cpp
// Function: displayPalette(Data&, Options const&)
void displayPalette(Data& data, const Options& options) {
  data.loadInspect();
  if(data.error) return;
  std::cout << (options.use_hex ? std::hex: std::dec);

  const LodePNGInfo& info = data.state.info_png;
  const LodePNGColorMode& color = info.color;

  std::cout << "Palette size: " << color.palettesize << std::endl;
  std::cout << "Palette colors: ";
  std::ios_base::fmtflags flags = std::cout.flags();
  std::cout << std::hex << std::setfill('0');
  for(size_t i = 0; i < color.palettesize; i++) {
    unsigned char* p = &color.palette[i * 4];
    std::cout << "#" << std::setw(2) << (int)p[0] << std::setw(2) << (int)p[1] << std::setw(2) << (int)p[2] << std::setw(2) << (int)p[3] << " ";
  }
  std::cout.flags(flags);
  std::cout << std::endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x317c0
movq -0x8(%rbp), %rax
cmpl $0x0, 0x2d8(%rax)
je 0x2a54e
jmp 0x2a77a
movq -0x10(%rbp), %rax
testb $0x1, 0x24(%rax)
je 0x2a565
leaq 0x76f1(%rip), %rax      # 0x31c50
movq %rax, -0x50(%rbp)
jmp 0x2a572
leaq 0x7714(%rip), %rax      # 0x31c80
movq %rax, -0x50(%rbp)
jmp 0x2a572
movq -0x50(%rbp), %rsi
movq 0x1ca53(%rip), %rdi     # 0x46fd0
callq 0x20b0
movq -0x8(%rbp), %rax
addq $0x58, %rax
addq $0xd0, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x20(%rbp)
movq 0x1ca29(%rip), %rdi     # 0x46fd0
leaq 0xffe1(%rip), %rsi      # 0x3a58f
callq 0x2250
movq %rax, %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x2080
movq %rax, %rdi
movq 0x1c9f3(%rip), %rsi     # 0x46fc0
callq 0x22a0
movq 0x1c9f7(%rip), %rdi     # 0x46fd0
leaq 0xffbe(%rip), %rsi      # 0x3a59e
callq 0x2250
movq 0x1c9e4(%rip), %rax     # 0x46fd0
movq (%rax), %rax
movq 0x1c9da(%rip), %rdi     # 0x46fd0
addq -0x18(%rax), %rdi
callq 0x32230
movl %eax, -0x24(%rbp)
movq 0x1c9c7(%rip), %rdi     # 0x46fd0
leaq 0x7640(%rip), %rsi      # 0x31c50
callq 0x20b0
movq %rax, -0x58(%rbp)
movl $0x30, %edi
callq 0x32270
movq -0x58(%rbp), %rdi
movb %al, -0x25(%rbp)
movzbl -0x25(%rbp), %esi
callq 0x23c0
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x2a74a
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq 0x1c965(%rip), %rdi     # 0x46fd0
leaq 0xfec9(%rip), %rsi      # 0x3a53b
callq 0x2250
movq %rax, -0x78(%rbp)
movl $0x2, %edi
callq 0x32290
movq -0x78(%rbp), %rdi
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %esi
callq 0x22e0
movq %rax, %rdi
movq -0x38(%rbp), %rax
movzbl (%rax), %esi
callq 0x2420
movq %rax, -0x70(%rbp)
movl $0x2, %edi
callq 0x32290
movq -0x70(%rbp), %rdi
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %esi
callq 0x22e0
movq %rax, %rdi
movq -0x38(%rbp), %rax
movzbl 0x1(%rax), %esi
callq 0x2420
movq %rax, -0x68(%rbp)
movl $0x2, %edi
callq 0x32290
movq -0x68(%rbp), %rdi
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %esi
callq 0x22e0
movq %rax, %rdi
movq -0x38(%rbp), %rax
movzbl 0x2(%rax), %esi
callq 0x2420
movq %rax, -0x60(%rbp)
movl $0x2, %edi
callq 0x32290
movq -0x60(%rbp), %rdi
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %esi
callq 0x22e0
movq %rax, %rdi
movq -0x38(%rbp), %rax
movzbl 0x3(%rax), %esi
callq 0x2420
movq %rax, %rdi
leaq 0x106b9(%rip), %rsi     # 0x3aded
callq 0x2250
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x2a63b
movq 0x1c87f(%rip), %rax     # 0x46fd0
movq (%rax), %rax
movq 0x1c875(%rip), %rdi     # 0x46fd0
addq -0x18(%rax), %rdi
movl -0x24(%rbp), %esi
callq 0x32250
movq 0x1c862(%rip), %rdi     # 0x46fd0
movq 0x1c84b(%rip), %rsi     # 0x46fc0
callq 0x22a0
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)