// File: /workspace/github_c_makefile_star2_O3/martincameron[P]towntalk/tt.c
// Function: main
int main( int argc, char **argv ) {
	int exit_code = EXIT_FAILURE;
	char *file_name, message[ 256 ] = "";
	struct variable result = { 0 }, except = { 0 };
	struct function_expression expr = { 0 };
	struct variables vars = { 0 };
	struct function *func = NULL;
	struct array *arr;
	vars.exception = &except;
	/* Handle command-line.*/
	if( argc < 2 ) {
		fprintf( stderr, "Usage: %s program.tt [args]\n", argv[ 0 ] );
		return EXIT_FAILURE;
	}
	file_name = argv[ 1 ];
	/* Install signal handler. */
	if( signal( SIGINT, interrupt_handler ) != SIG_ERR ) {
		/* Parse program file. */
		if( initialize_environment( &env, MAX_STACK, message )
		&& initialize_worker_extension( &env, message )
#if defined( ASM_STATEMENT )
		&& add_statements( asm_keyword, &env, message )
#endif
		&& parse_tt_file( file_name, &env, message ) ) {
			env.argc = argc - 1;
			env.argv = &argv[ 1 ];
			if( env.entry_point ) {
				/* Evaluate the last entry-point function. */
				initialize_entry_point( &expr, env.entry_point );
				if( initialize_globals( &env, &except ) && expr.expr.evaluate( &expr.expr, &vars, &result ) ) {
					exit_code = EXIT_SUCCESS;
				} else if( except.string_value && except.string_value->type == EXIT ) {
					if( except.string_value->string ) {
						fputs( except.string_value->string, stderr );
						fputc( '\n', stderr );
					}
					exit_code = except.number_value;
				} else {
					fprintf( stderr, "Unhandled exception %d.\n", ( int ) except.number_value );
					if( except.string_value && except.string_value->string ) {
						if( except.string_value->type == ARRAY ) {
							arr = ( struct array * ) except.string_value;
							if( arr->length > 0 && arr->string_values && arr->string_values[ 0 ]->type == FUNCTION ) {
								/* Stack-trace. */
								func = ( struct function * ) arr->string_values[ 0 ];
							}
						}
						if( func ) {
							fprintf( stderr, "%s (on line %d of '%s')\n", arr->str.string, ( int ) arr->number_values[ 0 ], func->file->string );
						} else {
							fprintf( stderr, "%s\n", except.string_value->string );
						}
					}
				}
				dispose_variable( &result );
				dispose_variable( &except );
			} else {
				fprintf( stderr, "No programs found.\n" );
			}
		} else {
			fprintf( stderr, "%s\n", message );
		}
	}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x190, %rsp            # imm = 0x190
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x90(%rsp), %rdi
xorl %r14d, %r14d
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x30f0
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq %rsp, %rax
movaps %xmm0, (%rax)
movq %r14, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x30(%rsp)
movq %r14, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movq %rax, 0x38(%rsp)
cmpl $0x1, %ebp
jle 0x360c
movq 0x8(%rbx), %r14
leaq 0x19e(%rip), %rsi       # 0x3669
movl $0x2, %edi
callq 0x3190
cmpq $-0x1, %rax
je 0x361b
leaq 0x16bd2(%rip), %rdi     # 0x1a0b8
leaq 0x90(%rsp), %rdx
movl $0x100000, %esi         # imm = 0x100000
callq 0x7d8c
testl %eax, %eax
je 0x35ea
leaq 0x16bb1(%rip), %rdi     # 0x1a0b8
leaq 0x90(%rsp), %rsi
callq 0x107b1
testl %eax, %eax
je 0x35ea
leaq 0x15c0d(%rip), %rdi     # 0x19130
leaq 0x16b8e(%rip), %rsi     # 0x1a0b8
leaq 0x90(%rsp), %rdx
callq 0x7b88
testl %eax, %eax
je 0x35ea
leaq 0x16b72(%rip), %rsi     # 0x1a0b8
leaq 0x90(%rsp), %rdx
movq %r14, %rdi
callq 0x78ed
testl %eax, %eax
je 0x35ea
addq $0x8, %rbx
decl %ebp
movl %ebp, 0x16b5a(%rip)     # 0x1a0c4
movq %rbx, 0x16b57(%rip)     # 0x1a0c8
movq 0x16ed8(%rip), %rsi     # 0x1a450
testq %rsi, %rsi
je 0x363b
leaq 0x60(%rsp), %rdi
callq 0x7df9
leaq 0x16b26(%rip), %rdi     # 0x1a0b8
movq %rsp, %rsi
callq 0x7abf
testl %eax, %eax
je 0x35b6
leaq 0x60(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq *0x18(%rdi)
xorl %ebx, %ebx
testl %eax, %eax
jne 0x35d6
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x3622
cmpb $0xa, 0x14(%rax)
jne 0x3622
movq 0x8(%rax), %rdi
testq %rdi, %rdi
jne 0x365f
movl (%rsp), %ebx
leaq 0x20(%rsp), %rdi
callq 0x392b
movq %rsp, %rdi
callq 0x392b
jmp 0x3645
movq 0x15a07(%rip), %rax     # 0x18ff8
movq (%rax), %rdi
leaq 0xea92(%rip), %rsi      # 0x1208d
leaq 0x90(%rsp), %rdx
xorl %eax, %eax
callq 0x3150
jmp 0x3640
movq %rbx, %rdi
callq 0x3343
movl $0x1, %ebx
jmp 0x3651
callq 0x3316
jmp 0x3640
leaq 0x8(%rsp), %rsi
movq %rsp, %rdi
leaq 0x1c(%rsp), %rbx
movq %rbx, %rdx
callq 0x325d
movl (%rbx), %ebx
jmp 0x35d6
callq 0x32f4
movl $0x1, %ebx
leaq 0x16a6c(%rip), %rdi     # 0x1a0b8
callq 0x3b86
movl %ebx, %eax
addq $0x190, %rsp            # imm = 0x190
popq %rbx
popq %r14
popq %rbp
retq
callq 0x3240
jmp 0x35d3