// File: /workspace/github_cpp_makefile_star2_O2/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, 0x20(%rsp)
movl %edx, %ebp
movq %rdi, 0x40(%rsp)
movq 0x12b68(%rip), %rbx     # 0x26fd0
movq (%rbx), %rax
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
movl %ecx, 0xc(%rsp)
testl %esi, %esi
sete %cl
testl %edx, %edx
sete %dl
orb %cl, %dl
jne 0x1463a
movl %esi, %r14d
leaq 0xa425(%rip), %rsi      # 0x1e8b8
movq %rbx, %rdi
callq 0x2210
movq %rax, %rdi
callq 0x2100
movl %r14d, %ecx
movl %ebp, %eax
movq %rax, 0x30(%rsp)
movl %r14d, %eax
movq %rax, 0x28(%rsp)
shll $0x3, %ecx
movq $0x0, 0x10(%rsp)
xorl %esi, %esi
movl %ecx, 0x1c(%rsp)
movq (%rbx), %rax
movq -0x18(%rax), %rax
cmpq 0x30(%rsp), %rsi
je 0x1463a
movl 0xc(%rsp), %ecx
movl %ecx, 0x18(%rbx,%rax)
movq %rbx, %rdi
movq %rsi, 0x38(%rsp)
callq 0x2150
movq %rax, %rdi
leaq 0xa41b(%rip), %rsi      # 0x1e913
callq 0x2210
movq 0x10(%rsp), %rax
movq 0x28(%rsp), %rbx
subq $0x1, %rbx
jb 0x1460e
movl %eax, 0x24(%rsp)
movl %eax, %eax
movq 0x40(%rsp), %rcx
movq (%rcx), %rcx
movzbl (%rcx,%rax), %r12d
cmpb $0x0, 0x20(%rsp)
je 0x1455f
shll $0x8, %r12d
movzbl 0x1(%rcx,%rax), %edx
orl %edx, %r12d
movzwl 0x2(%rcx,%rax), %ebp
bswapl %ebp
shrl $0x10, %ebp
movzwl 0x4(%rcx,%rax), %r13d
bswapl %r13d
shrl $0x10, %r13d
movzwl 0x6(%rcx,%rax), %r14d
bswapl %r14d
shrl $0x10, %r14d
pushq $0x4
jmp 0x14572
movzbl 0x2(%rcx,%rax), %ebp
movzbl 0x4(%rcx,%rax), %r13d
movzbl 0x6(%rcx,%rax), %r14d
pushq $0x2
popq %r15
movq 0x12a55(%rip), %rdi     # 0x26fd0
movq (%rdi), %rax
movq -0x18(%rax), %rax
movl 0x18(%rdi,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%rdi,%rax)
pushq $0x30
popq %rsi
callq 0x2310
movq %rax, %rdi
leaq 0xa334(%rip), %rsi      # 0x1e8d6
callq 0x2210
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r15, 0x10(%rax,%rcx)
movq %rax, %rdi
movl %r12d, %esi
callq 0x2390
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r15, 0x10(%rax,%rcx)
movq %rax, %rdi
movl %ebp, %esi
callq 0x2390
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r15, 0x10(%rax,%rcx)
movq %rax, %rdi
movl %r13d, %esi
callq 0x2390
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r15, 0x10(%rax,%rcx)
movq %rax, %rdi
movl %r14d, %esi
callq 0x2390
movl 0x24(%rsp), %eax
addl $0x8, %eax
jmp 0x14507
movq 0x129bb(%rip), %rbx     # 0x26fd0
movq %rbx, %rdi
callq 0x2100
movq 0x38(%rsp), %rsi
incq %rsi
movl 0x1c(%rsp), %ecx
movq 0x10(%rsp), %rax
addl %ecx, %eax
movq %rax, 0x10(%rsp)
jmp 0x144c7
movl 0xc(%rsp), %ecx
movl %ecx, 0x18(%rbx,%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq