// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movl %edi, %ebp
movl %edi, 0x7a61(%rip)      # 0x9d54
movq %rsi, 0x7a5e(%rip)      # 0x9d58
xorl %eax, %eax
movb %al, 0x7a5e(%rip)       # 0x9d60
movb $0x1, 0x7a58(%rip)      # 0x9d61
movb %al, 0x7a53(%rip)       # 0x9d62
andl $0x0, 0x7a4e(%rip)      # 0x9d64
movb %al, 0x7a47(%rip)       # 0x9d63
andq $0x0, 0x7a4c(%rip)      # 0x9d70
movb %al, 0x7a3e(%rip)       # 0x9d68
movb %al, 0x7a39(%rip)       # 0x9d69
movq 0x6cc1(%rip), %rax      # 0x8ff8
movq (%rax), %r14
movq %r14, 0x7a37(%rip)      # 0x9d78
andl $0x0, 0x7a38(%rip)      # 0x9d80
movl $0x30000, %edi          # imm = 0x30000
callq 0x2120
movq %rax, 0x79ef(%rip)      # 0x9d48
testq %rax, %rax
je 0x2606
movq 0x79d7(%rip), %rcx      # 0x9d40
movq %rcx, 0x10(%rax)
andl $0x0, 0x79dc(%rip)      # 0x9d50
movups 0x79b5(%rip), %xmm0     # 0x9d30
movups %xmm0, (%rax)
xorl %r14d, %r14d
leaq 0x6d68(%rip), %r15      # 0x90f0
cmpq $0x120, %r14            # imm = 0x120
je 0x23ac
leaq (%r14,%r15), %rdi
addq $0x4, %rdi
movl -0x4(%rdi), %edx
movl 0x8(%rdi), %esi
xorl %ecx, %ecx
callq 0x2623
addq $0x18, %r14
jmp 0x2388
xorl %r14d, %r14d
leaq 0x6e5a(%rip), %r15      # 0x9210
cmpq $0x7c8, %r14            # imm = 0x7C8
je 0x23da
leaq (%r14,%r15), %rdi
addq $0x4, %rdi
movl -0x4(%rdi), %edx
movl 0x8(%rdi), %esi
xorl %ecx, %ecx
callq 0x2623
addq $0x18, %r14
jmp 0x23b6
movl %ebp, %edi
movq %rbx, %rsi
callq 0x26de
movl $0x1, 0x7992(%rip)      # 0x9d80
callq 0x2a34
movl 0x798b(%rip), %eax      # 0x9d84
movl %eax, 0x7989(%rip)      # 0x9d88
leaq 0x798a(%rip), %rdi      # 0x9d90
leaq 0x40f6(%rip), %rsi      # 0x6503
callq 0x2140
movq %rax, 0x79f7(%rip)      # 0x9e10
movq %rax, 0x79f8(%rip)      # 0x9e18
leaq 0x79f9(%rip), %rdi      # 0x9e20
leaq 0x40d8(%rip), %rsi      # 0x6506
callq 0x2140
movq %rax, 0x7a66(%rip)      # 0x9ea0
movq %rax, 0x7a67(%rip)      # 0x9ea8
xorl %edi, %edi
callq 0x2b78
cmpb $0x0, 0x7913(%rip)      # 0x9d62
jne 0x245e
callq 0x2ba9
pushq $0x5
popq %rdi
callq 0x2b78
cmpl $0x0, 0x7a4b(%rip)      # 0x9eb0
jle 0x246c
callq 0x2bef
andl $0x0, 0x7911(%rip)      # 0x9d84
andl $0x0, 0x7a3a(%rip)      # 0x9eb4
cmpb $0x0, 0x78e8(%rip)      # 0x9d69
je 0x24c5
movq 0x78be(%rip), %rax      # 0x9d48
addq $0x14, %rax
xorl %ecx, %ecx
xorl %edx, %edx
movslq 0x78b7(%rip), %rsi      # 0x9d50
cmpq %rsi, %rcx
jge 0x24b3
movl %edx, -0x4(%rax)
movl (%rax), %esi
andl $0x0, (%rax)
addl %esi, %edx
incl %edx
incq %rcx
addq $0x18, %rax
jmp 0x2492
movslq %edx, %rdi
pushq $0x4
popq %rsi
callq 0x20e0
movq %rax, 0x79f3(%rip)      # 0x9eb8
movl $0x2, 0x78b1(%rip)      # 0x9d80
callq 0x2a34
movq 0x793d(%rip), %rax      # 0x9e18
movq %rax, 0x792e(%rip)      # 0x9e10
pushq $0x1
popq %rdi
callq 0x2b78
movq 0x79b7(%rip), %rdi      # 0x9ea8
movq %rdi, 0x79a8(%rip)      # 0x9ea0
movl 0x7886(%rip), %edx      # 0x9d84
testl %edx, %edx
je 0x2562
movq 0x786f(%rip), %rdi      # 0x9d78
cmpl $0x1, %edx
leaq 0x752a(%rip), %r12      # 0x9a3d
leaq 0x7529(%rip), %rbx      # 0x9a43
movq %rbx, %r8
cmoveq %r12, %r8
leaq 0x3ff1(%rip), %r14      # 0x6519
leaq 0x7505(%rip), %r15      # 0x9a34
movq %r14, %rsi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2110
movq 0x795d(%rip), %rdi      # 0x9ea0
movl 0x783b(%rip), %edx      # 0x9d84
cmpl $0x1, %edx
cmoveq %r12, %rbx
movq %r14, %rsi
movq %r15, %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0x2110
jmp 0x2585
leaq 0x3f9f(%rip), %rsi      # 0x6508
leaq 0x74da(%rip), %rdx      # 0x9a4a
leaq 0x74cc(%rip), %rcx      # 0x9a43
leaq 0x74b6(%rip), %r8       # 0x9a34
xorl %eax, %eax
callq 0x2110
cmpb $0x0, 0x77dc(%rip)      # 0x9d68
je 0x2593
callq 0x2cc5
cmpb $0x0, 0x77c6(%rip)      # 0x9d60
je 0x25a1
callq 0x2d87
cmpb $0x0, 0x77c1(%rip)      # 0x9d69
je 0x25af
callq 0x2e5d
movq 0x785a(%rip), %rdi      # 0x9e10
callq 0x2080
movq 0x78de(%rip), %rdi      # 0x9ea0
callq 0x2080
movl 0x77bb(%rip), %eax      # 0x9d88
orl 0x77b1(%rip), %eax      # 0x9d84
jne 0x25e5
cmpb $0x0, 0x7787(%rip)      # 0x9d63
je 0x25f1
callq 0x304b
jmp 0x25f1
leaq 0x77a4(%rip), %rdi      # 0x9d90
callq 0x2050
xorl %eax, %eax
cmpl $0x0, 0x778a(%rip)      # 0x9d84
setne %al
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3ec9(%rip), %rdi      # 0x64d6
pushq $0x2c
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0x2180
pushq $-0x1
popq %rdi
callq 0x2170