// File: /workspace/github_cpp_makefile_star2_O3/lvandeve[P]lodepng/pngdetail.cpp
// Function: displayAsciiArt(std::vector<unsigned char, std::allocator<unsigned char>> const&, unsigned int, unsigned int, unsigned int)
void displayAsciiArt(const std::vector<unsigned char>& image, unsigned w, unsigned h, unsigned asciiw) {
  const std::vector<unsigned char>* imagep = &image;
  std::vector<unsigned char> image2;
  if(asciiw < w) {
    unsigned w2 = asciiw;
    unsigned h2 = h * w2 / w;
    image2 = rescale(image, w, h, w2, h2, true);
    imagep = &image2;
    w = w2;
    h = h2;
  }
  if(w > 0 && h > 0) {
    std::cout << "ASCII Art Preview: " << std::endl;
    unsigned h2 = 1 + ((h - 1) * 4) / 7; //compensate for non-square characters in terminal
    std::cout << '+';
    for(unsigned x = 0; x < w; x++) std::cout << '-';
    std::cout << '+' << std::endl;
    for(unsigned y = 0; y < h2; y++) {
      std::cout << "|";
      unsigned y2 = y * h / h2;
      for(unsigned x = 0; x < w; x++) {
        int r = (*imagep)[y2 * w * 8 + x * 8 + 0];
        int g = (*imagep)[y2 * w * 8 + x * 8 + 2];
        int b = (*imagep)[y2 * w * 8 + x * 8 + 4];
        int a = (*imagep)[y2 * w * 8 + x * 8 + 6];
        char symbol = RGBtoLetter(r, g, b, a, x, y, true, false);
        std::cout << (char)symbol;
      }
      std::cout << "|";
      std::cout << std::endl;
    }
    std::cout << '+';
    for(unsigned x = 0; x < w; x++) std::cout << '-';
    std::cout << '+' << std::endl;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %ecx, %r14d
movl %edx, %r13d
movl %esi, %ecx
movq %rdi, %r15
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
cmpl %esi, %r14d
jae 0x1755e
movl %r14d, %eax
imull %r13d, %eax
xorl %edx, %edx
divl %ecx
movl %eax, %ebx
subq $0x8, %rsp
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
movl %ecx, %edx
movl %r13d, %ecx
movl %r14d, %r8d
movl %eax, %r9d
pushq $0x1
callq 0x16f12
addq $0x10, %rsp
leaq 0x40(%rsp), %r15
movq %rsp, %rsi
movq %r15, %rdi
callq 0x14d46
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x17559
callq 0x2210
movl %ebx, %r13d
jmp 0x17561
movl %ecx, %r14d
testl %r14d, %r14d
sete %al
testl %r13d, %r13d
sete %cl
orb %al, %cl
jne 0x177f0
movq 0x13a54(%rip), %rbx     # 0x2afd0
leaq 0xc4db(%rip), %rsi      # 0x23a5e
movl $0x13, %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 0x13a22(%rip), %rdi     # 0x2afd0
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq %rsp, %rsi
movb $0x2b, (%rsi)
movq 0x13a08(%rip), %rdi     # 0x2afd0
movl $0x1, %edx
callq 0x2290
leal -0x4(,%r13,4), %ecx
imulq $0x24924925, %rcx, %rax # imm = 0x24924925
shrq $0x20, %rax
subl %eax, %ecx
shrl %ecx
addl %eax, %ecx
shrl $0x2, %ecx
movq %rcx, 0x30(%rsp)
leal 0x1(%rcx), %eax
movl %eax, 0x1c(%rsp)
movq 0x139cf(%rip), %rbx     # 0x2afd0
movq %rsp, %r12
movq %r14, 0x20(%rsp)
movl %r14d, %ebp
movb $0x2d, (%rsp)
movl $0x1, %edx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2290
decl %ebp
jne 0x1760c
movq %rsp, %rsi
movb $0x2b, (%rsi)
movq 0x1399f(%rip), %rdi     # 0x2afd0
movl $0x1, %edx
callq 0x2290
movq 0x20(%rsp), %r12
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
movl %r12d, %r14d
leal (,%r12,8), %eax
movl %eax, 0x18(%rsp)
xorl %ebx, %ebx
movq %rsp, %r12
xorl %ebp, %ebp
movq %r13, 0x28(%rsp)
movl $0x1, %edx
movq 0x1393f(%rip), %rdi     # 0x2afd0
leaq 0xc3da(%rip), %rsi      # 0x23a72
callq 0x2290
movq %rbx, 0x38(%rsp)
movl %ebx, %eax
xorl %edx, %edx
divl 0x1c(%rsp)
movl %eax, %ebx
imull 0x18(%rsp), %ebx
addl $0x6, %ebx
xorl %r13d, %r13d
leal -0x6(%rbx), %eax
movq (%r15), %rcx
movzbl (%rcx,%rax), %edi
leal -0x4(%rbx), %eax
movzbl (%rcx,%rax), %esi
leal -0x2(%rbx), %eax
movzbl (%rcx,%rax), %edx
movl %ebx, %eax
movzbl (%rcx,%rax), %ecx
movl %r13d, %r8d
movl %ebp, %r9d
pushq $0x0
pushq $0x1
callq 0x16c80
addq $0x10, %rsp
movb %al, (%rsp)
movl $0x1, %edx
movq 0x138d9(%rip), %rdi     # 0x2afd0
movq %r12, %rsi
callq 0x2290
incq %r13
addl $0x8, %ebx
cmpq %r13, %r14
jne 0x176b7
movl $0x1, %edx
movq 0x138ba(%rip), %rdi     # 0x2afd0
leaq 0xc355(%rip), %rsi      # 0x23a72
callq 0x2290
movq 0x138a7(%rip), %rcx     # 0x2afd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq 0x13889(%rip), %rdi     # 0x2afd0
callq 0x2040
movq %rax, %rdi
callq 0x2170
leal 0x1(%rbp), %eax
movq 0x28(%rsp), %r13
movq 0x38(%rsp), %rbx
addl %r13d, %ebx
cmpl 0x30(%rsp), %ebp
movl %eax, %ebp
jne 0x17685
movq %rsp, %rsi
movb $0x2b, (%rsi)
movq 0x13853(%rip), %rdi     # 0x2afd0
movl $0x1, %edx
callq 0x2290
movq 0x20(%rsp), %r15
movq 0x1383d(%rip), %rbx     # 0x2afd0
movq %rsp, %r14
movb $0x2d, (%rsp)
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2290
decl %r15d
jne 0x17796
movq %rsp, %rsi
movb $0x2b, (%rsi)
movq 0x13814(%rip), %rdi     # 0x2afd0
movl $0x1, %edx
callq 0x2290
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 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x177ff
callq 0x2210
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x17832
callq 0x2210
jmp 0x17832
jmp 0x1782f
jmp 0x1782f
jmp 0x1782f
jmp 0x1782f
jmp 0x1782f
jmp 0x1782f
jmp 0x1782f
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x17841
callq 0x2210
movq %rbx, %rdi
callq 0x23a0