// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/src/bstub.c
// Function: JS_LoadSpriteExts
int
JS_LoadSpriteExts(const char *mapname)
{
     int       fh,i,nr,nex;

     for (i=0; i<MAXSPRITES; i++) {
          memset(&spriteXT[i], 0, sizeof(struct spriteextension));
          spriteXT[i].lock=0x00;
     }

     fh = kopen4load(mapname, 0);
     if ( fh == -1 ) {
          return(-1);
     }

     // read in XTtrailer 
     klseek(fh, -((int)sizeof(struct XTtrailertype)), SEEK_END);
     memset(&XTtrailer, 0, sizeof(struct XTtrailertype));
     kread(fh, &XTtrailer, sizeof(struct XTtrailertype));

     // if no previous extension info then continue
     if( strcmp(XTtrailer.ID, TRAILERID) != 0 ) {
          buildputs("New File - No extension information...\n");
          goto noext;
     }

     buildputs("Reading in extensions...\n");

     // load and intialize spriteXT array members
     klseek(fh, XTtrailer.start, SEEK_SET);
     for( i=0; i<XTtrailer.numXTs; i++ ) {
          nr=kread(fh, &XTsave, sizeof(struct XTsavetype));
          if( nr != sizeof(struct XTsavetype) )
               break;
          spriteXT[XTsave.XTnum]=XTsave.sprXT;  // struct assign
     }

     nex=JS_CheckExtras();
     if( nex != i ) {
          buildprintf("ERROR: %d Sprite Extras != %d Extensions.\n", nex,i);
     }
     else {
          buildprintf("Loaded %d extensions.\n", i);
     }

noext:

     kclose(fh);

 return(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
xorl %eax, %eax
leaq 0x9612d(%rip), %r12     # 0x9e810
xorps %xmm0, %xmm0
cmpq $0x88000, %rax          # imm = 0x88000
je 0x8706
movups %xmm0, 0x10(%rax,%r12)
movups %xmm0, (%rax,%r12)
andw $0x0, 0x20(%rax,%r12)
addq $0x22, %rax
jmp 0x86e6
xorl %esi, %esi
callq 0x1dc36
cmpl $-0x1, %eax
je 0x8776
movl %eax, %ebx
pushq $-0x22
popq %rsi
pushq $0x2
popq %rdx
movl %eax, %edi
callq 0x1e023
xorps %xmm0, %xmm0
movups %xmm0, 0x11e0e5(%rip)   # 0x126810
movups %xmm0, 0x11e0ee(%rip)   # 0x126820
andw $0x0, 0x11e0f6(%rip)    # 0x126830
leaq 0x11e0cf(%rip), %rsi    # 0x126810
pushq $0x22
popq %rdx
movl %ebx, %edi
callq 0x1de3f
leaq 0x11e0d3(%rip), %rdi    # 0x126825
leaq 0x5fd01(%rip), %rsi     # 0x6845a
pushq $0xd
popq %rdx
callq 0x6720
testl %eax, %eax
je 0x877e
leaq 0x5fcfb(%rip), %rdi     # 0x68467
callq 0x30c8d
jmp 0x8823
pushq $-0x1
popq %rax
jmp 0x882c
leaq 0x5fd0a(%rip), %rdi     # 0x6848f
callq 0x30c8d
movl 0x11e084(%rip), %esi    # 0x126814
xorl %ebp, %ebp
movl %ebx, %edi
xorl %edx, %edx
callq 0x1e023
leaq 0x11e090(%rip), %r14    # 0x126832
pushq $0x24
popq %r15
cmpl 0x11e064(%rip), %ebp    # 0x126810
jge 0x87f6
movl %ebx, %edi
movq %r14, %rsi
movl %r15d, %edx
callq 0x1de3f
cmpl $0x24, %eax
jne 0x87f6
movswq 0x11e06a(%rip), %rax    # 0x126832
imulq $0x22, %rax, %rax
movzwl 0x11e081(%rip), %ecx    # 0x126854
movw %cx, 0x20(%rax,%r12)
movups 0x11e064(%rip), %xmm0   # 0x126844
movups %xmm0, 0x10(%rax,%r12)
movups 0x11e047(%rip), %xmm0   # 0x126834
movups %xmm0, (%rax,%r12)
incl %ebp
jmp 0x87a6
callq 0x8835
cmpl %ebp, %eax
jne 0x8811
leaq 0x5fcce(%rip), %rdi     # 0x684d4
movl %ebp, %esi
xorl %eax, %eax
callq 0x22427
jmp 0x8823
leaq 0x5fc91(%rip), %rdi     # 0x684a9
movl %eax, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x22427
movl %ebx, %edi
callq 0x1e2db
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq