// File: /workspace/github_c_makefile_star2_O3/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, %ecx
movq %rcx, 0x1438d(%rip)     # 0x16fb0
xorl %eax, %eax
movq %rax, 0x1438c(%rip)     # 0x16fb8
movq %rcx, 0x1438d(%rip)     # 0x16fc0
movq %rax, 0x1438e(%rip)     # 0x16fc8
leaq 0x1438f(%rip), %rcx     # 0x16fd0
movaps 0x55d8(%rip), %xmm0     # 0x8220
leaq 0x14b81(%rip), %rdx     # 0x177d0
movaps %xmm0, (%rax,%rcx)
movaps %xmm0, (%rax,%rdx)
addq $0x10, %rax
cmpq $0x800, %rax            # imm = 0x800
jne 0x2c4f
xorl %ebx, %ebx
movq %rbx, 0x15364(%rip)     # 0x17fd0
movq %rbx, 0x15365(%rip)     # 0x17fd8
leaq 0xa026(%rip), %r13      # 0xcca0
movq (%rbx,%r13), %rdi
testq %rdi, %rdi
je 0x2c88
callq 0x2030
addq $0x8, %rbx
cmpq $0x2000, %rbx           # imm = 0x2000
jne 0x2c7a
xorl %eax, %eax
movq %rax, 0x15342(%rip)     # 0x17fe0
movq %rax, 0x15743(%rip)     # 0x183e8
movq $0x1, 0x15b40(%rip) # 0x187f0
movb $0x1, 0x15b41(%rip)     # 0x187f8
movl %eax, 0x15b3f(%rip)     # 0x187fc
movl %eax, 0x15b3d(%rip)     # 0x18800
movl %eax, 0x15b3b(%rip)     # 0x18804
movb $0x0, 0x15b38(%rip)     # 0x18808
movl $0x3c, 0x15b32(%rip)    # 0x1880c
movq $0x8, 0x15b2b(%rip) # 0x18810
movslq 0x141b4(%rip), %rax     # 0x16ea0
movl %eax, 0x15b26(%rip)     # 0x18818
movq 0x9f8f(%rip), %rcx      # 0xcc88
movq (%rcx,%rax,8), %rdi
leaq 0x55a8(%rip), %rsi      # 0x82ac
callq 0x2160
movq %rax, 0x14188(%rip)     # 0x16e98
testq %rax, %rax
je 0x3151
leaq 0x15b00(%rip), %rbx     # 0x18820
callq 0x381e
callq 0x3ad6
movq 0x15ed7(%rip), %rbp     # 0x18c08
movzbl (%rbp,%rbx), %eax
cmpl $0x29, %eax
jg 0x2dff
testl %eax, %eax
je 0x2d20
cmpl $0xa, %eax
je 0x2d20
cmpl $0x24, %eax
je 0x3131
movsbq %al, %r14
movq 0x15ebc(%rip), %r15     # 0x18c18
movzbl (%r15,%rbx), %r12d
callq 0x21a0
movq (%rax), %rax
movzwl (%rax,%r14,2), %eax
cmpl $0x3d, %r12d
je 0x2ea9
cmpl $0x2c, %r12d
je 0x2f84
btl $0xa, %eax
jb 0x2f45
movq 0x1421d(%rip), %r15     # 0x16fb0
callq 0x4429
movq %rax, %r12
andl $0xfff, %r12d           # imm = 0xFFF
movq 0x1420f(%rip), %rsi     # 0x16fb8
orq %r15, %rsi
movq %rbx, %rdi
movq %r12, %rdx
movl $0x2, %ecx
callq 0x3f83
movq %r15, %rdi
movq %r12, %rsi
callq 0x6be8
movq 0x141e2(%rip), %rdi     # 0x16fb0
callq 0x68fe
movq 0x141d6(%rip), %rax     # 0x16fb0
movl %eax, %ecx
andl $0x7000, %ecx           # imm = 0x7000
incl %eax
andl $0xfff, %eax            # imm = 0xFFF
orq %rax, %rcx
movq %rcx, 0x141bd(%rip)     # 0x16fb0
movq %rax, 0x141c6(%rip)     # 0x16fc0
jmp 0x2d2a
cmpl $0x2a, %eax
je 0x2e1b
cmpl $0x3b, %eax
je 0x2d25
cmpl $0x2f, %eax
jne 0x2d51
jmp 0x2d20
callq 0x3ad6
callq 0x3bf8
cmpb $0x0, 0x15de4(%rip)     # 0x18c10
jne 0x2d2a
movq 0x9d8f(%rip), %r15      # 0xcbc8
andl $0xfff, %r15d           # imm = 0xFFF
orq 0x14171(%rip), %r15     # 0x16fb8
movq 0x14162(%rip), %rsi     # 0x16fb0
movl %esi, %eax
xorl %r15d, %eax
testl $0xf80, %eax            # imm = 0xF80
je 0x2e69
decq %rsi
leaq 0x1517c(%rip), %rdi     # 0x17fe0
callq 0x3e30
subq 0x14158(%rip), %r15     # 0x16fc8
movq %r15, 0x14139(%rip)     # 0x16fb0
movl %r15d, %edx
andl $0xfff, %edx            # imm = 0xFFF
movq %rdx, 0x14139(%rip)     # 0x16fc0
cmpb $0x0, 0x9e06(%rip)      # 0xcc94
jne 0x2e9f
movq %r15, %rdi
callq 0x3f1f
movq 0x14121(%rip), %rdx     # 0x16fc0
movq %rbx, %rdi
xorl %esi, %esi
jmp 0x2f36
btl $0xa, %eax
jb 0x2eef
movq 0x15d72(%rip), %r12     # 0x18c28
leaq 0xa(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x423f
leaq 0x9b20(%rip), %rdi      # 0xc9f0
movq %r14, %rsi
movq %r12, %rdx
callq 0x42b6
callq 0x3ad6
callq 0x3ad6
callq 0x4429
jmp 0x2d2a
movb $0x3d, 0x15d2a(%rip)    # 0x18c20
callq 0x43d7
callq 0x3ad6
callq 0x4429
movq %rax, %r12
leaq 0xa(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x423f
movq %r14, %rdi
movq %r12, %rsi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2b42
movq %rbx, %rdi
xorl %esi, %esi
movq %r12, %rdx
movl $0x1, %ecx
callq 0x3f83
jmp 0x2d2a
callq 0x45df
movq 0x10(%rax), %rbp
movl (%rax), %eax
notl %eax
testl $0x101, %eax            # imm = 0x101
je 0x3064
testb $0x43, %al
jne 0x2d8c
callq 0x3ad6
andl $0xfff, %ebp            # imm = 0xFFF
movl %ebp, %edi
callq 0x4647
testb %al, %al
jne 0x2d2a
jmp 0x2d20
btl $0xa, %eax
jb 0x2fb4
leaq 0xa(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x423f
leaq 0x9a1c(%rip), %rdi      # 0xc9c0
movq %r14, %rsi
movq %rbp, %rdx
callq 0x42b6
jmp 0x305a
leaq 0x11(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x423f
movq %r14, %rdi
callq 0x4109
movq %rax, %rbp
movl (%rax), %eax
movq 0x13fd5(%rip), %r15     # 0x16fb0
testb $0x1, %al
je 0x3022
movl %r15d, %ecx
andl $0xfff, %ecx            # imm = 0xFFF
cmpq %rcx, 0x10(%rbp)
je 0x301c
cmpq $0x2, 0xbd3a(%rip)      # 0xed30
jne 0x301c
movq %rbp, %rsi
addq $0x4, %rsi
movq 0x15c02(%rip), %rdx     # 0x18c08
leaq 0x9973(%rip), %rdi      # 0xc980
callq 0x42b6
movl (%rbp), %eax
movq 0x13f94(%rip), %r15     # 0x16fb0
orl $0x21, %eax
movl %eax, (%rbp)
movq 0x15bdf(%rip), %rbp     # 0x18c08
movq 0x15be8(%rip), %rdx     # 0x18c18
addq 0x13f91(%rip), %r15     # 0x16fc8
leaq 0xa(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0x423f
movq %r14, %rdi
movq %r15, %rsi
movl $0x9, %edx
movq %rbp, %rcx
callq 0x2b42
callq 0x3ad6
jmp 0x2d25
movb $0x1, %cl
xorl %eax, %eax
movq 0x15bc1(%rip), %r15     # 0x18c30
movabsq $0x4000100100001200, %rdi # imm = 0x4000100100001200
movabsq $0x800000000401, %r8    # imm = 0x800000000401
movzbl (%r15,%rbx), %esi
cmpq $0x2f, %rsi
ja 0x3094
btq %rsi, %r8
jb 0x30d3
cmpl $0x3b, %esi
je 0x30d3
cmpl $0x13, %eax
jg 0x30d3
cmpl $0x3e, %esi
ja 0x30bb
movb $0x1, %dl
movl %esi, %esi
btq %rsi, %rdi
jae 0x30bb
incq %r15
movq %r15, 0x15b79(%rip)     # 0x18c30
movl %edx, %ecx
jmp 0x3083
testb %cl, %cl
je 0x30cf
movslq %eax, %rcx
incl %eax
leaq 0x9b25(%rip), %rdx      # 0xcbf0
movl %r15d, (%rdx,%rcx,4)
xorl %edx, %edx
jmp 0x30ad
cmpl $0x13, %eax
jg 0x30fc
movslq %eax, %rcx
leaq 0x9b0e(%rip), %rdx      # 0xcbf0
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 0x15b38(%rip), %rdi     # 0x18c40
movq %rbx, %rsi
callq 0x2130
movq %r15, 0x15f11(%rip)     # 0x19028
movq (%r13,%rbp,8), %rax
movq %rax, 0x14eb5(%rip)     # 0x17fd8
testq %rax, %rax
je 0x2d25
jmp 0x2d20
callq 0x3bbd
movq 0x13d5b(%rip), %rdi     # 0x16e98
callq 0x20a0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x238f