// File: /workspace/github_c_makefile_star2_O1/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, %rbx
xorl %eax, %eax
movq %rax, 0x8895(%rip)      # 0xb3e0
movq %rax, 0x88ce(%rip)      # 0xb420
movq %rax, 0x89e7(%rip)      # 0xb540
movq %rax, 0x89e8(%rip)      # 0xb548
movq %rax, 0x8949(%rip)      # 0xb4b0
movq %rax, 0x894a(%rip)      # 0xb4b8
movl $0x8, 0x89e4(%rip)      # 0xb55c
movl %edi, 0xc(%rsp)
cmpl $0x2, %edi
jl 0x2ce1
movl $0x1, %r15d
movq 0x87c6(%rip), %rcx      # 0xb358
leaq 0x4477(%rip), %r12      # 0x7010
movslq %r15d, %rax
movq (%rbx,%rax,8), %rax
cmpb $0x2d, (%rax)
jne 0x2cb1
movq %rcx, 0x10(%rsp)
movl $0x1, %r13d
movslq %r15d, %rax
movq (%rbx,%rax,8), %r14
movslq %r13d, %rbp
movzbl (%r14,%rbp), %eax
leal -0x61(%rax), %ecx
cmpl $0x17, %ecx
ja 0x2be0
movslq (%r12,%rcx,4), %rax
addq %r12, %rax
jmpq *%rax
movb $0x1, 0x8774(%rip)      # 0xb34f
jmp 0x2ca9
cmpl $0x24, %eax
jne 0x2cc6
movb $0x1, 0x875e(%rip)      # 0xb34e
jmp 0x2ca9
movb $0x1, 0x8754(%rip)      # 0xb350
jmp 0x2ca9
movb $0x1, 0x8742(%rip)      # 0xb34a
jmp 0x2ca9
movb $0x0, 0x8736(%rip)      # 0xb34a
jmp 0x2ca9
movb $0x1, 0x872c(%rip)      # 0xb34c
jmp 0x2ca9
movb $0x1, 0x871f(%rip)      # 0xb34b
jmp 0x2ca9
cmpb $0x0, 0x1(%r14,%rbp)
je 0x2c77
leaq 0x1(%rbp), %r13
leaq (%r14,%rbp), %rdi
incq %rdi
callq 0x2170
movl %eax, 0x8910(%rip)      # 0xb55c
movslq %r13d, %rax
decl %ebp
addq %r14, %rax
movl %ebp, %r13d
incl %r13d
cmpb $0x0, (%rax)
leaq 0x1(%rax), %rax
jne 0x2c57
jmp 0x2ca9
movb $0x1, 0x86e1(%rip)      # 0xb34d
jmp 0x2ca9
movb $0x1, 0x86dc(%rip)      # 0xb351
jmp 0x2ca9
incl %r15d
cmpl 0xc(%rsp), %r15d
jge 0x2ee3
movslq %r15d, %rax
movq (%rbx,%rax,8), %rdi
xorl %r13d, %r13d
cmpb $0x0, (%rdi,%r13)
leaq 0x1(%r13), %r13
jne 0x2c8f
addl $-0x2, %r13d
callq 0x2170
movl %eax, 0x88b3(%rip)      # 0xb55c
incl %r13d
jmp 0x2bb4
testq %rcx, %rcx
jne 0x2eeb
movq %rax, 0x8697(%rip)      # 0xb358
movq %rax, %rcx
jmp 0x2cd3
testl %eax, %eax
jne 0x2ebb
movq 0x10(%rsp), %rcx
incl %r15d
cmpl 0xc(%rsp), %r15d
jl 0x2b99
movq 0x8670(%rip), %r15      # 0xb358
testq %r15, %r15
je 0x2ef3
movq %r15, %rdi
callq 0x20a0
movq %rax, %r14
cmpl $0x7c, %r14d
jge 0x2efb
leaq 0x44f9(%rip), %rsi      # 0x7206
movq %r15, %rdi
callq 0x2160
movq %rax, 0x8704(%rip)      # 0xb420
testq %rax, %rax
je 0x2f06
movslq %r14d, %r12
movq 0x8629(%rip), %rbx      # 0xb358
movb -0x1(%rbx,%r12), %al
decq %r12
movl %eax, %ecx
andb $-0x2, %cl
cmpb $0x2e, %cl
jne 0x2d46
movl %r12d, %ecx
jmp 0x2d6a
movslq %r12d, %rdx
movl %r12d, %ecx
testq %rdx, %rdx
js 0x2d6a
cmpb $0x5c, %al
je 0x2d6a
decl %ecx
movb -0x1(%rbx,%rdx), %al
decq %rdx
movl %eax, %esi
andb $-0x2, %sil
cmpb $0x2e, %sil
jne 0x2d4c
cmpb $0x5c, %al
je 0x2d76
movzbl %al, %eax
cmpl $0x2f, %eax
jne 0x2d79
movl %r14d, %ecx
movslq %ecx, %r14
leaq 0x86ad(%rip), %r15      # 0xb430
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2050
xorl %ebp, %ebp
movb %bpl, (%r14,%r15)
cmpb %bpl, 0x85af(%rip)      # 0xb34d
leaq 0x4b34(%rip), %rax      # 0x78d9
leaq 0x4b28(%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 0x86f0(%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 0x8562(%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 0x8734(%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 0x2e76
cmpb $0x3a, 0x1(%rbx)
jne 0x2e76
cmpb $0x5c, 0x2(%rbx)
je 0x2e76
movb $0x5c, 0x1(%rbx)
movq 0x84db(%rip), %rax      # 0xb358
movb (%rax,%r12), %cl
cmpb $0x2f, %cl
je 0x2e9a
testq %r12, %r12
js 0x2e9a
cmpb $0x5c, %cl
je 0x2e9a
movb -0x1(%rax,%r12), %cl
decq %r12
jmp 0x2e81
leaq (%rax,%r12), %rsi
incq %rsi
leaq 0x8738(%rip), %rdi      # 0xb5e0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2070
movq 0x7136(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq (%rbx), %rdx
leaq 0x47dd(%rip), %rsi      # 0x76ac
movq %r14, %rcx
xorl %eax, %eax
callq 0x2120
callq 0x2501
callq 0x2412
movq %rbx, %rdi
callq 0x2442
movq %rbx, %rdi
callq 0x23eb
movq %rbx, %rdi
callq 0x24da
movq %rbx, %rdi
movq %r15, %rsi
callq 0x24b0
movq %rbx, %rdi
callq 0x2469