// File: /workspace/github_c_makefile_star2_O3/Edilbert[P]BS9/bs9.c
// Function: ParseLoadData
char *ParseLoadData(char *p)
{
   int Start,Size,Advance;
   char *Filename,*EndPtr;
   FILE *lp;

   p = SkipSpace(p);

   Advance = 1;
   if (*p == '\"') Start = pc;
   else
   {
      Advance = 0;
      p = EvalOperand(p,&Start,0);

      if (Start < 0 || Start > 0xffff)
      {
         ErrorMsg("Illegal start address for LOAD %d\n",Start);
         exit(1);
      }
      p = NeedChar(p,',');
      if (!p)
      {
         ErrorMsg("Missing ',' after start address\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);
   if (df) fprintf(df,"Loading %4.4x <%s>\n",Start,Filename);
   PrintLine();
   lp = fopen(Filename,"rb");
   AssertFileOp(lp,"Could not LOAD <%s>\n");
   fseek(lp,0,SEEK_END);
   Size = ftell(lp);
   rewind(lp);
   if (Start + Size > 0x10000)
   {
      ErrorMsg("LOADING %4.4x to %4.4x violates 64K size\n",
         Start,Start+Size);
      exit(1);
   }

   if (!Pass) fread(ROM+Start,Size,1,lp);
   fclose(lp);
   if (Advance) pc += Size;
   p += strlen(p);
   return p;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movsbq (%rdi), %r14
testq %r14, %r14
je 0x58da
callq 0x2320
movq (%rax), %rax
testb $0x20, 0x1(%rax,%r14,2)
je 0x58c3
movsbq 0x1(%rbx), %r14
incq %rbx
jmp 0x58b1
cmpb $0x22, %r14b
jne 0x58da
movl 0xee64(%rip), %r14d     # 0x14734
movl %r14d, 0xc(%rsp)
movb $0x1, %bpl
jmp 0x5953
leaq 0xc(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x3e17
movl (%r14), %r14d
cmpl $0x10000, %r14d         # imm = 0x10000
jae 0x5a66
movq %rax, %rbx
cmpb $0x0, (%rax)
je 0x5a35
callq 0x2320
movq (%rax), %rax
decq %rbx
movb 0x1(%rbx), %cl
incq %rbx
movsbq %cl, %rdx
testb $0x20, 0x1(%rax,%rdx,2)
jne 0x5913
cmpb $0x2c, %cl
jne 0x5a35
cmpb $0x0, 0x1(%rbx)
je 0x5a3e
movb 0x1(%rbx), %cl
incq %rbx
movsbq %cl, %rdx
testb $0x20, 0x1(%rax,%rdx,2)
jne 0x5937
cmpb $0x22, %cl
jne 0x5a3e
xorl %ebp, %ebp
incq %rbx
xorl %esi, %esi
movzbl (%rbx,%rsi), %eax
testl %eax, %eax
je 0x596a
cmpl $0x22, %eax
je 0x596a
incq %rsi
jmp 0x5958
movq %rbx, %rdi
callq 0x2878
movq %rax, %r15
movq 0x20094(%rip), %rdi     # 0x25a10
testq %rdi, %rdi
je 0x5995
leaq 0x6fac(%rip), %rsi      # 0xc934
movl %r14d, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x2210
callq 0x314b
leaq 0x6fa7(%rip), %rsi      # 0xc948
movq %r15, %rdi
callq 0x22b0
testq %rax, %rax
je 0x5a4e
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2270
movq %r15, %rdi
callq 0x2220
movq %rax, %r12
movq %r15, %rdi
callq 0x2140
leal (%r14,%r12), %edx
cmpl $0x10001, %edx          # imm = 0x10001
jge 0x5a53
cmpl $0x0, 0x2002e(%rip)     # 0x25a18
jne 0x5a09
movslq %r14d, %rax
leaq 0xf25a(%rip), %rdi      # 0x14c50
addq %rax, %rdi
movslq %r12d, %rsi
movl $0x1, %edx
movq %r15, %rcx
callq 0x20d0
movq %r15, %rdi
callq 0x2100
testb %bpl, %bpl
je 0x5a1d
addl %r12d, 0xed17(%rip)     # 0x14734
movq %rbx, %rdi
callq 0x2110
addq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6d9b(%rip), %rdi      # 0xc7d7
jmp 0x5a45
leaq 0x6dea(%rip), %rdi      # 0xc82f
xorl %eax, %eax
callq 0x2e72
jmp 0x5a77
callq 0x23ac
leaq 0x6f06(%rip), %rdi      # 0xc960
movl %r14d, %esi
xorl %eax, %eax
callq 0x2e72
jmp 0x5a77
leaq 0x6ea4(%rip), %rdi      # 0xc911
movl %r14d, %esi
xorl %eax, %eax
callq 0x2e72
movl $0x1, %edi
callq 0x22f0