// File: /workspace/github_c_makefile_star2_O2/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 $0x180, %rsp            # imm = 0x180
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x80(%rsp), %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x30f0
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq %rsp, %rax
movaps %xmm0, (%rax)
movaps %xmm0, 0x60(%rsp)
andq $0x0, 0x70(%rsp)
movaps %xmm0, 0x50(%rsp)
andq $0x0, 0x40(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x30(%rsp)
movq %rax, 0x28(%rsp)
cmpl $0x1, %ebp
jle 0x34d7
movq 0x8(%rbx), %r14
leaq 0x278(%rip), %rsi       # 0x360f
pushq $0x2
popq %rdi
callq 0x3190
cmpq $-0x1, %rax
je 0x34f7
leaq 0x16008(%rip), %rdi     # 0x193b8
leaq 0x80(%rsp), %rdx
movl $0x100000, %esi         # imm = 0x100000
callq 0x777a
testl %eax, %eax
je 0x34bc
leaq 0x15fe7(%rip), %rdi     # 0x193b8
leaq 0x80(%rsp), %rsi
callq 0xf840
testl %eax, %eax
je 0x34bc
leaq 0x14d43(%rip), %rdi     # 0x18130
leaq 0x15fc4(%rip), %rsi     # 0x193b8
leaq 0x80(%rsp), %rdx
callq 0x75ba
testl %eax, %eax
je 0x34bc
leaq 0x15fa8(%rip), %rsi     # 0x193b8
leaq 0x80(%rsp), %rdx
movq %r14, %rdi
callq 0x734b
testl %eax, %eax
je 0x34bc
addq $0x8, %rbx
decl %ebp
movl %ebp, 0x15f90(%rip)     # 0x193c4
movq %rbx, 0x15f8d(%rip)     # 0x193c8
movq 0x1630e(%rip), %rsi     # 0x19750
testq %rsi, %rsi
je 0x35b9
leaq 0x50(%rsp), %rdi
callq 0x77e7
leaq 0x15f5c(%rip), %rdi     # 0x193b8
movq %rsp, %rsi
callq 0x74ff
testl %eax, %eax
je 0x3480
leaq 0x50(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq *0x18(%rdi)
xorl %ebx, %ebx
testl %eax, %eax
jne 0x34a8
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x353e
cmpb $0xa, 0x14(%rax)
jne 0x353e
movq 0x8(%rax), %rdi
testq %rdi, %rdi
jne 0x35da
movl (%rsp), %ebx
leaq 0x10(%rsp), %rdi
callq 0x3896
movq %rsp, %rdi
callq 0x3896
jmp 0x3524
movq 0x14b35(%rip), %rax     # 0x17ff8
movq (%rax), %rdi
leaq 0xdbc0(%rip), %rsi      # 0x1108d
leaq 0x80(%rsp), %rdx
jmp 0x351a
movq 0x14b1a(%rip), %rax     # 0x17ff8
movq (%rax), %rdi
movq (%rbx), %rdx
leaq 0xdb1d(%rip), %rsi      # 0x11008
xorl %eax, %eax
callq 0x3150
pushq $0x1
popq %rbx
jmp 0x3530
movq 0x14afa(%rip), %rax     # 0x17ff8
movq (%rax), %rbx
callq 0x3040
movl (%rax), %edi
callq 0x3220
leaq 0xdb57(%rip), %rsi      # 0x1106b
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3150
pushq $0x1
popq %rbx
leaq 0x15e8d(%rip), %rdi     # 0x193b8
callq 0x3aaf
movl %ebx, %eax
addq $0x180, %rsp            # imm = 0x180
popq %rbx
popq %r14
popq %rbp
retq
movq 0x14ab3(%rip), %r14     # 0x17ff8
movq (%r14), %rdi
movl (%rsp), %edx
leaq 0xdad3(%rip), %rsi      # 0x11025
xorl %eax, %eax
callq 0x3150
movq 0x8(%rsp), %rax
pushq $0x1
popq %rbx
testq %rax, %rax
je 0x34a8
movq 0x8(%rax), %rdx
testq %rdx, %rdx
je 0x34a8
cmpb $0x2, 0x14(%rax)
jne 0x35f9
cmpl $0x0, 0x40(%rax)
jle 0x35f9
movq 0x20(%rax), %rcx
testq %rcx, %rcx
je 0x35f9
movq (%rcx), %rsi
cmpb $0x6, 0x14(%rsi)
jne 0x35f9
movq (%r14), %rdi
movq 0x18(%rax), %rax
movl (%rax), %ecx
movq 0x28(%rsi), %rax
movq 0x8(%rax), %r8
leaq 0xda91(%rip), %rsi      # 0x1103e
xorl %eax, %eax
callq 0x3150
jmp 0x34a8
movq 0x14a38(%rip), %rax     # 0x17ff8
movq (%rax), %rcx
leaq 0xda8d(%rip), %rdi      # 0x11057
pushq $0x13
popq %rsi
pushq $0x1
popq %rdx
callq 0x3210
jmp 0x3521
movq 0x14a17(%rip), %rbx     # 0x17ff8
movq (%rbx), %rsi
callq 0x30e0
movq (%rbx), %rsi
pushq $0xa
popq %rdi
callq 0x3100
jmp 0x34a5
movq (%r14), %rdi
leaq 0xda8a(%rip), %rsi      # 0x1108d
xorl %eax, %eax
callq 0x3150
jmp 0x34a8