// File: IsaacLaw12[P]RayTracer/./src/Image.cpp
// Function: Image::apply_anti_alias()
void Image::apply_anti_alias(){
    std::vector<Eigen::MatrixXd*> image;
    image.push_back(&red_pixels);
    image.push_back(&green_pixels);
    image.push_back(&blue_pixels);

    int scale = anti_alias + 1;
    int new_width = image_width / scale;
    int new_height = image_height / scale;

    Eigen::MatrixXd scaled_down = Eigen::MatrixXd();
    scaled_down.resize(new_width, new_height);
    for (Eigen::MatrixXd* cur: image){
        for (int x=0; x<new_width; x++){
            for (int y=0; y<new_height; y++){
                scaled_down(x, y) = get_anti_alias_val(x, y, scale, cur);
            }
        }
        // Assign scaled down values to image
        cur->resize(new_width, new_height);
        *cur = Eigen::MatrixXd(scaled_down);
    }
    std::cout << "Image_width: " << image_width << "\n";
    image_width = new_width;
    std::cout << "Image_width: " << image_width << "\n";
    image_height = new_height;
}

// Assembly:
subq $0xf8, %rsp
movq %rdi, 0xf0(%rsp)
movq 0xf0(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0xd8(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x62c0
movq 0x38(%rsp), %rax
movq 0x40(%rsp), %rdi
addq $0x18, %rax
movq %rax, 0xd0(%rsp)
leaq 0xd0(%rsp), %rsi
callq 0x62d0
jmp 0x5843
movq 0x38(%rsp), %rax
addq $0x30, %rax
movq %rax, 0xb8(%rsp)
leaq 0xd8(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x62d0
jmp 0x586b
movq 0x38(%rsp), %rax
addq $0x48, %rax
movq %rax, 0xb0(%rsp)
leaq 0xd8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x62d0
jmp 0x5893
movq 0x38(%rsp), %rax
movl 0x4(%rax), %ecx
incl %ecx
movl %ecx, 0xac(%rsp)
movl 0x10(%rax), %eax
movl 0xac(%rsp), %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq 0x38(%rsp), %rax
movl %ecx, 0xa8(%rsp)
movl 0x14(%rax), %eax
movl 0xac(%rsp), %ecx
cltd
idivl %ecx
movl %eax, 0xa4(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x6060
jmp 0x58e2
movslq 0xa8(%rsp), %rsi
movslq 0xa4(%rsp), %rdx
leaq 0x88(%rsp), %rdi
callq 0x6300
jmp 0x5901
leaq 0xd8(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rdi
callq 0x6410
movq %rax, 0x78(%rsp)
movq 0x80(%rsp), %rdi
callq 0x6440
movq %rax, 0x70(%rsp)
leaq 0x78(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x6470
testb $0x1, %al
jne 0x594d
jmp 0x5a9a
leaq 0x78(%rsp), %rdi
callq 0x64b0
movq (%rax), %rax
movq %rax, 0x68(%rsp)
movl $0x0, 0x64(%rsp)
movl 0x64(%rsp), %eax
cmpl 0xa8(%rsp), %eax
jge 0x5a42
movl $0x0, 0x60(%rsp)
movl 0x60(%rsp), %eax
cmpl 0xa4(%rsp), %eax
jge 0x5a30
movq 0x38(%rsp), %rdi
movl 0x64(%rsp), %esi
movl 0x60(%rsp), %edx
movl 0xac(%rsp), %ecx
movq 0x68(%rsp), %r8
callq 0x5f90
movsd %xmm0, 0x30(%rsp)
jmp 0x59b7
movslq 0x64(%rsp), %rsi
movslq 0x60(%rsp), %rdx
leaq 0x88(%rsp), %rdi
callq 0x61c0
movq %rax, 0x28(%rsp)
jmp 0x59d5
movq 0x28(%rsp), %rax
movsd 0x30(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x60(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x60(%rsp)
jmp 0x5980
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
jmp 0x5b66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x60b0
jmp 0x5b66
jmp 0x5a32
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x5967
movq 0x68(%rsp), %rdi
movslq 0xa8(%rsp), %rsi
movslq 0xa4(%rsp), %rdx
callq 0x6300
jmp 0x5a5e
leaq 0x48(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x6290
jmp 0x5a72
movq 0x68(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x60c0
leaq 0x48(%rsp), %rdi
callq 0x60b0
leaq 0x78(%rsp), %rdi
callq 0x64c0
jmp 0x5935
movq 0x9551f(%rip), %rdi     # 0x9afc0
leaq 0x575c9(%rip), %rsi     # 0x5d071
callq 0x4360
movq %rax, 0x20(%rsp)
jmp 0x5ab4
movq 0x20(%rsp), %rdi
movq 0x38(%rsp), %rax
movl 0x10(%rax), %esi
callq 0x45c0
movq %rax, 0x18(%rsp)
jmp 0x5acd
movq 0x18(%rsp), %rdi
leaq 0x5c324(%rip), %rsi     # 0x61dfd
callq 0x4360
jmp 0x5ae0
movq 0x38(%rsp), %rax
movl 0xa8(%rsp), %ecx
movl %ecx, 0x10(%rax)
movq 0x954ca(%rip), %rdi     # 0x9afc0
leaq 0x57574(%rip), %rsi     # 0x5d071
callq 0x4360
movq %rax, 0x10(%rsp)
jmp 0x5b09
movq 0x10(%rsp), %rdi
movq 0x38(%rsp), %rax
movl 0x10(%rax), %esi
callq 0x45c0
movq %rax, 0x8(%rsp)
jmp 0x5b22
movq 0x8(%rsp), %rdi
leaq 0x5c2cf(%rip), %rsi     # 0x61dfd
callq 0x4360
jmp 0x5b35
movq 0x38(%rsp), %rax
movl 0xa4(%rsp), %ecx
movl %ecx, 0x14(%rax)
leaq 0x88(%rsp), %rdi
callq 0x60b0
leaq 0xd8(%rsp), %rdi
callq 0x64e0
addq $0xf8, %rsp
retq
leaq 0xd8(%rsp), %rdi
callq 0x64e0
movq 0xc8(%rsp), %rdi
callq 0x45e0