// File: /workspace/github_c_makefile_star2_O1/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, 0x9785(%rip)      # 0xbc80
movq %rsi, 0x9786(%rip)      # 0xbc88
xorl %r14d, %r14d
movb %r14b, 0x9784(%rip)     # 0xbc90
movb %r14b, 0x977e(%rip)     # 0xbc91
movb $0x1, 0x9778(%rip)      # 0xbc92
movb %r14b, 0x9772(%rip)     # 0xbc93
movb %r14b, 0x976c(%rip)     # 0xbc94
movb %r14b, 0x9766(%rip)     # 0xbc95
movb %r14b, 0x9760(%rip)     # 0xbc96
movb %r14b, 0x975a(%rip)     # 0xbc97
movq %r14, 0x9754(%rip)      # 0xbc98
leaq 0x9755(%rip), %rdi      # 0xbca0
movl $0x2000, %edx           # imm = 0x2000
xorl %esi, %esi
callq 0x20d0
movl %ebp, %edi
movq %rbx, %rsi
callq 0x28b6
leaq 0xb738(%rip), %rdi      # 0xdca0
leaq 0x4ece(%rip), %rsi      # 0x743d
callq 0x2160
movq %rax, 0xb7a5(%rip)      # 0xdd20
movl %r14d, 0xb7a6(%rip)     # 0xdd28
movl %r14d, 0xb7a3(%rip)     # 0xdd2c
movq %r14, 0xb7a0(%rip)      # 0xdd30
movl $0x50000, %edi          # imm = 0x50000
callq 0x2140
movq %rax, 0xb797(%rip)      # 0xdd38
testq %rax, %rax
je 0x28b1
movq 0x96c7(%rip), %rcx      # 0xbc78
movq %rcx, 0x20(%rax)
movups 0x96ac(%rip), %xmm0     # 0xbc68
movups %xmm0, 0x10(%rax)
movups 0x9691(%rip), %xmm0     # 0xbc58
movups %xmm0, (%rax)
movl %r14d, 0xb76f(%rip)     # 0xdd40
movl %r14d, 0xb76c(%rip)     # 0xdd44
addq $-0x28, %rax
movq %rax, 0xb765(%rip)      # 0xdd48
leaq 0x7b06(%rip), %rbx      # 0xa0f0
leaq (%r14,%rbx), %rdi
addq $0x4, %rdi
movq 0xc(%rdi), %rsi
movl -0x4(%rdi), %edx
xorl %ecx, %ecx
callq 0x2b4e
addq $0x28, %r14
cmpq $0x578, %r14            # imm = 0x578
jne 0x25ea
xorl %ebx, %ebx
leaq 0x805a(%rip), %r14      # 0xa670
leaq (%rbx,%r14), %rdi
addq $0x4, %rdi
movq 0xc(%rdi), %rsi
movl -0x4(%rdi), %edx
orl $0x3, %edx
xorl %ecx, %ecx
callq 0x2b4e
addq $0x28, %rbx
cmpq $0x12c0, %rbx           # imm = 0x12C0
jne 0x2616
movslq 0xb6fd(%rip), %rax      # 0xdd40
movl %eax, 0xb6fb(%rip)      # 0xdd44
movq 0xb6e8(%rip), %rcx      # 0xdd38
leaq (%rax,%rax,4), %rax
leaq (%rcx,%rax,8), %rax
addq $-0x28, %rax
movq %rax, 0xb6e5(%rip)      # 0xdd48
leaq 0xb6e6(%rip), %rdi      # 0xdd50
xorl %r14d, %r14d
movl $0x8000, %edx           # imm = 0x8000
xorl %esi, %esi
callq 0x20d0
movq $0x8001, 0x136cc(%rip) # imm = 0x8001
movq $-0x8001, 0x136c9(%rip) # imm = 0xFFFF7FFF
movq %r14, 0x136ca(%rip)     # 0x15d60
movq $0x1, 0xb68f(%rip) # 0xdd30
callq 0x2c0e
movl 0xb67c(%rip), %eax      # 0xdd28
movl %eax, 0x136b6(%rip)     # 0x15d68
movq 0xb667(%rip), %rdi      # 0xdd20
callq 0x20a0
leaq 0xb5db(%rip), %rdi      # 0xdca0
leaq 0x4d71(%rip), %rbx      # 0x743d
movq %rbx, %rsi
callq 0x2160
movq %rax, 0xb645(%rip)      # 0xdd20
leaq 0x1368e(%rip), %rdi     # 0x15d70
leaq 0x4fda(%rip), %rsi      # 0x76c3
callq 0x2160
movq %rax, 0x136fb(%rip)     # 0x15df0
movq %rax, 0x136fc(%rip)     # 0x15df8
leaq 0x136fd(%rip), %rdi     # 0x15e00
movq %rbx, %rsi
callq 0x2160
movq %rax, 0x1376e(%rip)     # 0x15e80
movq %rax, 0x1376f(%rip)     # 0x15e88
movl $0x10, %edi
callq 0x314a
movq %r14, 0x13636(%rip)     # 0x15d60
movl %r14d, 0xb5f7(%rip)     # 0xdd28
movl %r14d, 0xb5f4(%rip)     # 0xdd2c
cmpb $0x0, 0x9557(%rip)      # 0xbc96
je 0x27b2
movslq 0xb5f8(%rip), %rcx      # 0xdd40
testq %rcx, %rcx
jle 0x2786
movq 0xb5e4(%rip), %rax      # 0xdd38
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, 0x136f3(%rip)     # 0x15e90
testl %ebx, %ebx
jle 0x27b2
movl %r14d, %edx
shlq $0x3, %rdx
movq %rax, %rdi
xorl %esi, %esi
callq 0x20d0
movq $0x2, 0xb573(%rip) # 0xdd30
callq 0x2c0e
movq 0x1362f(%rip), %rax     # 0x15df8
movq %rax, 0x13620(%rip)     # 0x15df0
callq 0x3184
movl $0x10, %edi
callq 0x314a
movq 0x136a2(%rip), %rdi     # 0x15e88
movq %rdi, 0x13693(%rip)     # 0x15e80
movl 0xb535(%rip), %eax      # 0xdd28
testl %eax, %eax
jne 0x28a5
leaq 0x4ec4(%rip), %rsi      # 0x76c6
leaq 0x913d(%rip), %rdx      # 0xb946
leaq 0x9120(%rip), %rcx      # 0xb930
leaq 0x9128(%rip), %r8       # 0xb93f
xorl %eax, %eax
callq 0x2120
cmpb $0x0, 0x9470(%rip)      # 0xbc95
je 0x282c
callq 0x31bc
cmpb $0x0, 0x9460(%rip)      # 0xbc93
je 0x283a
callq 0x3351
cmpb $0x0, 0x9455(%rip)      # 0xbc96
je 0x2848
callq 0x34b4
cmpb $0x0, 0x9448(%rip)      # 0xbc97
je 0x2856
callq 0x36a9
movq 0x13593(%rip), %rdi     # 0x15df0
callq 0x20a0
movq 0x13617(%rip), %rdi     # 0x15e80
callq 0x20a0
movq 0xb4ab(%rip), %rdi      # 0xdd20
callq 0x20a0
movl 0x134e8(%rip), %eax     # 0x15d68
orl 0xb4a2(%rip), %eax      # 0xdd28
jne 0x2894
leaq 0xb411(%rip), %rdi      # 0xdca0
callq 0x2050
xorl %eax, %eax
cmpl $0x0, 0xb48b(%rip)      # 0xdd28
setne %al
popq %rbx
popq %r14
popq %rbp
retq
movl %eax, %edi
callq 0x21c0
jmp 0x281e
callq 0x225e