// File: dannycalegari[P]circle_pack/./graphics.cc
// Function: graphics_routine(Packing&, bool&)
void graphics_routine(Packing &P, bool &finished){
	P.draw_circles();
	XFlush(display);
			
	XNextEvent(display, &report);
    	switch (report.type) {
      		case KeyPress:
  				if(XLookupKeysym(&report.xkey, 0) == XK_q){
  					finished=true;
                    XCloseDisplay(display);
                	exit(0);
                   	break;
               	};
               	if(P.write_geometry()=='S'){
           	    	if(XLookupKeysym(&report.xkey, 0) == XK_Right){
            	   		P.XZ_rotate(-TWOPI/50.0);
            	   	};
            	   	if(XLookupKeysym(&report.xkey, 0) == XK_Left){
               			P.XZ_rotate(TWOPI/50.0);
               		};
               		if(XLookupKeysym(&report.xkey, 0) == XK_Up){
               			P.YZ_rotate(-TWOPI/50.0);
               		};
               		if(XLookupKeysym(&report.xkey, 0) == XK_Down){
               			P.YZ_rotate(TWOPI/50.0);
               		};
               	} else if(P.write_geometry()=='E'){
               		if(XLookupKeysym(&report.xkey, 0) == XK_Up){
               			P.dilate(1.02);
               		};
               		if(XLookupKeysym(&report.xkey, 0) == XK_Down){
               			P.dilate(1.0/1.02);
               		};               		          
               		if(XLookupKeysym(&report.xkey, 0) == XK_g){
	               		P.reset_VIEWMATRIX();
               			P.change_geometry('S');
               		};
               	};
          //     	break;
            default:
               	break;
        };
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x8950
movq 0xf0e0(%rip), %rdi      # 0x18240
callq 0x2330
movq 0xf0d4(%rip), %rdi      # 0x18240
leaq 0xf0e5(%rip), %rsi      # 0x18258
callq 0x22f0
movl 0xf0da(%rip), %eax      # 0x18258
subl $0x2, %eax
jne 0x92fd
jmp 0x9189
leaq 0xf0c8(%rip), %rdi      # 0x18258
xorl %esi, %esi
callq 0x2290
cmpq $0x71, %rax
jne 0x91b7
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
movq 0xf095(%rip), %rdi      # 0x18240
callq 0x2410
xorl %edi, %edi
callq 0x2250
movq -0x8(%rbp), %rdi
callq 0xae60
movsbl %al, %eax
cmpl $0x53, %eax
jne 0x926d
leaq 0xf085(%rip), %rdi      # 0x18258
xorl %esi, %esi
callq 0x2290
cmpq $0xff53, %rax           # imm = 0xFF53
jne 0x91f3
movq -0x8(%rbp), %rdi
movsd 0x7eb2(%rip), %xmm0     # 0x110a0
callq 0x8eb0
leaq 0xf05e(%rip), %rdi      # 0x18258
xorl %esi, %esi
callq 0x2290
cmpq $0xff51, %rax           # imm = 0xFF51
jne 0x921a
movq -0x8(%rbp), %rdi
movsd 0x7e93(%rip), %xmm0     # 0x110a8
callq 0x8eb0
leaq 0xf037(%rip), %rdi      # 0x18258
xorl %esi, %esi
callq 0x2290
cmpq $0xff52, %rax           # imm = 0xFF52
jne 0x9241
movq -0x8(%rbp), %rdi
movsd 0x7e64(%rip), %xmm0     # 0x110a0
callq 0x8f70
leaq 0xf010(%rip), %rdi      # 0x18258
xorl %esi, %esi
callq 0x2290
cmpq $0xff54, %rax           # imm = 0xFF54
jne 0x9268
movq -0x8(%rbp), %rdi
movsd 0x7e45(%rip), %xmm0     # 0x110a8
callq 0x8f70
jmp 0x92fb
movq -0x8(%rbp), %rdi
callq 0xae60
movsbl %al, %eax
cmpl $0x45, %eax
jne 0x92f9
leaq 0xefd3(%rip), %rdi      # 0x18258
xorl %esi, %esi
callq 0x2290
cmpq $0xff52, %rax           # imm = 0xFF52
jne 0x92a5
movq -0x8(%rbp), %rdi
movsd 0x7df0(%rip), %xmm0     # 0x11090
callq 0x9030
leaq 0xefac(%rip), %rdi      # 0x18258
xorl %esi, %esi
callq 0x2290
cmpq $0xff54, %rax           # imm = 0xFF54
jne 0x92cc
movq -0x8(%rbp), %rdi
movsd 0x7dd1(%rip), %xmm0     # 0x11098
callq 0x9030
leaq 0xef85(%rip), %rdi      # 0x18258
xorl %esi, %esi
callq 0x2290
cmpq $0x67, %rax
jne 0x92f7
movq -0x8(%rbp), %rdi
callq 0x90f0
movq -0x8(%rbp), %rdi
movl $0x53, %esi
callq 0x68e0
jmp 0x92f9
jmp 0x92fb
jmp 0x92fd
jmp 0x92ff
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)