// File: /workspace/github_c_makefile_star2_O3/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, 0x74c5(%rip)      # 0x9ec0
movq %rax, 0x749e(%rip)      # 0x9ea0
movq %rax, 0x749f(%rip)      # 0x9ea8
movq %rax, 0x7400(%rip)      # 0x9e10
movq %rax, 0x7401(%rip)      # 0x9e18
cmpl $0x2, %edi
jl 0x2ac9
movl %edi, %ebp
movl $0x1, %r15d
leaq 0x35d5(%rip), %r12      # 0x6004
movslq %r15d, %rax
movq (%r14,%rax,8), %rbx
cmpb $0x2d, (%rbx)
jne 0x2add
incl %r15d
incq %rbx
movzbl (%rbx), %eax
cmpl $0x6c, %eax
jle 0x2a6b
addl $-0x6d, %eax
cmpl $0xb, %eax
ja 0x2c67
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movb $0x0, 0x72f8(%rip)      # 0x9d61
jmp 0x2a42
cmpl $0x53, %eax
je 0x2aa2
cmpl $0x64, %eax
jne 0x2ab8
movb $0x1, 0x72ec(%rip)      # 0x9d68
jmp 0x2a42
movb $0x1, 0x72de(%rip)      # 0x9d63
jmp 0x2a42
movb $0x1, 0x72d4(%rip)      # 0x9d62
jmp 0x2a42
movb $0x1, 0x72c9(%rip)      # 0x9d60
jmp 0x2a42
movb $0x1, 0x72c9(%rip)      # 0x9d69
jmp 0x2a42
cmpl %ebp, %r15d
jg 0x2a42
movslq %r15d, %rax
incl %r15d
movq (%r14,%rax,8), %rdi
callq 0x350d
jmp 0x2a42
testl %eax, %eax
jne 0x2c67
cmpl %ebp, %r15d
jl 0x2a2f
movq 0x72a0(%rip), %rbx      # 0x9d70
testq %rbx, %rbx
jne 0x2aeb
movq %r14, %rdi
callq 0x2218
movl %r15d, 0x73e4(%rip)     # 0x9ec8
movq %rbx, 0x7285(%rip)      # 0x9d70
movq %rbx, %rdi
callq 0x2090
cmpl $0x7c, %eax
jge 0x2c72
movslq %eax, %r12
movb -0x1(%rbx,%r12), %cl
decq %r12
movl %ecx, %edx
andb $-0x2, %dl
cmpb $0x2e, %dl
jne 0x2b16
movl %r12d, %edx
jmp 0x2b3b
movq %r12, %rsi
movl %r12d, %edx
testq %rsi, %rsi
js 0x2b3b
cmpb $0x5c, %cl
je 0x2b3b
decl %edx
movb -0x1(%rbx,%rsi), %cl
decq %rsi
movl %ecx, %edi
andb $-0x2, %dil
cmpb $0x2e, %dil
jne 0x2b1c
cmpb $0x5c, %cl
je 0x2b48
movzbl %cl, %ecx
cmpl $0x2f, %ecx
jne 0x2b4a
movl %eax, %edx
movslq %edx, %r14
leaq 0x723c(%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 0x729c(%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 0x731e(%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 0x7370(%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 0x2c31
cmpb $0x3a, 0x1(%rbx)
jne 0x2c31
cmpb $0x5c, 0x2(%rbx)
je 0x2c31
movb $0x5c, 0x1(%rbx)
movq 0x713f(%rip), %rbx      # 0x9d70
movb (%rbx,%r12), %al
cmpb $0x2f, %al
je 0x2c4c
testq %r12, %r12
js 0x2c4c
cmpb $0x5c, %al
je 0x2c4c
movb -0x1(%rbx,%r12), %al
decq %r12
jmp 0x2c35
leaq (%rbx,%r12), %rsi
incq %rsi
leaq 0x7376(%rip), %rdi      # 0x9fd0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2070
movq %r14, %rdi
movl %r15d, %esi
callq 0x223f
movq %r14, %rdi
movq %rbx, %rsi
callq 0x21ee