// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x1, -0x14(%rbp)
leaq -0x120(%rbp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x30f0
leaq -0x130(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x30f0
leaq -0x140(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x30f0
leaq -0x168(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x30f0
leaq -0x190(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x30f0
movq $0x0, -0x198(%rbp)
leaq -0x140(%rbp), %rax
movq %rax, -0x188(%rbp)
cmpl $0x2, -0x8(%rbp)
jge 0x33e9
movq 0x1dc33(%rip), %rax     # 0x20ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
leaq 0x17c32(%rip), %rsi     # 0x1b008
movb $0x0, %al
callq 0x3140
movl $0x1, -0x4(%rbp)
jmp 0x3732
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movl $0x2, %edi
leaq 0x33f(%rip), %rsi       # 0x3740
callq 0x3180
movq $-0x1, %rcx
cmpq %rcx, %rax
je 0x36eb
leaq -0x120(%rbp), %rdx
leaq 0x1ef84(%rip), %rdi     # 0x223a8
movl $0x100000, %esi         # imm = 0x100000
callq 0xa560
cmpl $0x0, %eax
je 0x36ca
leaq -0x120(%rbp), %rsi
leaq 0x1ef63(%rip), %rdi     # 0x223a8
callq 0x17670
cmpl $0x0, %eax
je 0x36ca
leaq -0x120(%rbp), %rdx
leaq 0x1dcbf(%rip), %rdi     # 0x21120
leaq 0x1ef40(%rip), %rsi     # 0x223a8
callq 0xa260
cmpl $0x0, %eax
je 0x36ca
movq -0x20(%rbp), %rdi
leaq -0x120(%rbp), %rdx
leaq 0x1ef20(%rip), %rsi     # 0x223a8
callq 0x9f10
cmpl $0x0, %eax
je 0x36ca
movl -0x8(%rbp), %eax
subl $0x1, %eax
movl %eax, 0x1ef12(%rip)     # 0x223b4
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, 0x1ef07(%rip)     # 0x223b8
cmpq $0x0, 0x1f287(%rip)     # 0x22740
je 0x36b0
movq 0x1f27a(%rip), %rsi     # 0x22740
leaq -0x168(%rbp), %rdi
callq 0xa600
leaq 0x1eecf(%rip), %rdi     # 0x223a8
leaq -0x140(%rbp), %rsi
callq 0xa120
cmpl $0x0, %eax
je 0x3519
movq -0x150(%rbp), %rax
leaq -0x168(%rbp), %rdi
leaq -0x190(%rbp), %rsi
leaq -0x130(%rbp), %rdx
callq *%rax
cmpl $0x0, %eax
je 0x3519
movl $0x0, -0x14(%rbp)
jmp 0x3696
cmpq $0x0, -0x138(%rbp)
je 0x357d
movq -0x138(%rbp), %rax
movsbl 0x14(%rax), %eax
cmpl $0xa, %eax
jne 0x357d
movq -0x138(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x356f
movq -0x138(%rbp), %rax
movq 0x8(%rax), %rdi
movq 0x1daa5(%rip), %rax     # 0x20ff8
movq (%rax), %rsi
callq 0x30e0
movq 0x1da96(%rip), %rax     # 0x20ff8
movq (%rax), %rsi
movl $0xa, %edi
callq 0x3100
movl -0x140(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0x3694
movq 0x1da74(%rip), %rax     # 0x20ff8
movq (%rax), %rdi
movl -0x140(%rbp), %edx
leaq 0x17a91(%rip), %rsi     # 0x1b025
movb $0x0, %al
callq 0x3140
cmpq $0x0, -0x138(%rbp)
je 0x3692
movq -0x138(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x3692
movq -0x138(%rbp), %rax
movsbl 0x14(%rax), %eax
cmpl $0x2, %eax
jne 0x3622
movq -0x138(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movq -0x1a0(%rbp), %rax
cmpl $0x0, 0x40(%rax)
jle 0x3620
movq -0x1a0(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x3620
movq -0x1a0(%rbp), %rax
movq 0x20(%rax), %rax
movq (%rax), %rax
movsbl 0x14(%rax), %eax
cmpl $0x6, %eax
jne 0x3620
movq -0x1a0(%rbp), %rax
movq 0x20(%rax), %rax
movq (%rax), %rax
movq %rax, -0x198(%rbp)
jmp 0x3622
cmpq $0x0, -0x198(%rbp)
je 0x366d
movq 0x1d9c5(%rip), %rax     # 0x20ff8
movq (%rax), %rdi
movq -0x1a0(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x1a0(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %ecx
movq -0x198(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %r8
leaq 0x179da(%rip), %rsi     # 0x1b03e
movb $0x0, %al
callq 0x3140
jmp 0x3690
movq 0x1d984(%rip), %rax     # 0x20ff8
movq (%rax), %rdi
movq -0x138(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x17a04(%rip), %rsi     # 0x1b08d
movb $0x0, %al
callq 0x3140
jmp 0x3692
jmp 0x3694
jmp 0x3696
leaq -0x130(%rbp), %rdi
callq 0x3be0
leaq -0x140(%rbp), %rdi
callq 0x3be0
jmp 0x36c8
movq 0x1d941(%rip), %rax     # 0x20ff8
movq (%rax), %rdi
leaq 0x17996(%rip), %rsi     # 0x1b057
movb $0x0, %al
callq 0x3140
jmp 0x36e9
movq 0x1d927(%rip), %rax     # 0x20ff8
movq (%rax), %rdi
leaq -0x120(%rbp), %rdx
leaq 0x179ab(%rip), %rsi     # 0x1b08d
movb $0x0, %al
callq 0x3140
jmp 0x3720
movq 0x1d906(%rip), %rax     # 0x20ff8
movq (%rax), %rax
movq %rax, -0x1a8(%rbp)
callq 0x3040
movl (%rax), %edi
callq 0x3210
movq -0x1a8(%rbp), %rdi
movq %rax, %rdx
leaq 0x17952(%rip), %rsi     # 0x1b06b
movb $0x0, %al
callq 0x3140
leaq 0x1ec81(%rip), %rdi     # 0x223a8
callq 0x40e0
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
nop