// File: /workspace/github_c_makefile_star2_O0/simh[P]simtools/crossassemblers/macro1/macro1.c
// Function: main
int
main( int argc, char *argv[] )
{
    int     ix;
    int     space;

    save_argc = argc;
    save_argv = argv;

    /* Set the default values for global symbols. */
    print_permanent_symbols = FALSE;
    nomac_exp = TRUE;
    rim_mode = FALSE;			/* default to loader tapes */
    sym_dump = FALSE;
    noinput = FALSE;

    symtab_print = FALSE;
    xref = FALSE;
    pathname = NULL;

    /* init symbol table before processing arguments, so we can
     * load symbol punch tapes on the fly
     */

    /*
     * Setup the error file in case symbol table overflows while
     * installing the permanent symbols.
     */
    errorfile = stderr;
    pass = 0;				/* required for symbol table init */
    symtab = (SYM_T *) malloc( sizeof( SYM_T ) * SYMBOL_TABLE_SIZE );

    if( symtab == NULL ) {
	fprintf( stderr, "Could not allocate memory for symbol table.\n");
	exit( -1 );
    }

    init_symtab();

    /* Enter the pseudo-ops into the symbol table */
    for( ix = 0; ix < DIM( pseudos ); ix++ )
	defineSymbol( pseudos[ix].name, pseudos[ix].val, pseudos[ix].type, 0 );

    /* Enter the predefined symbols into the table. */
    /* Also make them part of the permanent symbol table. */
    for( ix = 0; ix < DIM( permanent_symbols ); ix++ )
	defineSymbol( permanent_symbols[ix].name,
		      permanent_symbols[ix].val,
		      permanent_symbols[ix].type, 0 );

    /* Get the options and pathnames */
    getArgs( argc, argv );

    /* Do pass one of the assembly */
    pass = 1;
    onePass();
    errors_pass_1 = errors;

    /* Set up for pass two */
    objectfile = fopen( objectpathname, "wb" );
    objectsave = objectfile;

    listfile = fopen( listpathname, "w" );
    listsave = listfile;

    /* XXX punch title into tape! */
    punchLeader( 0 );
    if (!rim_mode) {
	punchLoader();
	punchLeader(5);
    }

    if (nlit > 0)
	constants();			/* implied "constants"? */

    /* Do pass two of the assembly */
    errors = 0;
    save_error_count = 0;

    if( xref ) {
	/* Get the amount of space that will be required for the concordance */
	for( space = 0, ix = 0; ix < symbol_top; ix++ ) {
	    symtab[ix].xref_index = space; /* Index into concordance table. */
	    space += symtab[ix].xref_count + 1;
	    symtab[ix].xref_count = 0;	/* Clear the count for pass 2. */
	}
	/* Allocate & clear the necessary space. */
	xreftab = (WORD32 *) calloc( space, sizeof( WORD32 ));
    }
    pass = 2;
    onePass();

    objectfile = objectsave;

    /* Works great for trailer. */
    punchLeader( 1 );

    /* undo effects of NOLIST for any following output to listing file. */
    listfile = listsave;

    /* Display value of error counter. */
    if( errors == 0 ) {
	fprintf( listfile, "\n      %s %s %s\n", s_no, s_errors, s_detected );
    }
    else {
	fprintf( errorfile, "\n      %d %s %s\n", errors, s_detected,
		 ( errors == 1 ? s_error : s_errors ));
	fprintf( listfile, "\n      %d %s %s\n", errors, s_detected,
		 ( errors == 1 ? s_error : s_errors ));
    }

    if( symtab_print )
	printSymbolTable();

    if( print_permanent_symbols )
	printPermanentSymbolTable();

    if( xref )
	printCrossReference();

    fclose( objectfile );
    fclose( listfile );
    if( errors == 0 && errors_pass_1 == 0 ) {
	/* after closing objectfile -- we reuse the FILE *!! */
	if (sym_dump)
	    dump_symbols();
    }
    else
	remove( objectpathname );

    return( errors != 0 );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl -0x8(%rbp), %eax
movl %eax, 0x9a35(%rip)      # 0xbd54
movq -0x10(%rbp), %rax
movq %rax, 0x9a2e(%rip)      # 0xbd58
movb $0x0, 0x9a2f(%rip)      # 0xbd60
movb $0x1, 0x9a29(%rip)      # 0xbd61
movb $0x0, 0x9a23(%rip)      # 0xbd62
movb $0x0, 0x9a1d(%rip)      # 0xbd63
movl $0x0, 0x9a14(%rip)      # 0xbd64
movb $0x0, 0x9a11(%rip)      # 0xbd68
movb $0x0, 0x9a0b(%rip)      # 0xbd69
movq $0x0, 0x9a07(%rip) # 0xbd70
movq 0x8c88(%rip), %rax      # 0xaff8
movq (%rax), %rax
movq %rax, 0x99fe(%rip)      # 0xbd78
movl $0x0, 0x99fc(%rip)      # 0xbd80
movl $0x30000, %edi          # imm = 0x30000
callq 0x2130
movq %rax, 0x99b3(%rip)      # 0xbd48
cmpq $0x0, 0x99ab(%rip)      # 0xbd48
jne 0x23c1
movq 0x8c52(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x624a(%rip), %rsi      # 0x85fa
movb $0x0, %al
callq 0x2110
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2190
callq 0x22c0
movl $0x0, -0x14(%rbp)
movslq -0x14(%rbp), %rax
cmpq $0xc, %rax
jae 0x2428
movslq -0x14(%rbp), %rax
leaq 0x8d0e(%rip), %rdi      # 0xb0f0
imulq $0x18, %rax, %rax
addq %rax, %rdi
addq $0x4, %rdi
movslq -0x14(%rbp), %rcx
leaq 0x8cf8(%rip), %rax      # 0xb0f0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %esi
movslq -0x14(%rbp), %rcx
leaq 0x8ce3(%rip), %rax      # 0xb0f0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %edx
xorl %ecx, %ecx
callq 0x2740
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x23cd
movl $0x0, -0x14(%rbp)
movslq -0x14(%rbp), %rax
cmpq $0x53, %rax
jae 0x248a
movslq -0x14(%rbp), %rax
leaq 0x8dcc(%rip), %rdi      # 0xb210
imulq $0x18, %rax, %rax
addq %rax, %rdi
addq $0x4, %rdi
movslq -0x14(%rbp), %rcx
leaq 0x8db6(%rip), %rax      # 0xb210
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %esi
movslq -0x14(%rbp), %rcx
leaq 0x8da1(%rip), %rax      # 0xb210
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %edx
xorl %ecx, %ecx
callq 0x2740
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x242f
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x2890
movl $0x1, 0x98e0(%rip)      # 0xbd80
callq 0x2dd0
movl 0x98d9(%rip), %eax      # 0xbd84
movl %eax, 0x98d7(%rip)      # 0xbd88
leaq 0x98d8(%rip), %rdi      # 0xbd90
leaq 0x6168(%rip), %rsi      # 0x8627
callq 0x2150
movq %rax, 0x9945(%rip)      # 0xbe10
movq 0x993e(%rip), %rax      # 0xbe10
movq %rax, 0x993f(%rip)      # 0xbe18
leaq 0x9940(%rip), %rdi      # 0xbe20
leaq 0x6143(%rip), %rsi      # 0x862a
callq 0x2150
movq %rax, 0x99ad(%rip)      # 0xbea0
movq 0x99a6(%rip), %rax      # 0xbea0
movq %rax, 0x99a7(%rip)      # 0xbea8
xorl %edi, %edi
callq 0x2f80
cmpb $0x0, 0x9853(%rip)      # 0xbd62
jne 0x2520
callq 0x2ff0
movl $0x5, %edi
callq 0x2f80
cmpl $0x0, 0x9989(%rip)      # 0xbeb0
jle 0x252e
callq 0x3050
movl $0x0, 0x984c(%rip)      # 0xbd84
movl $0x0, 0x9972(%rip)      # 0xbeb4
cmpb $0x0, 0x9820(%rip)      # 0xbd69
je 0x25d7
movl $0x0, -0x18(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x97ea(%rip), %eax      # 0xbd50
jge 0x25c2
movl -0x18(%rbp), %ecx
movq 0x97d6(%rip), %rax      # 0xbd48
movslq -0x14(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
movq 0x97c1(%rip), %rax      # 0xbd48
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
addl $0x1, %eax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
movq 0x97a3(%rip), %rax      # 0xbd48
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x14(%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x255d
movslq -0x18(%rbp), %rdi
movl $0x4, %esi
callq 0x20e0
movq %rax, 0x98e1(%rip)      # 0xbeb8
movl $0x2, 0x979f(%rip)      # 0xbd80
callq 0x2dd0
movq 0x982b(%rip), %rax      # 0xbe18
movq %rax, 0x981c(%rip)      # 0xbe10
movl $0x1, %edi
callq 0x2f80
movq 0x98a3(%rip), %rax      # 0xbea8
movq %rax, 0x9894(%rip)      # 0xbea0
cmpl $0x0, 0x9771(%rip)      # 0xbd84
jne 0x2641
movq 0x9884(%rip), %rdi      # 0xbea0
leaq 0x6009(%rip), %rsi      # 0x862c
leaq 0x9420(%rip), %rdx      # 0xba4a
leaq 0x9412(%rip), %rcx      # 0xba43
leaq 0x93fc(%rip), %r8       # 0xba34
movb $0x0, %al
callq 0x2110
jmp 0x26bb
movq 0x9730(%rip), %rdi      # 0xbd78
movl 0x9736(%rip), %edx      # 0xbd84
movl 0x9730(%rip), %ecx      # 0xbd84
leaq 0x93e8(%rip), %r8       # 0xba43
leaq 0x93db(%rip), %rax      # 0xba3d
cmpl $0x1, %ecx
cmoveq %rax, %r8
leaq 0x5fcd(%rip), %rsi      # 0x863d
leaq 0x93bd(%rip), %rcx      # 0xba34
movb $0x0, %al
callq 0x2110
movq 0x981b(%rip), %rdi      # 0xbea0
movl 0x96f9(%rip), %edx      # 0xbd84
movl 0x96f3(%rip), %ecx      # 0xbd84
leaq 0x93ab(%rip), %r8       # 0xba43
leaq 0x939e(%rip), %rax      # 0xba3d
cmpl $0x1, %ecx
cmoveq %rax, %r8
leaq 0x5f90(%rip), %rsi      # 0x863d
leaq 0x9380(%rip), %rcx      # 0xba34
movb $0x0, %al
callq 0x2110
cmpb $0x0, 0x96a6(%rip)      # 0xbd68
je 0x26c9
callq 0x3130
cmpb $0x0, 0x9690(%rip)      # 0xbd60
je 0x26d7
callq 0x3240
cmpb $0x0, 0x968b(%rip)      # 0xbd69
je 0x26e5
callq 0x3350
movq 0x9724(%rip), %rdi      # 0xbe10
callq 0x2080
movq 0x97a8(%rip), %rdi      # 0xbea0
callq 0x2080
cmpl $0x0, 0x9680(%rip)      # 0xbd84
jne 0x271f
cmpl $0x0, 0x967b(%rip)      # 0xbd88
jne 0x271f
cmpb $0x0, 0x964d(%rip)      # 0xbd63
je 0x271d
callq 0x35b0
jmp 0x272b
leaq 0x966a(%rip), %rdi      # 0xbd90
callq 0x2050
cmpl $0x0, 0x9652(%rip)      # 0xbd84
setne %al
andb $0x1, %al
movzbl %al, %eax
addq $0x20, %rsp
popq %rbp
retq