// File: /workspace/github_cpp_makefile_star2_O2/dannycalegari[P]circle_pack/./graphics.cc
// Function: draw_3d_circle(Point, double, bool)
void draw_3d_circle(Point P, double R, bool front){
	double t;
	double theta,r;
	double fraction;
	fraction=0.003/R;	// the bigger the radius, the smaller fraction should be
	Matrix M;
	Point Q;
	int x1,y1,x2,y2;
    theta=sph_ang(P);
    r=acos(P.z);
    M=ROT(theta)*XZ_ROT(-r);
    Q.x=0.0;
    Q.y=0.0;
    Q.z=1.0;
  //  write_Point(M(Q));
	// write_Point(P);
	if(front){
	    for(t=0.0;t<=TWOPI*(1.0+fraction);t=t+TWOPI*fraction){
    		Q.x=sin(R)*cos(t);
    		Q.y=sin(R)*sin(t);
    		Q.z=cos(R);
    		Q=M(Q);
    		x2=x1;
    		y2=y1;
    		x1=(int) (300.0+Q.x*200.0);
    		y1=(int) (300.0+Q.y*200.0);
    		if(t!=0.0 && Q.z>=0.0){
    			draw_line(x1,y1,x2,y2);
    		};
    	};
	} else {
	    for(t=0.0;t<=TWOPI*(1.0+fraction);t=t+TWOPI*fraction){
    		Q.x=sin(R)*cos(t);
    		Q.y=sin(R)*sin(t);
    		Q.z=cos(R);
    		Q=M(Q);
    		x2=x1;
    		y2=y1;
    		x1=(int) (300.0+Q.x*200.0);
    		y1=(int) (300.0+Q.y*200.0);
    		if(t!=0.0 && Q.z<=0.0){
    			draw_line(x1,y1,x2,y2);
    		};
    	};
	};
	

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movl %edi, %ebx
movsd %xmm0, 0x28(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
andq $0x0, 0x70(%rsp)
movsd 0x170(%rsp), %xmm0
xorpd %xmm1, %xmm1
ucomisd 0x31be(%rip), %xmm0     # 0x9088
jae 0x5ef2
leaq 0x160(%rsp), %rax
movsd (%rax), %xmm1
movsd %xmm0, 0x20(%rsp)
movsd 0x8(%rax), %xmm0
callq 0x2040
movapd %xmm0, %xmm1
movsd 0x20(%rsp), %xmm0
movsd %xmm1, 0x20(%rsp)
callq 0x21c0
movapd %xmm0, 0x30(%rsp)
leaq 0x110(%rsp), %rdi
movsd 0x20(%rsp), %xmm0
callq 0x279b
movapd 0x30(%rsp), %xmm0
xorpd 0x30fc(%rip), %xmm0     # 0x9020
leaq 0xf8(%rsp), %rdi
callq 0x293d
leaq 0x40(%rsp), %rdi
leaq 0x110(%rsp), %rsi
leaq 0xf8(%rsp), %rdx
callq 0x768c
movsd 0x31a5(%rip), %xmm0     # 0x90f8
divsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x40(%rsp), %r14
movq %r14, %rsi
callq 0x797e
movq %r14, %rdi
callq 0x78f0
leaq 0xf8(%rsp), %rdi
callq 0x78f0
leaq 0x110(%rsp), %rdi
callq 0x78f0
movsd 0x30(%rsp), %xmm1
movsd 0x30e7(%rip), %xmm0     # 0x9088
addsd %xmm1, %xmm0
mulsd 0x30f3(%rip), %xmm0     # 0x90a0
movsd %xmm0, 0x58(%rsp)
testb %bl, %bl
je 0x6121
leaq 0x40(%rsp), %rbx
leaq 0x60(%rsp), %r14
mulsd 0x30d3(%rip), %xmm1     # 0x90a0
movsd %xmm1, 0x30(%rsp)
xorpd %xmm1, %xmm1
movsd 0x58(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x6283
movsd 0x28(%rsp), %xmm0
movsd %xmm1, 0x20(%rsp)
callq 0x2060
movaps %xmm0, 0xb0(%rsp)
movsd 0x20(%rsp), %xmm0
callq 0x23e0
movaps %xmm0, 0xa0(%rsp)
movsd 0x28(%rsp), %xmm0
callq 0x2060
movaps %xmm0, 0x90(%rsp)
movsd 0x20(%rsp), %xmm0
callq 0x2060
movaps %xmm0, 0x80(%rsp)
movsd 0x28(%rsp), %xmm0
callq 0x23e0
movapd 0xb0(%rsp), %xmm1
unpcklpd 0x90(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0]
movapd 0xa0(%rsp), %xmm2
unpcklpd 0x80(%rsp), %xmm2       # xmm2 = xmm2[0],mem[0]
mulpd %xmm1, %xmm2
movapd %xmm2, 0xe0(%rsp)
movsd %xmm0, 0xf0(%rsp)
movq 0xf0(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0xe0(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7600
movsd 0x40(%rsp), %xmm0
movsd 0x3050(%rip), %xmm2     # 0x9100
mulsd %xmm2, %xmm0
movsd 0x48(%rsp), %xmm1
mulsd %xmm2, %xmm1
movsd 0x3042(%rip), %xmm2     # 0x9108
addsd %xmm2, %xmm0
cvttsd2si %xmm0, %r12d
addsd %xmm2, %xmm1
cvttsd2si %xmm1, %r13d
movsd 0x20(%rsp), %xmm0
ucomisd 0x2fe2(%rip), %xmm0     # 0x90c8
jne 0x60ea
jnp 0x610a
movsd 0x50(%rsp), %xmm0
ucomisd 0x2fd0(%rip), %xmm0     # 0x90c8
jb 0x610a
movl %r12d, %edi
movl %r13d, %esi
movl %ebp, %edx
movl %r15d, %ecx
callq 0x5d7b
movsd 0x20(%rsp), %xmm1
addsd 0x30(%rsp), %xmm1
movl %r12d, %ebp
movl %r13d, %r15d
jmp 0x5fd7
leaq 0x40(%rsp), %rbx
leaq 0x60(%rsp), %r14
mulsd 0x2f6d(%rip), %xmm1     # 0x90a0
movsd %xmm1, 0x30(%rsp)
xorpd %xmm1, %xmm1
movsd 0x58(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x6283
movsd 0x28(%rsp), %xmm0
movsd %xmm1, 0x20(%rsp)
callq 0x2060
movaps %xmm0, 0xb0(%rsp)
movsd 0x20(%rsp), %xmm0
callq 0x23e0
movaps %xmm0, 0xa0(%rsp)
movsd 0x28(%rsp), %xmm0
callq 0x2060
movaps %xmm0, 0x90(%rsp)
movsd 0x20(%rsp), %xmm0
callq 0x2060
movaps %xmm0, 0x80(%rsp)
movsd 0x28(%rsp), %xmm0
callq 0x23e0
movapd 0xb0(%rsp), %xmm1
unpcklpd 0x90(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0]
movapd 0xa0(%rsp), %xmm2
unpcklpd 0x80(%rsp), %xmm2       # xmm2 = xmm2[0],mem[0]
mulpd %xmm1, %xmm2
movapd %xmm2, 0xc0(%rsp)
movsd %xmm0, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0xc0(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7600
movsd 0x40(%rsp), %xmm0
movsd 0x2eea(%rip), %xmm2     # 0x9100
mulsd %xmm2, %xmm0
movsd 0x48(%rsp), %xmm1
mulsd %xmm2, %xmm1
movsd 0x2edc(%rip), %xmm2     # 0x9108
addsd %xmm2, %xmm0
cvttsd2si %xmm0, %r12d
addsd %xmm2, %xmm1
cvttsd2si %xmm1, %r13d
movsd 0x20(%rsp), %xmm0
ucomisd 0x2e7c(%rip), %xmm0     # 0x90c8
jne 0x6250
jnp 0x626c
xorpd %xmm0, %xmm0
ucomisd 0x50(%rsp), %xmm0
jb 0x626c
movl %r12d, %edi
movl %r13d, %esi
movl %ebp, %edx
movl %r15d, %ecx
callq 0x5d7b
movsd 0x20(%rsp), %xmm1
addsd 0x30(%rsp), %xmm1
movl %r12d, %ebp
movl %r13d, %r15d
jmp 0x613d
leaq 0x60(%rsp), %rdi
callq 0x78f0
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x78f0
jmp 0x62b4
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0x78f0
jmp 0x62ca
jmp 0x62c7
jmp 0x62c7
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x78f0
movq %rbx, %rdi
callq 0x23c0