// File: /workspace/github_c_makefile_star2_O3/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, 0x2a14fe(%rip)   # 0x2c047c
movdqu %xmm0, 0x2a14ea(%rip)   # 0x2c0470
movdqu %xmm0, 0x2a14d2(%rip)   # 0x2c0460
movw $0xffff, 0x2a14f3(%rip) # imm = 0xFFFF
leaq 0x132292(%rip), %rbx    # 0x151230
xorl %r14d, %r14d
movl $0x88000, %edx          # imm = 0x88000
movq %rbx, %rdi
xorl %esi, %esi
callq 0x8440
leaq 0xc6859(%rip), %rdi     # 0xe5810
xorl %esi, %esi
callq 0x34174
cmpl $-0x1, %eax
je 0x1f368
movl %eax, %ebp
movl %eax, %edi
movl $0xffffffde, %esi       # imm = 0xFFFFFFDE
movl $0x2, %edx
callq 0x345aa
pxor %xmm0, %xmm0
movdqu %xmm0, 0x2a14a6(%rip)   # 0x2c048c
movdqu %xmm0, 0x2a14ae(%rip)   # 0x2c049c
movw $0x0, 0x2a14b5(%rip)    # 0x2c04ac
leaq 0x2a148e(%rip), %rsi    # 0x2c048c
movl %ebp, %edi
movl $0x22, %edx
callq 0x343bc
movabsq $0x58455f50414d2a2a, %rax # imm = 0x58455F50414D2A2A
xorq 0x2a1486(%rip), %rax    # 0x2c04a1
movabsq $0x2a2a535458455f, %rcx # imm = 0x2A2A535458455F
xorq 0x2a147a(%rip), %rcx    # 0x2c04a6
orq %rax, %rcx
je 0x1f07b
movl %ebp, %edi
callq 0x34878
leaq 0x111fe5(%rip), %rax    # 0x131024
movl (%rax), %eax
cmpl $0x2, %eax
jb 0x1f068
je 0x1f0fa
cmpl $0x3, %eax
jne 0x1f108
movl $0x3, 0x2a1475(%rip)    # 0x2c04d4
movw $0x3, %ax
jmp 0x1f10f
movl $0xffffffff, 0x2a1462(%rip) # imm = 0xFFFFFFFF
movw $0xffff, %ax            # imm = 0xFFFF
jmp 0x1f10f
movl 0x2a140f(%rip), %esi    # 0x2c0490
xorl %r15d, %r15d
movl %ebp, %edi
xorl %edx, %edx
callq 0x345aa
cmpl $0x0, 0x2a13f8(%rip)    # 0x2c048c
jle 0x1f031
leaq 0x2a1411(%rip), %r14    # 0x2c04ae
movl %ebp, %edi
movq %r14, %rsi
movl $0x24, %edx
callq 0x343bc
cmpl $0x24, %eax
jne 0x1f031
movswq 0x2a13f5(%rip), %rax    # 0x2c04ae
movq %rax, %rcx
shlq $0x5, %rcx
leaq (%rcx,%rax,2), %rax
movzwl 0x2a1405(%rip), %ecx    # 0x2c04d0
movw %cx, 0x20(%rbx,%rax)
movups 0x2a13e9(%rip), %xmm0   # 0x2c04c0
movups %xmm0, 0x10(%rbx,%rax)
movdqu 0x2a13cc(%rip), %xmm0   # 0x2c04b0
movdqu %xmm0, (%rbx,%rax)
incl %r15d
cmpl 0x2a1399(%rip), %r15d   # 0x2c048c
jl 0x1f09d
jmp 0x1f031
movl $0x0, 0x2a13d0(%rip)    # 0x2c04d4
xorl %eax, %eax
jmp 0x1f10f
movzwl 0x2a13c5(%rip), %eax    # 0x2c04d4
movd %eax, %xmm0
pshuflw $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0,4,5,6,7]
xorl %ecx, %ecx
leaq 0x40ea0f(%rip), %r14    # 0x42db30
pxor %xmm1, %xmm1
movswq 0x2a(%r14,%rcx), %rdx
cmpq $-0x1, %rdx
je 0x1f181
movq %rdx, %rsi
shlq $0x5, %rsi
leaq (%rsi,%rdx,2), %rdx
movzwl 0x8(%rbx,%rdx), %edx
addl $0xffffff35, %edx       # imm = 0xFFFFFF35
cmpl $0x3, %edx
ja 0x1f181
cmpl $0x2, %edx
je 0x1f181
movd 0x20(%r14,%rcx), %xmm2
paddw %xmm0, %xmm2
pmaxsw %xmm1, %xmm2
movd %xmm2, 0x20(%r14,%rcx)
movzwl 0x24(%r14,%rcx), %edx
addw %ax, %dx
testw %dx, %dx
movl $0x0, %esi
cmovgl %edx, %esi
movw %si, 0x24(%r14,%rcx)
addq $0x2c, %rcx
cmpq $0xb0000, %rcx          # imm = 0xB0000
jne 0x1f125
leaq 0xb27e3(%rip), %rax     # 0xd1978
cmpb $0x0, 0x4(%rax)
je 0x1f1e2
addq $0x2a, %r14
xorl %r15d, %r15d
movswq (%r14), %rax
cmpq $-0x1, %rax
je 0x1f1d2
cmpw $0xce, -0x10(%r14)
jne 0x1f1c9
movq %rax, %rcx
shlq $0x5, %rcx
leaq (%rcx,%rax,2), %rax
cmpw $0xce, 0x8(%rbx,%rax)
je 0x1f1d2
movswl %r15w, %edi
callq 0x1eb19
incq %r15
addq $0x2c, %r14
cmpq $0x4000, %r15           # imm = 0x4000
jne 0x1f1a2
leaq 0x111e4b(%rip), %rax    # 0x131034
cmpl $0x0, (%rax)
je 0x1f216
xorl %ebx, %ebx
leaq 0x112039(%rip), %r14    # 0x131230
movq (%r14,%rbx,8), %rax
cmpw $-0x1, 0x2a(%rax)
je 0x1f20a
movswl %bx, %edi
callq 0x1eb19
incq %rbx
cmpq $0x4000, %rbx           # imm = 0x4000
jne 0x1f1f7
leaq 0x111e1b(%rip), %rax    # 0x131038
cmpl $0x0, (%rax)
je 0x1f269
xorl %ebx, %ebx
leaq 0x112005(%rip), %r14    # 0x131230
leaq 0x1b9ffe(%rip), %r15    # 0x1d9230
movq (%r14,%rbx,8), %rax
cmpw $0xcb, 0x1a(%rax)
je 0x1f255
movswq 0x2a(%rax), %rax
cmpq $-0x1, %rax
je 0x1f25d
movq (%r15,%rax,8), %rax
cmpw $0xcb, 0x8(%rax)
jne 0x1f25d
movswl %bx, %edi
callq 0x1eb19
incq %rbx
cmpq $0x4000, %rbx           # imm = 0x4000
jne 0x1f232
leaq 0x111dcc(%rip), %rax    # 0x13103c
cmpl $0x0, (%rax)
je 0x1f2bc
xorl %ebx, %ebx
leaq 0x111fb2(%rip), %r14    # 0x131230
leaq 0x1b9fab(%rip), %r15    # 0x1d9230
movq (%r14,%rbx,8), %rax
cmpw $0xcc, 0x1a(%rax)
je 0x1f2a8
movswq 0x2a(%rax), %rax
cmpq $-0x1, %rax
je 0x1f2b0
movq (%r15,%rax,8), %rax
cmpw $0xcc, 0x8(%rax)
jne 0x1f2b0
movswl %bx, %edi
callq 0x1eb19
incq %rbx
cmpq $0x4000, %rbx           # imm = 0x4000
jne 0x1f285
leaq 0x111d7d(%rip), %rax    # 0x131040
cmpl $0x0, (%rax)
je 0x1f30f
xorl %ebx, %ebx
leaq 0x111f5f(%rip), %r14    # 0x131230
leaq 0x1b9f58(%rip), %r15    # 0x1d9230
movq (%r14,%rbx,8), %rax
cmpw $0xce, 0x1a(%rax)
je 0x1f2fb
movswq 0x2a(%rax), %rax
cmpq $-0x1, %rax
je 0x1f303
movq (%r15,%rax,8), %rax
cmpw $0xce, 0x8(%rax)
jne 0x1f303
movswl %bx, %edi
callq 0x1eb19
incq %rbx
cmpq $0x4000, %rbx           # imm = 0x4000
jne 0x1f2d8
leaq 0x111d2e(%rip), %rax    # 0x131044
movl $0x1, %r14d
cmpl $0x0, (%rax)
je 0x1f368
xorl %ebx, %ebx
leaq 0x111f06(%rip), %r15    # 0x131230
leaq 0x1b9eff(%rip), %r12    # 0x1d9230
movq (%r15,%rbx,8), %rax
cmpw $0xd1, 0x1a(%rax)
je 0x1f354
movswq 0x2a(%rax), %rax
cmpq $-0x1, %rax
je 0x1f35c
movq (%r12,%rax,8), %rax
cmpw $0xd1, 0x8(%rax)
jne 0x1f35c
movswl %bx, %edi
callq 0x1eb19
incq %rbx
cmpq $0x4000, %rbx           # imm = 0x4000
jne 0x1f331
movl %r14d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq