// File: dannycalegari[P]circle_pack/./Input_handler.cc
// Function: input_routine(Packing&, bool&)
void input_routine(Packing &P, bool &finished){
	char c;
	string s;
	ifstream packing_input_file;
	ofstream packing_output_file, eps_output_file;
	int i;
	Point Q;
	
	cout << "Current packing has " << P.size() << " circles. \n";
	cout << "Enter command ([h] for help):";
	cin >> c;
	switch (c){
		case 'h':
			cout << "[h] for help (i.e. return to this list) \n";
			cout << "[v] to toggle verbose \n";
			cout << "[r] to read packing from a file \n";
			cout << "[g] to change geometry \n";
			cout << "[n] to normalize Euclidean coordinates \n";
			cout << "[w] to write packing to a file \n";
			cout << "[e] to write .eps output \n";
			cout << "[f] to find closest center \n";
			cout << "[q] to quit to graphics display \n";
			break;
		case 'v':
			P.toggle_verbose();
			break;
		case 'r':
			cout << "enter name of packing file to read from:";
			cin >> s;
			packing_input_file.open(s.c_str());
			P.read_packing(packing_input_file);
			packing_input_file.close();
			cout << "read packing from file " << s << "\n";
			cout << "finding radii.\n";
			P.find_radii(0.000000001);
			cout << "radii found.\n";
			cout << "determining layout.\n";
			P.determine_layout();
			cout << "layout determined.\n";
			cout << "determining centers.\n";
			P.determine_centers();
			cout << "centers determined.\n";
			break;
		case 'g':
			cout << "change to what geometry (S/E/H):";
			cin >> c;
			P.change_geometry(c);
			cout << "geometry changed.\n";
			break;
		case 'n':
			cout << "normalizing coordinates.\n";
			P.rescale();
			break;
		case 'w':
			cout << "enter name of packing file to write to:";
			cin >> s;
			packing_output_file.open(s.c_str());
			P.write_packing(packing_output_file);
			packing_output_file.close();
			cout << "wrote packing to file " << s << "\n";
			break;
		case 'e':
			cout << "enter name of .eps file to write to:";
			cin >> s;
			eps_output_file.open(s.c_str());
			P.write_packing_eps(eps_output_file);
			eps_output_file.close();
			cout << "wrote .eps to file " << s << "\n";
			break;
		case 'f':
			cout << "current geometry is " << P.write_geometry() << "\n";
			cout << "enter coordinates of point: ";
			cin >> Q.x >> Q.y >> Q.z;
			i=P.find_closest_vertex(Q);
			cout << "closest point is " << i << "\n";
			break;
		case 'q':
			cout << "quit to graphics display.\n" 
				<< "focus in graphics window and press [q] again to exit.\n";
			finished=true;
			break;
		default:
			break;
	};
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x740, %rsp            # imm = 0x740
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x22b0
leaq -0x240(%rbp), %rdi
callq 0x2230
jmp 0x98aa
leaq -0x450(%rbp), %rdi
callq 0x2390
jmp 0x98b8
leaq -0x650(%rbp), %rdi
callq 0x2390
jmp 0x98c6
movq 0xe703(%rip), %rdi      # 0x17fd0
leaq 0x7dbe(%rip), %rsi      # 0x11692
callq 0x21f0
movq %rax, -0x698(%rbp)
jmp 0x98e2
movq -0x8(%rbp), %rdi
callq 0xae40
movl %eax, -0x69c(%rbp)
jmp 0x98f3
movl -0x69c(%rbp), %esi
movq -0x698(%rbp), %rdi
callq 0x23a0
movq %rax, -0x6a8(%rbp)
jmp 0x990e
movq -0x6a8(%rbp), %rdi
leaq 0x7d8b(%rip), %rsi      # 0x116a7
callq 0x21f0
jmp 0x9923
movq 0xe6a6(%rip), %rdi      # 0x17fd0
leaq 0x7d82(%rip), %rsi      # 0x116b3
callq 0x21f0
jmp 0x9938
movq 0xe6a1(%rip), %rdi      # 0x17fe0
leaq -0x11(%rbp), %rsi
callq 0x2280
jmp 0x994a
movsbl -0x11(%rbp), %eax
addl $-0x65, %eax
movl %eax, %ecx
movq %rcx, -0x6b0(%rbp)
subl $0x12, %eax
ja 0x9f8a
movq -0x6b0(%rbp), %rax
leaq 0x778f(%rip), %rcx      # 0x11100
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
jmp 0x9fda
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
jmp 0x9fce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
jmp 0x9fc2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
leaq -0x650(%rbp), %rdi
callq 0x2310
jmp 0x9fc2
movq 0xe5e7(%rip), %rdi      # 0x17fd0
leaq 0x7ce1(%rip), %rsi      # 0x116d1
callq 0x21f0
jmp 0x99f7
movq 0xe5d2(%rip), %rdi      # 0x17fd0
leaq 0x7cf6(%rip), %rsi      # 0x116fb
callq 0x21f0
jmp 0x9a0c
movq 0xe5bd(%rip), %rdi      # 0x17fd0
leaq 0x7cf9(%rip), %rsi      # 0x11713
callq 0x21f0
jmp 0x9a21
movq 0xe5a8(%rip), %rdi      # 0x17fd0
leaq 0x7d06(%rip), %rsi      # 0x11735
callq 0x21f0
jmp 0x9a36
movq 0xe593(%rip), %rdi      # 0x17fd0
leaq 0x7d0a(%rip), %rsi      # 0x1174e
callq 0x21f0
jmp 0x9a4b
movq 0xe57e(%rip), %rdi      # 0x17fd0
leaq 0x7d1e(%rip), %rsi      # 0x11777
callq 0x21f0
jmp 0x9a60
movq 0xe569(%rip), %rdi      # 0x17fd0
leaq 0x7d2a(%rip), %rsi      # 0x11798
callq 0x21f0
jmp 0x9a75
movq 0xe554(%rip), %rdi      # 0x17fd0
leaq 0x7d30(%rip), %rsi      # 0x117b3
callq 0x21f0
jmp 0x9a8a
movq 0xe53f(%rip), %rdi      # 0x17fd0
leaq 0x7d38(%rip), %rsi      # 0x117d0
callq 0x21f0
jmp 0x9a9f
jmp 0x9f8c
movq -0x8(%rbp), %rdi
callq 0xae80
jmp 0x9aaf
jmp 0x9f8c
movq 0xe515(%rip), %rdi      # 0x17fd0
leaq 0x7d30(%rip), %rsi      # 0x117f2
callq 0x21f0
jmp 0x9ac9
movq 0xe510(%rip), %rdi      # 0x17fe0
leaq -0x38(%rbp), %rsi
callq 0x2260
jmp 0x9adb
leaq -0x38(%rbp), %rdi
callq 0x20e0
movq %rax, %rsi
leaq -0x240(%rbp), %rdi
movl $0x8, %edx
callq 0x2130
jmp 0x9afa
movq -0x8(%rbp), %rdi
leaq -0x240(%rbp), %rsi
callq 0x5190
jmp 0x9b0c
leaq -0x240(%rbp), %rdi
callq 0x2050
jmp 0x9b1a
movq 0xe4af(%rip), %rdi      # 0x17fd0
leaq 0x7cf3(%rip), %rsi      # 0x1181b
callq 0x21f0
movq %rax, -0x6b8(%rbp)
jmp 0x9b36
movq -0x6b8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x21b0
movq %rax, -0x6c0(%rbp)
jmp 0x9b4f
movq -0x6c0(%rbp), %rdi
leaq 0x7b9c(%rip), %rsi      # 0x116f9
callq 0x21f0
jmp 0x9b64
movq 0xe465(%rip), %rdi      # 0x17fd0
leaq 0x7cc1(%rip), %rsi      # 0x11833
callq 0x21f0
jmp 0x9b79
movq -0x8(%rbp), %rdi
movsd 0x752b(%rip), %xmm0     # 0x110b0
callq 0x4b00
jmp 0x9b8c
movq 0xe43d(%rip), %rdi      # 0x17fd0
leaq 0x7ca9(%rip), %rsi      # 0x11843
callq 0x21f0
jmp 0x9ba1
movq 0xe428(%rip), %rdi      # 0x17fd0
leaq 0x7ca2(%rip), %rsi      # 0x11851
callq 0x21f0
jmp 0x9bb6
movq -0x8(%rbp), %rdi
callq 0x5740
jmp 0x9bc1
movq 0xe408(%rip), %rdi      # 0x17fd0
leaq 0x7c97(%rip), %rsi      # 0x11866
callq 0x21f0
jmp 0x9bd6
movq 0xe3f3(%rip), %rdi      # 0x17fd0
leaq 0x778c(%rip), %rsi      # 0x11370
callq 0x21f0
jmp 0x9beb
movq -0x8(%rbp), %rdi
callq 0x6320
jmp 0x9bf6
movq 0xe3d3(%rip), %rdi      # 0x17fd0
leaq 0x7c76(%rip), %rsi      # 0x1187a
callq 0x21f0
jmp 0x9c0b
jmp 0x9f8c
movq 0xe3b9(%rip), %rdi      # 0x17fd0
leaq 0x7c71(%rip), %rsi      # 0x1188f
callq 0x21f0
jmp 0x9c25
movq 0xe3b4(%rip), %rdi      # 0x17fe0
leaq -0x11(%rbp), %rsi
callq 0x2280
jmp 0x9c37
movq -0x8(%rbp), %rdi
movsbl -0x11(%rbp), %esi
callq 0x68e0
jmp 0x9c46
movq 0xe383(%rip), %rdi      # 0x17fd0
leaq 0x7c5c(%rip), %rsi      # 0x118b0
callq 0x21f0
jmp 0x9c5b
jmp 0x9f8c
movq 0xe369(%rip), %rdi      # 0x17fd0
leaq 0x7c55(%rip), %rsi      # 0x118c3
callq 0x21f0
jmp 0x9c75
movq -0x8(%rbp), %rdi
callq 0x3de0
jmp 0x9c80
jmp 0x9f8c
movq 0xe344(%rip), %rdi      # 0x17fd0
leaq 0x7c4a(%rip), %rsi      # 0x118dd
callq 0x21f0
jmp 0x9c9a
movq 0xe33f(%rip), %rdi      # 0x17fe0
leaq -0x38(%rbp), %rsi
callq 0x2260
jmp 0x9cac
leaq -0x38(%rbp), %rdi
callq 0x20e0
movq %rax, %rsi
leaq -0x450(%rbp), %rdi
movl $0x10, %edx
callq 0x2030
jmp 0x9ccb
movq -0x8(%rbp), %rdi
leaq -0x450(%rbp), %rsi
callq 0x96b0
jmp 0x9cdd
leaq -0x450(%rbp), %rdi
callq 0x22e0
jmp 0x9ceb
movq 0xe2de(%rip), %rdi      # 0x17fd0
leaq 0x7c0c(%rip), %rsi      # 0x11905
callq 0x21f0
movq %rax, -0x6c8(%rbp)
jmp 0x9d07
movq -0x6c8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x21b0
movq %rax, -0x6d0(%rbp)
jmp 0x9d20
movq -0x6d0(%rbp), %rdi
leaq 0x79cb(%rip), %rsi      # 0x116f9
callq 0x21f0
jmp 0x9d35
jmp 0x9f8c
movq 0xe28f(%rip), %rdi      # 0x17fd0
leaq 0x7bd4(%rip), %rsi      # 0x1191c
callq 0x21f0
jmp 0x9d4f
movq 0xe28a(%rip), %rdi      # 0x17fe0
leaq -0x38(%rbp), %rsi
callq 0x2260
jmp 0x9d61
leaq -0x38(%rbp), %rdi
callq 0x20e0
movq %rax, %rsi
leaq -0x650(%rbp), %rdi
movl $0x10, %edx
callq 0x2030
jmp 0x9d80
movq -0x8(%rbp), %rdi
leaq -0x650(%rbp), %rsi
callq 0x9310
jmp 0x9d92
leaq -0x650(%rbp), %rdi
callq 0x22e0
jmp 0x9da0
movq 0xe229(%rip), %rdi      # 0x17fd0
leaq 0x7b93(%rip), %rsi      # 0x11941
callq 0x21f0
movq %rax, -0x6d8(%rbp)
jmp 0x9dbc
movq -0x6d8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x21b0
movq %rax, -0x6e0(%rbp)
jmp 0x9dd5
movq -0x6e0(%rbp), %rdi
leaq 0x7916(%rip), %rsi      # 0x116f9
callq 0x21f0
jmp 0x9dea
jmp 0x9f8c
movq 0xe1da(%rip), %rdi      # 0x17fd0
leaq 0x7b58(%rip), %rsi      # 0x11955
callq 0x21f0
movq %rax, -0x6e8(%rbp)
jmp 0x9e0b
movq -0x8(%rbp), %rdi
callq 0xae60
movb %al, -0x6e9(%rbp)
jmp 0x9e1c
movq -0x6e8(%rbp), %rdi
movb -0x6e9(%rbp), %al
movsbl %al, %esi
callq 0x2240
movq %rax, -0x6f8(%rbp)
jmp 0x9e3a
movq -0x6f8(%rbp), %rdi
leaq 0x78b1(%rip), %rsi      # 0x116f9
callq 0x21f0
jmp 0x9e4f
movq 0xe17a(%rip), %rdi      # 0x17fd0
leaq 0x7b0d(%rip), %rsi      # 0x1196a
callq 0x21f0
jmp 0x9e64
movq 0xe175(%rip), %rdi      # 0x17fe0
leaq -0x670(%rbp), %rsi
callq 0x2190
movq %rax, -0x700(%rbp)
jmp 0x9e80
movq -0x700(%rbp), %rdi
leaq -0x668(%rbp), %rsi
callq 0x2190
movq %rax, -0x708(%rbp)
jmp 0x9e9c
movq -0x708(%rbp), %rdi
leaq -0x660(%rbp), %rsi
callq 0x2190
jmp 0x9eb1
movq -0x8(%rbp), %rdi
movq -0x660(%rbp), %rax
movq %rax, -0x680(%rbp)
movups -0x670(%rbp), %xmm0
movaps %xmm0, -0x690(%rbp)
movq -0x680(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x10(%rax)
movaps -0x690(%rbp), %xmm0
movups %xmm0, (%rax)
callq 0x7e10
movl %eax, -0x70c(%rbp)
jmp 0x9ef6
movl -0x70c(%rbp), %eax
movl %eax, -0x654(%rbp)
movq 0xe0c7(%rip), %rdi      # 0x17fd0
leaq 0x7a77(%rip), %rsi      # 0x11987
callq 0x21f0
movq %rax, -0x718(%rbp)
jmp 0x9f1e
movq -0x718(%rbp), %rdi
movl -0x654(%rbp), %esi
callq 0x23a0
movq %rax, -0x720(%rbp)
jmp 0x9f39
movq -0x720(%rbp), %rdi
leaq 0x77b2(%rip), %rsi      # 0x116f9
callq 0x21f0
jmp 0x9f4e
jmp 0x9f8c
movq 0xe079(%rip), %rdi      # 0x17fd0
leaq 0x7a3b(%rip), %rsi      # 0x11999
callq 0x21f0
movq %rax, -0x728(%rbp)
jmp 0x9f6c
movq -0x728(%rbp), %rdi
leaq 0x7a3a(%rip), %rsi      # 0x119b4
callq 0x21f0
jmp 0x9f81
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
jmp 0x9f8c
jmp 0x9f8c
leaq -0x650(%rbp), %rdi
callq 0x2310
leaq -0x450(%rbp), %rdi
callq 0x2310
leaq -0x240(%rbp), %rdi
callq 0x2080
leaq -0x38(%rbp), %rdi
callq 0x2110
addq $0x740, %rsp            # imm = 0x740
popq %rbp
retq
leaq -0x450(%rbp), %rdi
callq 0x2310
leaq -0x240(%rbp), %rdi
callq 0x2080
leaq -0x38(%rbp), %rdi
callq 0x2110
movq -0x248(%rbp), %rdi
callq 0x23c0
nop