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

  /* Set the defaults                                                         */
  errorfile = NULL;
  infile = NULL;
  listfile = NULL;
  listsave = NULL;
  objectfile = NULL;
  objectsave = NULL;
  tabstops = 8;

  for( ix = 1; ix < argc; ix++ )
  {
    if( argv[ix][0] == '-' )
    {
      for( jx = 1; argv[ix][jx] != 0; jx++ )
      {
        switch( argv[ix][jx] )
        {
        case '$':
          dollar_not_required = TRUE;
          break;

        case 'd':
          symtab_print = TRUE;
          break;

        case 'a':
          additional_enabled = TRUE;
          break;

        case 'r':
          rim_mode = TRUE;
          break;

        case 'e':
          literals_ok = FALSE;
          break;

        case 'l':
          literals_ok = TRUE;
          break;

        case 'n':
          perm_redef_error = TRUE;
          break;

        case 'p':
          print_permanent_symbols = TRUE;
          break;

        /* Added -tN; RK 20071029 */
        /* Damn, this is ugly, we should use getopt() */
        case 't':
          if (argv [ix][jx + 1]) {
            tabstops = atoi (argv [ix] + (jx + 1));
            /* advance past numbers */
            for (jx++; argv [ix][jx]; jx++) ;
            jx--;
          } else {
            ix++;
            if (ix >= argc) {
              fprintf( stderr, "%s: missing argument for -t, expected number of tabsopts\n", argv[0] );
              exit( -1 );
            }
            for (jx = 0; argv [ix][jx]; jx++) ;
            jx--;
            tabstops = atoi (argv [ix]);
          }
          break;

        case 'x':
          xref = TRUE;
          break;

        case 'v':
          fprintf( stderr, "%s\n", release );
          fflush( stderr );
          exit( -1 );
          break;

        default:
          fprintf( stderr, "%s: unknown flag: %s\n", argv[0], argv[ix] );
        case 'h':
          fprintf( stderr, " -$ -- allow file to not end with $\n" );
          fprintf( stderr, " -a -- enable additional function not in PAL8\n" );
          fprintf( stderr, " -d -- dump symbol table\n" );
          fprintf( stderr, " -e -- error if link generated\n" );
          fprintf( stderr, " -h -- show this help\n" );
          fprintf( stderr, " -l -- generate literal/link (default)\n" );
          fprintf( stderr, " -n -- no redefining with label permanent symbols\n" );
          fprintf( stderr, " -p -- output permanent symbols to file\n" );
          fprintf( stderr, " -r -- output rim format file\n" );
          fprintf( stderr, " -t N -- set tab stops to N\n" );
          fprintf( stderr, " -v -- display version\n" );
          fprintf( stderr, " -x -- output cross reference to file\n" );
          fflush( stderr );
          exit( -1 );
        } /* end switch                                                       */
      } /* end for                                                            */
    }
    else
    {
      if( pathname != NULL )
      {
        fprintf( stderr, "%s: too many input files\n", argv[0] );
        exit( -1 );
      }
      pathname = &argv[ix][0];
    }
  } /* end for                                                                */

  if( pathname == NULL )
  {
    fprintf( stderr, "%s:  no input file specified\n", argv[0] );
    exit( -1 );
  }

  len = strlen( pathname );
  if( len > NAMELEN - 5 )
  {
    fprintf( stderr, "%s: pathname \"%s\" too long\n", argv[0], pathname );
    exit( -1 );
  }

  /* Now open the input file.                                                 */
  if(( infile = fopen( pathname, "r" )) == NULL )
  {
    fprintf( stderr, "%s: cannot open \"%s\": %s\n", argv[0], pathname, strerror(errno) );
    exit( -1 );
  }

  /* Now make the pathnames                                                   */
  /* Find last '.', if it exists.                                             */
  jx = len - 1;
  while( pathname[jx] != '.'  && pathname[jx] != '/'
      && pathname[jx] != '\\' && jx >= 0 )
  {
    jx--;
  }

  switch( pathname[jx] )
  {
  case '.':
    break;

  case '/':
  case '\\':
    jx = len;
    break;

  default:
    break;
  }

  /* Add the pathname extensions.                                             */
  strncpy( objectpathname, pathname, jx );
  objectpathname[jx] = '\0';
  strcat( objectpathname, rim_mode ? ".rim" : ".bin" );

  strncpy( listpathname, pathname, jx );
  listpathname[jx] = '\0';
  strcat( listpathname, ".lst" );

  strncpy( errorpathname, pathname, jx );
  errorpathname[jx] = '\0';
  strcat( errorpathname, ".err" );

  strncpy( permpathname, pathname, jx );
  permpathname[jx] = '\0';
  strcat( permpathname, ".prm" );

  /* Extract the filename from the path.                                      */
  if( isalpha( pathname[0] ) && pathname[1] == ':' && pathname[2] != '\\' )
  {
    pathname[1] = '\\';         /* MS-DOS style pathname                      */
  }

  jx = len - 1;
  while( pathname[jx] != '/' && pathname[jx] != '\\' && jx >= 0 )
  {
    jx--;
  }
  strcpy( filename, &pathname[jx + 1] );

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
andq $0x0, 0x8b75(%rip)      # 0xb3d0
andq $0x0, 0x8bad(%rip)      # 0xb410
andq $0x0, 0x8cc5(%rip)      # 0xb530
movq %rsi, (%rsp)
andq $0x0, 0x8cc1(%rip)      # 0xb538
movl %edi, 0xc(%rsp)
andq $0x0, 0x8c1d(%rip)      # 0xb4a0
andq $0x0, 0x8c1d(%rip)      # 0xb4a8
movl $0x8, 0x8cb7(%rip)      # 0xb54c
pushq $0x1
popq %r12
movq 0x8aa8(%rip), %rbx      # 0xb348
leaq 0x4769(%rip), %r13      # 0x7010
cmpl 0xc(%rsp), %r12d
jge 0x2b2f
movslq %r12d, %rax
movq (%rsp), %rcx
movq (%rcx,%rax,8), %r15
cmpb $0x2d, (%r15)
jne 0x29d1
movq %rbx, 0x10(%rsp)
pushq $0x1
popq %rax
movl %eax, %r14d
movslq %r14d, %rbx
movzbl (%r15,%rbx), %eax
leal -0x61(%rax), %ecx
cmpl $0x17, %ecx
ja 0x28f8
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
jmpq *%rax
movb $0x1, 0x8a4c(%rip)      # 0xb33f
jmp 0x29c9
cmpl $0x24, %eax
jne 0x29e6
movb $0x1, 0x8a36(%rip)      # 0xb33e
jmp 0x29c9
movb $0x1, 0x8a2c(%rip)      # 0xb340
jmp 0x29c9
movb $0x1, 0x8a1a(%rip)      # 0xb33a
jmp 0x29c9
movb $0x0, 0x8a0e(%rip)      # 0xb33a
jmp 0x29c9
movb $0x1, 0x8a04(%rip)      # 0xb33c
jmp 0x29c9
movb $0x1, 0x89f7(%rip)      # 0xb33b
jmp 0x29c9
cmpb $0x0, 0x1(%r15,%rbx)
je 0x2990
leaq 0x1(%rbx), %rbp
leaq (%r15,%rbx), %rdi
incq %rdi
callq 0x2150
movl %eax, 0x8be5(%rip)      # 0xb54c
decl %ebx
addq %r15, %rbp
movl %ebx, %r14d
incl %r14d
cmpb $0x0, (%rbp)
leaq 0x1(%rbp), %rbp
jne 0x296f
jmp 0x29c9
movb $0x1, 0x89b8(%rip)      # 0xb33d
jmp 0x29c9
movb $0x1, 0x89b3(%rip)      # 0xb341
jmp 0x29c9
incl %r12d
cmpl 0xc(%rsp), %r12d
jge 0x2d0d
movslq %r12d, %rax
movq (%rsp), %rcx
movq (%rcx,%rax,8), %r15
xorl %r14d, %r14d
cmpb $0x0, (%r15,%r14)
leaq 0x1(%r14), %r14
jne 0x29ac
addl $-0x2, %r14d
movq %r15, %rdi
callq 0x2150
movl %eax, 0x8b83(%rip)      # 0xb54c
incl %r14d
jmp 0x28d2
testq %rbx, %rbx
jne 0x2d31
movq %r15, 0x8967(%rip)      # 0xb348
movq %r15, %rbx
jmp 0x29ef
testl %eax, %eax
jne 0x29f7
movq 0x10(%rsp), %rbx
incl %r12d
jmp 0x28a7
movq 0x75fa(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq (%rsp), %rax
movq (%rax), %rdx
leaq 0x4c9d(%rip), %rsi      # 0x76ac
movq %r15, %rcx
xorl %eax, %eax
callq 0x2110
movq 0x75d8(%rip), %r14      # 0x9ff8
movq (%r14), %rcx
leaq 0x4c98(%rip), %rdi      # 0x76c2
pushq $0x24
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x2180
movq (%r14), %rcx
leaq 0x4ca5(%rip), %rdi      # 0x76e7
pushq $0x2e
popq %rsi
movq %rbx, %rdx
callq 0x2180
movq (%r14), %rcx
leaq 0x4cbf(%rip), %rdi      # 0x7716
pushq $0x19
popq %rsi
movq %rbx, %rdx
callq 0x2180
movq (%r14), %rcx
leaq 0x4cc4(%rip), %rdi      # 0x7730
pushq $0x1f
popq %rsi
movq %rbx, %rdx
callq 0x2180
movq (%r14), %rcx
leaq 0x4ccf(%rip), %rdi      # 0x7750
pushq $0x16
popq %rsi
movq %rbx, %rdx
callq 0x2180
movq (%r14), %rcx
leaq 0x4cd1(%rip), %rdi      # 0x7767
pushq $0x27
popq %rsi
movq %rbx, %rdx
callq 0x2180
movq (%r14), %rcx
leaq 0x4ce4(%rip), %rdi      # 0x778f
pushq $0x32
popq %rsi
movq %rbx, %rdx
callq 0x2180
movq (%r14), %rcx
leaq 0x4d02(%rip), %rdi      # 0x77c2
pushq $0x28
popq %rsi
movq %rbx, %rdx
callq 0x2180
movq (%r14), %rcx
leaq 0x4d16(%rip), %rdi      # 0x77eb
pushq $0x1e
popq %rsi
movq %rbx, %rdx
callq 0x2180
movq (%r14), %rcx
leaq 0x4d20(%rip), %rdi      # 0x780a
pushq $0x1c
popq %rsi
movq %rbx, %rdx
callq 0x2180
movq (%r14), %rcx
leaq 0x4d28(%rip), %rdi      # 0x7827
pushq $0x17
popq %rsi
movq %rbx, %rdx
callq 0x2180
movq (%r14), %rcx
leaq 0x4d2b(%rip), %rdi      # 0x783f
pushq $0x26
popq %rsi
movq %rbx, %rdx
callq 0x2180
movq (%r14), %rdi
callq 0x2130
pushq $-0x1
popq %rdi
callq 0x2170
testq %rbx, %rbx
je 0x2d4b
movq %rbx, %rdi
callq 0x20a0
movq %rax, %r15
cmpl $0x7c, %r15d
jge 0x2d65
leaq 0x46b2(%rip), %rsi      # 0x7206
movq %rbx, %rdi
callq 0x2140
movq %rax, 0x88ad(%rip)      # 0xb410
testq %rax, %rax
je 0x2d8c
movq 0x87d5(%rip), %rbx      # 0xb348
leal -0x1(%r15), %eax
movslq %eax, %r12
movq %r12, %rax
movzbl (%rbx,%rax), %ecx
movl %ecx, %edx
andb $-0x2, %dl
cmpb $0x2e, %dl
je 0x2b9a
testq %rax, %rax
js 0x2b9a
cmpb $0x5c, %cl
je 0x2b9a
decq %rax
jmp 0x2b7d
cmpl $0x2f, %ecx
je 0x2ba7
cmpl $0x5c, %ecx
je 0x2ba7
movq %rax, %r15
movslq %r15d, %r14
leaq 0x886f(%rip), %r15      # 0xb420
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2050
xorl %ebp, %ebp
movb %bpl, (%r14,%r15)
cmpb %bpl, 0x8771(%rip)      # 0xb33d
leaq 0x4d06(%rip), %rax      # 0x78d9
leaq 0x4cfa(%rip), %r13      # 0x78d4
cmoveq %rax, %r13
movq %r15, %rdi
callq 0x20a0
movl (%r13), %ecx
movl %ecx, (%rax,%r15)
movb 0x4(%r13), %cl
movb %cl, 0x4(%rax,%r15)
leaq 0x88b2(%rip), %r15      # 0xb4b0
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2050
movb %bpl, (%r14,%r15)
movq %r15, %rdi
callq 0x20a0
movb %bpl, 0x4(%rax,%r15)
movl $0x74736c2e, (%rax,%r15) # imm = 0x74736C2E
leaq 0x8724(%rip), %r15      # 0xb350
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2050
movb %bpl, (%r14,%r15)
movq %r15, %rdi
callq 0x20a0
movb %bpl, 0x4(%rax,%r15)
movl $0x7272652e, (%rax,%r15) # imm = 0x7272652E
leaq 0x88f6(%rip), %r15      # 0xb550
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2050
movb %bpl, (%r14,%r15)
movq %r15, %rdi
callq 0x20a0
movb %bpl, 0x4(%rax,%r15)
movl $0x6d72702e, (%rax,%r15) # imm = 0x6D72702E
callq 0x21a0
movq (%rax), %rax
movsbq (%rbx), %rcx
testb $0x4, 0x1(%rax,%rcx,2)
je 0x2cab
cmpb $0x3a, 0x1(%rbx)
jne 0x2cab
cmpb $0x5c, 0x2(%rbx)
je 0x2cab
movb $0x5c, 0x1(%rbx)
movq 0x869d(%rip), %rbx      # 0xb348
leaq (%r12,%rbx), %rcx
incq %rcx
movq %rcx, %rsi
movb -0x1(%rcx), %al
cmpb $0x2f, %al
je 0x2ccc
testq %r12, %r12
js 0x2ccc
decq %r12
leaq -0x1(%rsi), %rcx
cmpb $0x5c, %al
jne 0x2cb2
leaq 0x88fd(%rip), %rdi      # 0xb5d0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2070
movq 0x730b(%rip), %rbx      # 0x9ff8
movq (%rbx), %rdi
movq 0x73f9(%rip), %rdx      # 0xa0f0
leaq 0x4bd2(%rip), %rsi      # 0x78d0
xorl %eax, %eax
callq 0x2110
movq (%rbx), %rdi
jmp 0x2b22
movq 0x72e4(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq (%rsp), %rax
movq (%rax), %rdx
leaq 0x494d(%rip), %rsi      # 0x7672
xorl %eax, %eax
callq 0x2110
jmp 0x2b27
movq 0x72c0(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq (%rsp), %rax
movq (%rax), %rdx
leaq 0x4b1d(%rip), %rsi      # 0x7866
jmp 0x2d25
movq 0x72a6(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq (%rsp), %rax
movq (%rax), %rdx
leaq 0x4b1d(%rip), %rsi      # 0x7880
jmp 0x2d25
movq 0x728c(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq (%rsp), %rax
movq (%rax), %rdx
leaq 0x4b21(%rip), %rsi      # 0x789e
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2110
jmp 0x2b27
movq 0x7265(%rip), %rax      # 0x9ff8
movq (%rax), %r14
movq (%rsp), %rax
movq (%rax), %rbx
movq 0x85a4(%rip), %r15      # 0xb348
callq 0x2040
movl (%rax), %edi
callq 0x2190
leaq 0x4b03(%rip), %rsi      # 0x78ba
movq %r14, %rdi
movq %rbx, %rdx
movq %r15, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x2110
jmp 0x2b27