// File: /workspace/github_cpp_makefile_star2_O1/lvandeve[P]lodepng/pngdetail.cpp
// Function: displayColorsHex(std::vector<unsigned char, std::allocator<unsigned char>> const&, unsigned int, unsigned int, bool)
void displayColorsHex(const std::vector<unsigned char>& image, unsigned w, unsigned h, bool sixteen) {
  std::ios_base::fmtflags flags = std::cout.flags();

  if(w > 0 && h > 0) {
    std::cout << "Colors (CSS RGBA hex format):" << std::endl;

    for(unsigned y = 0; y < h; y++) {
      std::cout.flags(flags); //print line numbers in hex or dec whatever it originally was
      std::cout << y << ":";
      for(unsigned x = 0; x < w; x++) {
        size_t index = y * w * 8 + x * 8;
        if (sixteen) {
          int r = image[index + 0] * 256 + image[index + 1];
          int g = image[index + 2] * 256 + image[index + 3];
          int b = image[index + 4] * 256 + image[index + 5];
          int a = image[index + 6] * 256 + image[index + 7];
          std::cout << std::hex << std::setfill('0') << " #" << std::setw(4) << r << std::setw(4) << g << std::setw(4) << b << std::setw(4) << a;
        } else {
          int r = image[index + 0];
          int g = image[index + 2];
          int b = image[index + 4];
          int a = image[index + 6];
          std::cout << std::hex << std::setfill('0') << " #" << std::setw(2) << r << std::setw(2) << g << std::setw(2) << b << std::setw(2) << a;
        }
      }
      std::cout << std::endl;
    }
  }

  std::cout.flags(flags);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, 0x1c(%rsp)
movq %rdi, 0x40(%rsp)
movq 0x13549(%rip), %r14     # 0x2afd0
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x18(%r14,%rax), %eax
movl %eax, 0x8(%rsp)
testl %esi, %esi
sete %al
testl %edx, %edx
sete %cl
orb %al, %cl
jne 0x17cec
movl %edx, %ebx
movl %esi, %ebp
leaq 0xbda0(%rip), %rsi      # 0x23854
movl $0x1d, %edx
movq %r14, %rdi
callq 0x2280
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2160
movl %ebx, %eax
movq %rax, 0x28(%rsp)
movl %ebp, %eax
movq %rax, 0x20(%rsp)
shll $0x3, %ebp
movl %ebp, 0x18(%rsp)
xorl %r13d, %r13d
xorl %esi, %esi
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x8(%rsp), %ecx
movl %ecx, 0x18(%r14,%rax)
movq %r14, %rdi
movq %rsi, 0x30(%rsp)
callq 0x2150
movl $0x1, %edx
movq %rax, %rdi
leaq 0xbd81(%rip), %rsi      # 0x238af
callq 0x2280
movq 0x20(%rsp), %r12
movq %r13, 0x38(%rsp)
movl %r13d, %r13d
movq 0x40(%rsp), %rax
movq (%rax), %rax
movzbl (%rax,%r13), %ebp
cmpb $0x0, 0x1c(%rsp)
je 0x17bb8
shll $0x8, %ebp
movzbl 0x1(%rax,%r13), %ecx
orl %ecx, %ebp
movzwl 0x2(%rax,%r13), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
movl %ecx, 0xc(%rsp)
movzwl 0x4(%rax,%r13), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
movl %ecx, 0x10(%rsp)
movzwl 0x6(%rax,%r13), %eax
rolw $0x8, %ax
movzwl %ax, %eax
movl %eax, 0x14(%rsp)
movq (%r14), %rax
movq -0x18(%rax), %rcx
movl 0x18(%r14,%rcx), %edx
andl $-0x4b, %edx
orl $0x8, %edx
movl %edx, 0x18(%r14,%rcx)
movq -0x18(%rax), %rax
leaq (%r14,%rax), %r15
movl $0x4, %ebx
jmp 0x17bfa
movzbl 0x2(%rax,%r13), %ecx
movl %ecx, 0xc(%rsp)
movzbl 0x4(%rax,%r13), %ecx
movl %ecx, 0x10(%rsp)
movzbl 0x6(%rax,%r13), %eax
movl %eax, 0x14(%rsp)
movq (%r14), %rax
movq -0x18(%rax), %rcx
movl 0x18(%r14,%rcx), %edx
andl $-0x4b, %edx
orl $0x8, %edx
movl %edx, 0x18(%r14,%rcx)
movq -0x18(%rax), %rax
leaq (%r14,%rax), %r15
movl $0x2, %ebx
cmpb $0x0, 0xe1(%r14,%rax)
jne 0x17c21
movq %r15, %rdi
movl $0x20, %esi
callq 0x2210
movb %al, 0xe0(%r15)
movb $0x1, 0xe1(%r15)
movb $0x30, 0xe0(%r15)
movl $0x2, %edx
movq %r14, %rdi
leaq 0xbc3a(%rip), %rsi      # 0x23872
callq 0x2280
movq (%r14), %rax
movq -0x18(%rax), %rax
movq %rbx, 0x10(%r14,%rax)
movq %r14, %rdi
movl %ebp, %esi
callq 0x2380
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %rbx, 0x10(%rax,%rcx)
movq %rax, %rdi
movl 0xc(%rsp), %esi
callq 0x2380
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %rbx, 0x10(%rax,%rcx)
movq %rax, %rdi
movl 0x10(%rsp), %esi
callq 0x2380
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %rbx, 0x10(%rax,%rcx)
movq %rax, %rdi
movl 0x14(%rsp), %esi
callq 0x2380
addl $0x8, %r13d
decq %r12
jne 0x17b3d
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2160
movq 0x30(%rsp), %rsi
incq %rsi
movq 0x38(%rsp), %r13
addl 0x18(%rsp), %r13d
cmpq 0x28(%rsp), %rsi
jne 0x17b02
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x8(%rsp), %ecx
movl %ecx, 0x18(%r14,%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq