// File: /workspace/github_c_makefile_star2_O3/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, 0x776e(%rip)      # 0x9d54
movq %rsi, 0x776b(%rip)      # 0x9d58
xorl %eax, %eax
movb %al, 0x776b(%rip)       # 0x9d60
movb $0x1, 0x7765(%rip)      # 0x9d61
movb %al, 0x7760(%rip)       # 0x9d62
movb %al, 0x775b(%rip)       # 0x9d63
movl %eax, 0x7756(%rip)      # 0x9d64
movb %al, 0x7754(%rip)       # 0x9d68
movb %al, 0x774f(%rip)       # 0x9d69
movq $0x0, 0x774b(%rip) # 0x9d70
movq 0x69cc(%rip), %rcx      # 0x8ff8
movq (%rcx), %r14
movq %r14, 0x7742(%rip)      # 0x9d78
movl %eax, 0x7744(%rip)      # 0x9d80
movl $0x30000, %edi          # imm = 0x30000
callq 0x2120
movq %rax, 0x76fb(%rip)      # 0x9d48
testq %rax, %rax
je 0x2923
movq 0x76e3(%rip), %rcx      # 0x9d40
movq %rcx, 0x10(%rax)
movups 0x76c8(%rip), %xmm0     # 0x9d30
movups %xmm0, (%rax)
movl $0x0, 0x76db(%rip)      # 0x9d50
xorl %r14d, %r14d
leaq 0x6a71(%rip), %r15      # 0x90f0
leaq (%r14,%r15), %rdi
addq $0x4, %rdi
movl -0x4(%rdi), %edx
movl 0x8(%rdi), %esi
xorl %ecx, %ecx
callq 0x292b
addq $0x18, %r14
cmpq $0x120, %r14            # imm = 0x120
jne 0x267f
xorl %r14d, %r14d
leaq 0x6b65(%rip), %r15      # 0x9210
leaq (%r14,%r15), %rdi
addq $0x4, %rdi
movl -0x4(%rdi), %edx
movl 0x8(%rdi), %esi
xorl %ecx, %ecx
callq 0x292b
addq $0x18, %r14
cmpq $0x7c8, %r14            # imm = 0x7C8
jne 0x26ab
movl %ebp, %edi
movq %rbx, %rsi
callq 0x29e7
movl $0x1, 0x769f(%rip)      # 0x9d80
callq 0x2c7d
movl 0x7698(%rip), %eax      # 0x9d84
movl %eax, 0x7696(%rip)      # 0x9d88
leaq 0x7697(%rip), %rdi      # 0x9d90
leaq 0x3e33(%rip), %rsi      # 0x6533
callq 0x2140
movq %rax, 0x7704(%rip)      # 0x9e10
movq %rax, 0x7705(%rip)      # 0x9e18
leaq 0x7706(%rip), %rdi      # 0x9e20
leaq 0x3e15(%rip), %rsi      # 0x6536
callq 0x2140
movq %rax, 0x7773(%rip)      # 0x9ea0
movq %rax, 0x7774(%rip)      # 0x9ea8
cmpq $0x0, 0x76d4(%rip)      # 0x9e10
je 0x2755
movl $0xf0, %ebx
movq 0x76c6(%rip), %rsi      # 0x9e10
xorl %edi, %edi
callq 0x20c0
decl %ebx
jne 0x2743
cmpb $0x0, 0x7606(%rip)      # 0x9d62
jne 0x276d
callq 0x2dd4
movl $0x5, %edi
callq 0x2da1
cmpl $0x0, 0x773c(%rip)      # 0x9eb0
jle 0x277b
callq 0x2e26
xorl %eax, %eax
movl %eax, 0x7601(%rip)      # 0x9d84
movl %eax, 0x772b(%rip)      # 0x9eb4
cmpb $0x0, 0x75d9(%rip)      # 0x9d69
je 0x27e0
xorl %edi, %edi
cmpl $0x0, 0x75b5(%rip)      # 0x9d50
jle 0x27cf
movq 0x75a4(%rip), %rax      # 0x9d48
addq $0x14, %rax
xorl %ecx, %ecx
movl %edi, -0x4(%rax)
movl (%rax), %edx
addl %edx, %edi
incl %edi
movl $0x0, (%rax)
incq %rcx
movslq 0x758d(%rip), %rdx      # 0x9d50
addq $0x18, %rax
cmpq %rdx, %rcx
jl 0x27aa
movslq %edi, %rdi
movl $0x4, %esi
callq 0x20e0
movq %rax, 0x76d8(%rip)      # 0x9eb8
movl $0x2, 0x7596(%rip)      # 0x9d80
callq 0x2c7d
movq 0x7622(%rip), %rax      # 0x9e18
movq %rax, 0x7613(%rip)      # 0x9e10
movl $0x1, %edi
callq 0x2da1
movq 0x769a(%rip), %rdi      # 0x9ea8
movq %rdi, 0x768b(%rip)      # 0x9ea0
movl 0x7569(%rip), %edx      # 0x9d84
testl %edx, %edx
je 0x287f
movq 0x7552(%rip), %rdi      # 0x9d78
cmpl $0x1, %edx
leaq 0x720d(%rip), %r12      # 0x9a3d
leaq 0x720c(%rip), %rbx      # 0x9a43
movq %rbx, %r8
cmoveq %r12, %r8
leaq 0x3d04(%rip), %r14      # 0x6549
leaq 0x71e8(%rip), %r15      # 0x9a34
movq %r14, %rsi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2110
movq 0x7640(%rip), %rdi      # 0x9ea0
movl 0x751e(%rip), %edx      # 0x9d84
cmpl $0x1, %edx
cmoveq %r12, %rbx
movq %r14, %rsi
movq %r15, %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0x2110
jmp 0x28a2
leaq 0x3cb2(%rip), %rsi      # 0x6538
leaq 0x71bd(%rip), %rdx      # 0x9a4a
leaq 0x71af(%rip), %rcx      # 0x9a43
leaq 0x7199(%rip), %r8       # 0x9a34
xorl %eax, %eax
callq 0x2110
cmpb $0x0, 0x74bf(%rip)      # 0x9d68
je 0x28b0
callq 0x2f34
cmpb $0x0, 0x74a9(%rip)      # 0x9d60
je 0x28be
callq 0x2ffa
cmpb $0x0, 0x74a4(%rip)      # 0x9d69
je 0x28cc
callq 0x30df
movq 0x753d(%rip), %rdi      # 0x9e10
callq 0x2080
movq 0x75c1(%rip), %rdi      # 0x9ea0
callq 0x2080
movl 0x749e(%rip), %eax      # 0x9d88
orl 0x7494(%rip), %eax      # 0x9d84
jne 0x2902
cmpb $0x0, 0x746a(%rip)      # 0x9d63
je 0x290e
callq 0x32cc
jmp 0x290e
leaq 0x7487(%rip), %rdi      # 0x9d90
callq 0x2050
xorl %eax, %eax
cmpl $0x0, 0x746d(%rip)      # 0x9d84
setne %al
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0x21d0