// File: /workspace/github_c_makefile_star2_O2/AK6DN[P]dec-utilities-for-pdp/macro8x/macro8x.c
// Function: onePass
void onePass()
{
  BOOL    blanks;
  int     ix;
  int     jx;
  char    name[SYMLEN];
  WORD32  newclc;
  BOOL    scanning_line;
  WORD32  start;
  SYM_T  *sym;
  WORD32  term;
  WORD32  val;

  clc = 0200;                   /* Default starting address is 200 octal.     */
  field = 0;
  fieldlc = 0200;
  reloc = 0;
  for( ix = 0; ix < TOTAL_PAGES; ix++ )
  {
    lit_loc[ix] = lit_base[ix] = 00200;
  }
  mac_count = 0;               /* No macros defined.                          */
  mac_ptr = NULL;              /* Not in a macro.                             */
  for( ix = 0; ix < MAC_TABLE_LENGTH; ix++)
  {
    if ( mac_bodies[ix] )
    {
      free( mac_bodies[ix] );
    }
  }
  cp.error = FALSE;
  pz.error = FALSE;
  listed = TRUE;
  lgm_flag = TRUE;
  lineno = 0;
  list_pageno = 0;
  list_lineno = 0;
  list_title_set = FALSE;
  page_lineno = LIST_LINES_PER_PAGE;    /* Force top of page for new titles.  */
  radix = 8;                    /* Initial radix is octal (base 8).           */

  /* Now open the first input file.                                           */
  filix_curr = filix_start;     /* Initialize pointer to input files.         */
  if(( infile = fopen( save_argv[filix_curr], "r" )) == NULL )
  {
    fprintf( stderr, "%s: cannot open \"%s\"\n", save_argv[0], save_argv[filix_curr] );
    exit( -1 );
  }

  while( TRUE )
  {
    readLine();
    nextLexeme();

    scanning_line = TRUE;
    while( scanning_line )
    {
      if( is_end( line[lexstart] ))
      {
        scanning_line = FALSE;
      }
      else
      {
        switch( line[lexstart] )
        {
        case '/':
          scanning_line = FALSE;
          break;

        case ';':
          nextLexeme();
          break;

        case '$':
          endOfBinary();
          fclose( infile );
          return;

        case '*':
          nextLexeme();             /* Skip '*', (set origin symbol)          */
          newclc = ((getExpr())->val & 07777 ) | field;
          /* Do not change Current Location Counter if an error occurred.     */
          if( !error_in_line )
          {
            if(( newclc & 07600 ) != ( clc & 07600 ))
            {
              /* Current page has changed.                                    */
              punchLiteralPool( &cp, clc - 1 );
            }
            clc = newclc - reloc;
            fieldlc = clc & 07777;

            if( !rim_mode )
            {
              /* Not rim mode, put out origin.                                */
              punchOrigin( clc );
            }
            printLine( line, 0, fieldlc, LINE_VAL );
          }
          break;

        default:
          switch( line[lexterm] )
          {
          case ',':
            if( is_alpha( line[lexstart] ))
            {
              /* Use lookup so symbol will not be counted as reference.       */
              sym = lookup( lexemeToName( name, lexstart, lexterm ));
              if( M_DEFINED( sym->type ))
              {
                if( sym->val != (clc & 07777) && pass == 2 )
                {
                  errorSymbol( &duplicate_label, sym->name, lexstart );
                }
                sym->type = sym->type | DUPLICATE;
              }
              /* Must call define on pass 2 to generate concordance.          */
              defineLexeme( lexstart, lexterm, ( clc+reloc ), LABEL );
            }
            else
            {
              errorLexeme( &label_syntax, lexstart );
            }
            nextLexeme();           /* skip label                             */
            nextLexeme();           /* skip comma                             */
            break;

          case '=':
            if( is_alpha( line[lexstart] ))
            {
              start = lexstart;
              term = lexterm;
              delimiter = line[lexterm];
              nextLexBlank();       /* skip symbol                            */
              nextLexeme();       /* skip trailing =                        */
              val = getExprs();
              defineLexeme( start, term, val, DEFINED );
              printLine( line, 0, val, LINE_VAL );
            }
            else
            {
              errorLexeme( &symbol_syntax, lexstartprev );
              nextLexeme();         /* skip symbol                            */
              nextLexeme();         /* skip trailing =                        */
              getExprs();           /* skip expression                        */
            }
            break;

          default:
            if( is_alpha( line[lexstart] ))
            {
              sym = evalSymbol();
              val = sym->val;
              if( M_MACRO( sym->type ))
              {                     /* Find arguments.                       */
                blanks = TRUE;      /* Expecting blanks.                     */
                for( jx = 0; !is_done( line[cc] ) && ( jx < MAC_MAX_ARGS ); cc++ )
                {
                  if(( line[cc] == ',' ) || is_blank( line[cc] )) blanks = TRUE;
                  else if( blanks )
                  {
                     mac_arg_pos[jx++] = cc;
                     blanks = FALSE;
                  }
                } /* end for                                                 */                
                for( ; jx < MAC_MAX_ARGS; jx++ )
                {
                  mac_arg_pos[jx] = 0;
                }
                for( jx = 0; jx < LINELEN; jx++ )
                {
                  mac_line[jx] = line[jx];
                }
                mac_cc = cc;       /* Save line and position in line.        */
                mac_ptr = mac_bodies[val];
                if( mac_ptr ) scanning_line = FALSE;
                else nextLexeme();
              } /* end if macro                                              */
              else if( M_PSEUDO( sym->type ))
              {
                nextLexeme();         /* Skip symbol                          */
                scanning_line = pseudoOperators( (PSEUDO_T)val & 07777 );
              }
              else
              {
                /* Identifier is not a pseudo-op, interpret as load value     */
                punchOutObject( clc, getExprs() & 07777 );
                incrementClc();
              }
            }
            else
            {
              /* Identifier is a value, interpret as load value               */
              punchOutObject( clc, getExprs() & 07777 );
              incrementClc();
            }
            break;
          } /* end switch                                                     */
          break;
        } /* end switch                                                       */
      } /* end if                                                             */
    } /* end while( scanning_line )                                           */
  } /* end while( TRUE )                                                      */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl $0x80, %eax
andq $0x0, 0x13461(%rip)     # 0x15fa8
movq %rax, 0x13452(%rip)     # 0x15fa0
andq $0x0, 0x13462(%rip)     # 0x15fb8
movq %rax, 0x13453(%rip)     # 0x15fb0
xorl %ecx, %ecx
leaq 0x1345a(%rip), %rdx     # 0x15fc0
leaq 0x13c53(%rip), %rsi     # 0x167c0
cmpq $0x800, %rcx            # imm = 0x800
je 0x2b84
movq %rax, (%rcx,%rdx)
movq %rax, (%rcx,%rsi)
addq $0x8, %rcx
jmp 0x2b6d
andq $0x0, 0x14434(%rip)     # 0x16fc0
andq $0x0, 0x14434(%rip)     # 0x16fc8
xorl %ebx, %ebx
leaq 0x90f3(%rip), %r14      # 0xbc90
cmpq $0x2000, %rbx           # imm = 0x2000
je 0x2bb5
movq (%rbx,%r14), %rdi
callq 0x2030
addq $0x8, %rbx
jmp 0x2b9d
andq $0x0, 0x14413(%rip)     # 0x16fd0
andq $0x0, 0x14813(%rip)     # 0x173d8
andl $0x0, 0x14c20(%rip)     # 0x177ec
andl $0x0, 0x14c1d(%rip)     # 0x177f0
movq $0x1, 0x14c02(%rip) # 0x177e0
andl $0x0, 0x14c0f(%rip)     # 0x177f4
movb $0x1, 0x14bfc(%rip)     # 0x177e8
movb $0x0, 0x14c05(%rip)     # 0x177f8
movl $0x3c, 0x14bff(%rip)    # 0x177fc
movq $0x8, 0x14bf8(%rip) # 0x17800
movslq 0x13281(%rip), %rax     # 0x15e90
movl %eax, 0x14bf3(%rip)     # 0x17808
movq 0x905c(%rip), %rcx      # 0xbc78
movq (%rcx,%rax,8), %rdi
leaq 0x4655(%rip), %rsi      # 0x727c
callq 0x2150
movq %rax, 0x13255(%rip)     # 0x15e88
testq %rax, %rax
je 0x2fd0
leaq 0x14bcd(%rip), %rbx     # 0x17810
leaq 0x14fe6(%rip), %rbp     # 0x17c30
callq 0x3653
callq 0x394b
movb $0x1, %al
testb %al, %al
je 0x2c4a
movq 0x14f97(%rip), %r12     # 0x17bf8
movzbl (%r12,%rbx), %ecx
xorl %eax, %eax
testl %ecx, %ecx
je 0x2c56
cmpl $0xa, %ecx
je 0x2c56
cmpl $0x2a, %ecx
je 0x2d55
cmpl $0x2f, %ecx
je 0x2c56
cmpl $0x3b, %ecx
je 0x2c4f
cmpl $0x24, %ecx
je 0x2fb0
movsbq %cl, %r13
movq 0x14f70(%rip), %r15     # 0x17c08
movzbl (%r15,%rbx), %r14d
callq 0x2190
movq (%rax), %rax
movzwl (%rax,%r13,2), %eax
cmpl $0x3d, %r14d
je 0x2e6c
cmpl $0x2c, %r14d
je 0x2f02
btl $0xa, %eax
jae 0x2e99
callq 0x4323
movq 0x10(%rax), %r12
movl (%rax), %eax
notl %eax
testw $0x101, %ax             # imm = 0x101
jne 0x2d73
movb $0x1, %dl
xorl %ecx, %ecx
movq 0x14f36(%rip), %rax     # 0x17c20
movzbl (%rax,%rbx), %edi
cmpq $0x2f, %rdi
ja 0x2d08
movabsq $0x800000000401, %rsi   # imm = 0x800000000401
btq %rdi, %rsi
jb 0x2d94
cmpl $0x3b, %edi
je 0x2d94
cmpl $0x13, %ecx
jg 0x2d94
cmpl $0x3e, %edi
ja 0x2d3e
movb $0x1, %sil
movl %edi, %edi
movabsq $0x4000100100001200, %r8 # imm = 0x4000100100001200
btq %rdi, %r8
jae 0x2d3e
incq %rax
movq %rax, 0x14ee6(%rip)     # 0x17c20
movl %esi, %edx
jmp 0x2cea
testb %dl, %dl
je 0x2d51
movslq %ecx, %rdx
incl %ecx
leaq 0x8e92(%rip), %rsi      # 0xbbe0
movl %eax, (%rsi,%rdx,4)
xorl %esi, %esi
jmp 0x2d30
callq 0x394b
callq 0x3a7a
cmpb $0x0, 0x14e9a(%rip)     # 0x17c00
movb $0x1, %al
jne 0x2c56
jmp 0x2df3
testb $0x43, %al
jne 0x2e99
callq 0x394b
andl $0xfff, %r12d           # imm = 0xFFF
movl %r12d, %edi
callq 0x438b
jmp 0x2c56
movslq %ecx, %rcx
leaq 0x8e42(%rip), %rdx      # 0xbbe0
leaq (%rdx,%rcx,4), %rdx
cmpq $0x14, %rcx
jge 0x2db4
andl $0x0, (%rdx)
incq %rcx
addq $0x4, %rdx
jmp 0x2da2
xorl %ecx, %ecx
cmpq $0xfa, %rcx
je 0x2dca
movb (%rcx,%rbx), %dl
movb %dl, (%rcx,%rbp)
incq %rcx
jmp 0x2db6
movq %rax, 0x15247(%rip)     # 0x18018
leaq 0x8eb8(%rip), %rax      # 0xbc90
movq (%rax,%r12,8), %rcx
movq %rcx, 0x141e5(%rip)     # 0x16fc8
xorl %eax, %eax
testq %rcx, %rcx
jne 0x2c56
jmp 0x2c4f
movq 0x8dbe(%rip), %r15      # 0xbbb8
andl $0xfff, %r15d           # imm = 0xFFF
orq 0x131a0(%rip), %r15     # 0x15fa8
movq 0x13191(%rip), %rsi     # 0x15fa0
movl %esi, %eax
xorl %r15d, %eax
testw $0xf80, %ax             # imm = 0xF80
je 0x2e29
decq %rsi
leaq 0x141ac(%rip), %rdi     # 0x16fd0
callq 0x3c51
subq 0x13188(%rip), %r15     # 0x15fb8
movq %r15, 0x13169(%rip)     # 0x15fa0
movl %r15d, %edx
andl $0xfff, %edx            # imm = 0xFFF
movq %rdx, 0x13169(%rip)     # 0x15fb0
cmpb $0x0, 0x8e36(%rip)      # 0xbc84
jne 0x2e5f
movq %r15, %rdi
callq 0x3d30
movq 0x13151(%rip), %rdx     # 0x15fb0
movq %rbx, %rdi
xorl %esi, %esi
pushq $0x1
popq %rcx
jmp 0x2ef8
btl $0xa, %eax
jb 0x2ebf
movq 0x14d9f(%rip), %rsi     # 0x17c18
leaq 0x8b60(%rip), %rdi      # 0xb9e0
callq 0x4122
callq 0x394b
callq 0x394b
callq 0x41b6
jmp 0x2c54
movq 0x13100(%rip), %r14     # 0x15fa0
callq 0x41b6
andl $0xfff, %eax            # imm = 0xFFF
movq %r14, %rdi
movq %rax, %rsi
callq 0x5226
callq 0x525e
jmp 0x2c54
movb $0x3d, 0x14d4a(%rip)    # 0x17c10
callq 0x4164
callq 0x394b
callq 0x41b6
movq %rax, %r14
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
pushq $0x1
popq %r15
movl %r15d, %ecx
callq 0x40e3
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
movl %r15d, %ecx
callq 0x3d4f
jmp 0x2c54
btl $0xa, %eax
jb 0x2f1c
leaq 0x8aa1(%rip), %rdi      # 0xb9b0
movq %r12, %rsi
callq 0x4122
jmp 0x2fa6
leaq 0x1(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x3fe9
movq %r14, %rdi
callq 0x3ed2
movq %rax, %r15
movl (%rax), %eax
movq 0x1305d(%rip), %rdx     # 0x15fa0
testb $0x1, %al
je 0x2f89
movl %edx, %ecx
andl $0xfff, %ecx            # imm = 0xFFF
cmpq %rcx, 0x10(%r15)
je 0x2f83
cmpq $0x2, 0xadc3(%rip)      # 0xdd20
jne 0x2f83
movq %r15, %rsi
addq $0x4, %rsi
movq 0x14c8b(%rip), %rdx     # 0x17bf8
leaq 0x89fc(%rip), %rdi      # 0xb970
callq 0x4043
movl (%r15), %eax
movq 0x1301d(%rip), %rdx     # 0x15fa0
orl $0x21, %eax
movl %eax, (%r15)
movq 0x14c68(%rip), %rdi     # 0x17bf8
movq 0x14c71(%rip), %rsi     # 0x17c08
addq 0x1301a(%rip), %rdx     # 0x15fb8
pushq $0x9
popq %rcx
callq 0x40e3
callq 0x394b
jmp 0x2c4f
callq 0x3a3f
movq 0x12ecc(%rip), %rdi     # 0x15e88
callq 0x20a0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x7021(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq 0x8c97(%rip), %rax      # 0xbc78
movq (%rax), %rdx
movslq 0x1481d(%rip), %rcx     # 0x17808
movq (%rax,%rcx,8), %rcx
leaq 0x4857(%rip), %rsi      # 0x784d
xorl %eax, %eax
callq 0x2120
pushq $-0x1
popq %rdi
callq 0x2170