// File: shirat74[P]resample/Image.cc
// Function: Image::getPixelBytes[abi:cxx11]() const
std::string
Image::getPixelBytes () const
{
  std::string bytes(width * height * nComps * (bpc / 8), 0);
  for (int32_t j = 0; j < height; j++) {
    for (int32_t i = 0; i < width; i++) {
      Color  pixel = getPixel(i, j);
      size_t pos   = (bpc / 8) * nComps * (j * width + i);
      for (int c = 0; c < nComps; c++) {
        if (bpc == 8) {
          bytes[pos + c] = round(255 * (pixel.v[c] / 65535.0));
        } else {
          bytes[pos+2*c]   = (pixel.v[c] >> 8) & 0xff;
          bytes[pos+2*c+1] =  pixel.v[c] & 0xff;
        }
      }
    }
  }
  return bytes;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x70(%rbp)
movq %rdi, %rax
movq %rax, -0x80(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rcx
movq %rcx, -0x78(%rbp)
movb $0x0, -0x11(%rbp)
movl (%rcx), %eax
movl 0x4(%rcx), %edx
imull %edx, %eax
movsbl 0x8(%rcx), %edx
imull %edx, %eax
movsbl 0x9(%rcx), %ecx
movl %ecx, %edx
addl $0x7, %edx
testl %ecx, %ecx
cmovsl %edx, %ecx
sarl $0x3, %ecx
imull %ecx, %eax
cltq
movq %rax, -0x68(%rbp)
leaq -0x12(%rbp), %rdi
movq %rdi, -0x60(%rbp)
callq 0x3510
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rcx
xorl %edx, %edx
callq 0x4330
jmp 0x4095
leaq -0x12(%rbp), %rdi
callq 0x3380
movl $0x0, -0x28(%rbp)
movq -0x78(%rbp), %rcx
movl -0x28(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0x42a0
movl $0x0, -0x2c(%rbp)
movq -0x78(%rbp), %rcx
movl -0x2c(%rbp), %eax
cmpl (%rcx), %eax
jge 0x4290
movq -0x78(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl -0x28(%rbp), %edx
callq 0x3e30
movq %rax, %rcx
movq -0x78(%rbp), %rax
movl %edx, -0x40(%rbp)
movq %rcx, -0x48(%rbp)
movq -0x48(%rbp), %rcx
movq %rcx, -0x38(%rbp)
movw -0x40(%rbp), %cx
movw %cx, -0x30(%rbp)
movb -0x3e(%rbp), %cl
movb %cl, -0x2e(%rbp)
movsbl 0x9(%rax), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movq -0x78(%rbp), %rdx
movsbl 0x8(%rdx), %ecx
imull %ecx, %eax
movl -0x28(%rbp), %ecx
imull (%rdx), %ecx
addl -0x2c(%rbp), %ecx
imull %ecx, %eax
cltq
movq %rax, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movq -0x78(%rbp), %rcx
movl -0x54(%rbp), %eax
movsbl 0x8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x4280
movq -0x78(%rbp), %rax
movsbl 0x9(%rax), %eax
cmpl $0x8, %eax
jne 0x41f5
movslq -0x54(%rbp), %rax
movq %rax, -0x98(%rbp)
movzwl -0x38(%rbp,%rax,2), %eax
cvtsi2sd %eax, %xmm0
movsd 0x8ea2(%rip), %xmm1     # 0xd010
divsd %xmm1, %xmm0
movsd 0x8e8e(%rip), %xmm1     # 0xd008
mulsd %xmm1, %xmm0
callq 0x3150
movq -0x98(%rbp), %rax
movq -0x70(%rbp), %rdi
cvttsd2si %xmm0, %ecx
movb %cl, -0x89(%rbp)
movq -0x50(%rbp), %rsi
addq %rax, %rsi
callq 0x35c0
movq %rax, -0x88(%rbp)
jmp 0x41ad
movq -0x88(%rbp), %rax
movb -0x89(%rbp), %cl
movb %cl, (%rax)
jmp 0x4270
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x12(%rbp), %rdi
callq 0x3380
jmp 0x42c0
movq -0x70(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x3210
jmp 0x42c0
movq -0x70(%rbp), %rdi
movslq -0x54(%rbp), %rcx
movl %ecx, %eax
movb -0x37(%rbp,%rcx,2), %cl
movb %cl, -0xa1(%rbp)
movq -0x50(%rbp), %rsi
addl %eax, %eax
cltq
addq %rax, %rsi
callq 0x35c0
movq %rax, -0xa0(%rbp)
jmp 0x4222
movq -0x70(%rbp), %rdi
movq -0xa0(%rbp), %rax
movb -0xa1(%rbp), %cl
movb %cl, (%rax)
movslq -0x54(%rbp), %rax
movl %eax, %ecx
movb -0x38(%rbp,%rax,2), %al
movb %al, -0xb1(%rbp)
movq -0x50(%rbp), %rax
addl %ecx, %ecx
movslq %ecx, %rcx
leaq 0x1(%rax,%rcx), %rsi
callq 0x35c0
movq %rax, -0xb0(%rbp)
jmp 0x4261
movq -0xb0(%rbp), %rax
movb -0xb1(%rbp), %cl
movb %cl, (%rax)
jmp 0x4272
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x412e
jmp 0x4282
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x40bc
jmp 0x4292
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x40a5
movb $0x1, -0x11(%rbp)
testb $0x1, -0x11(%rbp)
jne 0x42b3
movq -0x70(%rbp), %rdi
callq 0x3210
movq -0x80(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x34f0
nopl (%rax)