// File: /workspace/github_cpp_makefile_star2_O3/bsaikiran618[P]mandelbrot-set-viewer/Window.cpp
// Function: Window::drawScreen(Cartesian2DPlane*)
void Window::drawScreen(Cartesian2DPlane *plane)
{
			clock_t start, end;

			start = clock();

			SDL_SetRenderDrawColor(screenRenderer, 0,0,0,SDL_ALPHA_OPAQUE);
			SDL_RenderClear(screenRenderer);

			for(uint64_t scr_x = 0; scr_x < plane->getWidth(); scr_x++)
			{
				for(uint64_t scr_y = 0; scr_y < plane->getHeight(); scr_y++)
				{
					//convert the screen coordinates to the cartesian plane coordinates
					Cartesian2DPoint p1(uint64_t(scr_x), uint64_t(scr_y), plane);
					//convert cartesian plane coordinates to complex plane coordinates
					//std::complex<double> p2(p1.getPlaneX(), p1.getPlaneY());
					std::complex<double> p2(-p1.getPlaneY(), p1.getPlaneX());
					int c;
					if((c = inMandelbrotSet(p2, 20)) != -1)
					{
						/*
						int r = int(c * 0.01 * 255)%255;
						int g = int(c * 0.03 * 255)%255;
						int b = int(c * 0.05 * 255)%255;
						*/
						long int r,g,b;
						if(c != 0)
						{
							r = (c) % 256;
							g = (c*c) % 256;
							b = (c*c+c) % 256;
						}else r = g = b = 0;
						SDL_SetRenderDrawColor(screenRenderer, r, g, b, SDL_ALPHA_OPAQUE);
					}
					else
						SDL_SetRenderDrawColor(screenRenderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
					SDL_RenderDrawPoint(screenRenderer, p1.getOnScreenX(), p1.getOnScreenY());
				}
			}
			//drawAxes(plane);
			SDL_RenderPresent(screenRenderer);
			end = clock();
			double elapsed_time = double(end - start)/CLOCKS_PER_SEC;
			std::cout << "\r" << elapsed_time << " secs/frame";
			fflush(stdout);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r15
movq %rdi, %r14
callq 0x20e0
movq %rax, -0x38(%rbp)
movq 0x10(%r14), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21c0
movq 0x10(%r14), %rdi
callq 0x2150
movq (%r15), %rax
testq %rax, %rax
je 0x2901
movq 0x8(%r15), %rcx
movq $0x0, -0x30(%rbp)
leaq -0x58(%rbp), %r13
movq %r15, -0x40(%rbp)
testq %rcx, %rcx
je 0x28eb
xorl %ebx, %ebx
movq %r13, %rdi
movq -0x30(%rbp), %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x2b64
movsd -0x50(%rbp), %xmm0
xorps 0x869(%rip), %xmm0      # 0x30c0
movsd -0x58(%rbp), %xmm1
movl $0x14, %edi
callq 0x2e1c
cmpl $-0x1, %eax
je 0x2878
testl %eax, %eax
jne 0x2884
xorl %eax, %eax
xorl %ecx, %ecx
xorl %r8d, %r8d
jmp 0x288f
movq 0x10(%r14), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
jmp 0x289d
movl %eax, %ecx
imull %eax, %ecx
movl %eax, %r8d
addl %ecx, %r8d
movq 0x10(%r14), %rdi
movzbl %al, %esi
movzbl %cl, %edx
movzbl %r8b, %ecx
movl $0xff, %r8d
callq 0x21c0
movq 0x10(%r14), %r12
movq %r13, %rdi
callq 0x2c06
movq %r14, %r15
movq %rax, %r14
movq %r13, %rdi
callq 0x2c68
movq %r12, %rdi
movl %r14d, %esi
movq %r15, %r14
movl %eax, %edx
callq 0x2140
incq %rbx
movq -0x40(%rbp), %r15
movq 0x8(%r15), %rcx
cmpq %rcx, %rbx
jb 0x2839
movq (%r15), %rax
jmp 0x28ed
xorl %ecx, %ecx
movq -0x30(%rbp), %rsi
incq %rsi
movq %rsi, -0x30(%rbp)
cmpq %rax, %rsi
jb 0x282e
movq 0x10(%r14), %rdi
callq 0x2050
callq 0x20e0
subq -0x38(%rbp), %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x785(%rip), %xmm0      # 0x30a8
movsd %xmm0, -0x30(%rbp)
movq 0x26a1(%rip), %rbx      # 0x4fd0
leaq 0x7aa(%rip), %rsi       # 0x30e0
movl $0x1, %edx
movq %rbx, %rdi
callq 0x2180
movq %rbx, %rdi
movsd -0x30(%rbp), %xmm0
callq 0x21e0
leaq 0x78b(%rip), %rsi       # 0x30e2
movl $0xb, %edx
movq %rax, %rdi
callq 0x2180
movq 0x2645(%rip), %rax      # 0x4fb0
movq (%rax), %rdi
callq 0x2190
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq