// File: /workspace/github_c_makefile_star2_O3/yahya-tamur[P]Visualising-Complex-Functions/testImage.cc
// Function: main
int main() {
    auto before_frames = std::chrono::high_resolution_clock::now();
    auto frames = getFrames(function);
    auto after_frames = std::chrono::high_resolution_clock::now();

    ge_GIF *gif = ge_new_gif(file_name, width, height, colors,

        palette_bit_depth,
        0 // for infinite loop
    );

    std::cout << "writing..." << std::endl;
    auto before_fwrite = std::chrono::high_resolution_clock::now();
    for (int i = 0; i < num_frames; i++) {
        for (int j = 0; j < width * height; j++)
            gif->frame[j] = (*frames)[i][j];
        ge_add_frame(gif, delay);
        std::cout << i << " / num frames = " << num_frames << std::endl;
    }
    auto after_fwrite = std::chrono::high_resolution_clock::now();
    ge_close_gif(gif);

    auto frame_duration
        = std::chrono::duration_cast<std::chrono::microseconds>(after_frames - before_frames);
    auto fwrite_duration
        = std::chrono::duration_cast<std::chrono::microseconds>(after_fwrite - before_fwrite);

    FILE *p_file = NULL;
    p_file = fopen(file_name, "rb");
    fseek(p_file, 0, SEEK_END);
    int size = ftell(p_file);
    fclose(p_file);
    double file_size = size / 1000000.0;
    std::cout << "function duration (s) :      " << frame_duration.count() / 1000000.0 << std::endl;
    std::cout << "file write duration (s) : " << fwrite_duration.count() / 1000000.0 << std::endl;
    std::cout << "file size (mb) :          " << file_size << std::endl;
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
callq 0x2050
movq %rax, %rbx
leaq 0x28(%rsp), %rsi
movq $0x0, 0x8(%rsi)
leaq 0x6c3(%rip), %rax       # 0x3594
movq %rax, (%rsi)
leaq 0x671(%rip), %rax       # 0x354c
movq %rax, 0x18(%rsi)
leaq 0x68a(%rip), %rax       # 0x3570
movq %rax, 0x10(%rsi)
leaq 0x8(%rsp), %rdi
callq 0x2a4c
movq %rbx, 0x20(%rsp)
movq 0x38(%rsp), %rax
testq %rax, %rax
je 0x2f12
leaq 0x28(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
callq 0x2050
movq %rax, 0x18(%rsp)
leaq 0x3271(%rip), %r14      # 0x6194
movzwl (%r14), %esi
leaq 0x326a(%rip), %rbp      # 0x6198
movzwl (%rbp), %edx
leaq 0x32a7(%rip), %rax      # 0x61e0
movl (%rax), %r8d
leaq 0x321d(%rip), %rdi      # 0x6160
leaq 0x329a(%rip), %rcx      # 0x61e4
xorl %r9d, %r9d
callq 0x23bc
movq %rax, %r15
movq 0x307c(%rip), %rbx      # 0x5fd8
leaq 0x10e1(%rip), %rsi      # 0x4044
movl $0xa, %edx
movq %rbx, %rdi
callq 0x21a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0x304a(%rip), %rdi      # 0x5fd8
callq 0x2040
movq %rax, %rdi
callq 0x2110
callq 0x2050
movq %rax, 0x10(%rsp)
leaq 0x31bc(%rip), %rbx      # 0x6168
cmpl $0x0, (%rbx)
jle 0x3074
xorl %r13d, %r13d
movl (%rbp), %eax
imull (%r14), %eax
testl %eax, %eax
jle 0x2ff9
leaq (,%r13,2), %rax
addq %r13, %rax
xorl %ecx, %ecx
movq 0x8(%rsp), %rdx
movq (%rdx), %rdx
movq (%rdx,%rax,8), %rdx
movb (%rdx,%rcx), %dl
movq 0x18(%r15), %rsi
movb %dl, (%rsi,%rcx)
incq %rcx
movslq (%r14), %rdx
movslq (%rbp), %rsi
imulq %rdx, %rsi
cmpq %rsi, %rcx
jl 0x2fd0
leaq 0x3174(%rip), %rax      # 0x6174
movzwl (%rax), %esi
movq %r15, %rdi
callq 0x2562
movq 0x2fc6(%rip), %rdi      # 0x5fd8
movl %r13d, %esi
callq 0x2240
movq %rax, %r12
movl $0x10, %edx
movq %rax, %rdi
leaq 0x1023(%rip), %rsi      # 0x404f
callq 0x21a0
movl (%rbx), %esi
movq %r12, %rdi
callq 0x2240
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2110
incq %r13
movslq (%rbx), %rax
cmpq %rax, %r13
jl 0x2fb8
callq 0x2050
movq %rax, %rbx
movq %r15, %rdi
callq 0x28a5
subq 0x10(%rsp), %rbx
movabsq $0x20c49ba5e353f7cf, %r14 # imm = 0x20C49BA5E353F7CF
movq %rbx, %rax
imulq %r14
movq %rdx, %rbx
leaq 0x30bd(%rip), %rdi      # 0x6160
leaq 0xfb6(%rip), %rsi       # 0x4060
callq 0x21b0
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2190
movq %r12, %rdi
callq 0x2030
movq %rax, %r15
movq %r12, %rdi
callq 0x2160
movq 0x2efd(%rip), %rdi      # 0x5fd8
leaq 0xf81(%rip), %rsi       # 0x4063
movl $0x1d, %edx
callq 0x21a0
movq 0x18(%rsp), %rax
subq 0x20(%rsp), %rax
imulq %r14
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %rdx
addq %rax, %rdx
cvtsi2sd %rdx, %xmm0
divsd 0xf1c(%rip), %xmm0      # 0x4030
movq 0x2ebd(%rip), %rdi      # 0x5fd8
callq 0x2210
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2110
movq 0x2e87(%rip), %rdi      # 0x5fd8
leaq 0xf29(%rip), %rsi       # 0x4081
movl $0x1a, %edx
callq 0x21a0
movq %rbx, %rax
shrq $0x3f, %rax
sarq $0x7, %rbx
addq %rax, %rbx
xorps %xmm0, %xmm0
cvtsi2sd %rbx, %xmm0
divsd 0xeb0(%rip), %xmm0      # 0x4030
movq 0x2e51(%rip), %rdi      # 0x5fd8
callq 0x2210
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2110
movq 0x2e1b(%rip), %rdi      # 0x5fd8
leaq 0xed8(%rip), %rsi       # 0x409c
movl $0x1a, %edx
callq 0x21a0
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
divsd 0xe52(%rip), %xmm0      # 0x4030
movq 0x2df3(%rip), %rdi      # 0x5fd8
callq 0x2210
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2110
leaq 0x8(%rsp), %rdi
callq 0x32d2
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3251
jmp 0x325d
movq %rax, %rbx
movq 0x38(%rsp), %rax
testq %rax, %rax
je 0x326a
leaq 0x28(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x326a
movq %rax, %rdi
callq 0x3305
jmp 0x325d
jmp 0x325d
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x32d2
movq %rbx, %rdi
callq 0x2250