// File: /workspace/github_cpp_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
subq $0x2c0, %rsp            # imm = 0x2C0
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x40(%rsp), %rdi
callq 0xd328
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
leaq 0x625b(%rip), %rax      # 0x1e1e9
leaq 0x6264(%rip), %rcx      # 0x1e1f9
cmpb $0x0, 0x24(%rbx)
cmovneq %rax, %rcx
movq 0x1302c(%rip), %rdi     # 0x2afd0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
callq *%rcx
leaq 0x40(%rsp), %rcx
movl $0x0, 0x34(%rcx)
leaq 0x10(%rsp), %rdi
leaq 0x4(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %r14, %r8
callq 0xd69b
cmpl $0x3, 0x120(%rsp)
jne 0x18052
cmpb $0x1, 0x9(%rbx)
jne 0x18194
leaq 0x28(%rsp), %rdi
leaq 0xf(%rsp), %rcx
movl $0x100, %esi            # imm = 0x100
xorl %edx, %edx
callq 0x1e38c
movl 0x8(%rsp), %eax
imull 0x4(%rsp), %eax
testl %eax, %eax
je 0x1809d
xorl %r14d, %r14d
xorl %ebx, %ebx
movq 0x10(%rsp), %rdi
movl 0xec(%rsp), %edx
movq %r14, %rsi
callq 0x11841
movslq %eax, %rcx
movq 0x28(%rsp), %rdx
incq (%rdx,%rcx,8)
xorl %ecx, %ecx
cmpl 0xf8(%rsp), %eax
setge %cl
addq %rcx, %rbx
incq %r14
movl 0x8(%rsp), %eax
imull 0x4(%rsp), %eax
cmpq %rax, %r14
jb 0x18010
jmp 0x1809f
movq 0x12f77(%rip), %rbx     # 0x2afd0
leaq 0xbaed(%rip), %rsi      # 0x23b4d
movl $0x36, %edx
movq %rbx, %rdi
callq 0x2290
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq 0x12f45(%rip), %rdi     # 0x2afd0
callq 0x2040
movq %rax, %rdi
callq 0x2170
jmp 0x18270
xorl %ebx, %ebx
movq 0x12f2a(%rip), %r14     # 0x2afd0
leaq 0xba5a(%rip), %rsi      # 0x23b07
movl $0xf, %edx
movq %r14, %rdi
callq 0x2290
cmpq $0x0, 0xf8(%rsp)
je 0x18104
xorl %r13d, %r13d
movq 0x12f01(%rip), %r15     # 0x2afd0
leaq 0xc236(%rip), %r12      # 0x2430c
movq 0x28(%rsp), %rax
movq (%rax,%r13,8), %rsi
movq %r15, %rdi
callq 0x2160
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2290
incq %r13
cmpq 0xf8(%rsp), %r13
jb 0x180d6
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq 0x12eae(%rip), %rdi     # 0x2afd0
callq 0x2040
movq %rax, %rdi
callq 0x2170
testq %rbx, %rbx
je 0x18185
movq 0x12e95(%rip), %rdi     # 0x2afd0
leaq 0xb9d5(%rip), %rsi      # 0x23b17
movl $0x1e, %edx
callq 0x2290
movq 0x12e7d(%rip), %rdi     # 0x2afd0
movq %rbx, %rsi
callq 0x2160
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x18194
callq 0x2210
movq 0x12e35(%rip), %rbx     # 0x2afd0
leaq 0xb994(%rip), %rsi      # 0x23b36
movl $0x16, %edx
movq %rbx, %rdi
callq 0x2290
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq 0x12e03(%rip), %rbx     # 0x2afd0
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movl 0x8(%rsp), %eax
imull 0x4(%rsp), %eax
testl %eax, %eax
je 0x18270
xorl %r14d, %r14d
leaq 0xbca8(%rip), %r15      # 0x23ea0
movq 0x10(%rsp), %rdi
movl 0xec(%rsp), %edx
movq %r14, %rsi
callq 0x11841
movq %rbx, %rdi
movl %eax, %esi
callq 0x2390
movl $0x2, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2290
movl 0x4(%rsp), %ecx
movl %r14d, %eax
xorl %edx, %edx
divl %ecx
leal -0x1(%rcx), %eax
cmpl %eax, %edx
jne 0x18263
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movl 0x4(%rsp), %ecx
incq %r14
imull 0x8(%rsp), %ecx
cmpq %rcx, %r14
jb 0x181f8
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1827f
callq 0x2210
leaq 0x40(%rsp), %rdi
callq 0xd350
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x182b6
jmp 0x182a2
jmp 0x182a2
jmp 0x182b6
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x182b9
callq 0x2210
jmp 0x182b9
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x182c8
callq 0x2210
leaq 0x40(%rsp), %rdi
callq 0xd350
movq %rbx, %rdi
callq 0x23a0
movq %rax, %rdi
callq 0x14c96