// File: /workspace/github_c_makefile_star2_O1/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 0x361c
movq 0x8(%rbx), %r14
leaq 0x19e(%rip), %rsi       # 0x3679
movl $0x2, %edi
callq 0x3190
cmpq $-0x1, %rax
je 0x362b
leaq 0x16bc2(%rip), %rdi     # 0x1a0b8
leaq 0x90(%rsp), %rdx
movl $0x100000, %esi         # imm = 0x100000
callq 0x7f0d
testl %eax, %eax
je 0x35fa
leaq 0x16ba1(%rip), %rdi     # 0x1a0b8
leaq 0x90(%rsp), %rsi
callq 0x10aaa
testl %eax, %eax
je 0x35fa
leaq 0x15bfd(%rip), %rdi     # 0x19130
leaq 0x16b7e(%rip), %rsi     # 0x1a0b8
leaq 0x90(%rsp), %rdx
callq 0x7d09
testl %eax, %eax
je 0x35fa
leaq 0x16b62(%rip), %rsi     # 0x1a0b8
leaq 0x90(%rsp), %rdx
movq %r14, %rdi
callq 0x7a37
testl %eax, %eax
je 0x35fa
addq $0x8, %rbx
decl %ebp
movl %ebp, 0x16b4a(%rip)     # 0x1a0c4
movq %rbx, 0x16b47(%rip)     # 0x1a0c8
movq 0x16ec8(%rip), %rsi     # 0x1a450
testq %rsi, %rsi
je 0x364b
leaq 0x60(%rsp), %rdi
callq 0x7f7a
leaq 0x16b16(%rip), %rdi     # 0x1a0b8
movq %rsp, %rsi
callq 0x7c3b
testl %eax, %eax
je 0x35c6
leaq 0x60(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq *0x18(%rdi)
xorl %ebx, %ebx
testl %eax, %eax
jne 0x35e6
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x3632
cmpb $0xa, 0x14(%rax)
jne 0x3632
movq 0x8(%rax), %rdi
testq %rdi, %rdi
jne 0x366f
movl (%rsp), %ebx
leaq 0x20(%rsp), %rdi
callq 0x3957
movq %rsp, %rdi
callq 0x3957
jmp 0x3655
movq 0x159f7(%rip), %rax     # 0x18ff8
movq (%rax), %rdi
leaq 0xea82(%rip), %rsi      # 0x1208d
leaq 0x90(%rsp), %rdx
xorl %eax, %eax
callq 0x3150
jmp 0x3650
movq %rbx, %rdi
callq 0x334d
movl $0x1, %ebx
jmp 0x3661
callq 0x3320
jmp 0x3650
leaq 0x8(%rsp), %rsi
movq %rsp, %rdi
leaq 0x1c(%rsp), %rbx
movq %rbx, %rdx
callq 0x325d
movl (%rbx), %ebx
jmp 0x35e6
callq 0x32fe
movl $0x1, %ebx
leaq 0x16a5c(%rip), %rdi     # 0x1a0b8
callq 0x3bb8
movl %ebx, %eax
addq $0x190, %rsp            # imm = 0x190
popq %rbx
popq %r14
popq %rbp
retq
callq 0x3240
jmp 0x35e3