// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/src/tekstat.c
// Function: initspriteXTs
int
initspriteXTs()
{
     int       fh,i,nr,ext;

     memset(&pickup, 0, sizeof(pickup));
     pickup.extra=-1;

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

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

     // 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 ) {
          goto noext;
     }

     // 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
     }

noext:

     kclose(fh);

     switch( difficulty ) {
     case 0:
     case 1:
          vadd=-1;
          break;
     case 2:
          vadd=0;
          break;
     case 3:
          vadd=3;
          break;
     }

     // adjust speed for difficulty
     for( i=0; i<MAXSPRITES; i++ ) {
          if( sprite[i].extra != -1 ) {
              #ifdef  NOSHOWSPRITES
	          show2dsprite[i>>3] &= ~(1<<(i&7));
              #endif
               switch( spriteXT[sprite[i].extra].basestat ) {
               case GUARD:
               case CHASE:
               case STALK:
                    sprite[i].xvel+=vadd;
                    if( sprite[i].xvel < 0 )
                         sprite[i].xvel=0;
                    sprite[i].yvel+=vadd;
                    if( sprite[i].yvel < 0 )
                         sprite[i].yvel=0;
                    sprite[i].zvel+=vadd;
                    if( sprite[i].zvel < 0 )
                         sprite[i].zvel=0;
                    break;
               }
          }
     }

     // only CHASE in multiplayer
     if( option[4] != 0 ) {
          for( i=0; i<MAXSPRITES; i++ ) {
               if( (ext=sprite[i].extra) != -1 ) {
                    if( sprite[i].statnum != CHASE ) {
                         jsdeletesprite(i);
                    }
                    else if( spriteXT[ext].basestat != CHASE ) {
                         jsdeletesprite(i);
                    }
               }
          }
     }

     if( noenemiesflag != 0 ) {
          for( i=0; i<MAXSPRITES; i++ ) {
               if( sprptr[i]->extra != -1 ) {
                    jsdeletesprite(i);
               }
          }
     }

     if( noguardflag != 0 ) {
          for( i=0; i<MAXSPRITES; i++ ) {
               if( sprptr[i]->statnum == GUARD ) {
                    jsdeletesprite(i);
               }
               else {
                    if( sprptr[i]->extra != -1 ) {
                         if( sprXTptr[sprptr[i]->extra]->basestat == GUARD ) {
                              jsdeletesprite(i);
                         }
                    }
               }
          }
     }

     if( nostalkflag != 0 ) {
          for( i=0; i<MAXSPRITES; i++ ) {
               if( sprptr[i]->statnum == STALK ) {
                    jsdeletesprite(i);
               }
               else {
                    if( sprptr[i]->extra != -1 ) {
                         if( sprXTptr[sprptr[i]->extra]->basestat == STALK ) {
                              jsdeletesprite(i);
                         }
                    }
               }
          }
     }

     if( nochaseflag != 0 ) {
          for( i=0; i<MAXSPRITES; i++ ) {
               if( sprptr[i]->statnum == CHASE ) {
                    jsdeletesprite(i);
               }
               else {
                    if( sprptr[i]->extra != -1 ) {
                         if( sprXTptr[sprptr[i]->extra]->basestat == CHASE ) {
                              jsdeletesprite(i);
                         }
                    }
               }
          }
     }

     if( nostrollflag != 0 ) {
          for( i=0; i<MAXSPRITES; i++ ) {
               if( sprptr[i]->statnum == STROLL ) {
                    jsdeletesprite(i);
               }
               else {
                    if( sprptr[i]->extra != -1 ) {
                         if( sprXTptr[sprptr[i]->extra]->basestat == STROLL ) {
                              jsdeletesprite(i);
                         }
                    }
               }
          }
     }

     return(1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pxor %xmm0, %xmm0
movdqu %xmm0, 0x2991b0(%rip)   # 0x2b647c
movdqu %xmm0, 0x29919c(%rip)   # 0x2b6470
movdqu %xmm0, 0x299184(%rip)   # 0x2b6460
orw $-0x1, 0x2991a6(%rip)   # 0x2b648a
xorl %eax, %eax
leaq 0x129f43(%rip), %r15    # 0x147230
cmpq $0x88000, %rax          # imm = 0x88000
je 0x1d30f
movdqu %xmm0, 0x10(%r15,%rax)
movdqu %xmm0, (%r15,%rax)
andw $0x0, 0x20(%r15,%rax)
addq $0x22, %rax
jmp 0x1d2ed
leaq 0xbe4fa(%rip), %rdi     # 0xdb810
xorl %ebp, %ebp
xorl %esi, %esi
callq 0x302de
cmpl $-0x1, %eax
je 0x1d699
movl %eax, %ebx
pushq $-0x22
popq %rsi
pushq $0x2
popq %rdx
movl %eax, %edi
callq 0x306cb
pxor %xmm0, %xmm0
movdqu %xmm0, 0x299149(%rip)   # 0x2b648c
movdqu %xmm0, 0x299151(%rip)   # 0x2b649c
andw $0x0, 0x299159(%rip)    # 0x2b64ac
leaq 0x299132(%rip), %rsi    # 0x2b648c
pushq $0x22
popq %rdx
movl %ebx, %edi
callq 0x304e7
leaq 0x299136(%rip), %rdi    # 0x2b64a1
leaq 0x6511e(%rip), %rsi     # 0x82490
pushq $0xd
popq %rdx
callq 0x89f0
testl %eax, %eax
je 0x1d3c5
movl %ebx, %edi
callq 0x30983
leaq 0x109c98(%rip), %rax    # 0x127024
movl (%rax), %eax
cmpl $0x2, %eax
jb 0x1d3b5
je 0x1d434
cmpl $0x3, %eax
jne 0x1d43f
movl $0x3, 0x299128(%rip)    # 0x2b64d4
movw $0x3, %ax
jmp 0x1d446
orl $-0x1, 0x299118(%rip)   # 0x2b64d4
movw $0xffff, %ax            # imm = 0xFFFF
jmp 0x1d446
movl 0x2990c5(%rip), %esi    # 0x2b6490
xorl %r12d, %r12d
movl %ebx, %edi
xorl %edx, %edx
callq 0x306cb
leaq 0x2990d0(%rip), %r14    # 0x2b64ae
pushq $0x24
popq %rbp
cmpl 0x2990a4(%rip), %r12d   # 0x2b648c
jge 0x1d37e
movl %ebx, %edi
movq %r14, %rsi
movl %ebp, %edx
callq 0x304e7
cmpl $0x24, %eax
jne 0x1d37e
movswq 0x2990ab(%rip), %rax    # 0x2b64ae
imulq $0x22, %rax, %rax
movzwl 0x2990c2(%rip), %ecx    # 0x2b64d0
movw %cx, 0x20(%r15,%rax)
movups 0x2990a5(%rip), %xmm0   # 0x2b64c0
movups %xmm0, 0x10(%r15,%rax)
movdqu 0x299087(%rip), %xmm0   # 0x2b64b0
movdqu %xmm0, (%r15,%rax)
incl %r12d
jmp 0x1d3e1
andl $0x0, 0x299099(%rip)    # 0x2b64d4
xorl %eax, %eax
jmp 0x1d446
movzwl 0x29908e(%rip), %eax    # 0x2b64d4
movd %eax, %xmm0
pshuflw $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0,4,5,6,7]
xorl %ecx, %ecx
leaq 0x4066d8(%rip), %rbx    # 0x423b30
pxor %xmm1, %xmm1
cmpq $0xb0000, %rcx          # imm = 0xB0000
je 0x1d4bd
movswq 0x2a(%rbx,%rcx), %rdx
cmpq $-0x1, %rdx
je 0x1d4b7
imulq $0x22, %rdx, %rdx
movzwl 0x8(%r15,%rdx), %edx
addl $0xffffff35, %edx       # imm = 0xFFFFFF35
cmpl $0x3, %edx
ja 0x1d4b7
cmpl $0x2, %edx
je 0x1d4b7
movd 0x20(%rbx,%rcx), %xmm2
paddw %xmm0, %xmm2
pmaxsw %xmm1, %xmm2
movd %xmm2, 0x20(%rbx,%rcx)
movzwl 0x24(%rbx,%rcx), %edx
addw %ax, %dx
testw %dx, %dx
movl $0x0, %esi
cmovgl %edx, %esi
movw %si, 0x24(%rbx,%rcx)
addq $0x2c, %rcx
jmp 0x1d45c
leaq 0xaa4b4(%rip), %rax     # 0xc7978
cmpb $0x0, 0x4(%rax)
je 0x1d50c
addq $0x2a, %rbx
xorl %r14d, %r14d
cmpq $0x4000, %r14           # imm = 0x4000
je 0x1d50c
movswq (%rbx), %rax
cmpq $-0x1, %rax
je 0x1d503
cmpw $0xce, -0x10(%rbx)
jne 0x1d4fa
imulq $0x22, %rax, %rax
cmpw $0xce, 0x8(%r15,%rax)
je 0x1d503
movswl %r14w, %edi
callq 0x1cf5e
incq %r14
addq $0x2c, %rbx
jmp 0x1d4d1
leaq 0x109b21(%rip), %rax    # 0x127034
cmpl $0x0, (%rax)
je 0x1d542
xorl %ebx, %ebx
leaq 0x109d0f(%rip), %r14    # 0x127230
cmpq $0x4000, %rbx           # imm = 0x4000
je 0x1d542
movq (%r14,%rbx,8), %rax
cmpw $-0x1, 0x2a(%rax)
je 0x1d53d
movswl %bx, %edi
callq 0x1cf5e
incq %rbx
jmp 0x1d521
leaq 0x109aef(%rip), %rax    # 0x127038
cmpl $0x0, (%rax)
je 0x1d597
xorl %ebx, %ebx
leaq 0x109cd9(%rip), %r14    # 0x127230
leaq 0x1b1cd2(%rip), %r15    # 0x1cf230
cmpq $0x4000, %rbx           # imm = 0x4000
je 0x1d597
movq (%r14,%rbx,8), %rax
cmpw $0xcb, 0x1a(%rax)
je 0x1d58a
movswq 0x2a(%rax), %rax
cmpq $-0x1, %rax
je 0x1d592
movq (%r15,%rax,8), %rax
cmpw $0xcb, 0x8(%rax)
jne 0x1d592
movswl %bx, %edi
callq 0x1cf5e
incq %rbx
jmp 0x1d55e
leaq 0x109a9e(%rip), %rax    # 0x12703c
cmpl $0x0, (%rax)
je 0x1d5ec
xorl %ebx, %ebx
leaq 0x109c84(%rip), %r14    # 0x127230
leaq 0x1b1c7d(%rip), %r15    # 0x1cf230
cmpq $0x4000, %rbx           # imm = 0x4000
je 0x1d5ec
movq (%r14,%rbx,8), %rax
cmpw $0xcc, 0x1a(%rax)
je 0x1d5df
movswq 0x2a(%rax), %rax
cmpq $-0x1, %rax
je 0x1d5e7
movq (%r15,%rax,8), %rax
cmpw $0xcc, 0x8(%rax)
jne 0x1d5e7
movswl %bx, %edi
callq 0x1cf5e
incq %rbx
jmp 0x1d5b3
leaq 0x109a4d(%rip), %rax    # 0x127040
cmpl $0x0, (%rax)
je 0x1d641
xorl %ebx, %ebx
leaq 0x109c2f(%rip), %r14    # 0x127230
leaq 0x1b1c28(%rip), %r15    # 0x1cf230
cmpq $0x4000, %rbx           # imm = 0x4000
je 0x1d641
movq (%r14,%rbx,8), %rax
cmpw $0xce, 0x1a(%rax)
je 0x1d634
movswq 0x2a(%rax), %rax
cmpq $-0x1, %rax
je 0x1d63c
movq (%r15,%rax,8), %rax
cmpw $0xce, 0x8(%rax)
jne 0x1d63c
movswl %bx, %edi
callq 0x1cf5e
incq %rbx
jmp 0x1d608
leaq 0x1099fc(%rip), %rax    # 0x127044
pushq $0x1
popq %rbp
cmpl $0x0, (%rax)
je 0x1d699
xorl %ebx, %ebx
leaq 0x109bd7(%rip), %r14    # 0x127230
leaq 0x1b1bd0(%rip), %r15    # 0x1cf230
cmpq $0x4000, %rbx           # imm = 0x4000
je 0x1d699
movq (%r14,%rbx,8), %rax
cmpw $0xd1, 0x1a(%rax)
je 0x1d68c
movswq 0x2a(%rax), %rax
cmpq $-0x1, %rax
je 0x1d694
movq (%r15,%rax,8), %rax
cmpw $0xd1, 0x8(%rax)
jne 0x1d694
movswl %bx, %edi
callq 0x1cf5e
incq %rbx
jmp 0x1d660
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq