// File: /workspace/github_c_makefile_star2_O0/simh[P]simtools/crossassemblers/macro8x/macro8x.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.                               */
  binary_data_output = FALSE;
  fltg_input = FALSE;
  nomac_exp = TRUE;
  print_permanent_symbols = FALSE;
  rim_mode = FALSE;
  symtab_print = FALSE;
  xref = FALSE;
  pathname = NULL;
  for( ix = 0; ix < MAC_TABLE_LENGTH; ix++ )
  {
    mac_bodies[ix] = NULL;
  }

  /* Get the options and pathnames                                            */
  getArgs( argc, argv );

  /* Setup the error file in case symbol table overflows while installing the */
  /* permanent symbols.                                                       */
  errorfile = fopen( errorpathname, "w" );
  errors = 0;
  save_error_count = 0;
  pass = 0;             /* This is required for symbol table initialization.  */
  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 );
  }

  /* Place end marker in symbol table.                                        */
  symtab[0] = sym_undefined;
  symbol_top = 0;
  number_of_fixed_symbols = symbol_top;
  fixed_symbols = &symtab[symbol_top - 1];

  /* Enter the pseudo-ops into the symbol table                               */
  for( ix = 0; ix < DIM( pseudo ); ix++ )
  {
    defineSymbol( pseudo[ix].name, pseudo[ix].val, pseudo[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 | DEFFIX , 0 );
  }

  number_of_fixed_symbols = symbol_top;
  fixed_symbols = &symtab[symbol_top - 1];

  /* Do pass one of the assembly                                              */
  checksum = 0;
  pass = 1;
  onePass();
  errors_pass_1 = errors;
  fclose ( errorfile );

  /* Set up for pass two                                                      */
  errorfile = fopen( errorpathname, "w" );
  objectfile = fopen( objectpathname, "wb" );
  objectsave = objectfile;

  listfile = fopen( listpathname, "w" );
  listsave = listfile;

  punchLeader( 0 );
  checksum = 0;

  /* 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 the necessary space.                                          */
    xreftab = (WORD32 *) malloc( sizeof( WORD32 ) * space );

    /* Clear the cross reference space.                                       */
    for( ix = 0; ix < space; ix++ )
    {
      xreftab[ix] = 0;
    }
  }
  pass = 2;
  onePass();

  /* Undo effects of NOPUNCH for any following checksum                       */
  objectfile = objectsave;
  punchChecksum();

  /* 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_detected, s_errors );
  }
  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 ));
    fprintf( stderr,   "      %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 );
  fclose( errorfile );
  if( errors == 0 && errors_pass_1 == 0 )
  {
    remove( errorpathname );
  }

  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, 0xaf81(%rip)      # 0xd230
movq -0x10(%rbp), %rax
movq %rax, 0xaf7e(%rip)      # 0xd238
movb $0x0, 0xaf7f(%rip)      # 0xd240
movb $0x0, 0xaf79(%rip)      # 0xd241
movb $0x1, 0xaf73(%rip)      # 0xd242
movb $0x0, 0xaf6d(%rip)      # 0xd243
movb $0x0, 0xaf67(%rip)      # 0xd244
movb $0x0, 0xaf61(%rip)      # 0xd245
movb $0x0, 0xaf5b(%rip)      # 0xd246
movq $0x0, 0xaf52(%rip) # 0xd248
movl $0x0, -0x14(%rbp)
cmpl $0x400, -0x14(%rbp)     # imm = 0x400
jge 0x2324
movslq -0x14(%rbp), %rcx
leaq 0xaf3f(%rip), %rax      # 0xd250
movq $0x0, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x22fd
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x2830
leaq 0xcf19(%rip), %rdi      # 0xf250
leaq 0x70e3(%rip), %rsi      # 0x9421
callq 0x2140
movq %rax, 0xcf86(%rip)      # 0xf2d0
movl $0x0, 0xcf84(%rip)      # 0xf2d8
movl $0x0, 0xcf7e(%rip)      # 0xf2dc
movl $0x0, 0xcf78(%rip)      # 0xf2e0
movl $0x30000, %edi          # imm = 0x30000
callq 0x2120
movq %rax, 0xcf6f(%rip)      # 0xf2e8
cmpq $0x0, 0xcf67(%rip)      # 0xf2e8
jne 0x23a5
movq 0x9c6e(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x72e6(%rip), %rsi      # 0x967a
movb $0x0, %al
callq 0x2110
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2170
movq 0xcf3c(%rip), %rax      # 0xf2e8
movq 0xae65(%rip), %rcx      # 0xd218
movq %rcx, (%rax)
movq 0xae63(%rip), %rcx      # 0xd220
movq %rcx, 0x8(%rax)
movq 0xae60(%rip), %rcx      # 0xd228
movq %rcx, 0x10(%rax)
movl $0x0, 0xcf1a(%rip)      # 0xf2f0
movl 0xcf14(%rip), %eax      # 0xf2f0
movl %eax, 0xcf12(%rip)      # 0xf2f4
movq 0xceff(%rip), %rax      # 0xf2e8
movl 0xcf01(%rip), %ecx      # 0xf2f0
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0xcef5(%rip)      # 0xf2f8
movl $0x0, -0x14(%rbp)
movslq -0x14(%rbp), %rax
cmpq $0x1f, %rax
jae 0x2465
movslq -0x14(%rbp), %rax
leaq 0x9cc1(%rip), %rdi      # 0xc0e0
imulq $0x18, %rax, %rax
addq %rax, %rdi
addq $0x4, %rdi
movslq -0x14(%rbp), %rcx
leaq 0x9cab(%rip), %rax      # 0xc0e0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %esi
movslq -0x14(%rbp), %rcx
leaq 0x9c96(%rip), %rax      # 0xc0e0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %edx
xorl %ecx, %ecx
callq 0x2d30
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x240a
movl $0x0, -0x14(%rbp)
movslq -0x14(%rbp), %rax
cmpq $0x71, %rax
jae 0x24ca
movslq -0x14(%rbp), %rax
leaq 0x9f4f(%rip), %rdi      # 0xc3d0
imulq $0x18, %rax, %rax
addq %rax, %rdi
addq $0x4, %rdi
movslq -0x14(%rbp), %rcx
leaq 0x9f39(%rip), %rax      # 0xc3d0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %esi
movslq -0x14(%rbp), %rcx
leaq 0x9f24(%rip), %rax      # 0xc3d0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %edx
orl $0x3, %edx
xorl %ecx, %ecx
callq 0x2d30
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x246c
movl 0xce20(%rip), %eax      # 0xf2f0
movl %eax, 0xce1e(%rip)      # 0xf2f4
movq 0xce0b(%rip), %rax      # 0xf2e8
movl 0xce0d(%rip), %ecx      # 0xf2f0
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0xce01(%rip)      # 0xf2f8
movl $0x0, 0xcdff(%rip)      # 0xf300
movl $0x1, 0xcdd5(%rip)      # 0xf2e0
callq 0x2ea0
movl 0xcdc2(%rip), %eax      # 0xf2d8
movl %eax, 0xcde8(%rip)      # 0xf304
movq 0xcdad(%rip), %rdi      # 0xf2d0
callq 0x20a0
leaq 0xcd21(%rip), %rdi      # 0xf250
leaq 0x6eeb(%rip), %rsi      # 0x9421
callq 0x2140
movq %rax, 0xcd8e(%rip)      # 0xf2d0
leaq 0xcdc7(%rip), %rdi      # 0xf310
leaq 0x7157(%rip), %rsi      # 0x96a7
callq 0x2140
movq %rax, 0xce34(%rip)      # 0xf390
movq 0xce2d(%rip), %rax      # 0xf390
movq %rax, 0xce2e(%rip)      # 0xf398
leaq 0xce2f(%rip), %rdi      # 0xf3a0
leaq 0x6ea9(%rip), %rsi      # 0x9421
callq 0x2140
movq %rax, 0xce9c(%rip)      # 0xf420
movq 0xce95(%rip), %rax      # 0xf420
movq %rax, 0xce96(%rip)      # 0xf428
xorl %edi, %edi
callq 0x3620
movl $0x0, 0xcd5d(%rip)      # 0xf300
movl $0x0, 0xcd2b(%rip)      # 0xf2d8
movl $0x0, 0xcd25(%rip)      # 0xf2dc
cmpb $0x0, 0xac88(%rip)      # 0xd246
je 0x2679
movl $0x0, -0x18(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0xcd15(%rip), %eax      # 0xf2f0
jge 0x2637
movl -0x18(%rbp), %ecx
movq 0xcd01(%rip), %rax      # 0xf2e8
movslq -0x14(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
movq 0xccec(%rip), %rax      # 0xf2e8
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 0xccce(%rip), %rax      # 0xf2e8
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 0x25d2
movslq -0x18(%rbp), %rdi
shlq $0x2, %rdi
callq 0x2120
movq %rax, 0xcde5(%rip)      # 0xf430
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x2677
movq 0xcdcf(%rip), %rax      # 0xf430
movslq -0x14(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2652
jmp 0x2679
movl $0x2, 0xcc5d(%rip)      # 0xf2e0
callq 0x2ea0
movq 0xcd09(%rip), %rax      # 0xf398
movq %rax, 0xccfa(%rip)      # 0xf390
callq 0x3690
movl $0x1, %edi
callq 0x3620
movq 0xcd7c(%rip), %rax      # 0xf428
movq %rax, 0xcd6d(%rip)      # 0xf420
cmpl $0x0, 0xcc1e(%rip)      # 0xf2d8
jne 0x26eb
movq 0xcd5d(%rip), %rdi      # 0xf420
leaq 0x6fe0(%rip), %rsi      # 0x96aa
leaq 0xa7ad(%rip), %rdx      # 0xce7e
leaq 0xa790(%rip), %rcx      # 0xce68
leaq 0xa798(%rip), %r8       # 0xce77
movb $0x0, %al
callq 0x2110
jmp 0x27a5
movq 0xcbde(%rip), %rdi      # 0xf2d0
movl 0xcbe0(%rip), %edx      # 0xf2d8
movl 0xcbda(%rip), %ecx      # 0xf2d8
leaq 0xa772(%rip), %r8       # 0xce77
leaq 0xa765(%rip), %rax      # 0xce71
cmpl $0x1, %ecx
cmoveq %rax, %r8
leaq 0x6fa1(%rip), %rsi      # 0x96bb
leaq 0xa747(%rip), %rcx      # 0xce68
movb $0x0, %al
callq 0x2110
movq 0xccf1(%rip), %rdi      # 0xf420
movl 0xcba3(%rip), %edx      # 0xf2d8
movl 0xcb9d(%rip), %ecx      # 0xf2d8
leaq 0xa735(%rip), %r8       # 0xce77
leaq 0xa728(%rip), %rax      # 0xce71
cmpl $0x1, %ecx
cmoveq %rax, %r8
leaq 0x6f64(%rip), %rsi      # 0x96bb
leaq 0xa70a(%rip), %rcx      # 0xce68
movb $0x0, %al
callq 0x2110
movq 0x988c(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movl 0xcb63(%rip), %edx      # 0xf2d8
movl 0xcb5d(%rip), %ecx      # 0xf2d8
leaq 0xa6f5(%rip), %r8       # 0xce77
leaq 0xa6e8(%rip), %rax      # 0xce71
cmpl $0x1, %ecx
cmoveq %rax, %r8
leaq 0x6f25(%rip), %rsi      # 0x96bc
leaq 0xa6ca(%rip), %rcx      # 0xce68
movb $0x0, %al
callq 0x2110
cmpb $0x0, 0xaa99(%rip)      # 0xd245
je 0x27b3
callq 0x36d0
cmpb $0x0, 0xaa89(%rip)      # 0xd243
je 0x27c1
callq 0x3900
cmpb $0x0, 0xaa7e(%rip)      # 0xd246
je 0x27cf
callq 0x3ad0
movq 0xcbba(%rip), %rdi      # 0xf390
callq 0x20a0
movq 0xcc3e(%rip), %rdi      # 0xf420
callq 0x20a0
movq 0xcae2(%rip), %rdi      # 0xf2d0
callq 0x20a0
cmpl $0x0, 0xcade(%rip)      # 0xf2d8
jne 0x2811
cmpl $0x0, 0xcb01(%rip)      # 0xf304
jne 0x2811
leaq 0xca44(%rip), %rdi      # 0xf250
callq 0x2050
cmpl $0x0, 0xcac0(%rip)      # 0xf2d8
setne %al
andb $0x1, %al
movzbl %al, %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)