// File: /workspace/github_c_makefile_star2_O1/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 %rbx
pushq %rax
movq %rdi, %rbx
cmpb $0x0, (%rdi)
je 0x57fc
callq 0x2320
movq (%rax), %rax
decq %rbx
movsbq 0x1(%rbx), %rcx
incq %rbx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x57ed
movb (%rbx), %bpl
cmpb $0x22, %bpl
jne 0x5811
movl 0xef29(%rip), %eax      # 0x14734
movl %eax, 0x4(%rsp)
jmp 0x5864
leaq 0x4(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x3daa
movl (%r14), %esi
cmpl $0x10000, %esi          # imm = 0x10000
jae 0x595d
movq %rax, %rdi
movl $0x2c, %esi
callq 0x3342
testq %rax, %rax
je 0x596d
incq %rax
movq %rax, %rdi
movl $0x22, %esi
callq 0x3342
movq %rax, %rbx
testq %rax, %rax
je 0x5976
incq %rbx
xorl %esi, %esi
movzbl (%rbx,%rsi), %eax
testl %eax, %eax
je 0x587b
cmpl $0x22, %eax
je 0x587b
incq %rsi
jmp 0x5869
movq %rbx, %rdi
callq 0x2878
movq %rax, %r14
movq 0x20183(%rip), %rdi     # 0x25a10
testq %rdi, %rdi
je 0x58a7
movl 0x4(%rsp), %edx
leaq 0x70ab(%rip), %rsi      # 0xc948
movq %r14, %rcx
xorl %eax, %eax
callq 0x2210
callq 0x313c
leaq 0x70a9(%rip), %rsi      # 0xc95c
movq %r14, %rdi
callq 0x22b0
testq %rax, %rax
je 0x5948
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2270
movq %r14, %rdi
callq 0x2220
movq %rax, %r15
movq %r14, %rdi
callq 0x2140
movslq 0x4(%rsp), %rsi
leal (%rsi,%r15), %edx
cmpl $0x10001, %edx          # imm = 0x10001
jge 0x594d
cmpl $0x0, 0x20117(%rip)     # 0x25a18
jne 0x591d
leaq 0xf346(%rip), %rdi      # 0x14c50
addq %rsi, %rdi
movslq %r15d, %rsi
movl $0x1, %edx
movq %r14, %rcx
callq 0x20d0
movq %r14, %rdi
callq 0x2100
cmpb $0x22, %bpl
jne 0x5932
addl %r15d, 0xee02(%rip)     # 0x14734
movq %rbx, %rdi
callq 0x2110
addq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x23ac
leaq 0x7020(%rip), %rdi      # 0xc974
xorl %eax, %eax
callq 0x2e63
jmp 0x5984
leaq 0x6fc1(%rip), %rdi      # 0xc925
xorl %eax, %eax
callq 0x2e63
jmp 0x5984
leaq 0x6e77(%rip), %rdi      # 0xc7eb
jmp 0x597d
leaq 0x6ec6(%rip), %rdi      # 0xc843
xorl %eax, %eax
callq 0x2e63
movl $0x1, %edi
callq 0x22f0