// File: /workspace/github_cpp_makefile_star2_O1/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 0xd100
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
leaq 0x6150(%rip), %rax      # 0x1e2ff
leaq 0x6159(%rip), %rcx      # 0x1e30f
cmpb $0x0, 0x24(%rbx)
cmovneq %rax, %rcx
movq 0x12e0b(%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 0xd482
cmpl $0x3, 0x120(%rsp)
jne 0x18273
cmpb $0x1, 0x9(%rbx)
jne 0x183b5
leaq 0x28(%rsp), %rdi
leaq 0xf(%rsp), %rcx
movl $0x100, %esi            # imm = 0x100
xorl %edx, %edx
callq 0x1e49a
movl 0x8(%rsp), %eax
imull 0x4(%rsp), %eax
testl %eax, %eax
je 0x182be
xorl %r14d, %r14d
xorl %ebx, %ebx
movq 0x10(%rsp), %rdi
movl 0xec(%rsp), %edx
movq %r14, %rsi
callq 0x11bb5
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 0x18231
jmp 0x182c0
movq 0x12d56(%rip), %rbx     # 0x2afd0
leaq 0xb6ac(%rip), %rsi      # 0x2392d
movl $0x36, %edx
movq %rbx, %rdi
callq 0x2280
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq 0x12d24(%rip), %rdi     # 0x2afd0
callq 0x2040
movq %rax, %rdi
callq 0x2160
jmp 0x18492
xorl %ebx, %ebx
movq 0x12d09(%rip), %r14     # 0x2afd0
leaq 0xb619(%rip), %rsi      # 0x238e7
movl $0xf, %edx
movq %r14, %rdi
callq 0x2280
cmpq $0x0, 0xf8(%rsp)
je 0x18325
xorl %r13d, %r13d
movq 0x12ce0(%rip), %r15     # 0x2afd0
leaq 0xbe2b(%rip), %r12      # 0x24122
movq 0x28(%rsp), %rax
movq (%rax,%r13,8), %rsi
movq %r15, %rdi
callq 0x2150
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2280
incq %r13
cmpq 0xf8(%rsp), %r13
jb 0x182f7
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq 0x12c8d(%rip), %rdi     # 0x2afd0
callq 0x2040
movq %rax, %rdi
callq 0x2160
testq %rbx, %rbx
je 0x183a6
movq 0x12c74(%rip), %rdi     # 0x2afd0
leaq 0xb594(%rip), %rsi      # 0x238f7
movl $0x1e, %edx
callq 0x2280
movq 0x12c5c(%rip), %rdi     # 0x2afd0
movq %rbx, %rsi
callq 0x2150
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2160
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x183b5
callq 0x2200
movq 0x12c14(%rip), %rbx     # 0x2afd0
leaq 0xb553(%rip), %rsi      # 0x23916
movl $0x16, %edx
movq %rbx, %rdi
callq 0x2280
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq 0x12be2(%rip), %rbx     # 0x2afd0
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2160
movl 0x8(%rsp), %eax
imull 0x4(%rsp), %eax
testl %eax, %eax
je 0x18492
xorl %r14d, %r14d
leaq 0xb89d(%rip), %r15      # 0x23cb6
movq 0x10(%rsp), %rdi
movl 0xec(%rsp), %edx
movq %r14, %rsi
callq 0x11bb5
movq %rbx, %rdi
movl %eax, %esi
callq 0x2380
movl $0x2, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2280
movl 0x4(%rsp), %ecx
movq %r14, %rax
xorl %edx, %edx
divq %rcx
leal -0x1(%rcx), %eax
cmpl %eax, %edx
jne 0x18481
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2160
incq %r14
movl 0x8(%rsp), %eax
imull 0x4(%rsp), %eax
cmpq %rax, %r14
jb 0x18419
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x184a1
callq 0x2200
leaq 0x40(%rsp), %rdi
callq 0xd128
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x184d8
jmp 0x184c4
jmp 0x184c4
jmp 0x184d8
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x184db
callq 0x2200
jmp 0x184db
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x184ea
callq 0x2200
leaq 0x40(%rsp), %rdi
callq 0xd128
movq %rbx, %rdi
callq 0x2390
movq %rax, %rdi
callq 0x14eb9