// File: /workspace/github_c_makefile_star2_O3/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, 0x204b3(%rip)     # 0x25a18
jne 0x5811
leaq 0x14(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x3e17
movl (%r14), %esi
cmpl $0x100000, %esi         # imm = 0x100000
jae 0x584d
movq %rax, %rbx
cmpb $0x0, (%rax)
je 0x582b
callq 0x2320
movq %rax, %r15
movq (%rax), %rax
movb (%rbx), %cl
movsbq %cl, %rdx
incq %rbx
testb $0x20, 0x1(%rax,%rdx,2)
jne 0x55a3
cmpb $0x2c, %cl
jne 0x582b
leaq 0x10(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x3e17
movl (%r14), %r14d
cmpl $0x10001, %r14d         # imm = 0x10001
jae 0x5856
cmpb $0x0, (%rax)
je 0x5834
movq (%r15), %rcx
movb (%rax), %dl
movsbq %dl, %rsi
incq %rax
testb $0x20, 0x1(%rcx,%rsi,2)
jne 0x55ea
cmpb $0x2c, %dl
jne 0x5834
cmpb $0x0, (%rax)
je 0x583d
movb (%rax), %dl
movsbq %dl, %rsi
incq %rax
testb $0x20, 0x1(%rcx,%rsi,2)
jne 0x560c
cmpb $0x22, %dl
jne 0x583d
leaq 0x1(%rax), %r13
xorl %esi, %esi
movzbl -0x1(%r13), %ecx
testl %ecx, %ecx
je 0x5640
cmpl $0x22, %ecx
je 0x5640
incq %r13
incl %esi
jmp 0x562b
movq %rax, %rdi
callq 0x2878
movq %rax, %r12
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
leaq -0x1(%r13), %rbx
xorl %ebp, %ebp
cmpb $0x0, (%r13)
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
je 0x5759
movq (%r15), %rax
movb (%r13), %cl
movsbq %cl, %rdx
incq %r13
testb $0x20, 0x1(%rax,%rdx,2)
jne 0x566c
cmpb $0x2c, %cl
jne 0x5759
leaq 0x71bd(%rip), %rsi      # 0xc84b
movq %r13, %rdi
callq 0x2969
xorl %ebp, %ebp
testq %rax, %rax
jne 0x56e7
leaq 0x71ab(%rip), %rsi      # 0xc84f
movq %r13, %rdi
callq 0x2969
movl $0x1, %ebp
testq %rax, %rax
jne 0x56e7
leaq 0x80a1(%rip), %rsi      # 0xd75e
movq %r13, %rdi
callq 0x2969
testq %rax, %rax
jne 0x56e7
leaq 0x7183(%rip), %rsi      # 0xc854
movq %r13, %rdi
callq 0x2969
movl $0x2, %ebp
testq %rax, %rax
je 0x5888
movq 0x20322(%rip), %rdi     # 0x25a10
testq %rdi, %rdi
je 0x5703
leaq 0x717e(%rip), %rsi      # 0xc878
movl %ebp, %edx
xorl %eax, %eax
callq 0x2210
cmpb $0x0, (%r13)
je 0x5754
movq (%r15), %rax
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movb (%r13), %cl
movsbq %cl, %rdx
incq %r13
testb $0x20, 0x1(%rax,%rdx,2)
jne 0x5712
cmpb $0x2c, %cl
jne 0x5759
leaq 0xc(%rsp), %r14
movq %r13, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x3e17
movl (%r14), %esi
cmpl $0xffff, %esi           # imm = 0xFFFF
ja 0x587f
movq %rax, %rbx
movl 0x10(%rsp), %r14d
jmp 0x5759
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl 0x14(%rsp), %edx
movslq 0x1f60c(%rip), %rax     # 0x24d70
leaq 0x7fb15(%rip), %rcx     # 0x85280
movl %edx, (%rcx,%rax,4)
leaq 0x7fb5b(%rip), %rcx     # 0x852d0
movl %r14d, (%rcx,%rax,4)
leaq 0x7fba0(%rip), %rcx     # 0x85320
movl %esi, (%rcx,%rax,4)
leaq 0x7fbe6(%rip), %rcx     # 0x85370
movq %r12, (%rcx,%rax,8)
leaq 0x7fc7b(%rip), %rcx     # 0x85410
movl %ebp, (%rcx,%rax,4)
movq 0x20271(%rip), %rdi     # 0x25a10
testq %rdi, %rdi
je 0x57f9
leal (%rdx,%r14), %ecx
decl %ecx
leaq 0x7106(%rip), %rsi      # 0xc8b7
movq %r12, %r8
xorl %eax, %eax
callq 0x2210
movq 0x2024e(%rip), %rcx     # 0x25a10
cmpl $0x1, %ebp
je 0x57d5
cmpl $0x2, %ebp
jne 0x57e3
leaq 0x7100(%rip), %rdi      # 0xc8d3
jmp 0x57dc
leaq 0x7100(%rip), %rdi      # 0xc8dc
movl $0x8, %esi
jmp 0x57ef
leaq 0x70fb(%rip), %rdi      # 0xc8e5
movl $0x7, %esi
movl $0x1, %edx
callq 0x2300
movl 0x1f571(%rip), %eax     # 0x24d70
cmpl $0x13, %eax
jg 0x5862
incl %eax
movl %eax, 0x1f564(%rip)     # 0x24d70
callq 0x314b
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 0x6fa5(%rip), %rdi      # 0xc7d7
jmp 0x5844
leaq 0x6fda(%rip), %rdi      # 0xc815
jmp 0x5844
leaq 0x6feb(%rip), %rdi      # 0xc82f
xorl %eax, %eax
callq 0x2e72
jmp 0x5875
leaq 0x6f5f(%rip), %rdi      # 0xc7b3
jmp 0x586e
leaq 0x6f9b(%rip), %rdi      # 0xc7f8
movl %r14d, %esi
jmp 0x586e
leaq 0x7084(%rip), %rdi      # 0xc8ed
movl $0x14, %esi
xorl %eax, %eax
callq 0x2e72
movl $0x1, %edi
callq 0x22f0
leaq 0x7003(%rip), %rdi      # 0xc889
jmp 0x586e
leaq 0x6fcd(%rip), %rdi      # 0xc85c
jmp 0x5844