// File: MarkCBell[P]twister/./twister/kernel/twister_main.cpp
// Function: main
int main(int argc, char **argv)
{
	// Set default values.
	set_globals_to_defaults();
	Manifold_type manifold_type = bundle;
	std::string manifold_name = "", handles = "", gluing = "", surface_file = "", surface_file_contents = "", output_file = "", warning_file = "";
	std::string manifold_contents = "";
	bool error_occured = false;
	
	try
	{
		// Parse the given command, extracting out all the interesting bits.
		parse_input(argc, argv, surface_file, output_file, warning_file, manifold_name, manifold_type, gluing, handles);
		surface_file_contents = load_file_contents(surface_file);
		
		// Build the manifold and get its information.
		manifold M(manifold_name, manifold_type);
		construct_manifold(M, surface_file_contents, gluing, handles);
		manifold_contents = M.to_string();
	}
	catch (...)
	{
		error_occured = true;
	}
	
	// Write out any messages stored in the GLOBAL_message_stream.
	try
	{
		if (GLOBAL_message_stream != "")
		{
			if (warning_file != "")
			{
				std::ofstream myfile(warning_file.c_str());
				if (not myfile.is_open())
					output_error("Unable to write to " + warning_file + ".");
				
				myfile << GLOBAL_message_stream;
				myfile.close();
			}
			else  // Else write it to std::cerr.
			{
				std::cerr << GLOBAL_message_stream << std::endl;
			}
		}
	}
	catch (...)
	{
		error_occured = true;
	}
	
	if (error_occured) exit(1);
	
	try
	{
		if (output_file != "")  // If we were given an output file, write it there.
		{
			std::ofstream myfile(output_file.c_str());
			if (not myfile.is_open())
				output_error("Unable to write to " + output_file + ".");
			
			myfile << manifold_contents;
			myfile.close();
		}
		else  // Else write it to std::cout.
		{
			std::cout << manifold_contents;
		}
	}
	catch (...)
	{
		error_occured = true;
	}
	
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x7b0, %rsp            # imm = 0x7B0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
callq 0x4bd0
movl $0x1, -0x14(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0x740(%rbp)
callq 0x3560
movq -0x740(%rbp), %rdx
leaq 0x156f(%rip), %rsi      # 0x272f2
leaq -0x38(%rbp), %rdi
callq 0x4e10
jmp 0x25d8e
leaq -0x39(%rbp), %rdi
callq 0x3360
leaq -0x71(%rbp), %rdi
movq %rdi, -0x748(%rbp)
callq 0x3560
movq -0x748(%rbp), %rdx
leaq 0x153d(%rip), %rsi      # 0x272f2
leaq -0x70(%rbp), %rdi
callq 0x4e10
jmp 0x25dc0
leaq -0x71(%rbp), %rdi
callq 0x3360
leaq -0x99(%rbp), %rdi
movq %rdi, -0x750(%rbp)
callq 0x3560
movq -0x750(%rbp), %rdx
leaq 0x1508(%rip), %rsi      # 0x272f2
leaq -0x98(%rbp), %rdi
callq 0x4e10
jmp 0x25df8
leaq -0x99(%rbp), %rdi
callq 0x3360
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x758(%rbp)
callq 0x3560
movq -0x758(%rbp), %rdx
leaq 0x14cd(%rip), %rsi      # 0x272f2
leaq -0xc0(%rbp), %rdi
callq 0x4e10
jmp 0x25e33
leaq -0xc1(%rbp), %rdi
callq 0x3360
leaq -0xe9(%rbp), %rdi
movq %rdi, -0x760(%rbp)
callq 0x3560
movq -0x760(%rbp), %rdx
leaq 0x1492(%rip), %rsi      # 0x272f2
leaq -0xe8(%rbp), %rdi
callq 0x4e10
jmp 0x25e6e
leaq -0xe9(%rbp), %rdi
callq 0x3360
leaq -0x111(%rbp), %rdi
movq %rdi, -0x768(%rbp)
callq 0x3560
movq -0x768(%rbp), %rdx
leaq 0x1457(%rip), %rsi      # 0x272f2
leaq -0x110(%rbp), %rdi
callq 0x4e10
jmp 0x25ea9
leaq -0x111(%rbp), %rdi
callq 0x3360
leaq -0x139(%rbp), %rdi
movq %rdi, -0x770(%rbp)
callq 0x3560
movq -0x770(%rbp), %rdx
leaq 0x141c(%rip), %rsi      # 0x272f2
leaq -0x138(%rbp), %rdi
callq 0x4e10
jmp 0x25ee4
leaq -0x139(%rbp), %rdi
callq 0x3360
leaq -0x161(%rbp), %rdi
movq %rdi, -0x778(%rbp)
callq 0x3560
movq -0x778(%rbp), %rdx
leaq 0x13e1(%rip), %rsi      # 0x272f2
leaq -0x160(%rbp), %rdi
callq 0x4e10
jmp 0x25f1f
leaq -0x161(%rbp), %rdi
callq 0x3360
movb $0x0, -0x162(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
movq %rsp, %rax
leaq -0x70(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq -0x98(%rbp), %rcx
movq %rcx, 0x8(%rax)
leaq -0x14(%rbp), %rcx
movq %rcx, (%rax)
leaq -0xc0(%rbp), %rdx
leaq -0x110(%rbp), %rcx
leaq -0x138(%rbp), %r8
leaq -0x38(%rbp), %r9
callq 0x24d50
jmp 0x25f76
leaq -0x1a8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x3130
jmp 0x25f8b
leaq -0x188(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x11880
jmp 0x25fa0
leaq -0xe8(%rbp), %rdi
leaq -0x188(%rbp), %rsi
movq %rsi, -0x780(%rbp)
callq 0x33c0
movq -0x780(%rbp), %rdi
callq 0x35f8
leaq -0x1a8(%rbp), %rdi
callq 0x35f8
leaq -0x238(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x3130
jmp 0x25fe4
movl -0x14(%rbp), %edx
leaq -0x218(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0x1d4a0
jmp 0x25ffc
leaq -0x238(%rbp), %rdi
callq 0x35f8
leaq -0x258(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x3130
jmp 0x2601d
leaq -0x278(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x3130
jmp 0x26032
leaq -0x298(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x3130
jmp 0x26044
leaq -0x218(%rbp), %rdi
leaq -0x258(%rbp), %rsi
leaq -0x278(%rbp), %rdx
leaq -0x298(%rbp), %rcx
callq 0x7f30
jmp 0x26067
leaq -0x298(%rbp), %rdi
callq 0x35f8
leaq -0x278(%rbp), %rdi
callq 0x35f8
leaq -0x258(%rbp), %rdi
callq 0x35f8
leaq -0x2b8(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0x203c0
jmp 0x260a0
leaq -0x160(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
callq 0x33c0
leaq -0x2b8(%rbp), %rdi
callq 0x35f8
leaq -0x218(%rbp), %rdi
callq 0x1d5e0
jmp 0x26279
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x39(%rbp), %rdi
callq 0x3360
jmp 0x266d3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x71(%rbp), %rdi
callq 0x3360
jmp 0x266ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x99(%rbp), %rdi
callq 0x3360
jmp 0x266c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xc1(%rbp), %rdi
callq 0x3360
jmp 0x266b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xe9(%rbp), %rdi
callq 0x3360
jmp 0x266a9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x111(%rbp), %rdi
callq 0x3360
jmp 0x2669d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x139(%rbp), %rdi
callq 0x3360
jmp 0x26691
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x161(%rbp), %rdi
callq 0x3360
jmp 0x26685
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x26260
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x35f8
jmp 0x26260
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x35f8
jmp 0x26260
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x26254
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x26248
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2623c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x298(%rbp), %rdi
callq 0x35f8
leaq -0x278(%rbp), %rdi
callq 0x35f8
leaq -0x258(%rbp), %rdi
callq 0x35f8
leaq -0x218(%rbp), %rdi
callq 0x1d5e0
movq -0x48(%rbp), %rdi
callq 0x3110
movb $0x1, -0x162(%rbp)
callq 0x34f0
jmp 0x26277
jmp 0x26279
leaq 0xf198(%rip), %rdi      # 0x35418
leaq 0x106b(%rip), %rsi      # 0x272f2
callq 0x8ba0
movb %al, -0x781(%rbp)
jmp 0x26294
movb -0x781(%rbp), %al
testb $0x1, %al
jne 0x262a3
jmp 0x2647e
leaq 0x1048(%rip), %rsi      # 0x272f2
leaq -0x138(%rbp), %rdi
callq 0x8ba0
movb %al, -0x782(%rbp)
jmp 0x262be
movb -0x782(%rbp), %al
testb $0x1, %al
jne 0x262cd
jmp 0x26449
leaq -0x138(%rbp), %rdi
callq 0x3120
movq %rax, %rsi
leaq -0x4b8(%rbp), %rdi
movl $0x10, %edx
callq 0x3370
jmp 0x262ef
leaq -0x4b8(%rbp), %rdi
callq 0x3230
movb %al, -0x783(%rbp)
jmp 0x26303
movb -0x783(%rbp), %al
testb $0x1, %al
jne 0x263e0
jmp 0x26313
leaq 0x1fe0(%rip), %rsi      # 0x282fa
leaq -0x4f8(%rbp), %rdi
leaq -0x138(%rbp), %rdx
callq 0x4ec0
jmp 0x2632f
leaq 0xdaf(%rip), %rdx       # 0x270e5
leaq -0x4d8(%rbp), %rdi
leaq -0x4f8(%rbp), %rsi
callq 0x4fd0
jmp 0x2634b
leaq -0x4d8(%rbp), %rdi
callq 0x4d40
jmp 0x26359
leaq -0x4d8(%rbp), %rdi
callq 0x35f8
leaq -0x4f8(%rbp), %rdi
callq 0x35f8
jmp 0x263e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x35f8
jmp 0x26685
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2641d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x26411
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x263d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x4d8(%rbp), %rdi
callq 0x35f8
leaq -0x4f8(%rbp), %rdi
callq 0x35f8
jmp 0x26411
leaq 0xf031(%rip), %rsi      # 0x35418
leaq -0x4b8(%rbp), %rdi
callq 0x32a0
jmp 0x263f5
leaq -0x4b8(%rbp), %rdi
callq 0x3450
jmp 0x26403
leaq -0x4b8(%rbp), %rdi
callq 0x3470
jmp 0x2647c
leaq -0x4b8(%rbp), %rdi
callq 0x3470
movq -0x48(%rbp), %rdi
callq 0x3110
movb $0x1, -0x162(%rbp)
callq 0x34f0
jmp 0x26434
jmp 0x26436
testb $0x1, -0x162(%rbp)
je 0x26480
movl $0x1, %edi
callq 0x33b0
movq 0xeba0(%rip), %rdi      # 0x34ff0
leaq 0xefc1(%rip), %rsi      # 0x35418
callq 0x32a0
movq %rax, -0x790(%rbp)
jmp 0x26465
movq -0x790(%rbp), %rdi
movq 0xeb45(%rip), %rsi      # 0x34fb8
callq 0x3340
jmp 0x2647a
jmp 0x2647c
jmp 0x2647e
jmp 0x26436
leaq 0xe6b(%rip), %rsi       # 0x272f2
leaq -0x110(%rbp), %rdi
callq 0x8ba0
movb %al, -0x791(%rbp)
jmp 0x2649b
movb -0x791(%rbp), %al
testb $0x1, %al
jne 0x264aa
jmp 0x26669
leaq -0x110(%rbp), %rdi
callq 0x3120
movq %rax, %rsi
leaq -0x6f8(%rbp), %rdi
movl $0x10, %edx
callq 0x3370
jmp 0x264cc
leaq -0x6f8(%rbp), %rdi
callq 0x3230
movb %al, -0x792(%rbp)
jmp 0x264e0
movb -0x792(%rbp), %al
testb $0x1, %al
jne 0x265a3
jmp 0x264f0
leaq 0x1e03(%rip), %rsi      # 0x282fa
leaq -0x738(%rbp), %rdi
leaq -0x110(%rbp), %rdx
callq 0x4ec0
jmp 0x2650c
leaq 0xbd2(%rip), %rdx       # 0x270e5
leaq -0x718(%rbp), %rdi
leaq -0x738(%rbp), %rsi
callq 0x4fd0
jmp 0x26528
leaq -0x718(%rbp), %rdi
callq 0x4d40
jmp 0x26536
leaq -0x718(%rbp), %rdi
callq 0x35f8
leaq -0x738(%rbp), %rdi
callq 0x35f8
jmp 0x265a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x265e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x265d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x26595
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x718(%rbp), %rdi
callq 0x35f8
leaq -0x738(%rbp), %rdi
callq 0x35f8
jmp 0x265d7
leaq -0x6f8(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x32a0
jmp 0x265b8
leaq -0x6f8(%rbp), %rdi
callq 0x3450
jmp 0x265c6
leaq -0x6f8(%rbp), %rdi
callq 0x3470
jmp 0x26680
leaq -0x6f8(%rbp), %rdi
callq 0x3470
movq -0x48(%rbp), %rdi
callq 0x3110
movb $0x1, -0x162(%rbp)
callq 0x34f0
jmp 0x265fa
jmp 0x265fc
movl $0x0, -0x4(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x35f8
leaq -0x138(%rbp), %rdi
callq 0x35f8
leaq -0x110(%rbp), %rdi
callq 0x35f8
leaq -0xe8(%rbp), %rdi
callq 0x35f8
leaq -0xc0(%rbp), %rdi
callq 0x35f8
leaq -0x98(%rbp), %rdi
callq 0x35f8
leaq -0x70(%rbp), %rdi
callq 0x35f8
leaq -0x38(%rbp), %rdi
callq 0x35f8
movl -0x4(%rbp), %eax
addq $0x7b0, %rsp            # imm = 0x7B0
popq %rbp
retq
movq 0xe960(%rip), %rdi      # 0x34fd0
leaq -0x160(%rbp), %rsi
callq 0x32a0
jmp 0x2667e
jmp 0x26680
jmp 0x265fc
leaq -0x138(%rbp), %rdi
callq 0x35f8
leaq -0x110(%rbp), %rdi
callq 0x35f8
leaq -0xe8(%rbp), %rdi
callq 0x35f8
leaq -0xc0(%rbp), %rdi
callq 0x35f8
leaq -0x98(%rbp), %rdi
callq 0x35f8
leaq -0x70(%rbp), %rdi
callq 0x35f8
leaq -0x38(%rbp), %rdi
callq 0x35f8
movq -0x48(%rbp), %rdi
callq 0x3550