// File: /workspace/github_cpp_makefile_star2_O1/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
cmpq $0x0, (%r15)
je 0x28eb
movq $0x0, -0x30(%rbp)
leaq -0x58(%rbp), %r13
movq %r15, -0x40(%rbp)
cmpq $0x0, 0x8(%r15)
je 0x28d7
xorl %ebx, %ebx
movq %r13, %rdi
movq -0x30(%rbp), %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x2b4c
movsd -0x50(%rbp), %xmm0
xorps 0x875(%rip), %xmm0      # 0x30c0
movsd -0x58(%rbp), %xmm1
movl $0x14, %edi
callq 0x2e04
cmpl $-0x1, %eax
je 0x286c
testl %eax, %eax
jne 0x2878
xorl %eax, %eax
xorl %ecx, %ecx
xorl %r8d, %r8d
jmp 0x2883
movq 0x10(%r14), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
jmp 0x2891
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 0x2bee
movq %r14, %r15
movq %rax, %r14
movq %r13, %rdi
callq 0x2c50
movq %r12, %rdi
movl %r14d, %esi
movq %r15, %r14
movl %eax, %edx
callq 0x2140
incq %rbx
movq -0x40(%rbp), %r15
cmpq 0x8(%r15), %rbx
jb 0x282d
movq -0x30(%rbp), %rcx
incq %rcx
movq %rcx, -0x30(%rbp)
cmpq (%r15), %rcx
jb 0x2820
movq 0x10(%r14), %rdi
callq 0x2050
callq 0x20e0
subq -0x38(%rbp), %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x79b(%rip), %xmm0      # 0x30a8
movsd %xmm0, -0x30(%rbp)
movq 0x26b7(%rip), %rbx      # 0x4fd0
leaq 0x7c0(%rip), %rsi       # 0x30e0
movl $0x1, %edx
movq %rbx, %rdi
callq 0x2180
movq %rbx, %rdi
movsd -0x30(%rbp), %xmm0
callq 0x21e0
leaq 0x7a1(%rip), %rsi       # 0x30e2
movl $0xb, %edx
movq %rax, %rdi
callq 0x2180
movq 0x265b(%rip), %rax      # 0x4fb0
movq (%rax), %rdi
callq 0x2190
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq