// File: /workspace/github_cpp_makefile_star2_O3/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 $0x38, %rsp
movl %edx, %r12d
movl (%rdi), %r8d
movl %edx, %eax
cltd
idivl %r8d
testl %edx, %edx
jne 0x9c9b
movl %ecx, %r14d
movq %rdi, %r15
movl 0x4(%rdi), %ecx
movl %r14d, %eax
cltd
idivl %ecx
testl %edx, %edx
jne 0x9c9b
movq %rsi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
imull %r14d, %r12d
testl %r12d, %r12d
jle 0x9a9b
movq %rbx, -0x58(%rbp)
leaq -0x50(%rbp), %r13
leaq -0x29(%rbp), %rbx
movb $0x0, -0x29(%rbp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x9ce8
movb $0x0, -0x29(%rbp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x9ce8
movb $0x0, -0x29(%rbp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x9ce8
movb $-0x1, -0x29(%rbp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x9ce8
decl %r12d
jne 0x9a4f
movl (%r15), %r8d
movl 0x4(%r15), %ecx
movq -0x58(%rbp), %rbx
testl %ecx, %ecx
jle 0x9bfc
decl %r14d
xorl %eax, %eax
movabsq $-0x5555555555555555, %rdi # imm = 0xAAAAAAAAAAAAAAAB
testl %r8d, %r8d
jle 0x9bef
xorl %ecx, %ecx
movl %r14d, %edx
imull %r8d, %edx
movslq %edx, %rsi
addq %rcx, %rsi
movq 0x8(%r15), %r9
movq 0x10(%r15), %rdx
subq %r9, %rdx
sarq $0x3, %rdx
imulq %rdi, %rdx
cmpq %rsi, %rdx
jbe 0x9c8d
imull %eax, %r8d
addl %ecx, %r8d
movslq %r8d, %r8
shlq $0x2, %r8
movq -0x50(%rbp), %r10
movq -0x48(%rbp), %rdx
subq %r10, %rdx
cmpq %r8, %rdx
jbe 0x9c8a
leaq (%rsi,%rsi,2), %rdx
cvttsd2si (%r9,%rdx,8), %edx
movb %dl, (%r10,%r8)
movl (%r15), %edx
imull %r14d, %edx
movslq %edx, %rsi
addq %rcx, %rsi
movq 0x10(%r15), %rdx
movq 0x8(%r15), %r9
subq %r9, %rdx
sarq $0x3, %rdx
imulq %rdi, %rdx
cmpq %rsi, %rdx
jbe 0x9c8d
movslq %r8d, %r8
movq %r8, %r10
orq $0x1, %r10
movq -0x50(%rbp), %r11
movq -0x48(%rbp), %rdx
subq %r11, %rdx
cmpq %r10, %rdx
jbe 0x9c85
leaq (%rsi,%rsi,2), %rdx
cvttsd2si 0x8(%r9,%rdx,8), %edx
movb %dl, (%r11,%r10)
movl (%r15), %edx
imull %r14d, %edx
movslq %edx, %rsi
addq %rcx, %rsi
movq 0x10(%r15), %rdx
movq 0x8(%r15), %r9
subq %r9, %rdx
sarq $0x3, %rdx
imulq %rdi, %rdx
cmpq %rsi, %rdx
jbe 0x9c8d
movq %r8, %r10
orq $0x2, %r10
movq -0x50(%rbp), %r11
movq -0x48(%rbp), %rdx
subq %r11, %rdx
cmpq %r10, %rdx
jbe 0x9c85
leaq (%rsi,%rsi,2), %rdx
cvttsd2si 0x10(%r9,%rdx,8), %edx
movb %dl, (%r11,%r10)
orq $0x3, %r8
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
subq %rsi, %rdx
cmpq %r8, %rdx
jbe 0x9c8a
movb $-0x1, (%rsi,%r8)
movl (%r15), %r8d
incq %rcx
cmpl %r8d, %ecx
jl 0x9abd
movl 0x4(%r15), %ecx
incl %eax
decl %r14d
cmpl %ecx, %eax
jl 0x9ab2
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
movl %r8d, %edx
movl $0x6, %r8d
movl $0x8, %r9d
callq 0x13eb0
testl %eax, %eax
je 0x9c61
movq 0x143ae(%rip), %rbx     # 0x1dfd0
leaq 0xd894(%rip), %rsi      # 0x174bd
movl $0xe, %edx
movq %rbx, %rdi
callq 0x3260
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x31e0
movsbl %al, %esi
movq 0x1437c(%rip), %rdi     # 0x1dfd0
callq 0x3040
movq %rax, %rdi
callq 0x3170
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x9c76
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x3220
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r10, %rsi
jmp 0x9c8d
movq %r8, %rsi
leaq 0xd7ad(%rip), %rdi      # 0x17441
xorl %eax, %eax
callq 0x3380
movq 0x1434e(%rip), %rdi     # 0x1dff0
leaq 0xd7e2(%rip), %rsi      # 0x1748b
callq 0x31f0
movq %rax, %rdi
callq 0x3110
xorl %edi, %edi
callq 0x3290
jmp 0x9cc7
jmp 0x9cc7
jmp 0x9cc7
jmp 0x9cc7
jmp 0x9cc7
movq %rax, %rbx
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x9cdf
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x3220
movq %rbx, %rdi
callq 0x3450
nop