// File: dannycalegari[P]circle_pack/./Packing.cc
// Function: Packing::find_radii(double)
void Packing::find_radii(double accuracy){	// adjust until fitness <= accuracy
	int i,j,step;
	step=0;
	if(verbose){
		cout << "determining radii to accuracy " << accuracy << ".\n";
	};
	if(geometry=='H'){
		if(verbose){
			cout << "hyperbolic geometry.\n";
		};
		determine_inner_vertices();
		determine_labels();
		if(verbose){
			cout << "initial fitness is " << interior_fitness() << "\n";
		};
		while(interior_fitness()>accuracy){
			for(i=0;i<(int) inner.size();i++){	// adjust radii (actually, labels) of inner vertices
				j=inner[i];
				hyperbolic_correct_radius(j);
			};
			for(i=0;i<(int) adj[INFV].size();i++){	// for neighbors of infinite vertices
				j=adj[INFV][i];
				if(lab[j]>0.0000000001){
					lab[j]=lab[j]/2.0;		// make labels/radii smaller/bigger (but not too small/big)
				};
			};
			step++;
			if(verbose){
				if(step%100==0){
					cout << "fitness is " << interior_fitness() << " after " << step << " steps. \n";
				};
			};
		};
		if(verbose){
			cout << "fitness is " << interior_fitness() << " after " << step << " steps. \n";
		};
		determine_radii();	// convert from labels to radii
	} else if (geometry=='E'){
		cout << "Euclidean geometry.\n";
		cout << "initial fitness is " << fitness() << "\n";
		while(fitness()>accuracy){	
			for(i=0;i<(int) adj.size();i++){
				Euclidean_correct_radius(i);
			};	
			step++;
			if(verbose){
				if(step%100==0){
					cout << "fitness is " << fitness() << " after " << step << " steps. \n";
				};
			};
		};
		cout << "fitness is " << fitness() << " after " << step << " steps. \n";
	} else {
		cout << "Spherical packing not implemented yet (move a vertex to infinity)\n";
	};
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x1c(%rbp)
testb $0x1, 0xb8(%rax)
je 0x4b58
movq 0x134a0(%rip), %rdi     # 0x17fd0
leaq 0xc686(%rip), %rsi      # 0x111bd
callq 0x21f0
movq %rax, %rdi
movsd -0x10(%rbp), %xmm0
callq 0x2400
movq %rax, %rdi
leaq 0xc79b(%rip), %rsi      # 0x112ee
callq 0x21f0
movq -0x28(%rbp), %rax
movsbl 0x60(%rax), %eax
cmpl $0x48, %eax
jne 0x4dfa
movq -0x28(%rbp), %rax
testb $0x1, 0xb8(%rax)
je 0x4b89
movq 0x13453(%rip), %rdi     # 0x17fd0
leaq 0xc658(%rip), %rsi      # 0x111dc
callq 0x21f0
movq -0x28(%rbp), %rdi
callq 0x3c00
movq -0x28(%rbp), %rdi
callq 0x3c80
movq -0x28(%rbp), %rax
testb $0x1, 0xb8(%rax)
je 0x4be0
movq 0x13421(%rip), %rdi     # 0x17fd0
leaq 0xc63c(%rip), %rsi      # 0x111f2
callq 0x21f0
movq -0x28(%rbp), %rdi
movq %rax, -0x30(%rbp)
callq 0x4730
movq -0x30(%rbp), %rdi
callq 0x2400
movq %rax, %rdi
leaq 0xcb1e(%rip), %rsi      # 0x116f9
callq 0x21f0
jmp 0x4be2
movq -0x28(%rbp), %rdi
callq 0x4730
ucomisd -0x10(%rbp), %xmm0
jbe 0x4d8d
movl $0x0, -0x14(%rbp)
movq -0x28(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, -0x34(%rbp)
addq $0x48, %rdi
callq 0xa4c0
movq %rax, %rcx
movl -0x34(%rbp), %eax
cmpl %ecx, %eax
jge 0x4c47
movq -0x28(%rbp), %rdi
addq $0x48, %rdi
movslq -0x14(%rbp), %rsi
callq 0xa4e0
movq -0x28(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %esi
callq 0x47f0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x4bfd
movl $0x0, -0x14(%rbp)
movq -0x28(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, -0x38(%rbp)
movslq 0xbc(%rdi), %rsi
callq 0xa4a0
movq %rax, %rdi
callq 0xa4c0
movq %rax, %rcx
movl -0x38(%rbp), %eax
cmpl %ecx, %eax
jge 0x4d0e
movq -0x28(%rbp), %rdi
movslq 0xbc(%rdi), %rsi
callq 0xa4a0
movq %rax, %rdi
movslq -0x14(%rbp), %rsi
callq 0xa4e0
movq -0x28(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x18(%rbp)
addq $0x30, %rdi
movslq -0x18(%rbp), %rsi
callq 0xa270
movsd (%rax), %xmm0
movsd 0xc380(%rip), %xmm1     # 0x11038
ucomisd %xmm1, %xmm0
jbe 0x4cfe
movq -0x28(%rbp), %rdi
addq $0x30, %rdi
movslq -0x18(%rbp), %rsi
callq 0xa270
movq -0x28(%rbp), %rdi
movsd (%rax), %xmm0
movsd 0xc329(%rip), %xmm1     # 0x11008
divsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
addq $0x30, %rdi
movslq -0x18(%rbp), %rsi
callq 0xa270
movsd -0x40(%rbp), %xmm0
movsd %xmm0, (%rax)
jmp 0x4d00
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x4c4e
movq -0x28(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x1c(%rbp)
testb $0x1, 0xb8(%rax)
je 0x4d88
movl -0x1c(%rbp), %eax
movl $0x64, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x4d86
movq 0x13295(%rip), %rdi     # 0x17fd0
leaq 0xc4b8(%rip), %rsi      # 0x111fa
callq 0x21f0
movq -0x28(%rbp), %rdi
movq %rax, -0x48(%rbp)
callq 0x4730
movq -0x48(%rbp), %rdi
callq 0x2400
movq %rax, %rdi
leaq 0xc49f(%rip), %rsi      # 0x11206
callq 0x21f0
movq %rax, %rdi
movl -0x1c(%rbp), %esi
callq 0x23a0
movq %rax, %rdi
leaq 0xc48d(%rip), %rsi      # 0x1120e
callq 0x21f0
jmp 0x4d88
jmp 0x4be2
movq -0x28(%rbp), %rax
testb $0x1, 0xb8(%rax)
je 0x4dec
movq 0x1322f(%rip), %rdi     # 0x17fd0
leaq 0xc452(%rip), %rsi      # 0x111fa
callq 0x21f0
movq -0x28(%rbp), %rdi
movq %rax, -0x50(%rbp)
callq 0x4730
movq -0x50(%rbp), %rdi
callq 0x2400
movq %rax, %rdi
leaq 0xc439(%rip), %rsi      # 0x11206
callq 0x21f0
movq %rax, %rdi
movl -0x1c(%rbp), %esi
callq 0x23a0
movq %rax, %rdi
leaq 0xc427(%rip), %rsi      # 0x1120e
callq 0x21f0
movq -0x28(%rbp), %rdi
callq 0x3d30
jmp 0x4f89
movq -0x28(%rbp), %rax
movsbl 0x60(%rax), %eax
cmpl $0x45, %eax
jne 0x4f74
movq 0x131be(%rip), %rdi     # 0x17fd0
leaq 0xc3ff(%rip), %rsi      # 0x11218
callq 0x21f0
movq 0x131ab(%rip), %rdi     # 0x17fd0
leaq 0xc3c6(%rip), %rsi      # 0x111f2
callq 0x21f0
movq -0x28(%rbp), %rdi
movq %rax, -0x58(%rbp)
callq 0x46a0
movq -0x58(%rbp), %rdi
callq 0x2400
movq %rax, %rdi
leaq 0xc8a8(%rip), %rsi      # 0x116f9
callq 0x21f0
movq -0x28(%rbp), %rdi
callq 0x46a0
ucomisd -0x10(%rbp), %xmm0
jbe 0x4f20
movl $0x0, -0x14(%rbp)
movq -0x28(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, -0x5c(%rbp)
callq 0xa520
movq %rax, %rcx
movl -0x5c(%rbp), %eax
cmpl %ecx, %eax
jge 0x4ea1
movq -0x28(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x49f0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x4e71
movq -0x28(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x1c(%rbp)
testb $0x1, 0xb8(%rax)
je 0x4f1b
movl -0x1c(%rbp), %eax
movl $0x64, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x4f19
movq 0x13102(%rip), %rdi     # 0x17fd0
leaq 0xc325(%rip), %rsi      # 0x111fa
callq 0x21f0
movq -0x28(%rbp), %rdi
movq %rax, -0x68(%rbp)
callq 0x46a0
movq -0x68(%rbp), %rdi
callq 0x2400
movq %rax, %rdi
leaq 0xc30c(%rip), %rsi      # 0x11206
callq 0x21f0
movq %rax, %rdi
movl -0x1c(%rbp), %esi
callq 0x23a0
movq %rax, %rdi
leaq 0xc2fa(%rip), %rsi      # 0x1120e
callq 0x21f0
jmp 0x4f1b
jmp 0x4e56
movq 0x130a9(%rip), %rdi     # 0x17fd0
leaq 0xc2cc(%rip), %rsi      # 0x111fa
callq 0x21f0
movq -0x28(%rbp), %rdi
movq %rax, -0x70(%rbp)
callq 0x46a0
movq -0x70(%rbp), %rdi
callq 0x2400
movq %rax, %rdi
leaq 0xc2b3(%rip), %rsi      # 0x11206
callq 0x21f0
movq %rax, %rdi
movl -0x1c(%rbp), %esi
callq 0x23a0
movq %rax, %rdi
leaq 0xc2a1(%rip), %rsi      # 0x1120e
callq 0x21f0
jmp 0x4f87
movq 0x13055(%rip), %rdi     # 0x17fd0
leaq 0xc2ab(%rip), %rsi      # 0x1122d
callq 0x21f0
jmp 0x4f89
addq $0x70, %rsp
popq %rbp
retq
nop