// File: /workspace/github_cpp_makefile_star2_O2/lvandeve[P]lodepng/pngdetail.cpp
// Function: displayPalettePixels(std::vector<unsigned char, std::allocator<unsigned char>> const&, Options const&)
void displayPalettePixels(const std::vector<unsigned char>& buffer, const Options& options) {
  unsigned w, h;
  lodepng::State state;
  std::vector<unsigned char> out;
  std::cout << (options.use_hex ? std::hex: std::dec);

  state.decoder.color_convert = 0;

  lodepng::decode(out, w, h, state, buffer);

  if(state.info_png.color.colortype == LCT_PALETTE) {
    if (options.show_color_stats) {
      std::vector<size_t> count(256, 0);
      size_t outofbounds = 0;

      for(size_t i = 0; i < w * h; i++) {
        int value = lodepng::getPaletteValue(&out[0], i, state.info_raw.bitdepth);
        count[value]++;
        if(value >= (int)state.info_raw.palettesize) outofbounds++;
      }

      std::cout << "Palette count: ";
      for(size_t i = 0; i < state.info_raw.palettesize; i++) {
        std::cout << count[i] << " ";
      }
      std::cout << std::endl;

      if(outofbounds > 0) std::cout << "Out of bounds palette values: " << outofbounds << std::endl;
    }

    std::cout << "Pixel palette indices:" << std::endl;
    for(size_t i = 0; i < w * h; i++) {
      int value = lodepng::getPaletteValue(&out[0], i, state.info_raw.bitdepth);
      std::cout << value << ", ";
      if(i % w == w - 1) std::cout << std::endl;
    }
  } else {
    std::cout << "Pixel palette indices: not shown, not a palette image\n" << std::endl;
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x2c8, %rsp            # imm = 0x2C8
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x48(%rsp), %rdi
callq 0xb81c
andq $0x0, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
leaq 0x46f7(%rip), %rax      # 0x190b2
leaq 0x4700(%rip), %rcx      # 0x190c2
cmpb $0x0, 0x24(%rbx)
cmovneq %rax, %rcx
movq 0x125ff(%rip), %rdi     # 0x26fd0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
callq *%rcx
leaq 0x48(%rsp), %rcx
andl $0x0, 0x34(%rcx)
leaq 0x10(%rsp), %rdi
leaq 0x4(%rsp), %rsi
leaq 0xc(%rsp), %rdx
movq %r14, %r8
callq 0xb9bf
cmpl $0x3, 0x128(%rsp)
jne 0x14a6b
cmpb $0x1, 0x9(%rbx)
jne 0x14b39
leaq 0x30(%rsp), %rdi
leaq 0xb(%rsp), %rcx
movl $0x100, %esi            # imm = 0x100
xorl %edx, %edx
callq 0x19208
xorl %ebx, %ebx
xorl %r14d, %r14d
movl 0xc(%rsp), %eax
imull 0x4(%rsp), %eax
cmpq %rax, %r14
jae 0x14aa9
movq 0x10(%rsp), %rdi
movl 0xf4(%rsp), %edx
movq %r14, %rsi
callq 0xf5aa
movslq %eax, %rcx
movq 0x30(%rsp), %rdx
incq (%rdx,%rcx,8)
xorl %ecx, %ecx
cmpl 0x100(%rsp), %eax
setge %cl
addq %rcx, %rbx
incq %r14
jmp 0x14a29
movq 0x1255e(%rip), %rdi     # 0x26fd0
leaq 0x9f18(%rip), %rsi      # 0x1e991
callq 0x2210
movq %rax, %rdi
callq 0x2100
leaq 0x10(%rsp), %rdi
callq 0xea4c
leaq 0x48(%rsp), %rdi
callq 0xb844
addq $0x2c8, %rsp            # imm = 0x2C8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x12520(%rip), %rdi     # 0x26fd0
leaq 0x9e94(%rip), %rsi      # 0x1e94b
callq 0x2210
xorl %r12d, %r12d
movq 0x1250a(%rip), %r14     # 0x26fd0
leaq 0xa683(%rip), %r15      # 0x1f150
cmpq 0x100(%rsp), %r12
jae 0x14af8
movq 0x30(%rsp), %rax
movq (%rax,%r12,8), %rsi
movq %r14, %rdi
callq 0x2150
movq %rax, %rdi
movq %r15, %rsi
callq 0x2210
incq %r12
jmp 0x14acd
movq 0x124d1(%rip), %rdi     # 0x26fd0
callq 0x2100
testq %rbx, %rbx
je 0x14b2f
movq 0x124c0(%rip), %rdi     # 0x26fd0
leaq 0x9e44(%rip), %rsi      # 0x1e95b
callq 0x2210
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2150
movq %rax, %rdi
callq 0x2100
leaq 0x30(%rsp), %rdi
callq 0x19658
movq 0x12490(%rip), %rdi     # 0x26fd0
leaq 0x9e33(%rip), %rsi      # 0x1e97a
callq 0x2210
movq %rax, %rdi
callq 0x2100
xorl %ebx, %ebx
movq 0x12473(%rip), %r14     # 0x26fd0
leaq 0xa180(%rip), %r15      # 0x1ece4
movl 0xc(%rsp), %eax
imull 0x4(%rsp), %eax
cmpq %rax, %rbx
jae 0x14a86
movq 0x10(%rsp), %rdi
movl 0xf4(%rsp), %edx
movq %rbx, %rsi
callq 0xf5aa
movq %r14, %rdi
movl %eax, %esi
callq 0x2390
movq %rax, %rdi
movq %r15, %rsi
callq 0x2210
movl 0x4(%rsp), %ecx
movl %ebx, %eax
xorl %edx, %edx
divl %ecx
decl %ecx
cmpl %ecx, %edx
jne 0x14bb7
movq %r14, %rdi
callq 0x2100
incq %rbx
jmp 0x14b64
jmp 0x14bda
jmp 0x14bda
jmp 0x14bcb
movq %rax, %rbx
jmp 0x14be7
jmp 0x14bda
jmp 0x14bcb
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x19658
jmp 0x14bdd
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xea4c
leaq 0x48(%rsp), %rdi
callq 0xb844
movq %rbx, %rdi
callq 0x23a0
movq %rax, %rdi
callq 0xe69c