// File: /workspace/github_cpp_makefile_star2_O2/IsaacLaw12[P]RayTracer/./src/Image.cpp
// Function: Image::save_image(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void Image::save_image(std::string file_name){
    std::ofstream output(file_name);

    if (focus_blur){
        // Blur the rgb matrices based on their distance t_values
        std::cout << "Adding focus blur\n";
        apply_focus_blur();
    }

    if (anti_alias > 0){
        std::cout << "Anti-aliasing image\n";
        apply_anti_alias();
    }

    output << "P3" << "\n";
    output << orig_width << " " << orig_height << " 255" << "\n";
    int red, green, blue;
    for (int i=orig_height-1;i>=0; i--){
        for (int j=0; j<orig_width; j++){
            red = convert_255(red_pixels(j, i));
            green = convert_255(green_pixels(j, i));
            blue = convert_255(blue_pixels(j, i));
            output << red << " " << green << " " << blue << " ";
        }
        output << "\n";
    }
    output.close();
    std::cout << "Image saved at: " << file_name << "\n";
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movq %rdi, %rbx
leaq 0x28(%rsp), %rdi
pushq $0x10
popq %rdx
movq %rsi, 0x18(%rsp)
callq 0x34f0
movq %rbx, 0x8(%rsp)
cmpb $0x1, (%rbx)
jne 0x3bb3
movq 0x26423(%rip), %rdi     # 0x29fc0
leaq 0x144a4(%rip), %rsi     # 0x18048
callq 0x32a0
movq 0x8(%rsp), %rdi
callq 0x3df2
movq 0x8(%rsp), %rax
cmpl $0x0, 0x4(%rax)
jle 0x3bdb
movq 0x263fb(%rip), %rdi     # 0x29fc0
leaq 0x1448f(%rip), %rsi     # 0x1805b
callq 0x32a0
movq 0x8(%rsp), %rdi
callq 0x3fa6
leaq 0x1448e(%rip), %rsi     # 0x18070
leaq 0x28(%rsp), %rdi
callq 0x32a0
leaq 0x155da(%rip), %rsi     # 0x191cd
movq %rax, %rdi
callq 0x32a0
movq 0x8(%rsp), %rax
movl 0x8(%rax), %esi
leaq 0x28(%rsp), %rdi
callq 0x3470
leaq 0x174fe(%rip), %rsi     # 0x1b112
movq %rax, %rdi
callq 0x32a0
movq 0x8(%rsp), %rcx
movl 0xc(%rcx), %esi
movq %rax, %rdi
callq 0x3470
leaq 0x14440(%rip), %rsi     # 0x18073
movq %rax, %rdi
callq 0x32a0
leaq 0x1558b(%rip), %rsi     # 0x191cd
movq %rax, %rdi
callq 0x32a0
movq 0x8(%rsp), %rax
movl 0xc(%rax), %r15d
leaq 0x18(%rax), %r12
leaq 0x30(%rax), %r13
leaq 0x48(%rax), %rbp
leaq 0x174ac(%rip), %rbx     # 0x1b112
testl %r15d, %r15d
jle 0x3d82
decq %r15
xorl %r14d, %r14d
movq 0x8(%rsp), %rax
movslq 0x8(%rax), %rax
cmpq %rax, %r14
jge 0x3d6c
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x4544
movsd 0x14393(%rip), %xmm0    # 0x18030
minsd (%rax), %xmm0
xorpd %xmm1, %xmm1
maxsd %xmm0, %xmm1
mulsd 0x14387(%rip), %xmm1    # 0x18038
movsd %xmm1, 0x10(%rsp)
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x4544
movsd 0x14363(%rip), %xmm0    # 0x18030
minsd (%rax), %xmm0
xorpd %xmm1, %xmm1
maxsd %xmm0, %xmm1
mulsd 0x14357(%rip), %xmm1    # 0x18038
movsd %xmm1, 0x20(%rsp)
movq %rbp, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x4544
cvttsd2si 0x10(%rsp), %esi
movsd 0x1432d(%rip), %xmm0    # 0x18030
minsd (%rax), %xmm0
xorpd %xmm1, %xmm1
maxsd %xmm0, %xmm1
mulsd 0x14321(%rip), %xmm1    # 0x18038
movsd %xmm1, 0x10(%rsp)
leaq 0x28(%rsp), %rdi
callq 0x3470
movq %rax, %rdi
movq %rbx, %rsi
callq 0x32a0
cvttsd2si 0x20(%rsp), %esi
movq %rax, %rdi
callq 0x3470
movq %rax, %rdi
movq %rbx, %rsi
callq 0x32a0
cvttsd2si 0x10(%rsp), %esi
movq %rax, %rdi
callq 0x3470
movq %rax, %rdi
movq %rbx, %rsi
callq 0x32a0
incq %r14
jmp 0x3c75
leaq 0x28(%rsp), %rdi
leaq 0x15455(%rip), %rsi     # 0x191cd
callq 0x32a0
jmp 0x3c66
leaq 0x28(%rsp), %rdi
callq 0x3370
movq 0x2622d(%rip), %rdi     # 0x29fc0
leaq 0x142de(%rip), %rsi     # 0x18078
callq 0x32a0
movq %rax, %rdi
movq 0x18(%rsp), %rsi
callq 0x3280
leaq 0x1541a(%rip), %rsi     # 0x191cd
movq %rax, %rdi
callq 0x32a0
leaq 0x28(%rsp), %rdi
callq 0x33b0
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3ddd
jmp 0x3ddd
jmp 0x3ddd
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x33b0
movq %rbx, %rdi
callq 0x3490