// File: /workspace/github_c_makefile_star2_O1/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
pushq %r14
pushq %rbx
movq %rsi, %rbx
movl %edi, %ebp
movl %edi, 0x8ca5(%rip)      # 0xb180
movq %rsi, 0x8ca6(%rip)      # 0xb188
xorl %r14d, %r14d
movb %r14b, 0x8ca4(%rip)     # 0xb190
movb %r14b, 0x8c9e(%rip)     # 0xb191
movb $0x1, 0x8c98(%rip)      # 0xb192
movb %r14b, 0x8c92(%rip)     # 0xb193
movb %r14b, 0x8c8c(%rip)     # 0xb194
movb %r14b, 0x8c86(%rip)     # 0xb195
movb %r14b, 0x8c80(%rip)     # 0xb196
movq $0x0, 0x8c77(%rip) # 0xb198
leaq 0x8c78(%rip), %rdi      # 0xb1a0
movl $0x2000, %edx           # imm = 0x2000
xorl %esi, %esi
callq 0x20d0
movl %ebp, %edi
movq %rbx, %rsi
callq 0x285b
leaq 0xac5b(%rip), %rdi      # 0xd1a0
leaq 0x4eb1(%rip), %rsi      # 0x73fd
callq 0x2150
movq %rax, 0xacc8(%rip)      # 0xd220
movl %r14d, 0xacc9(%rip)     # 0xd228
movl %r14d, 0xacc6(%rip)     # 0xd22c
movl %r14d, 0xacc3(%rip)     # 0xd230
movl $0x30000, %edi          # imm = 0x30000
callq 0x2130
movq %rax, 0xacba(%rip)      # 0xd238
testq %rax, %rax
je 0x2856
movq 0x8bea(%rip), %rcx      # 0xb178
movq %rcx, 0x10(%rax)
movups 0x8bcf(%rip), %xmm0     # 0xb168
movups %xmm0, (%rax)
movl %r14d, 0xac9d(%rip)     # 0xd240
movl %r14d, 0xac9a(%rip)     # 0xd244
addq $-0x18, %rax
movq %rax, 0xac93(%rip)      # 0xd248
leaq 0x7b24(%rip), %rbx      # 0xa0e0
leaq (%r14,%rbx), %rdi
addq $0x4, %rdi
movl -0x4(%rdi), %edx
movl 0x8(%rdi), %esi
xorl %ecx, %ecx
callq 0x2af8
addq $0x18, %r14
cmpq $0x2e8, %r14            # imm = 0x2E8
jne 0x25bc
xorl %ebx, %ebx
leaq 0x7de9(%rip), %r14      # 0xa3d0
leaq (%rbx,%r14), %rdi
addq $0x4, %rdi
movl -0x4(%rdi), %edx
movl 0x8(%rdi), %esi
orl $0x3, %edx
xorl %ecx, %ecx
callq 0x2af8
addq $0x18, %rbx
cmpq $0xa98, %rbx            # imm = 0xA98
jne 0x25e7
movslq 0xac2d(%rip), %rax      # 0xd240
movl %eax, 0xac2b(%rip)      # 0xd244
movq 0xac18(%rip), %rcx      # 0xd238
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rax
addq $-0x18, %rax
movq %rax, 0xac15(%rip)      # 0xd248
movl $0x0, 0xac13(%rip)      # 0xd250
movl $0x1, 0xabe9(%rip)      # 0xd230
callq 0x2bb7
movl 0xabd6(%rip), %eax      # 0xd228
movl %eax, 0xabfc(%rip)      # 0xd254
movq 0xabc1(%rip), %rdi      # 0xd220
callq 0x20a0
leaq 0xab35(%rip), %rdi      # 0xd1a0
leaq 0x4d8b(%rip), %rbx      # 0x73fd
movq %rbx, %rsi
callq 0x2150
movq %rax, 0xab9f(%rip)      # 0xd220
leaq 0xabd8(%rip), %rdi      # 0xd260
leaq 0x4ff4(%rip), %rsi      # 0x7683
callq 0x2150
movq %rax, 0xac45(%rip)      # 0xd2e0
movq %rax, 0xac46(%rip)      # 0xd2e8
leaq 0xac47(%rip), %rdi      # 0xd2f0
movq %rbx, %rsi
callq 0x2150
movq %rax, 0xacb8(%rip)      # 0xd370
movq %rax, 0xacb9(%rip)      # 0xd378
cmpq $0x0, 0xac19(%rip)      # 0xd2e0
je 0x26e3
movl $0xf0, %ebx
movq 0xac0b(%rip), %rsi      # 0xd2e0
movl $0x80, %edi
callq 0x20e0
decl %ebx
jne 0x26ce
xorl %ebx, %ebx
movl %ebx, 0xab65(%rip)      # 0xd250
movl %ebx, 0xab37(%rip)      # 0xd228
movl %ebx, 0xab35(%rip)      # 0xd22c
cmpb $0x0, 0x8a98(%rip)      # 0xb196
je 0x2766
cmpl $0x0, 0xab39(%rip)      # 0xd240
jle 0x273a
movq 0xab28(%rip), %rax      # 0xd238
addq $0x14, %rax
xorl %ecx, %ecx
xorl %ebx, %ebx
movl %ebx, -0x4(%rax)
movl (%rax), %edx
addl %edx, %ebx
incl %ebx
movl $0x0, (%rax)
incq %rcx
movslq 0xab0f(%rip), %rdx      # 0xd240
addq $0x18, %rax
cmpq %rdx, %rcx
jl 0x2718
movslq %ebx, %r14
leaq (,%r14,4), %rdi
callq 0x2130
movq %rax, 0xac2f(%rip)      # 0xd380
testl %r14d, %r14d
jle 0x2766
movl %ebx, %edx
shlq $0x2, %rdx
movq %rax, %rdi
xorl %esi, %esi
callq 0x20d0
movl $0x2, 0xaac0(%rip)      # 0xd230
callq 0x2bb7
movq 0xab6c(%rip), %rax      # 0xd2e8
movq %rax, 0xab5d(%rip)      # 0xd2e0
callq 0x310d
movl $0x1, %edi
callq 0x30d7
movq 0xabdf(%rip), %rdi      # 0xd378
movq %rdi, 0xabd0(%rip)      # 0xd370
movl 0xaa82(%rip), %eax      # 0xd228
testl %eax, %eax
jne 0x284a
leaq 0x4ed1(%rip), %rsi      # 0x7686
leaq 0x86c2(%rip), %rdx      # 0xae7e
leaq 0x86a5(%rip), %rcx      # 0xae68
leaq 0x86ad(%rip), %r8       # 0xae77
xorl %eax, %eax
callq 0x2120
cmpb $0x0, 0x89bd(%rip)      # 0xb195
je 0x27df
callq 0x3143
cmpb $0x0, 0x89ad(%rip)      # 0xb193
je 0x27ed
callq 0x32d8
cmpb $0x0, 0x89a2(%rip)      # 0xb196
je 0x27fb
callq 0x3433
movq 0xaade(%rip), %rdi      # 0xd2e0
callq 0x20a0
movq 0xab62(%rip), %rdi      # 0xd370
callq 0x20a0
movq 0xaa06(%rip), %rdi      # 0xd220
callq 0x20a0
movl 0xaa2f(%rip), %eax      # 0xd254
orl 0xa9fd(%rip), %eax      # 0xd228
jne 0x2839
leaq 0xa96c(%rip), %rdi      # 0xd1a0
callq 0x2060
xorl %eax, %eax
cmpl $0x0, 0xa9e6(%rip)      # 0xd228
setne %al
popq %rbx
popq %r14
popq %rbp
retq
movl %eax, %edi
callq 0x21b0
jmp 0x27d1
callq 0x224e