// File: /workspace/github_c_makefile_star2_O1/Edilbert[P]BS9/bs9.c
// Function: ParseStoreData
char *ParseStoreData(char *p)
{
   int Start,Length,FileFormat,Entry;
   char *Filename,*EndPtr;

   if (Pass) return p + strlen(p);
   p = EvalOperand(p,&Start,0);
   if (Start < 0 || Start > 0xfffff)
   {
      ErrorMsg("Illegal start address for STORE %d\n",Start);
      exit(1);
   }
   p = NeedChar(p,',');
   if (!p)
   {
      ErrorMsg("Missing ',' after start address\n");
      exit(1);
   }
   p = EvalOperand(p+1,&Length,0);
   if (Length < 0 || Length > 0x10000)
   {
      ErrorMsg("Illegal length for STORE %d\n",Length);
      exit(1);
   }
   p = NeedChar(p,',');
   if (!p)
   {
      ErrorMsg("Missing ',' after length\n");
      exit(1);
   }
   p = NeedChar(p+1,'"');
   if (!p)
   {
      ErrorMsg("Missing quote for filename\n");
      exit(1);
   }
   EndPtr = ++p;
   while (*EndPtr != '\0' && *EndPtr != '"') ++EndPtr;
   Filename = (char *)StrNDup(p, EndPtr - p);
   FileFormat = BINARY;
   Entry = -1;
   p = NeedChar(EndPtr+1,',');
   if (p)
   {
      ++p;
           if (StrMatch(p, "BIN"))  FileFormat = BINARY;
      else if (StrMatch(p, "SREC")) FileFormat = SRECORD;
      else if (StrMatch(p, "S19"))  FileFormat = SRECORD;
      else if (StrMatch(p, "SPARROW"))  FileFormat = SPARROW;
      else
      {
         ErrorMsg("Unknown output file format\n");
         exit(1);
      }
      if (df) fprintf(df,"Filefornat = %d\n",FileFormat);
      p = NeedChar(p,',');
      if (p)
      {
         p = EvalOperand(p+1,&Entry,0);
         if (Entry < 0 || Entry > 0xffff)
         {
            ErrorMsg("Illegal execution start address for STORE %d\n",Entry);
            exit(1);
         }
      } else p = EndPtr;
   } else p = EndPtr;

   SFA[StoreCount] = Start;
   SFL[StoreCount] = Length;
   SFE[StoreCount] = Entry;
   SFF[StoreCount] = Filename;
   SFT[StoreCount] = FileFormat;
   if (df)
   {
      fprintf(df,"Storing %4.4x - %4.4x <%s>,",
           Start,Start+Length-1,Filename);
           if (FileFormat == SPARROW) fprintf(df,"SPARROW\n");
      else if (FileFormat == SRECORD) fprintf(df,"SRECORD\n");
      else                            fprintf(df,"BINARY\n");
   }
   if (StoreCount < SFMAX) ++StoreCount;
   else
   {
      ErrorMsg("number of storage files exceeds %d\n",SFMAX);
      exit(1);
   }
   PrintLine();
   p += strlen(p);
   return p;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
cmpl $0x0, 0x2051b(%rip)     # 0x25a18
jne 0x5750
leaq 0x14(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x3daa
movl (%r14), %r14d
cmpl $0x100000, %r14d        # imm = 0x100000
jae 0x576a
movq %rax, %rdi
movl $0x2c, %esi
callq 0x3342
testq %rax, %rax
je 0x5776
incq %rax
leaq 0x10(%rsp), %rbx
movq %rax, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x3daa
movl (%rbx), %r15d
cmpl $0x10001, %r15d         # imm = 0x10001
jae 0x577f
movq %rax, %rdi
movl $0x2c, %esi
callq 0x3342
testq %rax, %rax
je 0x578b
incq %rax
movq %rax, %rdi
movl $0x22, %esi
callq 0x3342
testq %rax, %rax
je 0x5794
incq %rax
xorl %esi, %esi
movq %rax, %rbx
movzbl (%rbx), %ecx
testl %ecx, %ecx
je 0x55aa
cmpl $0x22, %ecx
je 0x55aa
incq %rbx
incl %esi
jmp 0x5597
movq %rax, %rdi
callq 0x2878
movq %rax, %r12
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
leaq 0x1(%rbx), %rdi
movl $0x2c, %esi
callq 0x3342
testq %rax, %rax
je 0x5692
movq %rax, %r13
incq %r13
leaq 0x727e(%rip), %rsi      # 0xc85f
movq %r13, %rdi
callq 0x2969
xorl %ebp, %ebp
testq %rax, %rax
jne 0x563a
leaq 0x726c(%rip), %rsi      # 0xc863
movq %r13, %rdi
callq 0x2969
movl $0x1, %ebp
testq %rax, %rax
jne 0x563a
leaq 0x8168(%rip), %rsi      # 0xd778
movq %r13, %rdi
callq 0x2969
testq %rax, %rax
jne 0x563a
leaq 0x7244(%rip), %rsi      # 0xc868
movq %r13, %rdi
callq 0x2969
movl $0x2, %ebp
testq %rax, %rax
je 0x57ca
movq 0x203cf(%rip), %rdi     # 0x25a10
testq %rdi, %rdi
je 0x5656
leaq 0x723f(%rip), %rsi      # 0xc88c
movl %ebp, %edx
xorl %eax, %eax
callq 0x2210
movq %r13, %rdi
movl $0x2c, %esi
callq 0x3342
testq %rax, %rax
je 0x5694
incq %rax
leaq 0xc(%rsp), %r13
movq %rax, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x3daa
movl (%r13), %esi
cmpl $0x10000, %esi          # imm = 0x10000
jae 0x57b2
movq %rax, %rbx
jmp 0x5694
xorl %ebp, %ebp
movslq 0x1f6d5(%rip), %rax     # 0x24d70
leaq 0x7fbde(%rip), %rcx     # 0x85280
movl %r14d, (%rcx,%rax,4)
leaq 0x7fc23(%rip), %rcx     # 0x852d0
movl %r15d, (%rcx,%rax,4)
movl 0xc(%rsp), %ecx
leaq 0x7fc64(%rip), %rdx     # 0x85320
movl %ecx, (%rdx,%rax,4)
leaq 0x7fcaa(%rip), %rcx     # 0x85370
movq %r12, (%rcx,%rax,8)
leaq 0x7fd3f(%rip), %rcx     # 0x85410
movl %ebp, (%rcx,%rax,4)
movq 0x20335(%rip), %rdi     # 0x25a10
testq %rdi, %rdi
je 0x5738
leal (%r14,%r15), %ecx
decl %ecx
leaq 0x71de(%rip), %rsi      # 0xc8cb
movl %r14d, %edx
movq %r12, %r8
xorl %eax, %eax
callq 0x2210
movq 0x2030f(%rip), %rcx     # 0x25a10
cmpl $0x1, %ebp
je 0x5714
cmpl $0x2, %ebp
jne 0x5722
leaq 0x71d5(%rip), %rdi      # 0xc8e7
jmp 0x571b
leaq 0x71d5(%rip), %rdi      # 0xc8f0
movl $0x8, %esi
jmp 0x572e
leaq 0x71d0(%rip), %rdi      # 0xc8f9
movl $0x7, %esi
movl $0x1, %edx
callq 0x2300
movl 0x1f632(%rip), %eax     # 0x24d70
cmpl $0x13, %eax
jg 0x57a4
incl %eax
movl %eax, 0x1f625(%rip)     # 0x24d70
callq 0x313c
movq %rbx, %rdi
callq 0x2110
addq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7056(%rip), %rdi      # 0xc7c7
movl %r14d, %esi
jmp 0x57b9
leaq 0x706e(%rip), %rdi      # 0xc7eb
jmp 0x579b
leaq 0x7086(%rip), %rdi      # 0xc80c
movl %r15d, %esi
jmp 0x57b9
leaq 0x7097(%rip), %rdi      # 0xc829
jmp 0x579b
leaq 0x70a8(%rip), %rdi      # 0xc843
xorl %eax, %eax
callq 0x2e63
jmp 0x57c0
leaq 0x7156(%rip), %rdi      # 0xc901
movl $0x14, %esi
jmp 0x57b9
leaq 0x70e4(%rip), %rdi      # 0xc89d
xorl %eax, %eax
callq 0x2e63
movl $0x1, %edi
callq 0x22f0
leaq 0x709f(%rip), %rdi      # 0xc870
jmp 0x579b