// File: /workspace/github_c_makefile_star2_O1/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
xorpd %xmm0, %xmm0
leaq 0x20(%rsp), %rsi
movapd %xmm0, (%rsi)
movapd %xmm0, 0x10(%rsi)
leaq 0x6b6(%rip), %rax       # 0x3584
movq %rax, (%rsi)
leaq 0x664(%rip), %rax       # 0x353c
movq %rax, 0x18(%rsi)
leaq 0x67d(%rip), %rax       # 0x3560
movq %rax, 0x10(%rsi)
movq %rsp, %rdi
callq 0x2a4c
movq %rbx, 0x18(%rsp)
movq 0x30(%rsp), %rax
testq %rax, %rax
je 0x2f0d
leaq 0x20(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
callq 0x2050
movq %rax, 0x10(%rsp)
leaq 0x3276(%rip), %r14      # 0x6194
movzwl (%r14), %esi
leaq 0x326f(%rip), %rbp      # 0x6198
movzwl (%rbp), %edx
leaq 0x32ac(%rip), %rax      # 0x61e0
movl (%rax), %r8d
leaq 0x3222(%rip), %rdi      # 0x6160
leaq 0x329f(%rip), %rcx      # 0x61e4
xorl %r9d, %r9d
callq 0x23bc
movq %rax, %r15
movq 0x3081(%rip), %rbx      # 0x5fd8
leaq 0x10e6(%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 0x304f(%rip), %rdi      # 0x5fd8
callq 0x2040
movq %rax, %rdi
callq 0x2110
callq 0x2050
movq %rax, 0x8(%rsp)
leaq 0x31c1(%rip), %rbx      # 0x6168
cmpl $0x0, (%rbx)
jle 0x306e
xorl %r13d, %r13d
movl (%rbp), %eax
imull (%r14), %eax
testl %eax, %eax
jle 0x2ff3
leaq (,%r13,2), %rax
addq %r13, %rax
xorl %ecx, %ecx
movq (%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 0x2fcb
leaq 0x317a(%rip), %rax      # 0x6174
movzwl (%rax), %esi
movq %r15, %rdi
callq 0x2562
movq 0x2fcc(%rip), %rdi      # 0x5fd8
movl %r13d, %esi
callq 0x2240
movq %rax, %r12
movl $0x10, %edx
movq %rax, %rdi
leaq 0x1029(%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 0x2fb3
callq 0x2050
movq %rax, %rbx
movq %r15, %rdi
callq 0x28a4
subq 0x8(%rsp), %rbx
movabsq $0x20c49ba5e353f7cf, %r14 # imm = 0x20C49BA5E353F7CF
movq %rbx, %rax
imulq %r14
movq %rdx, %rbx
leaq 0x30c3(%rip), %rdi      # 0x6160
leaq 0xfbc(%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 0x2f03(%rip), %rdi      # 0x5fd8
leaq 0xf87(%rip), %rsi       # 0x4063
movl $0x1d, %edx
callq 0x21a0
movq 0x10(%rsp), %rax
subq 0x18(%rsp), %rax
imulq %r14
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %rdx
addq %rax, %rdx
cvtsi2sd %rdx, %xmm0
divsd 0xf22(%rip), %xmm0      # 0x4030
movq 0x2ec3(%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 0x2e8d(%rip), %rdi      # 0x5fd8
leaq 0xf2f(%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 0xeb6(%rip), %xmm0      # 0x4030
movq 0x2e57(%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 0x2e21(%rip), %rdi      # 0x5fd8
leaq 0xede(%rip), %rsi       # 0x409c
movl $0x1a, %edx
callq 0x21a0
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
divsd 0xe58(%rip), %xmm0      # 0x4030
movq 0x2df9(%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 %rsp, %rdi
callq 0x32c8
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3249
jmp 0x3255
movq %rax, %rbx
movq 0x30(%rsp), %rax
testq %rax, %rax
je 0x3260
leaq 0x20(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x3260
movq %rax, %rdi
callq 0x32fb
jmp 0x3255
jmp 0x3255
movq %rax, %rbx
movq %rsp, %rdi
callq 0x32c8
movq %rbx, %rdi
callq 0x2250