// File: /workspace/github_c_makefile_star2_O3/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 %r14
pushq %rbx
pushq %rax
xorl %ebx, %ebx
movb %bl, 0x8c30(%rip)       # 0xb348
movb %bl, 0x8c2b(%rip)       # 0xb349
movb $0x1, 0x8c25(%rip)      # 0xb34a
movb %bl, 0x8c20(%rip)       # 0xb34b
movb %bl, 0x8c1b(%rip)       # 0xb34c
movb %bl, 0x8c16(%rip)       # 0xb34d
movb %bl, 0x8c11(%rip)       # 0xb34e
movb %bl, 0x8c0c(%rip)       # 0xb34f
movb %bl, 0x8c07(%rip)       # 0xb350
movb %bl, 0x8c02(%rip)       # 0xb351
movq $0x0, 0x8bfe(%rip) # 0xb358
callq 0x2b41
leaq 0x8bfa(%rip), %rdi      # 0xb360
leaq 0x4c9d(%rip), %rsi      # 0x740a
callq 0x2160
movq %rax, 0x8c67(%rip)      # 0xb3e0
testq %rax, %rax
je 0x2b2d
movl %ebx, 0x8c60(%rip)      # 0xb3e8
movl %ebx, 0x8c5e(%rip)      # 0xb3ec
movl %ebx, 0x8c5c(%rip)      # 0xb3f0
movl $0x18000, %edi          # imm = 0x18000
callq 0x2140
movq %rax, 0x8c53(%rip)      # 0xb3f8
testq %rax, %rax
je 0x2b32
movq 0x8b8b(%rip), %rcx      # 0xb340
movq %rcx, 0x10(%rax)
movups 0x8b70(%rip), %xmm0     # 0xb330
movups %xmm0, (%rax)
xorl %ebx, %ebx
movl %ebx, 0x8c35(%rip)      # 0xb400
movl %ebx, 0x8c33(%rip)      # 0xb404
addq $-0x18, %rax
movq %rax, 0x8c2c(%rip)      # 0xb408
leaq 0x792d(%rip), %r14      # 0xa110
leaq 0x4(%r14), %rdi
movswl 0xc(%r14), %esi
movl (%r14), %edx
xorl %ecx, %ecx
callq 0x2f2e
incq %rbx
xorl %eax, %eax
cmpb $0x0, 0x8b4d(%rip)      # 0xb34f
setne %al
leaq 0x1c(,%rax,2), %rax
addq $0x18, %r14
cmpq %rbx, %rax
ja 0x27e3
movswl 0x7bcf(%rip), %esi      # 0xa3ec
movl 0x7bbd(%rip), %edx      # 0xa3e0
orl $0x3, %edx
leaq 0x7bb7(%rip), %rdi      # 0xa3e4
xorl %ebx, %ebx
xorl %ecx, %ecx
callq 0x2f2e
movswl 0x7bc7(%rip), %esi      # 0xa404
movl 0x7bb5(%rip), %edx      # 0xa3f8
orl $0x3, %edx
leaq 0x7baf(%rip), %rdi      # 0xa3fc
xorl %ecx, %ecx
callq 0x2f2e
leaq 0x7bb5(%rip), %r14      # 0xa410
leaq (%rbx,%r14), %rdi
addq $0x4, %rdi
movswl 0x8(%rdi), %esi
movl -0x4(%rdi), %edx
orl $0x3, %edx
xorl %ecx, %ecx
callq 0x2f2e
addq $0x18, %rbx
cmpq $0xca8, %rbx            # imm = 0xCA8
jne 0x285b
movslq 0x8b78(%rip), %rax      # 0xb400
movl %eax, 0x8b76(%rip)      # 0xb404
movq 0x8b63(%rip), %rcx      # 0xb3f8
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rax
addq $-0x18, %rax
movq %rax, 0x8b60(%rip)      # 0xb408
movw $0x0, 0x8b5f(%rip)      # 0xb410
movl $0x1, 0x8b35(%rip)      # 0xb3f0
movl $0x37, 0x8b4f(%rip)     # 0xb414
callq 0x3082
movl 0x8b18(%rip), %eax      # 0xb3e8
movl %eax, 0x8b42(%rip)      # 0xb418
movq 0x8b43(%rip), %rdi      # 0xb420
callq 0x20b0
leaq 0x8b47(%rip), %rdi      # 0xb430
leaq 0x4d19(%rip), %rsi      # 0x7609
callq 0x2160
movq %rax, 0x8bb4(%rip)      # 0xb4b0
testq %rax, %rax
je 0x2b37
movq %rax, 0x8bac(%rip)      # 0xb4b8
leaq 0x8bad(%rip), %rdi      # 0xb4c0
leaq 0x4af0(%rip), %rsi      # 0x740a
callq 0x2160
movq %rax, 0x8c1a(%rip)      # 0xb540
testq %rax, %rax
je 0x2b3c
movq $0x0, 0x8c0e(%rip) # 0xb548
cmpq $0x0, 0x8b6e(%rip)      # 0xb4b0
je 0x295e
movl $0xf0, %ebx
movq 0x8b60(%rip), %rsi      # 0xb4b0
movl $0x80, %edi
callq 0x20e0
decl %ebx
jne 0x2949
movw $0x0, 0x8aa9(%rip)      # 0xb410
xorl %ebx, %ebx
movl %ebx, 0x8a79(%rip)      # 0xb3e8
movl %ebx, 0x8a77(%rip)      # 0xb3ec
movl $0x37, 0x8a95(%rip)     # 0xb414
cmpb $0x0, 0x89cb(%rip)      # 0xb351
je 0x29e9
cmpl $0x0, 0x8a71(%rip)      # 0xb400
jle 0x29c2
movq 0x8a60(%rip), %rax      # 0xb3f8
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 0x8a47(%rip), %rdx      # 0xb400
addq $0x18, %rax
cmpq %rdx, %rcx
jl 0x29a0
movslq %ebx, %r14
leaq (%r14,%r14), %rdi
callq 0x2140
movq %rax, 0x8b7b(%rip)      # 0xb550
testl %r14d, %r14d
jle 0x29e9
addl %ebx, %ebx
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x20d0
movl $0x2, 0x89fd(%rip)      # 0xb3f0
callq 0x3082
movq 0x8ab9(%rip), %rax      # 0xb4b8
movq %rax, 0x8aaa(%rip)      # 0xb4b0
callq 0x3519
movl $0x8, %edi
callq 0x34e3
movq 0x8b24(%rip), %rdi      # 0xb540
testq %rdi, %rdi
jne 0x2a2f
movq 0x8b20(%rip), %rdi      # 0xb548
movq %rdi, 0x8b11(%rip)      # 0xb540
movl 0x89b3(%rip), %eax      # 0xb3e8
testl %eax, %eax
jne 0x2b17
leaq 0x4c0c(%rip), %rsi      # 0x7650
leaq 0x8683(%rip), %rdx      # 0xb0ce
leaq 0x8666(%rip), %rcx      # 0xb0b8
leaq 0x866e(%rip), %r8       # 0xb0c7
xorl %eax, %eax
callq 0x2120
movl 0x8af2(%rip), %edi      # 0xb558
testl %edi, %edi
jne 0x2b23
movq 0x8acb(%rip), %rdi      # 0xb540
leaq 0x4bd5(%rip), %rsi      # 0x7651
leaq 0x864b(%rip), %rdx      # 0xb0ce
leaq 0x8685(%rip), %rcx      # 0xb10f
leaq 0x866f(%rip), %r8       # 0xb100
xorl %eax, %eax
callq 0x2120
cmpb $0x0, 0x88b1(%rip)      # 0xb350
je 0x2aa6
callq 0x354f
cmpb $0x0, 0x889f(%rip)      # 0xb34c
je 0x2ab4
callq 0x36f1
cmpb $0x0, 0x8896(%rip)      # 0xb351
je 0x2ac2
callq 0x385f
movq 0x89e7(%rip), %rdi      # 0xb4b0
callq 0x2090
movq 0x8a6b(%rip), %rdi      # 0xb540
callq 0x2090
movq 0x88ff(%rip), %rdi      # 0xb3e0
callq 0x2090
movl 0x88fc(%rip), %ecx      # 0xb3e8
movl 0x8926(%rip), %eax      # 0xb418
orl %ecx, %eax
jne 0x2b08
leaq 0x8863(%rip), %rdi      # 0xb360
callq 0x2060
movl 0x88e0(%rip), %ecx      # 0xb3e8
xorl %eax, %eax
testl %ecx, %ecx
setne %al
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movl %eax, %edi
callq 0x21e0
jmp 0x2a60
callq 0x227e
jmp 0x2a98
callq 0x23b1
callq 0x238c
callq 0x2352
callq 0x2318