// File: /workspace/github_cpp_makefile_star2_O3/miklhh[P]mandelbrot/src/color.cpp
// Function: get_color(unsigned int, std::complex<double> const&, std::complex<double> const&)
rgb_t get_color(
    unsigned int iterations, 
    const std::complex<double> & zn, 
    const std::complex<double> & c)
{
    rgb_t color{ 0, 0, 0, 0 };

    /* If it converges. */
    extern unsigned int max_iterations;
    if (iterations == max_iterations)
    {
        return color;
    }
    else
    {
        double convergence_value = get_convergence_value(iterations, zn, c);
        rgb_t color = hsl_to_rgb(
            {
                log(10 * convergence_value),
                1,
                0.7
            });
        return color;
    }
}

// Assembly:
leaq 0x4e75(%rip), %rcx      # 0x81d8
xorl %eax, %eax
cmpl %edi, (%rcx)
je 0x3536
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
movl %edi, %ebx
movups (%rdx), %xmm0
movaps %xmm0, (%rsp)
movupd (%rsi), %xmm0
leaq 0x10(%rsp), %r14
movapd %xmm0, (%r14)
movl $0x5, %ebp
leaq 0x20(%rsp), %r15
movaps 0x10(%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x35b2
movapd 0x20(%rsp), %xmm0
addpd (%rsp), %xmm0
movapd %xmm0, 0x10(%rsp)
decl %ebp
jne 0x3398
addl $0x5, %ebx
cvtsi2sd %ebx, %xmm1
movsd %xmm1, (%rsp)
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
callq 0x2380
callq 0x21b0
divsd 0x1e40(%rip), %xmm0     # 0x5228
callq 0x2360
movsd (%rsp), %xmm1
subsd %xmm0, %xmm1
mulsd 0x1e32(%rip), %xmm1     # 0x5230
movapd %xmm1, %xmm0
callq 0x21b0
movl $0x3e8, %eax            # imm = 0x3E8
movsd 0x1e24(%rip), %xmm4     # 0x5238
xorpd %xmm1, %xmm1
movsd 0x1e20(%rip), %xmm2     # 0x5240
ucomisd %xmm0, %xmm1
movapd %xmm4, %xmm3
ja 0x3434
ucomisd %xmm4, %xmm0
movapd %xmm2, %xmm3
jbe 0x343c
addsd %xmm3, %xmm0
decl %eax
jne 0x3420
divsd 0x1e04(%rip), %xmm0     # 0x5248
movsd %xmm0, (%rsp)
movsd 0x1dff(%rip), %xmm1     # 0x5250
callq 0x2280
movsd (%rsp), %xmm4
addsd 0x1df5(%rip), %xmm0     # 0x5258
andpd 0x1e35(%rip), %xmm0     # 0x52a0
movsd 0x1ded(%rip), %xmm1     # 0x5260
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
movsd 0x1de5(%rip), %xmm3     # 0x5268
mulsd %xmm3, %xmm2
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm4
jb 0x349d
ucomisd %xmm4, %xmm1
jb 0x349d
movapd %xmm2, %xmm1
jmp 0x34e3
ucomisd 0x1dbb(%rip), %xmm4     # 0x5260
movsd 0x1dbb(%rip), %xmm1     # 0x5268
jb 0x34c3
movsd 0x1d99(%rip), %xmm3     # 0x5250
ucomisd %xmm4, %xmm3
jb 0x34c3
movapd %xmm2, %xmm3
jmp 0x34e3
ucomisd 0x1d85(%rip), %xmm4     # 0x5250
xorpd %xmm3, %xmm3
jb 0x3537
movsd 0x1d97(%rip), %xmm0     # 0x5270
ucomisd %xmm4, %xmm0
jb 0x3537
movapd %xmm2, %xmm0
movsd 0x1da5(%rip), %xmm2     # 0x5290
addsd %xmm2, %xmm3
movsd 0x1da1(%rip), %xmm4     # 0x5298
mulsd %xmm4, %xmm3
cvttsd2si %xmm3, %ecx
addsd %xmm2, %xmm1
mulsd %xmm4, %xmm1
cvttsd2si %xmm1, %edx
addsd %xmm2, %xmm0
mulsd %xmm4, %xmm0
cvttsd2si %xmm0, %eax
movl $0xff, %esi
andl %esi, %ecx
andl %esi, %edx
shll $0x8, %edx
orl %ecx, %edx
andl %esi, %eax
shll $0x10, %eax
orl %edx, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
ucomisd 0x1d31(%rip), %xmm4     # 0x5270
movsd 0x1d21(%rip), %xmm0     # 0x5268
jb 0x355b
movsd 0x1d27(%rip), %xmm1     # 0x5278
ucomisd %xmm4, %xmm1
jae 0x3497
ucomisd 0x1d15(%rip), %xmm4     # 0x5278
jb 0x357b
xorpd %xmm1, %xmm1
movsd 0x1d0f(%rip), %xmm3     # 0x5280
ucomisd %xmm4, %xmm3
jae 0x34bd
ucomisd 0x1cfd(%rip), %xmm4     # 0x5280
xorpd %xmm1, %xmm1
jb 0x35a4
movsd 0x1cf7(%rip), %xmm0     # 0x5288
ucomisd %xmm4, %xmm0
jb 0x35a4
movsd 0x1cc9(%rip), %xmm3     # 0x5268
jmp 0x34df
xorpd %xmm0, %xmm0
xorpd %xmm3, %xmm3
jmp 0x34e3
nop