// File: /workspace/github_c_makefile_star2_O3/AK6DN[P]dec-utilities-for-pdp/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;
  memmap = 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];

  /* clear the memory map 						      */
  for( ix = 0; ix < sizeof(memory_map); ix++ ) memory_map[ix] = FALSE;
  memory_min = sizeof(memory_map)+1;
  memory_max = -memory_min;

  /* 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( LEADER_LENGTH );
  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( TRAILER_LENGTH );

  /* 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();
  }

  if( memmap )
  {
    printMemoryMap();
  }

  fclose( objectfile );
  fclose( listfile );
  fclose( errorfile );
  if( errors == 0 && errors_pass_1 == 0 )
  {
    remove( errorpathname );
  }

  return( errors != 0 );
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movl %edi, %ebp
movl %edi, 0xa785(%rip)      # 0xcc80
movq %rsi, 0xa786(%rip)      # 0xcc88
xorl %r14d, %r14d
movb %r14b, 0xa784(%rip)     # 0xcc90
movb %r14b, 0xa77e(%rip)     # 0xcc91
movb $0x1, 0xa778(%rip)      # 0xcc92
movb %r14b, 0xa772(%rip)     # 0xcc93
movb %r14b, 0xa76c(%rip)     # 0xcc94
movb %r14b, 0xa766(%rip)     # 0xcc95
movb %r14b, 0xa760(%rip)     # 0xcc96
movb %r14b, 0xa75a(%rip)     # 0xcc97
movq %r14, 0xa754(%rip)      # 0xcc98
leaq 0xa755(%rip), %rdi      # 0xcca0
movl $0x2000, %edx           # imm = 0x2000
xorl %esi, %esi
callq 0x20d0
movl %ebp, %edi
movq %rbx, %rsi
callq 0x28b9
leaq 0xc738(%rip), %rdi      # 0xeca0
leaq 0x5f2a(%rip), %rsi      # 0x8499
callq 0x2160
movq %rax, 0xc7a5(%rip)      # 0xed20
movl %r14d, 0xc7a6(%rip)     # 0xed28
movl %r14d, 0xc7a3(%rip)     # 0xed2c
movq %r14, 0xc7a0(%rip)      # 0xed30
movl $0x50000, %edi          # imm = 0x50000
callq 0x2140
movq %rax, 0xc797(%rip)      # 0xed38
testq %rax, %rax
je 0x28b4
movq 0xa6c7(%rip), %rcx      # 0xcc78
movq %rcx, 0x20(%rax)
movups 0xa6ac(%rip), %xmm0     # 0xcc68
movups %xmm0, 0x10(%rax)
movups 0xa691(%rip), %xmm0     # 0xcc58
movups %xmm0, (%rax)
movl %r14d, 0xc76f(%rip)     # 0xed40
movl %r14d, 0xc76c(%rip)     # 0xed44
addq $-0x28, %rax
movq %rax, 0xc765(%rip)      # 0xed48
leaq 0x8b06(%rip), %rbx      # 0xb0f0
leaq (%r14,%rbx), %rdi
addq $0x4, %rdi
movq 0xc(%rdi), %rsi
movl -0x4(%rdi), %edx
xorl %ecx, %ecx
callq 0x2b42
addq $0x28, %r14
cmpq $0x578, %r14            # imm = 0x578
jne 0x25ea
xorl %ebx, %ebx
leaq 0x905a(%rip), %r14      # 0xb670
leaq (%rbx,%r14), %rdi
addq $0x4, %rdi
movq 0xc(%rdi), %rsi
movl -0x4(%rdi), %edx
orl $0x3, %edx
xorl %ecx, %ecx
callq 0x2b42
addq $0x28, %rbx
cmpq $0x12c0, %rbx           # imm = 0x12C0
jne 0x2616
movslq 0xc6fd(%rip), %rax      # 0xed40
movl %eax, 0xc6fb(%rip)      # 0xed44
movq 0xc6e8(%rip), %rcx      # 0xed38
leaq (%rax,%rax,4), %rax
leaq (%rcx,%rax,8), %rax
addq $-0x28, %rax
movq %rax, 0xc6e5(%rip)      # 0xed48
leaq 0xc6e6(%rip), %rdi      # 0xed50
xorl %r14d, %r14d
movl $0x8000, %edx           # imm = 0x8000
xorl %esi, %esi
callq 0x20d0
movq $0x8001, 0x146cc(%rip) # imm = 0x8001
movq $-0x8001, 0x146c9(%rip) # imm = 0xFFFF7FFF
movq %r14, 0x146ca(%rip)     # 0x16d60
movq $0x1, 0xc68f(%rip) # 0xed30
callq 0x2c09
movl 0xc67c(%rip), %eax      # 0xed28
movl %eax, 0x146b6(%rip)     # 0x16d68
movq 0xc667(%rip), %rdi      # 0xed20
callq 0x20a0
leaq 0xc5db(%rip), %rdi      # 0xeca0
leaq 0x5dcd(%rip), %rbx      # 0x8499
movq %rbx, %rsi
callq 0x2160
movq %rax, 0xc645(%rip)      # 0xed20
leaq 0x1468e(%rip), %rdi     # 0x16d70
leaq 0x6036(%rip), %rsi      # 0x871f
callq 0x2160
movq %rax, 0x146fb(%rip)     # 0x16df0
movq %rax, 0x146fc(%rip)     # 0x16df8
leaq 0x146fd(%rip), %rdi     # 0x16e00
movq %rbx, %rsi
callq 0x2160
movq %rax, 0x1476e(%rip)     # 0x16e80
movq %rax, 0x1476f(%rip)     # 0x16e88
movl $0x10, %edi
callq 0x3156
movq %r14, 0x14636(%rip)     # 0x16d60
movl %r14d, 0xc5f7(%rip)     # 0xed28
movl %r14d, 0xc5f4(%rip)     # 0xed2c
cmpb $0x0, 0xa557(%rip)      # 0xcc96
je 0x27b2
movslq 0xc5f8(%rip), %rcx      # 0xed40
testq %rcx, %rcx
jle 0x2786
movq 0xc5e4(%rip), %rax      # 0xed38
shlq $0x3, %rcx
leaq (%rcx,%rcx,4), %rcx
xorl %edx, %edx
xorl %r14d, %r14d
movslq %r14d, %rsi
movq %rsi, 0x18(%rax,%rdx)
movl 0x20(%rax,%rdx), %edi
leal (%rsi,%rdi), %r14d
incl %r14d
movq $0x0, 0x20(%rax,%rdx)
addq $0x28, %rdx
cmpq %rdx, %rcx
jne 0x2761
movslq %r14d, %rbx
leaq (,%rbx,8), %rdi
callq 0x2140
movq %rax, 0x146f3(%rip)     # 0x16e90
testl %ebx, %ebx
jle 0x27b2
movl %r14d, %edx
shlq $0x3, %rdx
movq %rax, %rdi
xorl %esi, %esi
callq 0x20d0
movq $0x2, 0xc573(%rip) # 0xed30
callq 0x2c09
movq 0x1462f(%rip), %rax     # 0x16df8
movq %rax, 0x14620(%rip)     # 0x16df0
callq 0x3190
movl $0x10, %edi
callq 0x3156
movq 0x146a2(%rip), %rdi     # 0x16e88
movq %rdi, 0x14693(%rip)     # 0x16e80
movl 0xc535(%rip), %eax      # 0xed28
testl %eax, %eax
jne 0x28a8
leaq 0x5f20(%rip), %rsi      # 0x8722
leaq 0xa13d(%rip), %rdx      # 0xc946
leaq 0xa120(%rip), %rcx      # 0xc930
leaq 0xa128(%rip), %r8       # 0xc93f
xorl %eax, %eax
callq 0x2120
cmpb $0x0, 0xa470(%rip)      # 0xcc95
je 0x282c
callq 0x31c8
cmpb $0x0, 0xa460(%rip)      # 0xcc93
je 0x283a
callq 0x3369
cmpb $0x0, 0xa455(%rip)      # 0xcc96
je 0x2848
callq 0x34dd
cmpb $0x0, 0xa448(%rip)      # 0xcc97
je 0x2856
callq 0x36da
movq 0x14593(%rip), %rdi     # 0x16df0
callq 0x20a0
movq 0x14617(%rip), %rdi     # 0x16e80
callq 0x20a0
movq 0xc4ab(%rip), %rdi      # 0xed20
callq 0x20a0
movl 0xc4a8(%rip), %ecx      # 0xed28
movl 0x144e2(%rip), %eax     # 0x16d68
orl %ecx, %eax
jne 0x289c
leaq 0xc40f(%rip), %rdi      # 0xeca0
callq 0x2050
movl 0xc48c(%rip), %ecx      # 0xed28
xorl %eax, %eax
testl %ecx, %ecx
setne %al
popq %rbx
popq %r14
popq %rbp
retq
movl %eax, %edi
callq 0x21c0
jmp 0x281e
callq 0x225e