// File: /workspace/github_cpp_makefile_star2_O2/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, %rbx
callq 0x2110
movq %rax, -0x40(%rbp)
movq 0x10(%rbx), %rdi
xorl %r12d, %r12d
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21f0
movq %rbx, -0x30(%rbp)
movq 0x10(%rbx), %rdi
callq 0x2180
cmpq (%r15), %r12
jae 0x2853
xorl %ebx, %ebx
movq %r12, -0x38(%rbp)
cmpq 0x8(%r15), %rbx
jae 0x284b
leaq -0x58(%rbp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x2aa8
movsd -0x50(%rbp), %xmm0
xorps 0x900(%rip), %xmm0      # 0x30c0
movsd -0x58(%rbp), %xmm1
pushq $0x14
popq %rdi
callq 0x2d60
cmpl $-0x1, %eax
je 0x27e3
testl %eax, %eax
movq -0x30(%rbp), %r14
jne 0x27f3
xorl %eax, %eax
xorl %ecx, %ecx
xorl %r8d, %r8d
jmp 0x27fe
movq -0x30(%rbp), %r14
movq 0x10(%r14), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
jmp 0x280c
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 0x21f0
movq 0x10(%r14), %r12
leaq -0x58(%rbp), %r14
movq %r14, %rdi
callq 0x2b4a
movq %rax, %r13
movq %r14, %rdi
callq 0x2bac
movq %r12, %rdi
movl %r13d, %esi
movl %eax, %edx
callq 0x2170
incq %rbx
movq -0x38(%rbp), %r12
jmp 0x2798
incq %r12
jmp 0x2789
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2050
callq 0x2110
subq -0x40(%rbp), %rax
cvtsi2sd %rax, %xmm0
divsd 0x832(%rip), %xmm0      # 0x30a8
movsd %xmm0, -0x38(%rbp)
movq 0x274e(%rip), %rdi      # 0x4fd0
leaq 0x857(%rip), %rsi       # 0x30e0
callq 0x21a0
movq %rax, %rdi
movsd -0x38(%rbp), %xmm0
callq 0x2210
leaq 0x840(%rip), %rsi       # 0x30e2
movq %rax, %rdi
callq 0x21a0
movq 0x26ff(%rip), %rax      # 0x4fb0
movq (%rax), %rdi
callq 0x21b0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq