// File: /workspace/github_c_makefile_star2_O3/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
movq %rsi, (%rsp)
xorl %eax, %eax
movq %rax, 0x8884(%rip)      # 0xb3e0
movq %rax, 0x88bd(%rip)      # 0xb420
movq %rax, 0x89d6(%rip)      # 0xb540
movq %rax, 0x89d7(%rip)      # 0xb548
movq %rax, 0x8938(%rip)      # 0xb4b0
movq %rax, 0x8939(%rip)      # 0xb4b8
movl $0x8, 0x89d3(%rip)      # 0xb55c
movq 0x87c8(%rip), %rdx      # 0xb358
movl %edi, 0xc(%rsp)
cmpl $0x2, %edi
jl 0x2cfe
movl $0x1, %r12d
leaq 0x4466(%rip), %r13      # 0x7010
movslq %r12d, %rax
movq (%rsp), %rcx
movq (%rcx,%rax,8), %r14
cmpb $0x2d, (%r14)
jne 0x2cc9
movq %rdx, 0x10(%rsp)
movl $0x1, %r15d
movslq %r15d, %rbx
movzbl (%r14,%rbx), %eax
leal -0x61(%rax), %ecx
cmpl $0x17, %ecx
ja 0x2bf0
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
jmpq *%rax
movb $0x1, 0x8764(%rip)      # 0xb34f
jmp 0x2cc1
cmpl $0x24, %eax
jne 0x2cde
movb $0x1, 0x874e(%rip)      # 0xb34e
jmp 0x2cc1
movb $0x1, 0x8744(%rip)      # 0xb350
jmp 0x2cc1
movb $0x1, 0x8732(%rip)      # 0xb34a
jmp 0x2cc1
movb $0x0, 0x8726(%rip)      # 0xb34a
jmp 0x2cc1
movb $0x1, 0x871c(%rip)      # 0xb34c
jmp 0x2cc1
movb $0x1, 0x870f(%rip)      # 0xb34b
jmp 0x2cc1
cmpb $0x0, 0x1(%r14,%rbx)
je 0x2c88
leaq 0x1(%rbx), %rbp
leaq (%r14,%rbx), %rdi
incq %rdi
callq 0x2170
movl %eax, 0x88fd(%rip)      # 0xb55c
decl %ebx
addq %r14, %rbp
movl %ebx, %r15d
incl %r15d
cmpb $0x0, (%rbp)
leaq 0x1(%rbp), %rbp
jne 0x2c67
jmp 0x2cc1
movb $0x1, 0x86d0(%rip)      # 0xb34d
jmp 0x2cc1
movb $0x1, 0x86cb(%rip)      # 0xb351
jmp 0x2cc1
incl %r12d
cmpl 0xc(%rsp), %r12d
jge 0x2efe
movslq %r12d, %rax
movq (%rsp), %rcx
movq (%rcx,%rax,8), %r14
xorl %r15d, %r15d
cmpb $0x0, (%r14,%r15)
leaq 0x1(%r15), %r15
jne 0x2ca4
addl $-0x2, %r15d
movq %r14, %rdi
callq 0x2170
movl %eax, 0x889b(%rip)      # 0xb55c
incl %r15d
jmp 0x2bca
testq %rdx, %rdx
jne 0x2f07
movq %r14, 0x867f(%rip)      # 0xb358
movq %r14, %rdx
jmp 0x2cee
testl %eax, %eax
jne 0x2ed2
movq 0x10(%rsp), %rdx
movq %rdx, %r14
incl %r12d
cmpl 0xc(%rsp), %r12d
jl 0x2baa
jmp 0x2d01
movq %rdx, %r14
testq %r14, %r14
je 0x2f10
movq %r14, %rdi
callq 0x20a0
movq %rax, %r15
cmpl $0x7c, %r15d
jge 0x2f19
leaq 0x44e0(%rip), %rsi      # 0x7206
movq %r14, %rdi
callq 0x2160
movq %rax, 0x86eb(%rip)      # 0xb420
testq %rax, %rax
je 0x2f25
movslq %r15d, %r12
movq 0x8610(%rip), %rbx      # 0xb358
movb -0x1(%rbx,%r12), %al
decq %r12
movl %eax, %ecx
andb $-0x2, %cl
cmpb $0x2e, %cl
jne 0x2d5f
movl %r12d, %ecx
jmp 0x2d83
movq %r12, %rdx
movl %r12d, %ecx
testq %rdx, %rdx
js 0x2d83
cmpb $0x5c, %al
je 0x2d83
decl %ecx
movb -0x1(%rbx,%rdx), %al
decq %rdx
movl %eax, %esi
andb $-0x2, %sil
cmpb $0x2e, %sil
jne 0x2d65
cmpb $0x5c, %al
je 0x2d8f
movzbl %al, %eax
cmpl $0x2f, %eax
jne 0x2d92
movl %r15d, %ecx
movslq %ecx, %r14
leaq 0x8694(%rip), %r15      # 0xb430
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2050
xorl %ebp, %ebp
movb %bpl, (%r14,%r15)
cmpb %bpl, 0x8596(%rip)      # 0xb34d
leaq 0x4b1b(%rip), %rax      # 0x78d9
leaq 0x4b0f(%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 0x86d7(%rip), %r15      # 0xb4c0
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 0x8549(%rip), %r15      # 0xb360
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 0x871b(%rip), %r15      # 0xb560
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 0x21c0
movq (%rax), %rax
movsbq (%rbx), %rcx
testb $0x4, 0x1(%rax,%rcx,2)
je 0x2e96
cmpb $0x3a, 0x1(%rbx)
jne 0x2e96
cmpb $0x5c, 0x2(%rbx)
je 0x2e96
movb $0x5c, 0x1(%rbx)
movq 0x84c2(%rip), %rbx      # 0xb358
movb (%rbx,%r12), %al
cmpb $0x2f, %al
je 0x2eb1
testq %r12, %r12
js 0x2eb1
cmpb $0x5c, %al
je 0x2eb1
movb -0x1(%rbx,%r12), %al
decq %r12
jmp 0x2e9a
leaq (%rbx,%r12), %rsi
incq %rsi
leaq 0x8721(%rip), %rdi      # 0xb5e0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2070
movq 0x711f(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq (%rsp), %rax
movq (%rax), %rdx
leaq 0x47c2(%rip), %rsi      # 0x76ac
movq %r14, %rcx
xorl %eax, %eax
callq 0x2120
callq 0x2501
callq 0x2412
movq (%rsp), %rdi
callq 0x2442
movq (%rsp), %rdi
callq 0x23eb
movq (%rsp), %rdi
callq 0x24da
movq (%rsp), %rdi
movq %r14, %rsi
callq 0x24b0
movq (%rsp), %rdi
callq 0x2469