// File: /workspace/github_cpp_makefile_star2_O2/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 $0x68, %rsp
movl %ecx, %r8d
movl %edx, %r12d
movl %esi, %ecx
movq %rdi, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
cmpl %esi, %r8d
jae 0x14244
movl %r8d, %eax
imull %r12d, %eax
xorl %edx, %edx
divl %ecx
movl %eax, %ebx
subq $0x8, %rsp
leaq 0x58(%rsp), %rdi
movq %r14, %rsi
movl %ecx, %edx
movl %r12d, %ecx
movq %r8, %r15
movl %eax, %r9d
pushq $0x1
callq 0x13c5a
popq %rax
popq %rcx
leaq 0x30(%rsp), %r14
leaq 0x50(%rsp), %rsi
movq %r14, %rdi
callq 0x121f4
leaq 0x50(%rsp), %rdi
callq 0xea4c
movl %ebx, %r12d
jmp 0x14247
movl %ecx, %r15d
movq %r15, 0x10(%rsp)
testl %r15d, %r15d
sete %al
testl %r12d, %r12d
sete %cl
orb %al, %cl
jne 0x143f5
movq 0x12d69(%rip), %rdi     # 0x26fd0
leaq 0xa634(%rip), %rsi      # 0x1e8a2
callq 0x2210
movq %rax, %rdi
callq 0x2100
leal -0x4(,%r12,4), %eax
pushq $0x7
popq %rcx
xorl %edx, %edx
divl %ecx
movl %eax, 0xc(%rsp)
movq 0x12d3b(%rip), %rdi     # 0x26fd0
pushq $0x2b
popq %rsi
callq 0x2270
incl 0xc(%rsp)
movq 0x12d28(%rip), %rbx     # 0x26fd0
pushq $0x2d
popq %rbp
movq 0x10(%rsp), %rax
movl %eax, %r15d
subl $0x1, %r15d
jb 0x142c5
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2270
jmp 0x142b3
movq 0x12d04(%rip), %rdi     # 0x26fd0
pushq $0x2b
popq %rsi
callq 0x2270
movq %rax, %rdi
callq 0x2100
movq %r12, 0x20(%rsp)
movq 0x10(%rsp), %rax
movl %eax, %r12d
leal (,%rax,8), %eax
movl %eax, 0x1c(%rsp)
xorl %ebx, %ebx
movq 0x12cd3(%rip), %r13     # 0x26fd0
leaq 0xa5b2(%rip), %rbp      # 0x1e8b6
xorl %r15d, %r15d
cmpl 0xc(%rsp), %r15d
je 0x143aa
movq %r13, %rdi
movq %rbp, %rsi
callq 0x2210
movq %rbx, 0x28(%rsp)
movl %ebx, %eax
xorl %edx, %edx
divl 0xc(%rsp)
movl %eax, %ebp
imull 0x1c(%rsp), %ebp
addl $0x6, %ebp
xorl %ebx, %ebx
cmpq %rbx, %r12
je 0x1437f
leal -0x6(%rbp), %eax
movq (%r14), %rcx
movzbl (%rcx,%rax), %edi
leal -0x4(%rbp), %eax
movzbl (%rcx,%rax), %esi
leal -0x2(%rbp), %eax
movzbl (%rcx,%rax), %edx
movl %ebp, %eax
movzbl (%rcx,%rax), %ecx
movl %ebx, %r8d
movl %r15d, %r9d
pushq $0x0
pushq $0x1
callq 0x13a4c
addq $0x10, %rsp
movsbl %al, %esi
movq %r13, %rdi
callq 0x2270
incq %rbx
addl $0x8, %ebp
jmp 0x14336
movq %r13, %rdi
leaq 0xa52d(%rip), %rbp      # 0x1e8b6
movq %rbp, %rsi
callq 0x2210
movq %r13, %rdi
callq 0x2100
incl %r15d
movq 0x28(%rsp), %rbx
addl 0x20(%rsp), %ebx
jmp 0x14307
movq 0x12c1f(%rip), %rdi     # 0x26fd0
pushq $0x2b
popq %rsi
callq 0x2270
movq 0x12c10(%rip), %rbx     # 0x26fd0
pushq $0x2d
popq %rbp
movq 0x10(%rsp), %rax
subl $0x1, %eax
movq %rax, 0x10(%rsp)
jb 0x143de
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2270
jmp 0x143c3
movq 0x12beb(%rip), %rdi     # 0x26fd0
pushq $0x2b
popq %rsi
callq 0x2270
movq %rax, %rdi
callq 0x2100
leaq 0x30(%rsp), %rdi
callq 0xea4c
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0xea4c
jmp 0x1442e
jmp 0x1442b
jmp 0x1442b
jmp 0x1442b
jmp 0x1442b
jmp 0x1442b
jmp 0x1442b
jmp 0x1442b
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xea4c
movq %rbx, %rdi
callq 0x23a0
movq %rax, %rdi
callq 0xe69c