// File: /workspace/github_cpp_makefile_star2_O1/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 %edx, %eax
cltd
idivl (%rdi)
testl %edx, %edx
jne 0xa0c2
movl %ecx, %r14d
movq %rdi, %r15
movl %ecx, %eax
cltd
idivl 0x4(%rdi)
testl %edx, %edx
jne 0xa0c2
movq %rsi, -0x58(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
imull %r14d, %r12d
testl %r12d, %r12d
jle 0x9eba
leaq -0x50(%rbp), %r13
leaq -0x29(%rbp), %rbx
movb $0x0, -0x29(%rbp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0xa10e
movb $0x0, -0x29(%rbp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0xa10e
movb $0x0, -0x29(%rbp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0xa10e
movb $-0x1, -0x29(%rbp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0xa10e
decl %r12d
jne 0x9e79
movl 0x4(%r15), %ecx
testl %ecx, %ecx
jle 0xa022
decl %r14d
xorl %eax, %eax
movabsq $-0x5555555555555555, %rdi # imm = 0xAAAAAAAAAAAAAAAB
movl (%r15), %r8d
testl %r8d, %r8d
jle 0xa011
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 0xa0b4
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 0xa0b1
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 0xa0b4
movslq %r8d, %r8
movq %r8, %r10
orq $0x1, %r10
movq -0x50(%rbp), %r11
movq -0x48(%rbp), %rdx
subq %r11, %rdx
cmpq %r10, %rdx
jbe 0xa0ac
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 0xa0b4
movq %r8, %r10
orq $0x2, %r10
movq -0x50(%rbp), %r11
movq -0x48(%rbp), %rdx
subq %r11, %rdx
cmpq %r10, %rdx
jbe 0xa0ac
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 0xa0b1
movb $-0x1, (%rsi,%r8)
movl (%r15), %r8d
incq %rcx
cmpl %r8d, %ecx
jl 0x9ee3
incl %eax
movl 0x4(%r15), %ecx
decl %r14d
cmpl %ecx, %eax
jl 0x9ed5
movl (%r15), %edx
leaq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdi
movl $0x6, %r8d
movl $0x8, %r9d
callq 0x13d81
testl %eax, %eax
je 0xa088
movq 0x13f87(%rip), %rbx     # 0x1dfd0
leaq 0xd476(%rip), %rsi      # 0x174c6
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 0x13f55(%rip), %rdi     # 0x1dfd0
callq 0x3040
movq %rax, %rdi
callq 0x3160
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0xa09d
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 0xa0b4
movq %r8, %rsi
leaq 0xd38f(%rip), %rdi      # 0x1744a
xorl %eax, %eax
callq 0x3380
movq 0x13f27(%rip), %rdi     # 0x1dff0
leaq 0xd3c4(%rip), %rsi      # 0x17494
callq 0x31f0
movq %rax, %rdi
callq 0x3110
xorl %edi, %edi
callq 0x3290
jmp 0xa0ee
jmp 0xa0ee
jmp 0xa0ee
jmp 0xa0ee
jmp 0xa0ee
movq %rax, %rbx
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0xa106
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x3220
movq %rbx, %rdi
callq 0x3450