// File: /workspace/github_c_makefile_star2_O1/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
subq $0x18, %rsp
movl $0x80, %eax
movq %rax, 0x13388(%rip)     # 0x15fb0
xorl %ecx, %ecx
movq %rcx, 0x13387(%rip)     # 0x15fb8
movq %rax, 0x13388(%rip)     # 0x15fc0
movq %rcx, 0x13389(%rip)     # 0x15fc8
leaq 0x1338a(%rip), %rdx     # 0x15fd0
leaq 0x13b83(%rip), %rsi     # 0x167d0
movq %rax, (%rcx,%rdx)
movq %rax, (%rcx,%rsi)
addq $0x8, %rcx
cmpq $0x800, %rcx            # imm = 0x800
jne 0x2c4d
xorl %ebx, %ebx
movq %rbx, 0x14365(%rip)     # 0x16fd0
movq %rbx, 0x14366(%rip)     # 0x16fd8
leaq 0x9027(%rip), %r13      # 0xbca0
movq (%rbx,%r13), %rdi
testq %rdi, %rdi
je 0x2c87
callq 0x2030
addq $0x8, %rbx
cmpq $0x2000, %rbx           # imm = 0x2000
jne 0x2c79
xorl %eax, %eax
movq %rax, 0x14343(%rip)     # 0x16fe0
movq %rax, 0x14744(%rip)     # 0x173e8
movq $0x1, 0x14b41(%rip) # 0x177f0
movb $0x1, 0x14b42(%rip)     # 0x177f8
movl %eax, 0x14b40(%rip)     # 0x177fc
movl %eax, 0x14b3e(%rip)     # 0x17800
movl %eax, 0x14b3c(%rip)     # 0x17804
movb $0x0, 0x14b39(%rip)     # 0x17808
movl $0x3c, 0x14b33(%rip)    # 0x1780c
movq $0x8, 0x14b2c(%rip) # 0x17810
movslq 0x131b5(%rip), %rax     # 0x15ea0
movl %eax, 0x14b27(%rip)     # 0x17818
movq 0x8f90(%rip), %rcx      # 0xbc88
movq (%rcx,%rax,8), %rdi
leaq 0x454d(%rip), %rsi      # 0x7250
callq 0x2160
movq %rax, 0x13189(%rip)     # 0x15e98
testq %rax, %rax
je 0x3145
leaq 0x14b01(%rip), %rbx     # 0x17820
callq 0x37ea
callq 0x3ab5
movq 0x14ed8(%rip), %rbp     # 0x17c08
movzbl (%rbp,%rbx), %eax
cmpl $0x29, %eax
jg 0x2dfe
testl %eax, %eax
je 0x2d1f
cmpl $0xa, %eax
je 0x2d1f
cmpl $0x24, %eax
je 0x3125
movsbq %al, %r14
movq 0x14ebd(%rip), %r15     # 0x17c18
movzbl (%r15,%rbx), %r12d
callq 0x21a0
movq (%rax), %rax
movzwl (%rax,%r14,2), %eax
cmpl $0x3d, %r12d
je 0x2ea7
cmpl $0x2c, %r12d
je 0x2f82
btl $0xa, %eax
jb 0x2f43
movq 0x1321e(%rip), %r15     # 0x15fb0
callq 0x441b
movq %rax, %r12
andl $0xfff, %r12d           # imm = 0xFFF
movq 0x13210(%rip), %rsi     # 0x15fb8
orq %r15, %rsi
movq %rbx, %rdi
movq %r12, %rdx
movl $0x2, %ecx
callq 0x3f6b
movq %r15, %rdi
movq %r12, %rsi
callq 0x6b33
movq 0x131e3(%rip), %rdi     # 0x15fb0
callq 0x6843
movq 0x131d7(%rip), %rax     # 0x15fb0
movl %eax, %ecx
andl $0x7000, %ecx           # imm = 0x7000
incl %eax
andl $0xfff, %eax            # imm = 0xFFF
orq %rax, %rcx
movq %rcx, 0x131be(%rip)     # 0x15fb0
movq %rax, 0x131c7(%rip)     # 0x15fc0
jmp 0x2d29
cmpl $0x2a, %eax
je 0x2e1a
cmpl $0x3b, %eax
je 0x2d24
cmpl $0x2f, %eax
jne 0x2d50
jmp 0x2d1f
callq 0x3ab5
callq 0x3bea
cmpb $0x0, 0x14de5(%rip)     # 0x17c10
jne 0x2d29
movq 0x8d90(%rip), %r15      # 0xbbc8
andl $0xfff, %r15d           # imm = 0xFFF
orq 0x13172(%rip), %r15     # 0x15fb8
movq 0x13163(%rip), %rsi     # 0x15fb0
movl %esi, %eax
xorl %r15d, %eax
testl $0xf80, %eax            # imm = 0xF80
je 0x2e68
decq %rsi
leaq 0x1417d(%rip), %rdi     # 0x16fe0
callq 0x3e22
subq 0x13159(%rip), %r15     # 0x15fc8
movq %r15, 0x1313a(%rip)     # 0x15fb0
movl %r15d, %eax
andl $0xfff, %eax            # imm = 0xFFF
movq %rax, 0x1313b(%rip)     # 0x15fc0
cmpb $0x0, 0x8e08(%rip)      # 0xbc94
jne 0x2e96
movq %r15, %rdi
callq 0x3f07
movq 0x13123(%rip), %rdx     # 0x15fc0
movq %rbx, %rdi
xorl %esi, %esi
jmp 0x2f34
btl $0xa, %eax
jb 0x2eed
movq 0x14d74(%rip), %r12     # 0x17c28
leaq 0xa(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x422d
leaq 0x8b22(%rip), %rdi      # 0xb9f0
movq %r14, %rsi
movq %r12, %rdx
callq 0x42a8
callq 0x3ab5
callq 0x3ab5
callq 0x441b
jmp 0x2d29
movb %r12b, 0x14d2c(%rip)    # 0x17c20
callq 0x43c9
callq 0x3ab5
callq 0x441b
movq %rax, %r12
leaq 0xa(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x422d
movq %r14, %rdi
movq %r12, %rsi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2b4e
movq %rbx, %rdi
xorl %esi, %esi
movq %r12, %rdx
movl $0x1, %ecx
callq 0x3f6b
jmp 0x2d29
callq 0x4597
movq 0x10(%rax), %rbp
movl (%rax), %eax
notl %eax
testl $0x101, %eax            # imm = 0x101
je 0x3058
testb $0x43, %al
jne 0x2d8b
callq 0x3ab5
andl $0xfff, %ebp            # imm = 0xFFF
movl %ebp, %edi
callq 0x45ff
testb %al, %al
jne 0x2d29
jmp 0x2d1f
btl $0xa, %eax
jb 0x2fb2
leaq 0xa(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x422d
leaq 0x8a1e(%rip), %rdi      # 0xb9c0
movq %r14, %rsi
movq %rbp, %rdx
callq 0x42a8
jmp 0x304e
leaq 0x11(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x422d
movq %r14, %rdi
callq 0x40f1
testb $0x1, (%rax)
je 0x300f
movq %rax, %r15
movq 0x12fd4(%rip), %rax     # 0x15fb0
andl $0xfff, %eax            # imm = 0xFFF
cmpq %rax, 0x10(%r15)
je 0x300b
cmpq $0x2, 0xad41(%rip)      # 0xdd30
jne 0x300b
movq %r15, %rsi
addq $0x4, %rsi
movq 0x14c09(%rip), %rdx     # 0x17c08
leaq 0x897a(%rip), %rdi      # 0xb980
callq 0x42a8
orb $0x21, (%r15)
movq 0x14bf2(%rip), %r15     # 0x17c08
movq 0x14bfb(%rip), %rdx     # 0x17c18
movq 0x12fa4(%rip), %rbp     # 0x15fc8
addq 0x12f85(%rip), %rbp     # 0x15fb0
leaq 0xa(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x422d
movq %r14, %rdi
movq %rbp, %rsi
movl $0x9, %edx
movq %r15, %rcx
callq 0x2b4e
callq 0x3ab5
jmp 0x2d24
movb $0x1, %cl
xorl %eax, %eax
movq 0x14bcd(%rip), %r15     # 0x17c30
movabsq $0x4000100100001200, %rdi # imm = 0x4000100100001200
movabsq $0x800000000401, %r8    # imm = 0x800000000401
movzbl (%r15,%rbx), %esi
cmpq $0x2f, %rsi
ja 0x3088
btq %rsi, %r8
jb 0x30c7
cmpl $0x3b, %esi
je 0x30c7
cmpl $0x13, %eax
jg 0x30c7
cmpl $0x3e, %esi
ja 0x30af
movb $0x1, %dl
movl %esi, %esi
btq %rsi, %rdi
jae 0x30af
incq %r15
movq %r15, 0x14b85(%rip)     # 0x17c30
movl %edx, %ecx
jmp 0x3077
testb %cl, %cl
je 0x30c3
movslq %eax, %rcx
incl %eax
leaq 0x8b31(%rip), %rdx      # 0xbbf0
movl %r15d, (%rdx,%rcx,4)
xorl %edx, %edx
jmp 0x30a1
cmpl $0x13, %eax
jg 0x30f0
movslq %eax, %rcx
leaq 0x8b1a(%rip), %rdx      # 0xbbf0
leaq (%rdx,%rcx,4), %rdi
movl $0x13, %ecx
subl %eax, %ecx
leaq 0x4(,%rcx,4), %rdx
xorl %esi, %esi
callq 0x20d0
movl $0xfa, %edx
leaq 0x14b44(%rip), %rdi     # 0x17c40
movq %rbx, %rsi
callq 0x2130
movq %r15, 0x14f1d(%rip)     # 0x18028
movq (%r13,%rbp,8), %rax
movq %rax, 0x13ec1(%rip)     # 0x16fd8
testq %rax, %rax
je 0x2d24
jmp 0x2d1f
callq 0x3baf
movq 0x12d67(%rip), %rdi     # 0x15e98
callq 0x20a0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x238f