// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/crossassemblers/macro1/macro1.c
// Function: getArgs
void getArgs( int argc, char *argv[] )
{
  WORD32  len;
  WORD32  ix, jx;

  /* Set the defaults */
  infile = NULL;
  listfile = NULL;
  listsave = NULL;
  objectfile = NULL;
  objectsave = NULL;

  for( ix = 1; ix < argc; )
  {
    if( argv[ix][0] == '-' )
    {
      char *switches = argv[ix++];
      for( jx = 1; switches[jx] != 0; jx++ )
      {
        switch( switches[jx] )
        {
        case 'd':
          symtab_print = TRUE;
          break;

        case 'r':
          rim_mode = TRUE;		/* punch pure rim-mode tapes */
          break;

	case 's':
	  sym_dump = TRUE;
	  break;

        case 'm':
          nomac_exp = FALSE;
          break;

        case 'p':
          print_permanent_symbols = TRUE;
          break;

        case 'x':
          xref = TRUE;
          break;

	case 'S':
	  if (ix <= argc)
	      read_symbols(argv[ix++]);
	  break;

        default:
          fprintf( stderr, "%s: unknown flag: %s\n", argv[0], argv[ix] );
          fprintf( stderr, " -d -- dump symbol table\n" );
          fprintf( stderr, " -m -- output macro expansions\n" );
          fprintf( stderr, " -p -- output permanent symbols to file\n" );
          fprintf( stderr, " -r -- output RIM format file\n" );
          fprintf( stderr, " -s -- output symbol punch tape to file\n" ); 
          fprintf( stderr, " -S file -- read symbol punch tape\n" );
	  fprintf( stderr, " -x -- output cross reference to file\n" );
          fflush( stderr );
          exit( -1 );
        } /* end switch */
      } /* end for */
    }
    else
    {
      filix_start = ix;
      pathname = argv[ix];
      break;
    }
  } /* 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 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");

  strncpy( listpathname, pathname, jx );
  listpathname[jx] = '\0';
  strcat( listpathname, ".lst" );

  strncpy( permpathname, pathname, jx );
  permpathname[jx] = '\0';
  strcat( permpathname, ".prm" );

  strncpy( sympathname, pathname, jx );
  sympathname[jx] = '\0';
  strcat( sympathname, ".sym" );

  /* 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 %r12
pushq %rbx
movq %rsi, %r14
xorl %eax, %eax
movq %rax, 0x74d0(%rip)      # 0x9ec0
movq %rax, 0x74a9(%rip)      # 0x9ea0
movq %rax, 0x74aa(%rip)      # 0x9ea8
movq %rax, 0x740b(%rip)      # 0x9e10
movq %rax, 0x740c(%rip)      # 0x9e18
cmpl $0x2, %edi
jl 0x2acc
movl %edi, %ebx
movl $0x1, %ebp
leaq 0x35e1(%rip), %r15      # 0x6004
movslq %ebp, %rax
movq (%r14,%rax,8), %r12
cmpb $0x2d, (%r12)
jne 0x2abf
incl %ebp
incq %r12
movzbl (%r12), %eax
cmpl $0x6c, %eax
jle 0x2a62
addl $-0x6d, %eax
cmpl $0xb, %eax
ja 0x2c5a
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movb $0x0, 0x7301(%rip)      # 0x9d61
jmp 0x2a37
cmpl $0x53, %eax
je 0x2a99
cmpl $0x64, %eax
jne 0x2aad
movb $0x1, 0x72f5(%rip)      # 0x9d68
jmp 0x2a37
movb $0x1, 0x72e7(%rip)      # 0x9d63
jmp 0x2a37
movb $0x1, 0x72dd(%rip)      # 0x9d62
jmp 0x2a37
movb $0x1, 0x72d2(%rip)      # 0x9d60
jmp 0x2a37
movb $0x1, 0x72d2(%rip)      # 0x9d69
jmp 0x2a37
cmpl %ebx, %ebp
jg 0x2a37
movslq %ebp, %rax
incl %ebp
movq (%r14,%rax,8), %rdi
callq 0x34c0
jmp 0x2a37
testl %eax, %eax
jne 0x2c5a
cmpl %ebx, %ebp
jl 0x2a23
jmp 0x2acc
movl %ebp, 0x7403(%rip)      # 0x9ec8
movq %r12, 0x72a4(%rip)      # 0x9d70
movq 0x729d(%rip), %rbx      # 0x9d70
testq %rbx, %rbx
je 0x2c64
movq %rbx, %rdi
callq 0x2090
cmpl $0x7c, %eax
jge 0x2c6c
movslq %eax, %r12
movb -0x1(%rbx,%r12), %cl
decq %r12
movl %ecx, %edx
andb $-0x2, %dl
cmpb $0x2e, %dl
jne 0x2b07
movl %r12d, %edx
jmp 0x2b2c
movslq %r12d, %rsi
movl %r12d, %edx
testq %rsi, %rsi
js 0x2b2c
cmpb $0x5c, %cl
je 0x2b2c
decl %edx
movb -0x1(%rbx,%rsi), %cl
decq %rsi
movl %ecx, %edi
andb $-0x2, %dil
cmpb $0x2e, %dil
jne 0x2b0d
cmpb $0x5c, %cl
je 0x2b39
movzbl %cl, %ecx
cmpl $0x2f, %ecx
jne 0x2b3b
movl %eax, %edx
movslq %edx, %r14
leaq 0x724b(%rip), %r15      # 0x9d90
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2040
xorl %ebp, %ebp
movb %bpl, (%r14,%r15)
movq %r15, %rdi
callq 0x2090
movb %bpl, 0x4(%rax,%r15)
movl $0x6d69722e, (%rax,%r15) # imm = 0x6D69722E
leaq 0x72ab(%rip), %r15      # 0x9e20
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2040
movb %bpl, (%r14,%r15)
movq %r15, %rdi
callq 0x2090
movb %bpl, 0x4(%rax,%r15)
movl $0x74736c2e, (%rax,%r15) # imm = 0x74736C2E
leaq 0x732d(%rip), %r15      # 0x9ed0
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2040
movb %bpl, (%r14,%r15)
movq %r15, %rdi
callq 0x2090
movb %bpl, 0x4(%rax,%r15)
movl $0x6d72702e, (%rax,%r15) # imm = 0x6D72702E
leaq 0x737f(%rip), %r15      # 0x9f50
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2040
movb %bpl, (%r14,%r15)
movq %r15, %rdi
callq 0x2090
movb %bpl, 0x4(%rax,%r15)
movl $0x6d79732e, (%rax,%r15) # imm = 0x6D79732E
callq 0x21b0
movq (%rax), %rax
movsbq (%rbx), %rcx
testb $0x4, 0x1(%rax,%rcx,2)
je 0x2c1b
cmpb $0x3a, 0x1(%rbx)
jne 0x2c1b
cmpb $0x5c, 0x2(%rbx)
je 0x2c1b
movb $0x5c, 0x1(%rbx)
movq 0x714e(%rip), %rax      # 0x9d70
movb (%rax,%r12), %cl
cmpb $0x2f, %cl
je 0x2c3f
testq %r12, %r12
js 0x2c3f
cmpb $0x5c, %cl
je 0x2c3f
movb -0x1(%rax,%r12), %cl
decq %r12
jmp 0x2c26
leaq (%rax,%r12), %rsi
incq %rsi
leaq 0x7383(%rip), %rdi      # 0x9fd0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2070
movq %r14, %rdi
movl %ebp, %esi
callq 0x223f
movq %r14, %rdi
callq 0x2218
movq %r14, %rdi
movq %rbx, %rsi
callq 0x21ee