// File: /workspace/github_cpp_makefile_star2_O3/miklhh[P]mandelbrot/src/render.cpp
// Function: render_mandelbrot(std::complex<double> const&, std::complex<double> const&)
void render_mandelbrot(
    const std::complex<double> & upper_left, 
    const std::complex<double> & lower_right)
{
    /* Test if renderer is initialized. */
    if (!render_initialized)
    {
        std::cerr << "Renderer not initialized. Could not render." << std::endl;
        return;
    }
    /* Set the scale and the offset and aquire the segments. */
    scale = get_scale(upper_left, lower_right);
    offset = get_offset(upper_left, lower_right);
    supersample_init(scale, offset);
    int segment_size_x = scr_width / 20;
    int segment_size_y = scr_height / 20;
    for (int y = 0; y < scr_height / segment_size_y; y++)
    {
        for (int x = 0; x < scr_width / segment_size_x; x++)
        {
            segment_t segment = {
                segment_size_x * x,
                segment_size_y * y,
                segment_size_x * (1 + x),
                segment_size_y * (1 + y)};
            mandelbrot_thread_pool_add_job(thread_pool, segment);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
cmpb $0x0, 0x5668(%rip)      # 0x8240
je 0x2d11
leaq 0x244b(%rip), %rax      # 0x5030
movl (%rax), %ebx
leaq 0x2446(%rip), %rax      # 0x5034
movslq (%rax), %r14
movupd (%rdi), %xmm0
movupd (%rsi), %xmm1
subpd %xmm0, %xmm1
movd %ebx, %xmm0
movd %r14d, %xmm2
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
cvtdq2pd %xmm0, %xmm0
divpd %xmm0, %xmm1
movapd %xmm1, 0x5636(%rip)     # 0x8250
movupd (%rdi), %xmm0
movupd (%rsi), %xmm1
movhpd 0x8(%rdi), %xmm1        # xmm1 = xmm1[0],mem[0]
movhpd 0x8(%rsi), %xmm0        # xmm0 = xmm0[0],mem[0]
subpd %xmm0, %xmm1
mulpd 0x24c8(%rip), %xmm1     # 0x5100
leaq 0x5611(%rip), %rdi      # 0x8250
addpd %xmm0, %xmm1
movapd %xmm1, 0x5615(%rip)     # 0x8260
leaq 0x560e(%rip), %rsi      # 0x8260
callq 0x3620
imulq $0x66666667, %r14, %rcx # imm = 0x66666667
movq %rcx, %rax
shrq $0x3f, %rax
sarq $0x23, %rcx
addl %eax, %ecx
movl %r14d, %eax
cltd
movq %rcx, 0x8(%rsp)
idivl %ecx
testl %eax, %eax
jle 0x2d02
movl %eax, %ecx
movslq %ebx, %rax
imulq $0x66666667, %rax, %r14 # imm = 0x66666667
movq %r14, %rax
shrq $0x3f, %rax
sarq $0x23, %r14
addl %eax, %r14d
movl %ebx, %eax
cltd
idivl %r14d
movl %eax, %ebx
movl %ecx, %ecx
movq %rcx, 0x10(%rsp)
xorl %r12d, %r12d
movq %rbx, (%rsp)
testl %ebx, %ebx
jle 0x2cf8
movq 0x8(%rsp), %rcx
movl %ecx, %ebp
imull %r12d, %ebp
shlq $0x20, %rbp
incq %r12
movl %r12d, %r13d
imull %ecx, %r13d
shlq $0x20, %r13
xorl %r15d, %r15d
movl %r15d, %esi
orq %rbp, %rsi
addl %r14d, %r15d
movq %r13, %rdx
orq %r15, %rdx
movq 0x5560(%rip), %rdi      # 0x8248
callq 0x3c44
decq %rbx
jne 0x2cd2
movq (%rsp), %rbx
jmp 0x2cfb
incq %r12
cmpq 0x10(%rsp), %r12
jne 0x2cae
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x52d8(%rip), %rbx      # 0x7ff0
leaq 0x2435(%rip), %rsi      # 0x5154
movl $0x2b, %edx
movq %rbx, %rdi
callq 0x2250
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2160