// File: /workspace/github_cpp_makefile_star2_O1/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, 0x5646(%rip)      # 0x8230
je 0x2d47
movsd (%rsi), %xmm0
movsd 0x8(%rsi), %xmm1
subsd (%rdi), %xmm0
leaq 0x2400(%rip), %rax      # 0x5004
movl (%rax), %ebx
cvtsi2sd %ebx, %xmm2
divsd %xmm2, %xmm0
subsd 0x8(%rdi), %xmm1
leaq 0x23ee(%rip), %rax      # 0x5008
movslq (%rax), %r14
xorps %xmm2, %xmm2
cvtsi2sd %r14d, %xmm2
divsd %xmm2, %xmm1
movsd %xmm0, 0x560f(%rip)     # 0x8240
leaq 0x5608(%rip), %rax      # 0x8240
movsd %xmm1, 0x5608(%rip)     # 0x8248
movsd (%rsi), %xmm0
movsd 0x8(%rsi), %xmm1
movsd (%rdi), %xmm2
movsd 0x8(%rdi), %xmm3
subsd %xmm2, %xmm0
movsd 0x2482(%rip), %xmm4     # 0x50e0
mulsd %xmm4, %xmm0
addsd %xmm2, %xmm0
subsd %xmm1, %xmm3
mulsd %xmm4, %xmm3
addsd %xmm1, %xmm3
movsd %xmm0, 0x55d6(%rip)     # 0x8250
leaq 0x55cf(%rip), %rsi      # 0x8250
movsd %xmm3, 0x55cf(%rip)     # 0x8258
movq %rax, %rdi
callq 0x3678
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 0x2d38
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
movq %rax, (%rsp)
movl %ecx, %eax
movq %rax, 0x10(%rsp)
xorl %r13d, %r13d
cmpl $0x0, (%rsp)
jle 0x2d2e
movq 0x8(%rsp), %rax
movl %eax, %ebp
imull %r13d, %ebp
shlq $0x20, %rbp
leal 0x1(%r13), %r12d
imull %eax, %r12d
shlq $0x20, %r12
xorl %r15d, %r15d
movq (%rsp), %rbx
movl %r15d, %esi
orq %rbp, %rsi
addl %r14d, %r15d
movq %r12, %rdx
orq %r15, %rdx
movq 0x5514(%rip), %rdi      # 0x8238
callq 0x3d40
decq %rbx
jne 0x2d0e
incq %r13
cmpq 0x10(%rsp), %r13
jne 0x2ce6
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x52a2(%rip), %rbx      # 0x7ff0
leaq 0x23d7(%rip), %rsi      # 0x512c
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