// File: /workspace/github_c_makefile_star2_O0/yahya-tamur[P]Visualising-Complex-Functions/testImage.cc
// Function: getFrames(std::function<std::complex<long double> (std::complex<long double>)> const&)
std::unique_ptr<std::vector<std::vector<uint8_t>>> getFrames(
    const std::function<std::complex<long double>(std::complex<long double>)> &f) {

    auto frames = std::make_unique<std::vector<std::vector<uint8_t>>>(
        num_frames, std::vector<uint8_t>(width * height));
    //for every pixel, ...
    for (int i = 0; i < width; i++) {
        for (int j = 0; j < height; j++) {
            auto value
                = f(std::complex<long double>(x_min + ((long double) i / width) * (x_max - x_min),
                    y_max + ((long double) j / height) * (y_min - y_max)));
            int location_index = (width * j + i);

            //(the abs of a complex value is its magnitude)
            long double d = std::abs(value);
            if (logarithmic_contour_lines) {
                d = logl(d);
            }
            int contour_frame = 0;
            if (std::isnormal(d)) {
                contour_frame = fmodl(d, height_difference) * num_frames / height_difference;
            }
            if (contour_frame < 0) {
                contour_frame = (contour_frame % num_frames) + num_frames;
            }
            for (int k = 0; k < num_active_contour_frames; k++) {
                int active_frame = (contour_frame + k) % num_frames;
                (*frames)[active_frame][location_index] = 1;
            }

            d = std::arg(value);
            if (!std::isnormal(d))
                d = 0;
            if (d < 0)
                d += 2 * M_PI;
            int angle_frame = d * num_frames / (2 * M_PI);

            for (int k = 0; k < num_active_angle_frames; k++) {
                int active_frame = (angle_frame + k) % num_frames;
                (*frames)[active_frame][location_index] = 2;
            }
        }
        std::cout << i << " / width = " << width << std::endl;
    }
    return frames;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x110(%rbp)
movq %rdi, %rax
movq %rax, -0x108(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
leaq 0x73a5(%rip), %rax      # 0xa184
movl (%rax), %eax
leaq 0x73a0(%rip), %rcx      # 0xa188
movl (%rcx), %ecx
imull %ecx, %eax
cltq
movq %rax, -0x100(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x38d0
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0x38f0
jmp 0x2e1f
movq -0x110(%rbp), %rdi
leaq 0x732b(%rip), %rsi      # 0xa158
leaq -0x30(%rbp), %rdx
callq 0x3800
jmp 0x2e38
leaq -0x30(%rbp), %rdi
callq 0x3960
leaq -0x31(%rbp), %rdi
callq 0x39c0
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
leaq 0x7329(%rip), %rcx      # 0xa184
cmpl (%rcx), %eax
jge 0x3317
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
leaq 0x7314(%rip), %rcx      # 0xa188
cmpl (%rcx), %eax
jge 0x32a0
movq -0x10(%rbp), %rax
movq %rax, -0x118(%rbp)
leaq 0x7302(%rip), %rax      # 0xa190
fldt (%rax)
movl -0x48(%rbp), %eax
movl %eax, -0xd8(%rbp)
fildl -0xd8(%rbp)
leaq 0x72de(%rip), %rax      # 0xa184
movl (%rax), %eax
movl %eax, -0xd4(%rbp)
fildl -0xd4(%rbp)
fdivrp %st, %st(1)
leaq 0x72e3(%rip), %rax      # 0xa1a0
fldt (%rax)
fsub %st(2), %st
fmulp %st, %st(1)
faddp %st, %st(1)
leaq 0x72f4(%rip), %rax      # 0xa1c0
fldt (%rax)
movl -0x4c(%rbp), %eax
movl %eax, -0xd0(%rbp)
fildl -0xd0(%rbp)
leaq 0x72a4(%rip), %rax      # 0xa188
movl (%rax), %eax
movl %eax, -0xcc(%rbp)
fildl -0xcc(%rbp)
fdivrp %st, %st(1)
leaq 0x72b5(%rip), %rax      # 0xa1b0
fldt (%rax)
fsub %st(2), %st
fmulp %st, %st(1)
faddp %st, %st(1)
movq %rsp, %rax
fstpt 0x10(%rax)
fstpt (%rax)
leaq -0x90(%rbp), %rdi
callq 0x3a30
jmp 0x2f19
movq -0x118(%rbp), %rsi
movaps -0x90(%rbp), %xmm0
movaps -0x80(%rbp), %xmm1
movq %rsp, %rax
movaps %xmm1, 0x10(%rax)
movaps %xmm0, (%rax)
leaq -0x70(%rbp), %rdi
callq 0x39e0
jmp 0x2f40
leaq 0x723d(%rip), %rax      # 0xa184
movl (%rax), %eax
movl -0x4c(%rbp), %ecx
imull %ecx, %eax
movl -0x48(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x94(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x3a60
fstpt -0x124(%rbp)
jmp 0x2f6b
fldt -0x124(%rbp)
fstpt -0xb0(%rbp)
leaq 0x7202(%rip), %rax      # 0xa180
testb $0x1, (%rax)
je 0x2fe9
fldt -0xb0(%rbp)
movq %rsp, %rax
fstpt (%rax)
callq 0x20b0
fstpt -0xb0(%rbp)
jmp 0x2fe9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2fbe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3960
leaq -0x31(%rbp), %rdi
callq 0x39c0
jmp 0x333d
movq -0x110(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
callq 0x3b70
jmp 0x333d
movl $0x0, -0xb4(%rbp)
fldt -0xb0(%rbp)
movq %rsp, %rax
fstpt (%rax)
callq 0x3a90
movb %al, -0x125(%rbp)
jmp 0x300b
movb -0x125(%rbp), %al
testb $0x1, %al
jne 0x3017
jmp 0x3093
fldt -0xb0(%rbp)
leaq 0x714c(%rip), %rax      # 0xa170
movq %rax, -0x130(%rbp)
fldt (%rax)
movq %rsp, %rax
fstpt 0x10(%rax)
fstpt (%rax)
callq 0x2050
movq -0x130(%rbp), %rax
leaq 0x7110(%rip), %rcx      # 0xa158
movl (%rcx), %ecx
movl %ecx, -0xe0(%rbp)
fildl -0xe0(%rbp)
fmulp %st, %st(1)
fldt (%rax)
fdivrp %st, %st(1)
fnstcw -0xea(%rbp)
movzwl -0xea(%rbp), %eax
orl $0xc00, %eax            # imm = 0xC00
movw %ax, -0xec(%rbp)
fldcw -0xec(%rbp)
fistpl -0xdc(%rbp)
fldcw -0xea(%rbp)
movl -0xdc(%rbp), %eax
movl %eax, -0xb4(%rbp)
cmpl $0x0, -0xb4(%rbp)
jge 0x30bb
movl -0xb4(%rbp), %eax
leaq 0x70af(%rip), %rcx      # 0xa158
cltd
idivl (%rcx)
leaq 0x70a5(%rip), %rax      # 0xa158
addl (%rax), %edx
movl %edx, -0xb4(%rbp)
movl $0x0, -0xb8(%rbp)
movl -0xb8(%rbp), %eax
leaq 0x708e(%rip), %rcx      # 0xa160
cmpl (%rcx), %eax
jge 0x3141
movq -0x110(%rbp), %rdi
movl -0xb4(%rbp), %eax
movl -0xb8(%rbp), %ecx
addl %ecx, %eax
leaq 0x7066(%rip), %rcx      # 0xa158
movl (%rcx), %ecx
cltd
idivl %ecx
movl %edx, -0xbc(%rbp)
callq 0x3ad0
movq %rax, -0x138(%rbp)
jmp 0x310b
movq -0x138(%rbp), %rdi
movslq -0xbc(%rbp), %rsi
callq 0x3b00
movq %rax, %rdi
movslq -0x94(%rbp), %rsi
callq 0x3b20
movb $0x1, (%rax)
movl -0xb8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb8(%rbp)
jmp 0x30c5
leaq -0x70(%rbp), %rdi
callq 0x3b40
fstpt -0x144(%rbp)
jmp 0x3152
fldt -0x144(%rbp)
fstpt -0xb0(%rbp)
fldt -0xb0(%rbp)
movq %rsp, %rax
fstpt (%rax)
callq 0x3a90
movb %al, -0x145(%rbp)
jmp 0x3176
movb -0x145(%rbp), %al
testb $0x1, %al
jne 0x318a
jmp 0x3182
fldz
fstpt -0xb0(%rbp)
fldt -0xb0(%rbp)
fldz
fucompi %st(1), %st
fstp %st(0)
jbe 0x31ae
jmp 0x319a
fldt -0xb0(%rbp)
fldl 0x2e82(%rip)            # 0x6028
faddp %st, %st(1)
fstpt -0xb0(%rbp)
fldt -0xb0(%rbp)
leaq 0x6f9d(%rip), %rax      # 0xa158
movl (%rax), %eax
movl %eax, -0xe8(%rbp)
fildl -0xe8(%rbp)
fmulp %st, %st(1)
fldl 0x2e57(%rip)            # 0x6028
fdivrp %st, %st(1)
fnstcw -0xee(%rbp)
movzwl -0xee(%rbp), %eax
orl $0xc00, %eax            # imm = 0xC00
movw %ax, -0xf0(%rbp)
fldcw -0xf0(%rbp)
fistpl -0xe4(%rbp)
fldcw -0xee(%rbp)
movl -0xe4(%rbp), %eax
movl %eax, -0xc0(%rbp)
movl $0x0, -0xc4(%rbp)
movl -0xc4(%rbp), %eax
leaq 0x6f3b(%rip), %rcx      # 0xa15c
cmpl (%rcx), %eax
jge 0x3290
movq -0x110(%rbp), %rdi
movl -0xc0(%rbp), %eax
movl -0xc4(%rbp), %ecx
addl %ecx, %eax
leaq 0x6f17(%rip), %rcx      # 0xa158
movl (%rcx), %ecx
cltd
idivl %ecx
movl %edx, -0xc8(%rbp)
callq 0x3ad0
movq %rax, -0x150(%rbp)
jmp 0x325a
movq -0x150(%rbp), %rdi
movslq -0xc8(%rbp), %rsi
callq 0x3b00
movq %rax, %rdi
movslq -0x94(%rbp), %rsi
callq 0x3b20
movb $0x2, (%rax)
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0x3214
jmp 0x3292
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x2e6a
movl -0x48(%rbp), %esi
movq 0x6d2e(%rip), %rdi      # 0x9fd8
callq 0x2210
movq %rax, -0x158(%rbp)
jmp 0x32b8
movq -0x158(%rbp), %rdi
leaq 0x2d82(%rip), %rsi      # 0x6048
callq 0x2130
movq %rax, -0x160(%rbp)
jmp 0x32d4
movq -0x160(%rbp), %rdi
leaq 0x6ea2(%rip), %rax      # 0xa184
movl (%rax), %esi
callq 0x2210
movq %rax, -0x168(%rbp)
jmp 0x32f2
movq -0x168(%rbp), %rdi
movq 0x6cc8(%rip), %rsi      # 0x9fc8
callq 0x2170
jmp 0x3307
jmp 0x3309
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x2e51
movb $0x1, -0x11(%rbp)
testb $0x1, -0x11(%rbp)
jne 0x332d
movq -0x110(%rbp), %rdi
callq 0x3b70
movq -0x108(%rbp), %rax
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x2220
nopw %cs:(%rax,%rax)