// File: /workspace/github_cpp_makefile_star2_O2/logicx24[P]RayTracer/raytracer.cpp
// Function: Film::writeFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, int)
void writeFile(string fileName, int pixWidth, int pixHeight) {
        if (pixWidth % width != 0 || pixHeight % height != 0) {
        	cerr << "Image will not fit nicely into output dimensions." << endl;
        	exit(0);
        }
        int widthScale = pixWidth / width;
        int heightScale = pixHeight / height;
        vector<unsigned char> image;
        int area = pixWidth * pixHeight;

        for (int i = 0; i < area; i++) {
        	image.push_back(0);
        	image.push_back(0);
        	image.push_back(0);
        	image.push_back(255);
        }
        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
            	int position = 4 * (y * width + x);

            	image.at(position)     = film.at((pixHeight - y - 1) * width + x)[RED];
            	image.at(position + 1) = film.at((pixHeight - y - 1) * width + x)[GREEN];
            	image.at(position + 2) = film.at((pixHeight - y - 1) * width + x)[BLUE];
            	image.at(position + 3) = 255;
            }
        }
        unsigned error = lodepng::encode(fileName, image,  width, height);
        if (error) {
        	cout << "lodepng error." << endl;
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, %r14d
movl %edx, %ecx
movq %rsi, -0x68(%rbp)
movl %edx, %eax
cltd
idivl (%rdi)
testl %edx, %edx
jne 0x8cd9
movq %rdi, %r15
movl %r14d, %eax
cltd
idivl 0x4(%rdi)
testl %edx, %edx
jne 0x8cd9
leaq -0x60(%rbp), %r12
andq $0x0, 0x10(%r12)
xorps %xmm0, %xmm0
movaps %xmm0, (%r12)
imull %r14d, %ecx
xorl %ebx, %ebx
testl %ecx, %ecx
cmovgl %ecx, %ebx
leaq -0x29(%rbp), %r13
subl $0x1, %ebx
jb 0x8b89
movb $0x0, -0x29(%rbp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x8d38
movb $0x0, -0x29(%rbp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x8d38
movb $0x0, -0x29(%rbp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x8d38
movb $-0x1, -0x29(%rbp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x8d38
jmp 0x8b46
leaq 0x8(%r15), %r12
decl %r14d
xorl %eax, %eax
movl 0x4(%r15), %ecx
cmpl %ecx, %eax
jge 0x8c8a
movq %rax, -0x48(%rbp)
movl %r14d, -0x3c(%rbp)
movslq %r14d, %r14
xorl %ebx, %ebx
movl (%r15), %r13d
cmpl %r13d, %ebx
jge 0x8c78
movl -0x3c(%rbp), %eax
imull %r13d, %eax
addl %ebx, %eax
movslq %eax, %rsi
movq %r12, %rdi
callq 0x8aa4
imull -0x48(%rbp), %r13d
addl %ebx, %r13d
shll $0x2, %r13d
movsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movslq %r13d, %rsi
leaq -0x60(%rbp), %rdi
callq 0x8d1a
cvttsd2si -0x38(%rbp), %ecx
movb %cl, (%rax)
movslq (%r15), %rsi
imulq %r14, %rsi
addq %rbx, %rsi
movq %r12, %rdi
callq 0x8aa4
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movl %r13d, %eax
orl $0x1, %eax
movslq %eax, %rsi
leaq -0x60(%rbp), %rdi
callq 0x8d1a
cvttsd2si -0x38(%rbp), %ecx
movb %cl, (%rax)
movslq (%r15), %rsi
imulq %r14, %rsi
addq %rbx, %rsi
movq %r12, %rdi
callq 0x8aa4
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movl %r13d, %eax
orl $0x2, %eax
movslq %eax, %rsi
leaq -0x60(%rbp), %rdi
callq 0x8d1a
cvttsd2si -0x38(%rbp), %ecx
movb %cl, (%rax)
orl $0x3, %r13d
movslq %r13d, %rsi
leaq -0x60(%rbp), %rdi
callq 0x8d1a
movb $-0x1, (%rax)
incq %rbx
jmp 0x8bab
movq -0x48(%rbp), %rax
incl %eax
movl -0x3c(%rbp), %r14d
decl %r14d
jmp 0x8b92
movl (%r15), %edx
leaq -0x60(%rbp), %rsi
pushq $0x6
popq %r8
pushq $0x8
popq %r9
movq -0x68(%rbp), %rdi
callq 0x10c22
testl %eax, %eax
je 0x8cc1
movq 0x1131b(%rip), %rdi     # 0x19fc8
leaq 0xa812(%rip), %rsi      # 0x134c6
callq 0x31d0
movq %rax, %rdi
callq 0x3120
leaq -0x60(%rbp), %rdi
callq 0x8ee8
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x11310(%rip), %rdi     # 0x19ff0
leaq 0xa7ad(%rip), %rsi      # 0x13494
callq 0x31d0
movq %rax, %rdi
callq 0x3120
xorl %edi, %edi
callq 0x3260
jmp 0x8d05
jmp 0x8d05
jmp 0x8d05
jmp 0x8d05
jmp 0x8d05
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x8ee8
movq %rbx, %rdi
callq 0x33f0
nop