// File: 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
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xa5e0
movq -0x58(%rbp), %rax
testb $0x1, 0xb8(%rax)
je 0x579e
movq 0x1285c(%rip), %rdi     # 0x17fd0
leaq 0xbb8b(%rip), %rsi      # 0x11306
callq 0x21f0
jmp 0x5782
jmp 0x579e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xa6c0
jmp 0x5c29
movq -0x58(%rbp), %rax
movsbl 0x60(%rax), %eax
cmpl $0x48, %eax
jne 0x5c17
movq -0x58(%rbp), %rdi
addq $0x68, %rdi
callq 0xa600
movq -0x58(%rbp), %rdi
callq 0x5310
jmp 0x57c7
movq -0x58(%rbp), %rax
cmpl $-0x1, 0xc0(%rax)
je 0x5800
movq -0x58(%rbp), %rcx
movl 0xc0(%rcx), %eax
cmpl 0xbc(%rcx), %eax
je 0x5800
movq -0x58(%rbp), %rdi
movl 0xc0(%rdi), %esi
movl 0xbc(%rdi), %edx
callq 0x3b50
cmpl $-0x1, %eax
jle 0x5864
movl $0x0, -0x14(%rbp)
movq -0x58(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, -0x5c(%rbp)
callq 0xa520
movq %rax, %rcx
movl -0x5c(%rbp), %eax
cmpl %ecx, %eax
jge 0x5862
movq -0x58(%rbp), %rdi
addq $0x80, %rdi
movslq -0x14(%rbp), %rsi
callq 0xa4e0
movq -0x58(%rbp), %rcx
movl (%rax), %eax
cmpl 0x98(%rcx), %eax
jne 0x5855
movq -0x58(%rbp), %rax
movl -0x14(%rbp), %ecx
movl %ecx, -0xc(%rbp)
movl -0x14(%rbp), %ecx
movl %ecx, 0xc0(%rax)
jmp 0x5857
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x5807
jmp 0x58b7
movq -0x58(%rbp), %rax
movl 0xc0(%rax), %eax
movl %eax, -0xc(%rbp)
movq 0x12758(%rip), %rdi     # 0x17fd0
leaq 0xbaa2(%rip), %rsi      # 0x11321
callq 0x21f0
movq %rax, -0x68(%rbp)
jmp 0x588a
movq -0x68(%rbp), %rdi
movq -0x58(%rbp), %rax
movl 0xc0(%rax), %esi
callq 0x23a0
movq %rax, -0x70(%rbp)
jmp 0x58a3
movq -0x70(%rbp), %rdi
leaq 0xbe4b(%rip), %rsi      # 0x116f9
callq 0x21f0
jmp 0x58b5
jmp 0x58b7
leaq -0x38(%rbp), %rdi
movq %rdi, -0x78(%rbp)
callq 0xa500
movq -0x78(%rbp), %rdi
leaq -0xc(%rbp), %rsi
callq 0xa550
jmp 0x58d3
movl $0xffffffff, -0x48(%rbp) # imm = 0xFFFFFFFF
leaq -0x38(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xa720
jmp 0x58e9
movl $0xffffffff, -0x4c(%rbp) # imm = 0xFFFFFFFF
leaq -0x38(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
callq 0xa720
jmp 0x58ff
movq -0x58(%rbp), %rdi
addq $0x68, %rdi
leaq -0x38(%rbp), %rsi
callq 0xa620
jmp 0x5912
movq -0x58(%rbp), %rdi
movslq -0xc(%rbp), %rsi
callq 0xa4a0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xa4e0
movl (%rax), %eax
movl %eax, -0x10(%rbp)
leaq -0x38(%rbp), %rdi
movq %rdi, -0x80(%rbp)
callq 0xa500
movq -0x80(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0xa550
jmp 0x594c
leaq -0x38(%rbp), %rdi
leaq -0xc(%rbp), %rsi
callq 0xa550
jmp 0x595b
movl $0xffffffff, -0x50(%rbp) # imm = 0xFFFFFFFF
leaq -0x38(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xa720
jmp 0x5971
movq -0x58(%rbp), %rdi
addq $0x68, %rdi
leaq -0x38(%rbp), %rsi
callq 0xa620
jmp 0x5984
jmp 0x5986
movq -0x58(%rbp), %rdi
addq $0x68, %rdi
callq 0xa520
movq -0x58(%rbp), %rdi
movl %eax, -0x84(%rbp)
callq 0xa520
movq %rax, %rcx
movl -0x84(%rbp), %eax
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x5c15
movl $0x0, -0x14(%rbp)
movq -0x58(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, -0x88(%rbp)
callq 0xa520
movq %rax, %rcx
movl -0x88(%rbp), %eax
cmpl %ecx, %eax
jge 0x5b67
movq -0x58(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x56c0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x5b57
movq -0x58(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0xbc(%rcx), %eax
je 0x5b57
movl $0x0, -0x20(%rbp)
movq -0x58(%rbp), %rdi
movl -0x20(%rbp), %eax
movl %eax, -0x8c(%rbp)
movslq -0x14(%rbp), %rsi
callq 0xa4a0
movq %rax, %rdi
callq 0xa4c0
movq %rax, %rcx
movl -0x8c(%rbp), %eax
cmpl %ecx, %eax
jge 0x5b55
movq -0x58(%rbp), %rdi
movslq -0x14(%rbp), %rsi
callq 0xa4a0
movq %rax, %rdi
movslq -0x20(%rbp), %rsi
callq 0xa4e0
movq -0x58(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x18(%rbp)
movslq -0x14(%rbp), %rsi
callq 0xa4a0
movq -0x58(%rbp), %rdi
movq %rax, -0x98(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
movslq -0x14(%rbp), %rsi
callq 0xa4a0
movq %rax, %rdi
callq 0xa4c0
movq -0x98(%rbp), %rdi
movq %rax, %rcx
movl -0x90(%rbp), %eax
cltd
idivl %ecx
movslq %edx, %rsi
callq 0xa4e0
movq -0x58(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %esi
callq 0x56c0
testb $0x1, %al
jne 0x5ac8
jmp 0x5b45
movq -0x58(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x56c0
testb $0x1, %al
jne 0x5ada
jmp 0x5b45
leaq -0x38(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0xa500
movq -0xa0(%rbp), %rdi
leaq -0x14(%rbp), %rsi
callq 0xa550
jmp 0x5afc
leaq -0x38(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0xa550
jmp 0x5b0b
leaq -0x38(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
callq 0xa550
jmp 0x5b1a
movq -0x58(%rbp), %rdi
addq $0x68, %rdi
leaq -0x38(%rbp), %rsi
callq 0xa620
jmp 0x5b2d
movq -0x58(%rbp), %rdi
movslq -0x14(%rbp), %rsi
callq 0xa4a0
movq %rax, %rdi
callq 0xa4c0
movl %eax, -0x20(%rbp)
jmp 0x5b47
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x5a14
jmp 0x5b57
jmp 0x5b59
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x59bd
movq -0x58(%rbp), %rax
testb $0x1, 0xb8(%rax)
je 0x5c10
movq 0x12451(%rip), %rdi     # 0x17fd0
leaq 0xb7b4(%rip), %rsi      # 0x1133a
callq 0x21f0
movq %rax, -0xa8(%rbp)
jmp 0x5b94
movq -0x58(%rbp), %rdi
addq $0x68, %rdi
callq 0xa520
movq -0xa8(%rbp), %rdi
movq %rax, %rsi
callq 0x2070
movq %rax, -0xb0(%rbp)
jmp 0x5bb9
movq -0xb0(%rbp), %rdi
leaq 0xb784(%rip), %rsi      # 0x1134b
callq 0x21f0
movq %rax, -0xb8(%rbp)
jmp 0x5bd5
movq -0x58(%rbp), %rdi
callq 0xa520
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x2070
movq %rax, -0xc0(%rbp)
jmp 0x5bf9
movq -0xc0(%rbp), %rdi
leaq 0xbaf2(%rip), %rsi      # 0x116f9
callq 0x21f0
jmp 0x5c0e
jmp 0x5c10
jmp 0x5986
jmp 0x5c17
leaq -0x38(%rbp), %rdi
callq 0xa6c0
addq $0xc0, %rsp
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x23c0
nopw %cs:(%rax,%rax)