// File: mhe[P]raytracerframework_cpp/image.cpp
// Function: Image::write_png(char*) const
void Image::write_png(char* filename) const
{
	std::vector<unsigned char> image;
	image.resize(_width * _height * 4);
	std::vector<unsigned char>::iterator imageIterator = image.begin();
	Color *currentPixel = _pixel;
	while (imageIterator != image.end()) {
		*imageIterator = (unsigned char)(currentPixel->r * 255.0);
		imageIterator++;
		*imageIterator = (unsigned char)(currentPixel->g * 255.0);
		imageIterator++;
		*imageIterator = (unsigned char)(currentPixel->b * 255.0);
		imageIterator++;
		*imageIterator = 255;
		imageIterator++;
		currentPixel++;
	}
	LodePNG::encode(filename, image, _width, _height);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0x28(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x22d30
movq -0xa8(%rbp), %rcx
movq -0xa0(%rbp), %rdi
movl 0x8(%rcx), %eax
movl 0xc(%rcx), %ecx
imull %ecx, %eax
shll $0x2, %eax
movslq %eax, %rsi
callq 0x22d50
jmp 0x22662
leaq -0x28(%rbp), %rdi
callq 0x22de0
movq %rax, %rcx
movq -0xa8(%rbp), %rax
movq %rcx, -0x40(%rbp)
movq (%rax), %rax
movq %rax, -0x48(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x22e50
movq %rax, -0x50(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x22e10
testb $0x1, %al
jne 0x226a3
jmp 0x227be
movq -0x48(%rbp), %rax
movsd (%rax), %xmm0
movsd 0x2906d(%rip), %xmm1    # 0x4b720
movsd %xmm1, -0xb8(%rbp)
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movb %al, -0xca(%rbp)
leaq -0x40(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x22e80
movb -0xca(%rbp), %cl
movq -0xc8(%rbp), %rdi
movb %cl, (%rax)
xorl %esi, %esi
movl %esi, -0xbc(%rbp)
callq 0x22ea0
movq -0xc8(%rbp), %rdi
movsd -0xb8(%rbp), %xmm1
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rax
movsd 0x8(%rax), %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movb %al, -0xc9(%rbp)
callq 0x22e80
movb -0xc9(%rbp), %cl
movq -0xc8(%rbp), %rdi
movl -0xbc(%rbp), %esi
movb %cl, (%rax)
callq 0x22ea0
movsd -0xb8(%rbp), %xmm1
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rax
movsd 0x10(%rax), %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movb %al, -0xa9(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x22e80
movb -0xa9(%rbp), %cl
movb %cl, (%rax)
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x22ea0
movq %rax, -0x68(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x22e80
movb $-0x1, (%rax)
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x22ea0
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x48(%rbp)
jmp 0x22680
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x2287f
movq -0x10(%rbp), %rax
movq %rax, -0xe0(%rbp)
leaq -0x91(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x56d0
movq -0xe0(%rbp), %rsi
movq -0xd8(%rbp), %rdx
leaq -0x90(%rbp), %rdi
callq 0x20460
jmp 0x227f8
movq -0xa8(%rbp), %rax
movl 0x8(%rax), %edx
movl 0xc(%rax), %ecx
leaq -0x90(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0x6, %r8d
movl $0x8, %r9d
callq 0x2cf00
jmp 0x22823
leaq -0x90(%rbp), %rdi
callq 0x5788
leaq -0x91(%rbp), %rdi
callq 0x5420
leaq -0x28(%rbp), %rdi
callq 0x22ee0
addq $0xe0, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x22873
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x5788
leaq -0x91(%rbp), %rdi
callq 0x5420
leaq -0x28(%rbp), %rdi
callq 0x22ee0
movq -0x30(%rbp), %rdi
callq 0x56c0
nopw %cs:(%rax,%rax)