// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %rsi, %rbx
movl %edi, %ebp
callq 0x3cec
movl $0x1, 0x4(%rsp)
leaq 0x9e4(%rip), %r15       # 0x1130f
leaq 0xc8(%rsp), %rdi
leaq 0x208(%rsp), %rdx
movq %r15, %rsi
callq 0x3e82
leaq 0x1e8(%rsp), %r14
leaq 0x208(%rsp), %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x3e82
leaq 0x9aa(%rip), %rsi       # 0x1130f
leaq 0x1c8(%rsp), %r15
leaq 0x208(%rsp), %rdx
movq %r15, %rdi
callq 0x3e82
leaq 0x98b(%rip), %rsi       # 0x1130f
leaq 0xa8(%rsp), %rdi
leaq 0x208(%rsp), %rdx
callq 0x3e82
leaq 0x96f(%rip), %rsi       # 0x1130f
leaq 0x88(%rsp), %rdi
leaq 0x208(%rsp), %rdx
callq 0x3e82
leaq 0x953(%rip), %rsi       # 0x1130f
leaq 0x48(%rsp), %rdi
leaq 0x208(%rsp), %rdx
callq 0x3e82
leaq 0x93a(%rip), %rsi       # 0x1130f
leaq 0x28(%rsp), %rdi
leaq 0x208(%rsp), %rdx
callq 0x3e82
leaq 0x921(%rip), %rsi       # 0x1130f
leaq 0x68(%rsp), %rdi
leaq 0x208(%rsp), %rdx
callq 0x3e82
subq $0x8, %rsp
leaq 0xc(%rsp), %rax
leaq 0xb0(%rsp), %rdx
leaq 0x50(%rsp), %rcx
leaq 0x30(%rsp), %r8
leaq 0xd0(%rsp), %r9
movl %ebp, %edi
movq %rbx, %rsi
pushq %r14
pushq %r15
pushq %rax
callq 0xfede
addq $0x20, %rsp
leaq 0x1a8(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x32e0
leaq 0x208(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x7f98
leaq 0x88(%rsp), %rdi
leaq 0x208(%rsp), %rbx
movq %rbx, %rsi
callq 0x32a0
movq %rbx, %rdi
callq 0x3458
leaq 0x1a8(%rsp), %rdi
callq 0x3458
leaq 0x188(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x32e0
movl 0x4(%rsp), %edx
leaq 0x208(%rsp), %rdi
leaq 0x188(%rsp), %rsi
callq 0xd6bc
leaq 0x188(%rsp), %rdi
callq 0x3458
leaq 0x168(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x32e0
leaq 0x148(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
callq 0x32e0
leaq 0x128(%rsp), %rdi
leaq 0x1e8(%rsp), %rsi
callq 0x32e0
leaq 0x208(%rsp), %rdi
leaq 0x168(%rsp), %rsi
leaq 0x148(%rsp), %rdx
leaq 0x128(%rsp), %rcx
callq 0x5a41
leaq 0x128(%rsp), %rdi
callq 0x3458
leaq 0x148(%rsp), %rdi
callq 0x3458
leaq 0x168(%rsp), %rdi
callq 0x3458
leaq 0x8(%rsp), %rdi
leaq 0x208(%rsp), %rsi
callq 0xebc4
leaq 0x68(%rsp), %rdi
leaq 0x8(%rsp), %rbx
movq %rbx, %rsi
callq 0x32a0
movq %rbx, %rdi
callq 0x3458
leaq 0x208(%rsp), %rdi
callq 0xd786
xorl %ebx, %ebx
leaq 0x87b3(%rip), %rdi      # 0x19348
leaq 0x773(%rip), %rsi       # 0x1130f
callq 0x62e5
testb %al, %al
je 0x10c86
leaq 0x75f(%rip), %rsi       # 0x1130f
leaq 0x28(%rsp), %rdi
callq 0x62e5
testb %al, %al
je 0x10c6b
movq 0x28(%rsp), %rsi
leaq 0x208(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x3280
leaq 0x278(%rsp), %rdi
callq 0x3090
testb %al, %al
jne 0x10c3b
leaq 0x16dd(%rip), %rsi      # 0x122cc
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x3ebd
leaq 0x4fd(%rip), %rdx       # 0x11102
leaq 0x108(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x3f33
leaq 0x108(%rsp), %rdi
callq 0x3dec
leaq 0x108(%rsp), %rdi
callq 0x3458
leaq 0x8(%rsp), %rdi
callq 0x3458
leaq 0x8706(%rip), %rsi      # 0x19348
leaq 0x208(%rsp), %rdi
callq 0x3210
leaq 0x208(%rsp), %rdi
callq 0x3300
leaq 0x208(%rsp), %rdi
callq 0x3320
jmp 0x10c86
movq 0x837e(%rip), %rdi      # 0x18ff0
leaq 0x86cf(%rip), %rsi      # 0x19348
callq 0x3210
movq %rax, %rdi
callq 0x3120
testb %bl, %bl
jne 0x10e3f
leaq 0x67a(%rip), %rsi       # 0x1130f
leaq 0x48(%rsp), %rdi
callq 0x62e5
testb %al, %al
je 0x10d4e
movq 0x48(%rsp), %rsi
leaq 0x208(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x3280
leaq 0x278(%rsp), %rdi
callq 0x3090
testb %al, %al
jne 0x10d20
leaq 0x15f8(%rip), %rsi      # 0x122cc
leaq 0x8(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x3ebd
leaq 0x418(%rip), %rdx       # 0x11102
leaq 0xe8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x3f33
leaq 0xe8(%rsp), %rdi
callq 0x3dec
leaq 0xe8(%rsp), %rdi
callq 0x3458
leaq 0x8(%rsp), %rdi
callq 0x3458
leaq 0x208(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x3210
leaq 0x208(%rsp), %rdi
callq 0x3300
leaq 0x208(%rsp), %rdi
callq 0x3320
jmp 0x10d5f
movq 0x827b(%rip), %rdi      # 0x18fd0
leaq 0x68(%rsp), %rsi
callq 0x3210
leaq 0x68(%rsp), %rdi
callq 0x3458
leaq 0x28(%rsp), %rdi
callq 0x3458
leaq 0x48(%rsp), %rdi
callq 0x3458
leaq 0x88(%rsp), %rdi
callq 0x3458
leaq 0xa8(%rsp), %rdi
callq 0x3458
leaq 0x1c8(%rsp), %rdi
callq 0x3458
leaq 0x1e8(%rsp), %rdi
callq 0x3458
leaq 0xc8(%rsp), %rdi
callq 0x3458
xorl %eax, %eax
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x3458
jmp 0x10de3
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3458
jmp 0x10e19
jmp 0x10e16
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x3458
jmp 0x10e06
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3458
jmp 0x10e82
jmp 0x10e7f
jmp 0x10e2f
movq %rax, %rbx
leaq 0x208(%rsp), %rdi
callq 0x3320
jmp 0x10e32
jmp 0x10e2a
movq %rax, %rbx
jmp 0x10e8f
movq %rax, %rbx
movq %rbx, %rdi
callq 0x30f0
callq 0x3390
pushq $0x1
popq %rdi
callq 0x3290
jmp 0x10ea1
movq %rax, %rbx
leaq 0x128(%rsp), %rdi
callq 0x3458
jmp 0x10e5e
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0x3458
jmp 0x10e70
movq %rax, %rbx
leaq 0x168(%rsp), %rdi
callq 0x3458
jmp 0x10ea4
movq %rax, %rbx
leaq 0x208(%rsp), %rdi
callq 0x3320
movq %rbx, %rdi
callq 0x30f0
callq 0x3390
jmp 0x10d5f
movq %rax, %rbx
leaq 0x208(%rsp), %rdi
callq 0xd786
jmp 0x10ed9
movq %rax, %rbx
leaq 0x188(%rsp), %rdi
jmp 0x10ecd
jmp 0x10ed6
movq %rax, %rbx
leaq 0x1a8(%rsp), %rdi
callq 0x3458
jmp 0x10ed9
jmp 0x10ed6
movq %rax, %rbx
movq %rbx, %rdi
callq 0x30f0
movb $0x1, %bl
callq 0x3390
jmp 0x10b8e
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x3458
jmp 0x10eff
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x3458
jmp 0x10f0e
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x3458
jmp 0x10f1d
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x3458
jmp 0x10f2f
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x3458
leaq 0x1c8(%rsp), %rdi
callq 0x3458
leaq 0x1e8(%rsp), %rdi
callq 0x3458
leaq 0xc8(%rsp), %rdi
callq 0x3458
movq %rbx, %rdi
callq 0x33d0
movq %rax, %rbx
jmp 0x10f3c
movq %rax, %rbx
jmp 0x10f49
movq %rax, %rbx
jmp 0x10f56