// File: /workspace/github_cpp_makefile_star2_O1/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 0x1777e
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 0x17134
addq $0x10, %rsp
leaq 0x40(%rsp), %r15
movq %rsp, %rsi
movq %r15, %rdi
callq 0x14f68
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x17779
callq 0x2200
movl %ebx, %r13d
jmp 0x17781
movl %ecx, %r14d
testl %r14d, %r14d
sete %al
testl %r13d, %r13d
sete %cl
orb %al, %cl
jne 0x17a10
movq 0x13834(%rip), %rbx     # 0x2afd0
leaq 0xc09b(%rip), %rsi      # 0x2383e
movl $0x13, %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 0x13802(%rip), %rdi     # 0x2afd0
callq 0x2040
movq %rax, %rdi
callq 0x2160
movq %rsp, %rsi
movb $0x2b, (%rsi)
movq 0x137e8(%rip), %rdi     # 0x2afd0
movl $0x1, %edx
callq 0x2280
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 0x137af(%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 0x2280
decl %ebp
jne 0x1782c
movq %rsp, %rsi
movb $0x2b, (%rsi)
movq 0x1377f(%rip), %rdi     # 0x2afd0
movl $0x1, %edx
callq 0x2280
movq 0x20(%rsp), %r12
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
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 0x1371f(%rip), %rdi     # 0x2afd0
leaq 0xbf9a(%rip), %rsi      # 0x23852
callq 0x2280
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 0x16e8e
addq $0x10, %rsp
movb %al, (%rsp)
movl $0x1, %edx
movq 0x136b9(%rip), %rdi     # 0x2afd0
movq %r12, %rsi
callq 0x2280
incq %r13
addl $0x8, %ebx
cmpq %r13, %r14
jne 0x178d7
movl $0x1, %edx
movq 0x1369a(%rip), %rdi     # 0x2afd0
leaq 0xbf15(%rip), %rsi      # 0x23852
callq 0x2280
movq 0x13687(%rip), %rcx     # 0x2afd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq 0x13669(%rip), %rdi     # 0x2afd0
callq 0x2040
movq %rax, %rdi
callq 0x2160
leal 0x1(%rbp), %eax
movq 0x28(%rsp), %r13
movq 0x38(%rsp), %rbx
addl %r13d, %ebx
cmpl 0x30(%rsp), %ebp
movl %eax, %ebp
jne 0x178a5
movq %rsp, %rsi
movb $0x2b, (%rsi)
movq 0x13633(%rip), %rdi     # 0x2afd0
movl $0x1, %edx
callq 0x2280
movq 0x20(%rsp), %r15
movq 0x1361d(%rip), %rbx     # 0x2afd0
movq %rsp, %r14
movb $0x2d, (%rsp)
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2280
decl %r15d
jne 0x179b6
movq %rsp, %rsi
movb $0x2b, (%rsi)
movq 0x135f4(%rip), %rdi     # 0x2afd0
movl $0x1, %edx
callq 0x2280
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 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x17a1f
callq 0x2200
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 0x17a52
callq 0x2200
jmp 0x17a52
jmp 0x17a4f
jmp 0x17a4f
jmp 0x17a4f
jmp 0x17a4f
jmp 0x17a4f
jmp 0x17a4f
jmp 0x17a4f
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x17a61
callq 0x2200
movq %rbx, %rdi
callq 0x2390