// File: /workspace/github_c_makefile_star2_O2/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, 0x7a702(%rip)    # 0x82640
jge 0x8452
movq %rdi, %rbx
leaq 0x447d(%rip), %rsi      # 0xc3cb
callq 0x2994
movl %eax, %r14d
xorl %eax, %eax
xorl %ebp, %ebp
testl %r14d, %r14d
sete %al
setne %bpl
leaq (%rax,%rax,4), %r15
addq %rbx, %r15
movq 0x1ca9e(%rip), %rdi     # 0x24a10
testq %rdi, %rdi
je 0x7f87
leaq 0x4453(%rip), %rsi      # 0xc3d1
movl %ebp, %edx
xorl %eax, %eax
callq 0x2210
leaq 0x50(%rsp), %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x288d
movq %rax, %r15
movq %rbx, %rdi
callq 0x2110
movq %rax, %r12
testl %r14d, %r14d
je 0x7fc0
leaq 0x441a(%rip), %rsi      # 0xc3cb
movq %r15, %rdi
callq 0x269d
movq %rax, %r15
addq $0x5, %r15
movq %r15, %rdi
callq 0x2675
movq %rax, %r15
movq 0x1ca3e(%rip), %rdi     # 0x24a10
testq %rdi, %rdi
je 0x8002
leaq 0x4404(%rip), %rsi      # 0xc3e2
leaq 0x50(%rsp), %rdx
xorl %eax, %eax
callq 0x2210
movq 0x1ca1f(%rip), %rdi     # 0x24a10
leaq 0x43fc(%rip), %rsi      # 0xc3f4
movq %r15, %rdx
xorl %eax, %eax
callq 0x2210
xorl %eax, %eax
cmpb $0x28, (%r15)
sete %al
addq %rax, %r15
leaq 0x150(%rsp), %rsi
leaq 0x20(%rsp), %rdx
testl %r14d, %r14d
je 0x802a
movq %r15, %rdi
callq 0x7d8e
jmp 0x8035
pushq $0xa
popq %rcx
movq %r15, %rdi
callq 0x7c25
movq %rax, 0x10(%rsp)
movq 0x1c9cf(%rip), %rdi     # 0x24a10
testq %rdi, %rdi
je 0x80f8
movq %r12, 0x8(%rsp)
movl %ebp, 0x4(%rsp)
leaq 0x43a9(%rip), %rsi      # 0xc403
leaq 0x50(%rsp), %rdx
xorl %eax, %eax
callq 0x2210
movq 0x10(%rsp), %rcx
leal -0x1(%rcx), %eax
testl %ecx, %ecx
movl $0x0, %r14d
cmovgl %ecx, %r14d
movslq %eax, %rbx
leaq 0x4390(%rip), %r15      # 0xc414
pushq $0x2c
popq %r12
xorl %ebp, %ebp
cmpq %rbp, %r14
je 0x80d6
movslq 0x20(%rsp,%rbp,4), %rax
leaq (%rsp,%rax), %r13
addq $0x150, %r13            # imm = 0x150
movq %r13, %rdi
callq 0x2110
movq 0x1c962(%rip), %rdi     # 0x24a10
movq %r15, %rsi
movq %r13, %rdx
movl %eax, %ecx
xorl %eax, %eax
callq 0x2210
cmpq %rbx, %rbp
jge 0x80d1
movq 0x1c947(%rip), %rsi     # 0x24a10
movl %r12d, %edi
callq 0x21a0
incq %rbp
jmp 0x808a
movq 0x1c933(%rip), %rcx     # 0x24a10
leaq 0x3400(%rip), %rdi      # 0xb4e4
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
callq 0x2300
movl 0x4(%rsp), %ebp
movq 0x8(%rsp), %r12
leaq 0x50(%rsp), %rdi
callq 0x3141
testl %eax, %eax
js 0x81f2
movq %rax, 0x18(%rsp)
movb $0x1, %al
cmpl $0x0, 0x1c900(%rip)     # 0x24a18
jne 0x8129
callq 0x2c67
cmpl $0x0, 0x1c8f2(%rip)     # 0x24a18
setne %al
incl 0x1bc29(%rip)           # 0x23d58
cmpl $0x0, 0x9082(%rip)      # 0x111b8
je 0x8158
testb %al, %al
jne 0x8158
movq 0x1c8c5(%rip), %rdi     # 0x24a08
leaq 0x30cb(%rip), %rsi      # 0xb215
leaq 0x1bd4f(%rip), %rdx     # 0x23ea0
xorl %eax, %eax
callq 0x2210
leaq 0x1bd41(%rip), %rbx     # 0x23ea0
leaq 0x354d(%rip), %r14      # 0xb6b3
leaq 0x42ae(%rip), %r15      # 0xc41b
movq 0x7c004(%rip), %rdx     # 0x84178
movq %rbx, %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x21c0
cmpl $0x0, 0x1c890(%rip)     # 0x24a18
jne 0x81c0
callq 0x2c67
cmpl $0x0, 0x9022(%rip)      # 0x111b8
je 0x81ac
movq 0x1c869(%rip), %rdi     # 0x24a08
movq %r14, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2210
movq 0x7e625(%rip), %rsi     # 0x867d8
testq %rsi, %rsi
je 0x81c0
movq %rbx, %rdi
callq 0x2170
incl 0x1bb92(%rip)           # 0x23d58
movq 0x7bfab(%rip), %rdi     # 0x84178
callq 0x2230
testl %eax, %eax
jne 0x81e6
movq %rbx, %rdi
movq %r15, %rsi
callq 0x244e
testq %rax, %rax
je 0x816d
addl $-0x2, 0x1bb6b(%rip)    # 0x23d58
jmp 0x8426
movslq 0x7a447(%rip), %rbx     # 0x82640
leaq 0x50(%rsp), %rdi
movl %r12d, %esi
callq 0x258f
movq %rbx, 0x18(%rsp)
movq %rbx, %rcx
shlq $0x5, %rcx
leaq 0x7a437(%rip), %rdx     # 0x82650
leaq (%rdx,%rcx), %rsi
movq %rsi, 0x8(%rsp)
movq %rax, (%rcx,%rdx)
movq 0x10(%rsp), %rbx
movl %ebx, 0x10(%rcx,%rdx)
movl %ebp, 0x18(%rcx,%rdx)
movq 0x7bf3e(%rip), %rdx     # 0x84178
leaq 0x1bc5f(%rip), %r15     # 0x23ea0
movq %r15, %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x21c0
testl %ebx, %ebx
movl $0x0, %r14d
cmovgl %ebx, %r14d
pushq $0x1
popq %rax
movl %eax, 0x4(%rsp)
leaq 0x250(%rsp), %rbp
movq 0x7bf08(%rip), %rdi     # 0x84178
callq 0x2230
testl %eax, %eax
jne 0x83fe
movq %r15, %rdi
leaq 0x4194(%rip), %rsi      # 0xc41b
callq 0x244e
testq %rax, %rax
jne 0x83fe
incl 0x1babd(%rip)           # 0x23d58
movq %r15, %rdi
callq 0x2110
testl %eax, %eax
je 0x8342
movl %eax, %ecx
decl %ecx
movslq %ecx, %rcx
cmpb $0xa, (%rcx,%r15)
jne 0x82c8
cltq
movb $0x0, -0x1(%rax,%r15)
decq %rax
testl %eax, %eax
je 0x8342
cltq
cmpb $0xd, -0x1(%rax,%r15)
jne 0x8342
movb $0x0, -0x1(%rax,%r15)
jmp 0x8342
xorl %r13d, %r13d
cmpq %r13, %r14
je 0x8318
movslq 0x20(%rsp,%r13,4), %rax
leaq (%rsp,%rax), %r12
addq $0x150, %r12            # imm = 0x150
movq %r12, %rdi
callq 0x2110
testl %eax, %eax
je 0x8313
movslq %eax, %rbx
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x30ba
testl %eax, %eax
je 0x831d
incq %r13
jmp 0x82dd
movl %r14d, %r13d
jmp 0x832f
movb $0x60, (%rbp)
leal 0x30(%r13), %eax
movb %al, 0x1(%rbp)
addq $0x2, %rbp
addq %rbx, %r15
cmpl 0x10(%rsp), %r13d
jne 0x8342
movb (%r15), %al
incq %r15
movb %al, (%rbp)
incq %rbp
cmpb $0x0, (%r15)
jne 0x82da
movw $0xa, (%rbp)
movq 0x1c6bb(%rip), %rdi     # 0x24a10
testq %rdi, %rdi
leaq 0x1bb41(%rip), %r15     # 0x23ea0
leaq 0x250(%rsp), %rbp
je 0x8392
leaq 0x40b0(%rip), %rsi      # 0xc420
movq %r15, %rdx
xorl %eax, %eax
callq 0x2210
movq 0x1c68f(%rip), %rdi     # 0x24a10
leaq 0x40a7(%rip), %rsi      # 0xc42f
movq %rbp, %rdx
xorl %eax, %eax
callq 0x2210
movq %rbp, %rdi
callq 0x2110
movl 0x4(%rsp), %ecx
cmpl $0x1, %ecx
jne 0x83bf
leal 0x1(%rax), %ecx
movl %ecx, 0x4(%rsp)
movq %rbp, %rdi
movl %eax, %esi
callq 0x258f
movq 0x8(%rsp), %rcx
movq %rax, 0x8(%rcx)
jmp 0x83e5
addl %eax, %ecx
movq 0x8(%rsp), %rbx
movq 0x8(%rbx), %rdi
movl %ecx, 0x4(%rsp)
movslq %ecx, %rsi
callq 0x2566
movq %rax, 0x8(%rbx)
movq %rax, %rdi
movq %rbp, %rsi
callq 0x22e0
movq 0x7bd8c(%rip), %rdx     # 0x84178
movq %r15, %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x21c0
jmp 0x8269
movl 0x7a23c(%rip), %edx     # 0x82640
incl %edx
movl %edx, 0x7a234(%rip)     # 0x82640
movq 0x1c5fd(%rip), %rdi     # 0x24a10
testq %rdi, %rdi
je 0x843a
leaq 0x401f(%rip), %rsi      # 0xc43e
xorl %eax, %eax
callq 0x2210
cmpq $0x0, 0x1c5e2(%rip)     # 0x24a10
je 0x843a
movq 0x18(%rsp), %rdi
callq 0x7e40
incl 0x1b918(%rip)           # 0x23d58
addq $0x358, %rsp            # imm = 0x358
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
incl 0x1c5d4(%rip)           # 0x24a2c
leaq 0x3f54(%rip), %rdi      # 0xc3b3
movl $0xc8, %esi
xorl %eax, %eax
callq 0x2af7
pushq $0x1
popq %rdi
callq 0x22f0