// File: 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
subq $0xe0, %rsp
movq %rsi, -0x78(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq -0x8(%rbp), %rcx
movq %rcx, -0x70(%rbp)
movl -0x14(%rbp), %eax
cltd
idivl (%rcx)
cmpl $0x0, %edx
jne 0xed90
movq -0x70(%rbp), %rcx
movl -0x18(%rbp), %eax
cltd
idivl 0x4(%rcx)
cmpl $0x0, %edx
je 0xedb9
movq 0x21259(%rip), %rdi     # 0x2fff0
leaq 0x1675c(%rip), %rsi     # 0x254fa
callq 0x3220
movq %rax, %rdi
movq 0x2120b(%rip), %rsi     # 0x2ffb8
callq 0x3270
xorl %edi, %edi
callq 0x3310
movq -0x70(%rbp), %rcx
movl -0x14(%rbp), %eax
cltd
idivl (%rcx)
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %eax
cltd
idivl 0x4(%rcx)
movl %eax, -0x20(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xf0c0
movl -0x14(%rbp), %eax
imull -0x18(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0xee65
movb $0x0, -0x41(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x41(%rbp), %rsi
callq 0xf0e0
jmp 0xee05
movb $0x0, -0x55(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x55(%rbp), %rsi
callq 0xf0e0
jmp 0xee18
movb $0x0, -0x56(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x56(%rbp), %rsi
callq 0xf0e0
jmp 0xee2b
movb $-0x1, -0x57(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x57(%rbp), %rsi
callq 0xf0e0
jmp 0xee3e
jmp 0xee40
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xedea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xf150
jmp 0xf0b6
movl $0x0, -0x5c(%rbp)
movq -0x70(%rbp), %rcx
movl -0x5c(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0xf038
movl $0x0, -0x60(%rbp)
movq -0x70(%rbp), %rcx
movl -0x60(%rbp), %eax
cmpl (%rcx), %eax
jge 0xf028
movq -0x70(%rbp), %rcx
movl -0x5c(%rbp), %eax
movl (%rcx), %edx
imull %edx, %eax
movl -0x60(%rbp), %edx
addl %edx, %eax
shll $0x2, %eax
movl %eax, -0x64(%rbp)
movq %rcx, %rdi
addq $0x8, %rdi
movl -0x18(%rbp), %edx
movl -0x5c(%rbp), %eax
notl %eax
addl %edx, %eax
movl (%rcx), %ecx
imull %ecx, %eax
movl -0x60(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0xecb0
movq %rax, -0x80(%rbp)
jmp 0xeed2
movq -0x80(%rbp), %rdi
xorl %esi, %esi
callq 0x67c0
cvttsd2si (%rax), %eax
movb %al, -0x89(%rbp)
movslq -0x64(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xf110
movq %rax, -0x88(%rbp)
jmp 0xeefd
movq -0x70(%rbp), %rcx
movq -0x88(%rbp), %rax
movb -0x89(%rbp), %dl
movb %dl, (%rax)
movq %rcx, %rdi
addq $0x8, %rdi
movl -0x18(%rbp), %edx
movl -0x5c(%rbp), %eax
notl %eax
addl %edx, %eax
movl (%rcx), %ecx
imull %ecx, %eax
movl -0x60(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0xecb0
movq %rax, -0x98(%rbp)
jmp 0xef3c
movq -0x98(%rbp), %rdi
movl $0x1, %esi
callq 0x67c0
cvttsd2si (%rax), %eax
movb %al, -0xa1(%rbp)
movl -0x64(%rbp), %eax
incl %eax
movslq %eax, %rsi
leaq -0x38(%rbp), %rdi
callq 0xf110
movq %rax, -0xa0(%rbp)
jmp 0xef71
movq -0x70(%rbp), %rcx
movq -0xa0(%rbp), %rax
movb -0xa1(%rbp), %dl
movb %dl, (%rax)
movq %rcx, %rdi
addq $0x8, %rdi
movl -0x18(%rbp), %edx
movl -0x5c(%rbp), %eax
notl %eax
addl %edx, %eax
movl (%rcx), %ecx
imull %ecx, %eax
movl -0x60(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0xecb0
movq %rax, -0xb0(%rbp)
jmp 0xefb0
movq -0xb0(%rbp), %rdi
movl $0x2, %esi
callq 0x67c0
cvttsd2si (%rax), %eax
movb %al, -0xb9(%rbp)
movl -0x64(%rbp), %eax
addl $0x2, %eax
movslq %eax, %rsi
leaq -0x38(%rbp), %rdi
callq 0xf110
movq %rax, -0xb8(%rbp)
jmp 0xefe6
movq -0xb8(%rbp), %rax
movb -0xb9(%rbp), %cl
movb %cl, (%rax)
movl -0x64(%rbp), %eax
addl $0x3, %eax
movslq %eax, %rsi
leaq -0x38(%rbp), %rdi
callq 0xf110
movq %rax, -0xc8(%rbp)
jmp 0xf010
movq -0xc8(%rbp), %rax
movb $-0x1, (%rax)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0xee83
jmp 0xf02a
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0xee6c
movq -0x78(%rbp), %rdi
movq -0x70(%rbp), %rax
movl (%rax), %edx
movl 0x4(%rax), %ecx
leaq -0x38(%rbp), %rsi
movl $0x6, %r8d
movl $0x8, %r9d
callq 0x1ba40
movl %eax, -0xcc(%rbp)
jmp 0xf062
movl -0xcc(%rbp), %eax
movl %eax, -0x68(%rbp)
cmpl $0x0, -0x68(%rbp)
je 0xf0a4
movq 0x20f50(%rip), %rdi     # 0x2ffc8
leaq 0x164ad(%rip), %rsi     # 0x2552c
callq 0x3220
movq %rax, -0xd8(%rbp)
jmp 0xf08d
movq -0xd8(%rbp), %rdi
movq 0x20f1d(%rip), %rsi     # 0x2ffb8
callq 0x3270
jmp 0xf0a2
jmp 0xf0a4
leaq -0x38(%rbp), %rdi
callq 0xf150
addq $0xe0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x34f0
nop