// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl %edi, 0x99c6(%rip)      # 0xbc70
movq %rsi, 0x99c7(%rip)      # 0xbc78
xorl %eax, %eax
movb %al, 0x99c7(%rip)       # 0xbc80
movb %al, 0x99c2(%rip)       # 0xbc81
movb $0x1, 0x99bc(%rip)      # 0xbc82
movb %al, 0x99b7(%rip)       # 0xbc83
movb %al, 0x99b2(%rip)       # 0xbc84
movb %al, 0x99ad(%rip)       # 0xbc85
movb %al, 0x99a8(%rip)       # 0xbc86
movb %al, 0x99a3(%rip)       # 0xbc87
andq $0x0, 0x999c(%rip)      # 0xbc88
leaq 0x999d(%rip), %rcx      # 0xbc90
cmpq $0x2000, %rax           # imm = 0x2000
je 0x2306
andq $0x0, (%rax,%rcx)
addq $0x8, %rax
jmp 0x22f3
callq 0x2707
leaq 0xb97e(%rip), %rdi      # 0xdc90
leaq 0x5150(%rip), %rsi      # 0x7469
callq 0x2150
andl $0x0, 0xb9f3(%rip)      # 0xdd18
andl $0x0, 0xb9f0(%rip)      # 0xdd1c
movq %rax, 0xb9dd(%rip)      # 0xdd10
andq $0x0, 0xb9e5(%rip)      # 0xdd20
movl $0x50000, %edi          # imm = 0x50000
callq 0x2130
movq %rax, 0xb9dc(%rip)      # 0xdd28
testq %rax, %rax
je 0x26e3
movq 0x990c(%rip), %rcx      # 0xbc68
movq %rcx, 0x20(%rax)
movups 0x98f1(%rip), %xmm0     # 0xbc58
movups %xmm0, 0x10(%rax)
movups 0x98d6(%rip), %xmm0     # 0xbc48
andl $0x0, 0xb9b7(%rip)      # 0xdd30
movups %xmm0, (%rax)
andl $0x0, 0xb9b1(%rip)      # 0xdd34
addq $-0x28, %rax
movq %rax, 0xb9aa(%rip)      # 0xdd38
xorl %ebx, %ebx
leaq 0x7d49(%rip), %r14      # 0xa0e0
cmpq $0x578, %rbx            # imm = 0x578
je 0x23bc
leaq (%rbx,%r14), %rdi
addq $0x4, %rdi
movq 0xc(%rdi), %rsi
movl -0x4(%rdi), %edx
xorl %ecx, %ecx
callq 0x2a69
addq $0x28, %rbx
jmp 0x2397
xorl %ebx, %ebx
leaq 0x829b(%rip), %r14      # 0xa660
cmpq $0x12c0, %rbx           # imm = 0x12C0
je 0x23ed
leaq (%rbx,%r14), %rdi
addq $0x4, %rdi
movq 0xc(%rdi), %rsi
movl -0x4(%rdi), %edx
orl $0x3, %edx
xorl %ecx, %ecx
callq 0x2a69
addq $0x28, %rbx
jmp 0x23c5
movslq 0xb93c(%rip), %rax      # 0xdd30
movl %eax, 0xb93a(%rip)      # 0xdd34
movq 0xb927(%rip), %rcx      # 0xdd28
imulq $0x28, %rax, %rax
addq %rcx, %rax
addq $-0x28, %rax
movq %rax, 0xb925(%rip)      # 0xdd38
xorl %eax, %eax
leaq 0xb924(%rip), %rcx      # 0xdd40
cmpq $0x8000, %rax           # imm = 0x8000
je 0x242d
movb $0x0, (%rax,%rcx)
incq %rax
jmp 0x241c
movq $0x8001, 0x13908(%rip) # imm = 0x8001
movq $-0x8001, 0x13905(%rip) # imm = 0xFFFF7FFF
andq $0x0, 0x13905(%rip)     # 0x15d50
movq $0x1, 0xb8ca(%rip) # 0xdd20
callq 0x2b2f
movl 0xb8b7(%rip), %eax      # 0xdd18
movl %eax, 0x138f1(%rip)     # 0x15d58
movq 0xb8a2(%rip), %rdi      # 0xdd10
callq 0x20a0
leaq 0xb816(%rip), %rdi      # 0xdc90
leaq 0x4fe8(%rip), %rbx      # 0x7469
movq %rbx, %rsi
callq 0x2150
movq %rax, 0xb880(%rip)      # 0xdd10
leaq 0x138c9(%rip), %rdi     # 0x15d60
leaq 0x5251(%rip), %rsi      # 0x76ef
callq 0x2150
movq %rax, 0x13936(%rip)     # 0x15de0
movq %rax, 0x13937(%rip)     # 0x15de8
leaq 0x13938(%rip), %rdi     # 0x15df0
movq %rbx, %rsi
callq 0x2150
movq %rax, 0x139a9(%rip)     # 0x15e70
movq %rax, 0x139aa(%rip)     # 0x15e78
pushq $0x10
popq %rdi
callq 0x3005
andq $0x0, 0x13872(%rip)     # 0x15d50
andl $0x0, 0xb833(%rip)      # 0xdd18
andl $0x0, 0xb830(%rip)      # 0xdd1c
cmpb $0x0, 0x9793(%rip)      # 0xbc86
je 0x255a
movl 0xb835(%rip), %edx      # 0xdd30
movq 0xb826(%rip), %rax      # 0xdd28
xorl %ecx, %ecx
testl %edx, %edx
cmovlel %ecx, %edx
imulq $0x28, %rdx, %rdx
xorl %esi, %esi
movslq %esi, %rbx
cmpq %rcx, %rdx
je 0x2530
movq %rbx, 0x18(%rax,%rcx)
movl 0x20(%rax,%rcx), %esi
addl %ebx, %esi
incl %esi
andq $0x0, 0x20(%rax,%rcx)
addq $0x28, %rcx
jmp 0x250f
leaq (,%rbx,8), %rdi
callq 0x2130
movq %rax, 0x1393c(%rip)     # 0x15e80
xorl %ecx, %ecx
testl %ebx, %ebx
cmovlel %ecx, %ebx
cmpq %rcx, %rbx
je 0x255a
andq $0x0, (%rax,%rcx,8)
incq %rcx
jmp 0x254b
movq $0x2, 0xb7bb(%rip) # 0xdd20
callq 0x2b2f
movq 0x13877(%rip), %rax     # 0x15de8
movq %rax, 0x13868(%rip)     # 0x15de0
callq 0x303d
pushq $0x10
popq %rdi
callq 0x3005
movq 0x138ec(%rip), %rdi     # 0x15e78
movq %rdi, 0x138dd(%rip)     # 0x15e70
movl 0xb77f(%rip), %edx      # 0xdd18
testl %edx, %edx
jne 0x2655
leaq 0x514a(%rip), %rsi      # 0x76f2
leaq 0x9387(%rip), %rdx      # 0xb936
leaq 0x936a(%rip), %rcx      # 0xb920
leaq 0x9372(%rip), %r8       # 0xb92f
xorl %eax, %eax
callq 0x2120
cmpb $0x0, 0x96ba(%rip)      # 0xbc85
je 0x25d2
callq 0x3072
cmpb $0x0, 0x96aa(%rip)      # 0xbc83
je 0x25e0
callq 0x31f7
cmpb $0x0, 0x969f(%rip)      # 0xbc86
je 0x25ee
callq 0x3347
cmpb $0x0, 0x9692(%rip)      # 0xbc87
je 0x25fc
callq 0x3538
movq 0x137dd(%rip), %rdi     # 0x15de0
callq 0x20a0
movq 0x13861(%rip), %rdi     # 0x15e70
callq 0x20a0
movq 0xb6f5(%rip), %rdi      # 0xdd10
callq 0x20a0
movl 0xb6f2(%rip), %ecx      # 0xdd18
movl 0x1372c(%rip), %eax     # 0x15d58
orl %ecx, %eax
jne 0x2642
leaq 0xb659(%rip), %rdi      # 0xdc90
callq 0x2050
movl 0xb6d6(%rip), %ecx      # 0xdd18
xorl %eax, %eax
testl %ecx, %ecx
setne %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0xb6b4(%rip), %rdi      # 0xdd10
cmpl $0x1, %edx
leaq 0x92c3(%rip), %r12      # 0xb929
leaq 0x92c2(%rip), %rbx      # 0xb92f
movq %rbx, %r8
cmoveq %r12, %r8
leaq 0x5088(%rip), %r15      # 0x7703
leaq 0x929e(%rip), %r14      # 0xb920
movq %r15, %rsi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2120
movq 0x137da(%rip), %rdi     # 0x15e70
movl 0xb67c(%rip), %edx      # 0xdd18
cmpl $0x1, %edx
movq %rbx, %r8
cmoveq %r12, %r8
movq %r15, %rsi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2120
movq 0x793e(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movl 0xb655(%rip), %edx      # 0xdd18
cmpl $0x1, %edx
cmoveq %r12, %rbx
leaq 0x5033(%rip), %rsi      # 0x7704
movq %r14, %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0x2120
jmp 0x25c4
movq 0x790e(%rip), %rax      # 0x9ff8
movq (%rax), %rcx
leaq 0x4fce(%rip), %rdi      # 0x76c2
pushq $0x2c
popq %rsi
pushq $0x1
popq %rdx
callq 0x2180
pushq $-0x1
popq %rdi
callq 0x2170