// File: /workspace/github_cpp_makefile_star2_O2/dannycalegari[P]circle_pack/./Layout_routine.cc
// Function: Packing::determine_layout()
void Packing::determine_layout(){			// figure out layout order of vertices
	int first,second;
	int i,j,k,e;
	vector<int> triangle;
	if(verbose){
		cout << "determining layout order.\n";
	};
	if(geometry=='H'){	// don't lay out circle INFV
		lay.clear();	// initialize layout vector
		compute_distances_to_vertex_INFV();
		if(ZERV==-1 || ZERV==INFV || which_edge(ZERV,INFV)>-1){ // we don't yet have a vertex centered at 0
			for(i=0;i<(int) adj.size();i++){
				if(dist[i]==maximum_distance){
					first=i;					
					ZERV=i;		// new ZERV for future reference
				};
			};
		} else {
			first=ZERV;	// note: should *not be* adjacent to INFV
			cout << "We know ZERV, and it is " << ZERV << "\n";
		};
		triangle.clear();
		triangle.push_back(first);
		triangle.push_back(-1);
		triangle.push_back(-1);
		lay.push_back(triangle);	// add first triangle (special case)
		second=adj[first][0];
		triangle.clear();
		triangle.push_back(second);
		triangle.push_back(first);
		triangle.push_back(-1);
		lay.push_back(triangle);	// add second triangle (special case)
		while((int) lay.size() < (int) adj.size()-1){	// hyperbolic geometry: don't lay out INFV!
			for(i=0;i<(int) adj.size();i++){	
				if(already_laid_out(i)==false && i!=INFV){	// not yet laid out; don't lay out INFV!
					for(e=0;e<(int) adj[i].size();e++){
						j=adj[i][e];
						k=adj[i][(e+1)%(int) adj[i].size()];
						if(already_laid_out(j) && already_laid_out(k)){	// neighbors are both laid out
							triangle.clear();
							triangle.push_back(i);
							triangle.push_back(j);
							triangle.push_back(k);
							lay.push_back(triangle);
							e=(int) adj[i].size();	// don't add it twice!
						};
					};
				};
			};
			if(verbose){
				cout << "total laid out: " << lay.size() << " out of " << adj.size()-1 << "\n";
			};
		};
	};
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
andq $0x0, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
cmpb $0x1, 0xb8(%rdi)
jne 0x4601
movq 0x89db(%rip), %rdi      # 0xcfd0
leaq 0x4d42(%rip), %rsi      # 0x933e
callq 0x21e0
cmpb $0x48, 0x60(%rbx)
jne 0x4939
leaq 0x68(%rbx), %rdi
movq %rdi, 0x38(%rsp)
callq 0x75cc
movq %rbx, %rdi
callq 0x4360
movl 0xc0(%rbx), %r15d
pushq $0x18
popq %r14
cmpl $-0x1, %r15d
je 0x464c
movl 0xbc(%rbx), %edx
cmpl %edx, %r15d
je 0x464c
movq %rbx, %rdi
movl %r15d, %esi
callq 0x3304
testl %eax, %eax
js 0x4689
movq 0x8(%rbx), %rax
movq 0x80(%rbx), %rcx
subq (%rbx), %rax
cqto
idivq %r14
movl 0x98(%rbx), %edx
xorl %esi, %esi
testl %eax, %eax
cmovlel %esi, %eax
movl %esi, 0xc(%rsp)
cmpq %rsi, %rax
je 0x46be
cmpl %edx, (%rcx,%rsi,4)
jne 0x4684
movl %esi, 0x8(%rsp)
movl %esi, 0xc0(%rbx)
incq %rsi
jmp 0x466c
movl %r15d, 0x8(%rsp)
movq 0x893b(%rip), %rdi      # 0xcfd0
leaq 0x4cbd(%rip), %rsi      # 0x9359
callq 0x21e0
movl 0xc0(%rbx), %esi
movq %rax, %rdi
callq 0x23a0
leaq 0x507b(%rip), %rsi      # 0x9731
movq %rax, %rdi
callq 0x21e0
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0x46cf
movq %rax, 0x18(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x75ae
leaq 0x34(%rsp), %rsi
orl $-0x1, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x8580
leaq 0x34(%rsp), %rsi
orl $-0x1, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x8580
leaq 0x10(%rsp), %rsi
movq 0x38(%rsp), %rdi
callq 0x75d4
movslq 0x8(%rsp), %rax
movq (%rbx), %rcx
imulq $0x18, %rax, %rax
movq (%rcx,%rax), %rax
movl (%rax), %eax
movl %eax, 0x4c(%rsp)
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0x4738
movq %rax, 0x18(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x4c(%rsp), %rsi
callq 0x75ae
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x75ae
leaq 0x34(%rsp), %rsi
orl $-0x1, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x8580
leaq 0x10(%rsp), %rsi
movq 0x38(%rsp), %rdi
callq 0x75d4
movq 0x70(%rbx), %rax
subq 0x68(%rbx), %rax
cqto
idivq %r14
movq %rax, %rcx
movq (%rbx), %r15
movq 0x8(%rbx), %r13
movq %r13, %rax
subq %r15, %rax
cqto
idivq %r14
decl %eax
cmpl %ecx, %eax
jle 0x4939
xorl %r12d, %r12d
movl %r12d, 0xc(%rsp)
movq %r13, %rax
subq %r15, %rax
cqto
idivq %r14
cmpl %eax, %r12d
jge 0x48c6
movq %rbx, %rdi
movl %r12d, %esi
callq 0x458a
testb %al, %al
jne 0x48be
cmpl 0xbc(%rbx), %r12d
je 0x48be
xorl %eax, %eax
movslq %r12d, %rcx
imulq $0x18, %rcx, %rcx
movq (%r15,%rcx), %rbp
movq %r15, 0x50(%rsp)
movq 0x8(%r15,%rcx), %r15
subq %rbp, %r15
shrq $0x2, %r15
movslq %eax, %r14
cmpl %r15d, %r14d
jge 0x48b1
movl (%rbp,%r14,4), %esi
movl %esi, 0x48(%rsp)
leal 0x1(%r14), %eax
cltd
idivl %r15d
movslq %edx, %rax
movl (%rbp,%rax,4), %r13d
movl %r13d, 0x44(%rsp)
movq %rbx, %rdi
callq 0x458a
testb %al, %al
je 0x4842
movq %rbx, %rdi
movl %r13d, %esi
callq 0x458a
testb %al, %al
jne 0x4847
incq %r14
jmp 0x4800
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0x4858
movq %rax, 0x18(%rsp)
leaq 0x10(%rsp), %r14
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
callq 0x75ae
movq %r14, %rdi
leaq 0x48(%rsp), %rsi
callq 0x75ae
movq %r14, %rdi
leaq 0x44(%rsp), %rsi
callq 0x75ae
movq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0x75d4
movslq 0xc(%rsp), %r12
movq (%rbx), %r15
imulq $0x18, %r12, %rcx
movq 0x8(%r15,%rcx), %rax
subq (%r15,%rcx), %rax
shrq $0x2, %rax
incl %eax
jmp 0x47e1
movq 0x8(%rbx), %r13
pushq $0x18
popq %r14
movq 0x50(%rsp), %r15
incl %r12d
jmp 0x47a6
cmpb $0x1, 0xb8(%rbx)
jne 0x4777
movq 0x86f6(%rip), %rdi      # 0xcfd0
leaq 0x4a91(%rip), %rsi      # 0x9372
callq 0x21e0
movq %rax, %rdi
movq 0x70(%rbx), %rax
subq 0x68(%rbx), %rax
cqto
idivq %r14
movq %rax, %rsi
callq 0x2130
movq %rax, %rdi
leaq 0x4a7b(%rip), %rsi      # 0x9383
callq 0x21e0
movq %rax, %rdi
movq 0x8(%rbx), %rax
subq (%rbx), %rax
cqto
idivq %r14
leaq -0x1(%rax), %rsi
callq 0x2130
movq %rax, %rdi
leaq 0x4e02(%rip), %rsi      # 0x9731
callq 0x21e0
jmp 0x4777
leaq 0x10(%rsp), %rdi
callq 0x82b4
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x495c
jmp 0x495c
jmp 0x495c
jmp 0x495c
jmp 0x495c
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x82b4
movq %rbx, %rdi
callq 0x23c0