// File: /workspace/github_c_makefile_star2_O2/AK6DN[P]dec-utilities-for-pdp/palbart/palbart.c
// Function: main
int main( int argc, char *argv[] )
{
  int     ix;
  int     space;

  /* Set the default values for global symbols.                               */
  binary_data_output = FALSE;
  fltg_input = FALSE;
  literals_ok = TRUE;
  perm_redef_error = FALSE;
  print_permanent_symbols = FALSE;
  rim_mode = FALSE;
  dollar_not_required = FALSE;
  additional_enabled = FALSE;
  symtab_print = FALSE;
  xref = FALSE;
  pathname = 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" );
  if (errorfile == NULL) {
    fprintf( stderr, "Could not open error file %s: %s\n", errorpathname, strerror(errno));
    exit( -1 );

  }
  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 ) - 
        (additional_enabled ? 0 : NUMBER_ADDITIONAL_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( really_permanent_symbols ); ix++ )
  {
    defineSymbol( really_permanent_symbols[ix].name,
                  really_permanent_symbols[ix].val,
                  really_permanent_symbols[ix].type | DEFFIX , 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;
  page_lineno = LIST_LINES_PER_PAGE;
  onePass();
  errors_pass_1 = errors;

  /* Set up for pass two                                                      */
  rewind( infile );
  /*Opened in main errorfile = fopen( errorpathname, "w" );*/
  objectfile = fopen( objectpathname, "wb" );
  if (objectfile == NULL) {
    fprintf( stderr, "Could not open object file %s: %s\n", objectpathname, strerror(errno));
    exit( -1 );

  }
  objectsave = objectfile;

  listfile = fopen( listpathname, "w" );
  if (listfile == NULL) {
    fprintf( stderr, "Could not open list file %s: %s\n", listpathname, strerror(errno));
    exit( -1 );

  }
  listsave = NULL;

  punchLeader( 0 );
  checksum = 0;

  /* Do pass two of the assembly                                              */
  errors = 0;
  save_error_count = 0;
  page_lineno = LIST_LINES_PER_PAGE;

  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 = (WORD16 *) malloc( sizeof( WORD16 ) * 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( 8 );

  /* undo effects of XLIST for any following output to listing file.          */
  if( listfile == NULL )
  {
    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 ));
  }
  /* Display value of link counter.                                          */
  if( links == 0 )
  {
    fprintf( listfile, "      %s %s %s\n", s_no, s_links, s_generated );
  }
  else
  {
    fprintf( errorfile, "      %d %s %s\n", links, 
                                        ( links == 1 ? s_link : s_links ), 
                                        s_generated);
    fprintf( listfile, "      %d %s %s\n", links, 
                                        ( links == 1 ? s_link : s_links ), 
                                        s_generated);
    fprintf( stderr, "      %d %s %s\n", links, 
                                        ( links == 1 ? s_link : s_links ), 
                                        s_generated);
  }

  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 %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
xorl %eax, %eax
movb %al, 0x907c(%rip)       # 0xb338
movb %al, 0x9077(%rip)       # 0xb339
movb $0x1, 0x9071(%rip)      # 0xb33a
movb %al, 0x906c(%rip)       # 0xb33b
movb %al, 0x9067(%rip)       # 0xb33c
movb %al, 0x9062(%rip)       # 0xb33d
movb %al, 0x905d(%rip)       # 0xb33e
movb %al, 0x9058(%rip)       # 0xb33f
movb %al, 0x9053(%rip)       # 0xb340
movb %al, 0x904e(%rip)       # 0xb341
andq $0x0, 0x904d(%rip)      # 0xb348
callq 0x2845
leaq 0x9049(%rip), %rdi      # 0xb350
leaq 0x50fc(%rip), %rsi      # 0x740a
callq 0x2140
movq %rax, 0x90b6(%rip)      # 0xb3d0
testq %rax, %rax
je 0x27a2
andl $0x0, 0x90ae(%rip)      # 0xb3d8
andl $0x0, 0x90ab(%rip)      # 0xb3dc
andl $0x0, 0x90a8(%rip)      # 0xb3e0
movl $0x18000, %edi          # imm = 0x18000
callq 0x2120
movq %rax, 0x909f(%rip)      # 0xb3e8
testq %rax, %rax
je 0x27c8
movq 0x8fd7(%rip), %rcx      # 0xb330
movq %rcx, 0x10(%rax)
movups 0x8fbc(%rip), %xmm0     # 0xb320
andl $0x0, 0x9085(%rip)      # 0xb3f0
movups %xmm0, (%rax)
andl $0x0, 0x907f(%rip)      # 0xb3f4
addq $-0x18, %rax
movq %rax, 0x9078(%rip)      # 0xb3f8
leaq 0x7d79(%rip), %rbx      # 0xa100
xorl %r14d, %r14d
xorl %eax, %eax
cmpb $0x0, 0x8fac(%rip)      # 0xb33f
setne %al
leaq 0x1c(,%rax,2), %rax
cmpq %r14, %rax
jbe 0x23bd
leaq 0x4(%rbx), %rdi
movswl 0xc(%rbx), %esi
movl (%rbx), %edx
xorl %ecx, %ecx
callq 0x2dcf
incq %r14
addq $0x18, %rbx
jmp 0x238a
xorl %ebx, %ebx
leaq 0x800a(%rip), %r14      # 0xa3d0
cmpq $0x30, %rbx
je 0x23eb
leaq (%rbx,%r14), %rdi
addq $0x4, %rdi
movswl 0x8(%rdi), %esi
movl -0x4(%rdi), %edx
orl $0x3, %edx
xorl %ecx, %ecx
callq 0x2dcf
addq $0x18, %rbx
jmp 0x23c6
xorl %ebx, %ebx
leaq 0x800c(%rip), %r14      # 0xa400
cmpq $0xca8, %rbx            # imm = 0xCA8
je 0x241c
leaq (%rbx,%r14), %rdi
addq $0x4, %rdi
movswl 0x8(%rdi), %esi
movl -0x4(%rdi), %edx
orl $0x3, %edx
xorl %ecx, %ecx
callq 0x2dcf
addq $0x18, %rbx
jmp 0x23f4
movslq 0x8fcd(%rip), %rax      # 0xb3f0
movl %eax, 0x8fcb(%rip)      # 0xb3f4
movq 0x8fb8(%rip), %rcx      # 0xb3e8
imulq $0x18, %rax, %rax
andw $0x0, 0x8fc4(%rip)      # 0xb400
addq %rcx, %rax
addq $-0x18, %rax
movq %rax, 0x8fae(%rip)      # 0xb3f8
movl $0x1, 0x8f8c(%rip)      # 0xb3e0
movl $0x37, 0x8fa6(%rip)     # 0xb404
callq 0x2f1a
movl 0x8f6f(%rip), %eax      # 0xb3d8
movl %eax, 0x8f99(%rip)      # 0xb408
movq 0x8f9a(%rip), %rdi      # 0xb410
callq 0x20b0
leaq 0x8f9e(%rip), %rdi      # 0xb420
leaq 0x5180(%rip), %rsi      # 0x7609
callq 0x2140
movq %rax, 0x900b(%rip)      # 0xb4a0
testq %rax, %rax
je 0x27e6
movq %rax, 0x9003(%rip)      # 0xb4a8
leaq 0x9004(%rip), %rdi      # 0xb4b0
leaq 0x4f57(%rip), %rsi      # 0x740a
callq 0x2140
movq %rax, 0x9071(%rip)      # 0xb530
testq %rax, %rax
je 0x280c
andq $0x0, 0x9068(%rip)      # 0xb538
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x3260
andw $0x0, 0x8f1f(%rip)      # 0xb400
andl $0x0, 0x8ef0(%rip)      # 0xb3d8
andl $0x0, 0x8eed(%rip)      # 0xb3dc
movl $0x37, 0x8f0b(%rip)     # 0xb404
cmpb $0x0, 0x8e41(%rip)      # 0xb341
je 0x255a
movq 0x8edf(%rip), %rax      # 0xb3e8
addq $0x14, %rax
xorl %ecx, %ecx
movslq 0x8eda(%rip), %rdx      # 0xb3f0
cmpq %rdx, %rcx
jge 0x2530
movl %ebx, -0x4(%rax)
movl (%rax), %edx
andl $0x0, (%rax)
addl %edx, %ebx
incl %ebx
incq %rcx
addq $0x18, %rax
jmp 0x250f
movslq %ebx, %r14
leaq (%r14,%r14), %rdi
callq 0x2120
movq %rax, 0x8ffd(%rip)      # 0xb540
xorl %ecx, %ecx
testl %r14d, %r14d
cmovlel %ecx, %ebx
cmpq %rcx, %rbx
je 0x255a
andw $0x0, (%rax,%rcx,2)
incq %rcx
jmp 0x254b
movl $0x2, 0x8e7c(%rip)      # 0xb3e0
callq 0x2f1a
movq 0x8f38(%rip), %rax      # 0xb4a8
movq %rax, 0x8f29(%rip)      # 0xb4a0
callq 0x3294
pushq $0x8
popq %rdi
callq 0x3260
movq 0x8fa5(%rip), %rdi      # 0xb530
testq %rdi, %rdi
jne 0x259e
movq 0x8fa1(%rip), %rdi      # 0xb538
movq %rdi, 0x8f92(%rip)      # 0xb530
movl 0x8e34(%rip), %edx      # 0xb3d8
testl %edx, %edx
jne 0x268a
leaq 0x509d(%rip), %rsi      # 0x7650
leaq 0x8b04(%rip), %rdx      # 0xb0be
leaq 0x8ae7(%rip), %rcx      # 0xb0a8
leaq 0x8aef(%rip), %r8       # 0xb0b7
xorl %eax, %eax
callq 0x2110
movl 0x8f73(%rip), %edx      # 0xb548
testl %edx, %edx
jne 0x2718
movq 0x8f4c(%rip), %rdi      # 0xb530
leaq 0x5066(%rip), %rsi      # 0x7651
leaq 0x8acc(%rip), %rdx      # 0xb0be
leaq 0x8b06(%rip), %rcx      # 0xb0ff
leaq 0x8af0(%rip), %r8       # 0xb0f0
xorl %eax, %eax
callq 0x2110
cmpb $0x0, 0x8d32(%rip)      # 0xb340
je 0x2615
callq 0x32c9
cmpb $0x0, 0x8d20(%rip)      # 0xb33c
je 0x2623
callq 0x3453
cmpb $0x0, 0x8d17(%rip)      # 0xb341
je 0x2631
callq 0x35a1
movq 0x8e68(%rip), %rdi      # 0xb4a0
callq 0x2090
movq 0x8eec(%rip), %rdi      # 0xb530
callq 0x2090
movq 0x8d80(%rip), %rdi      # 0xb3d0
callq 0x2090
movl 0x8d7d(%rip), %ecx      # 0xb3d8
movl 0x8da7(%rip), %eax      # 0xb408
orl %ecx, %eax
jne 0x2677
leaq 0x8ce4(%rip), %rdi      # 0xb350
callq 0x2060
movl 0x8d61(%rip), %ecx      # 0xb3d8
xorl %eax, %eax
testl %ecx, %ecx
setne %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x8d3f(%rip), %rdi      # 0xb3d0
cmpl $0x1, %edx
leaq 0x8a16(%rip), %r12      # 0xb0b1
leaq 0x8a15(%rip), %rbx      # 0xb0b7
movq %rbx, %r8
cmoveq %r12, %r8
leaq 0x4fb1(%rip), %r15      # 0x7661
leaq 0x89f1(%rip), %r14      # 0xb0a8
movq %r15, %rsi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2110
movq 0x8e65(%rip), %rdi      # 0xb530
movl 0x8d07(%rip), %edx      # 0xb3d8
cmpl $0x1, %edx
movq %rbx, %r8
cmoveq %r12, %r8
movq %r15, %rsi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2110
movq 0x7909(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movl 0x8ce0(%rip), %edx      # 0xb3d8
cmpl $0x1, %edx
cmoveq %r12, %rbx
leaq 0x4f5c(%rip), %rsi      # 0x7662
movq %r14, %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0x2110
jmp 0x25cf
movq 0x8cb1(%rip), %rdi      # 0xb3d0
cmpl $0x1, %edx
leaq 0x89d1(%rip), %r12      # 0xb0fa
leaq 0x89cf(%rip), %rbx      # 0xb0ff
movq %rbx, %rcx
cmoveq %r12, %rcx
leaq 0x4f24(%rip), %r15      # 0x7662
leaq 0x89ab(%rip), %r14      # 0xb0f0
movq %r15, %rsi
movq %r14, %r8
xorl %eax, %eax
callq 0x2110
movq 0x8dd7(%rip), %rdi      # 0xb530
movl 0x8de9(%rip), %edx      # 0xb548
cmpl $0x1, %edx
movq %rbx, %rcx
cmoveq %r12, %rcx
movq %r15, %rsi
movq %r14, %r8
xorl %eax, %eax
callq 0x2110
movq 0x787b(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movl 0x8dc2(%rip), %edx      # 0xb548
cmpl $0x1, %edx
cmoveq %r12, %rbx
movq %r15, %rsi
movq %rbx, %rcx
movq %r14, %r8
xorl %eax, %eax
callq 0x2110
jmp 0x2607
movq 0x784f(%rip), %rax      # 0x9ff8
movq (%rax), %rbx
callq 0x2040
movl (%rax), %edi
callq 0x2190
leaq 0x4dfb(%rip), %rsi      # 0x75ba
leaq 0x8b8a(%rip), %rdx      # 0xb350
jmp 0x2830
movq 0x7829(%rip), %rax      # 0x9ff8
movq (%rax), %rcx
leaq 0x4e03(%rip), %rdi      # 0x75dc
pushq $0x2c
popq %rsi
pushq $0x1
popq %rdx
callq 0x2180
jmp 0x283d
movq 0x780b(%rip), %rax      # 0x9ff8
movq (%rax), %rbx
callq 0x2040
movl (%rax), %edi
callq 0x2190
leaq 0x4e09(%rip), %rsi      # 0x760c
leaq 0x8c16(%rip), %rdx      # 0xb420
jmp 0x2830
movq 0x77e5(%rip), %rax      # 0x9ff8
movq (%rax), %rbx
callq 0x2040
movl (%rax), %edi
callq 0x2190
leaq 0x4e06(%rip), %rsi      # 0x762f
leaq 0x8c80(%rip), %rdx      # 0xb4b0
movq %rbx, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x2110
pushq $-0x1
popq %rdi
callq 0x2170