// File: /workspace/github_c_makefile_star2_O3/Edilbert[P]BS9/bs9.c
// Function: RecordMacro
void RecordMacro(char *p)
{
   char Macro[ML];
   int i,j,l,al,an,bl,mf;
   int ap[10];
   char args[ML];
   char Buf[ML];
   char *b;
   char *at;

   if (Macros > MAXMAC -2)
   {
      ++ErrNum;
      ErrorMsg("Too many macros (> %d)\n",MAXMAC);
      exit(1);
   }

   bl = 1;
   mf = strcmpword(p,"MACRO") != 0; // 1 : name MACRO
   if (!mf) p += 5;                 // 0 : MACRO name
   if (df) fprintf(df,"macro type = %d\n",mf);

   p = NextSymbol(p,Macro);
   l = strlen(Macro);
   if (mf) p = StrMatch(p,"MACRO") + 5;
   p = SkipSpace(p);

   if (df)
   {
      fprintf(df,"Macro name: <%s>\n",Macro);
      fprintf(df,"Arglist: <%s>\n",p);
   }

   if (*p == '(') ++p;
   if (mf) an = ScanArgs(p,args,ap);
   else    an = ScanArguments(p,args,ap,MAXARGS);
   if (df)
   {
      fprintf(df,"RecordMacro: %s(",Macro);
      for (i=0 ; i < an ; ++i)
      {
         at = args + ap[i];
         al = strlen(at);
         fprintf(df,"%s[%d]",at,al);
         if (i < an-1) fprintf(df,",");
      }
      fprintf(df,")\n");
   }
   j = MacroIndex(Macro);
   if (j < 0)  // create new entry in macro table
   {
      j = Macros;
      Mac[j].Name = (char *)StrNDup(Macro,l);
      Mac[j].Narg = an;
      Mac[j].Type = mf;
      fgets(Line,sizeof(Line),sf);
      while (!feof(sf) && !StrCaseStr(Line,"ENDM"))
      {
         ++LiNo;
         l = strlen(Line);
         if (l && Line[l-1] == 10) Line[--l] = 0; // Remove linefeed
         if (l && Line[l-1] == 13) Line[--l] = 0; // Remove return

         // parse line and substitute arguments

         p = Line;
         b = Buf;
         while (*p)
         {
            for (i=0 ; i < an ; ++i)
            {
               at = args + ap[i];
               al = strlen(at);
               if (al && !StrnCmp(p,at,al))
               {
                  *b++ = CHAMAC;
                  *b++ = '0' + i;
                  p += al;
                  break;
               }
            }
            if (i == an) *b++ = *p++;
         }
         *b++ = '\n';
         *b = 0;

         if (df)
         {
            fprintf(df,"MAC line  :%s\n",Line);
            fprintf(df,"MAC parsed:%s\n",Buf);
         }
         l = strlen(Buf);
         if (bl == 1)
         {
            bl = l+1;
            Mac[j].Body = (char *)StrNDup(Buf,l);
         }
         else
         {
            bl += l;
            Mac[j].Body = (char *)ReallocOrDie(Mac[j].Body,bl);
            strcat(Mac[j].Body,Buf);
         }
         fgets(Line,sizeof(Line),sf);
      }
      Macros++;
      if (df) fprintf(df,"finished macro %d\n",Macros);
   }
   else  // Skip macro
   {
      if (!Pass) PrintLiNo();
      ++LiNo;
      if (ListOn && !Pass) fprintf(lf,"            %s\n",Line);
      do
      {
         fgets(Line,sizeof(Line),sf);
         if (!Pass)
         {
            PrintLiNo();
            if (ListOn) fprintf(lf,"            %s",Line);
            if (pf) fprintf(pf,"%s",Line);
         }
         ++LiNo;
      } while (!feof(sf) && !StrCaseStr(Line,"ENDM"));
      LiNo-=2;
   }
   if (df) MacroInfo(j);
   ++LiNo;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x358, %rsp            # imm = 0x358
cmpl $0xc7, 0x7a814(%rip)    # 0x83640
jge 0x93b3
movq %rdi, %r14
leaq 0x45ff(%rip), %rsi      # 0xd43b
callq 0x2cd8
movl %eax, %ebx
xorl %eax, %eax
xorl %ebp, %ebp
testl %ebx, %ebx
sete %al
setne %bpl
leaq (%rax,%rax,4), %r15
addq %r14, %r15
movq 0x1cbb2(%rip), %rdi     # 0x25a10
testq %rdi, %rdi
je 0x8e73
leaq 0x45d7(%rip), %rsi      # 0xd441
movl %ebp, %edx
xorl %eax, %eax
callq 0x2210
leaq 0x50(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x2bad
movq %rax, %r14
movq %r12, %rdi
callq 0x2110
movq %rax, %r15
testl %ebx, %ebx
je 0x8eab
leaq 0x459f(%rip), %rsi      # 0xd43b
movq %r14, %rdi
callq 0x2969
movq %rax, %r14
addq $0x5, %r14
cmpb $0x0, (%r14)
je 0x8ecd
callq 0x2320
movq (%rax), %rcx
decq %r14
movsbq 0x1(%r14), %rax
incq %r14
testb $0x20, 0x1(%rcx,%rax,2)
jne 0x8ebc
jmp 0x8ecf
xorl %eax, %eax
movq 0x1cb3a(%rip), %rdi     # 0x25a10
testq %rdi, %rdi
je 0x8f09
leaq 0x4570(%rip), %rsi      # 0xd452
leaq 0x50(%rsp), %rdx
xorl %eax, %eax
callq 0x2210
movq 0x1cb1b(%rip), %rdi     # 0x25a10
leaq 0x4568(%rip), %rsi      # 0xd464
movq %r14, %rdx
xorl %eax, %eax
callq 0x2210
movb (%r14), %al
xorl %ecx, %ecx
cmpb $0x28, %al
sete %cl
addq %rcx, %r14
leaq 0x150(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movq %r14, %rdi
testl %ebx, %ebx
je 0x8f2e
callq 0x8c44
jmp 0x8f38
movl $0xa, %ecx
callq 0x8a7e
movl %eax, %r12d
movq 0x1cace(%rip), %rdi     # 0x25a10
testq %rdi, %rdi
movq %r12, 0x8(%rsp)
je 0x8ff4
movq %r15, (%rsp)
leaq 0x4518(%rip), %rsi      # 0xd473
leaq 0x50(%rsp), %rdx
xorl %eax, %eax
callq 0x2210
testl %r12d, %r12d
jle 0x8fce
movq 0x8(%rsp), %rax
leal -0x1(%rax), %r14d
movl %eax, %r13d
leaq 0x4505(%rip), %rbx      # 0xd484
xorl %r15d, %r15d
movslq 0x20(%rsp,%r15,4), %rax
leaq (%rsp,%rax), %r12
addq $0x150, %r12            # imm = 0x150
movq %r12, %rdi
callq 0x2110
movq 0x1ca6f(%rip), %rdi     # 0x25a10
movq %rbx, %rsi
movq %r12, %rdx
movl %eax, %ecx
xorl %eax, %eax
callq 0x2210
cmpq %r14, %r15
jae 0x8fc6
movq 0x1ca54(%rip), %rsi     # 0x25a10
movl $0x2c, %edi
callq 0x21a0
incq %r15
cmpq %r15, %r13
jne 0x8f82
movq 0x1ca3b(%rip), %rcx     # 0x25a10
leaq 0x3578(%rip), %rdi      # 0xc554
movl $0x2, %esi
movl $0x1, %edx
callq 0x2300
movq 0x8(%rsp), %r12
movq (%rsp), %r15
leaq 0x50(%rsp), %rdi
callq 0x363f
testl %eax, %eax
js 0x912b
movl %eax, %ebx
movl 0x1ca0a(%rip), %eax     # 0x25a18
testl %eax, %eax
jne 0x903c
cmpl $0x0, 0x1bd43(%rip)     # 0x24d5c
je 0x903c
movq 0x1c9e6(%rip), %rdi     # 0x25a08
movl 0x1bd30(%rip), %edx     # 0x24d58
leaq 0x323b(%rip), %rsi      # 0xc26a
xorl %eax, %eax
callq 0x2210
movl 0x1c9dc(%rip), %eax     # 0x25a18
incl 0x1bd16(%rip)           # 0x24d58
cmpl $0x0, 0x916f(%rip)      # 0x121b8
je 0x906b
testl %eax, %eax
jne 0x906b
movq 0x1c9b2(%rip), %rdi     # 0x25a08
leaq 0x3228(%rip), %rsi      # 0xc285
leaq 0x1be3c(%rip), %rdx     # 0x24ea0
xorl %eax, %eax
callq 0x2210
leaq 0x1be2e(%rip), %r14     # 0x24ea0
leaq 0x36aa(%rip), %r15      # 0xc723
leaq 0x31ea(%rip), %r12      # 0xc26a
leaq 0x4404(%rip), %r13      # 0xd48b
movq 0x7c0ea(%rip), %rdx     # 0x85178
movq %r14, %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x21c0
cmpl $0x0, 0x1c976(%rip)     # 0x25a18
jne 0x90f5
cmpl $0x0, 0x1bcb1(%rip)     # 0x24d5c
je 0x90c4
movq 0x1c954(%rip), %rdi     # 0x25a08
movl 0x1bc9e(%rip), %edx     # 0x24d58
movq %r12, %rsi
xorl %eax, %eax
callq 0x2210
cmpl $0x0, 0x90ed(%rip)      # 0x121b8
je 0x90e1
movq 0x1c934(%rip), %rdi     # 0x25a08
movq %r15, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2210
movq 0x7e6f0(%rip), %rsi     # 0x877d8
testq %rsi, %rsi
je 0x90f5
movq %r14, %rdi
callq 0x2170
incl 0x1bc5d(%rip)           # 0x24d58
movq 0x7c076(%rip), %rdi     # 0x85178
callq 0x2230
testl %eax, %eax
jne 0x911f
movq %r14, %rdi
movq %r13, %rsi
callq 0x274e
testq %rax, %rax
je 0x9087
addl $-0x2, 0x1bc32(%rip)    # 0x24d58
jmp 0x938a
movslq 0x7a50e(%rip), %rbx     # 0x83640
leaq 0x50(%rsp), %rdi
movl %r15d, %esi
callq 0x2878
movq %rbx, 0x18(%rsp)
shlq $0x5, %rbx
leaq 0x7a501(%rip), %rcx     # 0x83650
movq %rax, (%rbx,%rcx)
movl %r12d, 0x10(%rbx,%rcx)
movq %rcx, 0x10(%rsp)
movl %ebp, 0x18(%rbx,%rcx)
movq 0x7c010(%rip), %rdx     # 0x85178
leaq 0x1bd31(%rip), %r15     # 0x24ea0
movq %r15, %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x21c0
movq 0x7bff5(%rip), %rdi     # 0x85178
callq 0x2230
testl %eax, %eax
jne 0x935d
addq %rbx, 0x10(%rsp)
movl %r12d, %r13d
movl $0x1, (%rsp)
leaq 0x250(%rsp), %rbp
movq %r15, %rdi
leaq 0x42da(%rip), %rsi      # 0xd48b
callq 0x274e
testq %rax, %rax
jne 0x935d
incl 0x1bb93(%rip)           # 0x24d58
movq %r15, %rdi
callq 0x2110
testl %eax, %eax
je 0x91fe
movl %eax, %ecx
decl %ecx
movslq %ecx, %rcx
cmpb $0xa, (%rcx,%r15)
jne 0x91ee
cltq
movb $0x0, -0x1(%rax,%r15)
decq %rax
testl %eax, %eax
je 0x91fe
cltq
cmpb $0xd, -0x1(%rax,%r15)
jne 0x91fe
movb $0x0, -0x1(%rax,%r15)
cmpb $0x0, 0x1bc9b(%rip)     # 0x24ea0
je 0x9290
leaq 0x250(%rsp), %rbp
leaq 0x1bc86(%rip), %r15     # 0x24ea0
xorl %r14d, %r14d
testl %r12d, %r12d
jle 0x9279
movslq 0x20(%rsp,%r14,4), %rax
leaq (%rsp,%rax), %rbx
addq $0x150, %rbx            # imm = 0x150
movq %rbx, %rdi
callq 0x2110
testl %eax, %eax
je 0x9253
movslq %eax, %r12
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x35ab
testl %eax, %eax
je 0x9262
incq %r14
cmpq %r14, %r13
jne 0x9222
movq 0x8(%rsp), %r12
jmp 0x927e
movb $0x60, (%rbp)
leal 0x30(%r14), %eax
movb %al, 0x1(%rbp)
addq $0x2, %rbp
addq %r12, %r15
movq 0x8(%rsp), %r12
cmpl %r12d, %r14d
jne 0x928a
movb (%r15), %al
incq %r15
movb %al, (%rbp)
incq %rbp
cmpb $0x0, (%r15)
jne 0x921a
movw $0xa, (%rbp)
movq 0x1c773(%rip), %rdi     # 0x25a10
testq %rdi, %rdi
leaq 0x1bbf9(%rip), %r15     # 0x24ea0
leaq 0x250(%rsp), %rbp
je 0x92da
leaq 0x41d8(%rip), %rsi      # 0xd490
movq %r15, %rdx
xorl %eax, %eax
callq 0x2210
movq 0x1c747(%rip), %rdi     # 0x25a10
leaq 0x41cf(%rip), %rsi      # 0xd49f
movq %rbp, %rdx
xorl %eax, %eax
callq 0x2210
movq %rbp, %rdi
callq 0x2110
movl (%rsp), %ecx
cmpl $0x1, %ecx
jne 0x9305
leal 0x1(%rax), %ecx
movl %ecx, (%rsp)
movq %rbp, %rdi
movl %eax, %esi
callq 0x2878
movq 0x10(%rsp), %rcx
movq %rax, 0x8(%rcx)
jmp 0x9335
addl %eax, %ecx
movq 0x10(%rsp), %r14
movq 0x8(%r14), %rdi
movl %ecx, (%rsp)
movslq %ecx, %rsi
callq 0x2280
movq %rax, %rbx
movq %rax, %rdi
callq 0x2834
movq %rbx, 0x8(%r14)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x22e0
movq 0x7be3c(%rip), %rdx     # 0x85178
movq %r15, %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x21c0
movq 0x7be28(%rip), %rdi     # 0x85178
callq 0x2230
testl %eax, %eax
je 0x91a7
movl 0x7a2dd(%rip), %edx     # 0x83640
incl %edx
movl %edx, 0x7a2d5(%rip)     # 0x83640
movq 0x1c69e(%rip), %rdi     # 0x25a10
testq %rdi, %rdi
movq 0x18(%rsp), %rbx
je 0x939b
leaq 0x412b(%rip), %rsi      # 0xd4ae
xorl %eax, %eax
callq 0x2210
cmpq $0x0, 0x1c67e(%rip)     # 0x25a10
je 0x939b
movl %ebx, %edi
callq 0x8d36
incl 0x1b9b7(%rip)           # 0x24d58
addq $0x358, %rsp            # imm = 0x358
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
incl 0x1c673(%rip)           # 0x25a2c
leaq 0x4063(%rip), %rdi      # 0xd423
movl $0xc8, %esi
xorl %eax, %eax
callq 0x2e72
movl $0x1, %edi
callq 0x22f0