// File: /workspace/github_c_makefile_star2_O1/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
xorps %xmm0, %xmm0
movups %xmm0, 0x29e750(%rip)   # 0x2bd45c
movups %xmm0, 0x29e73d(%rip)   # 0x2bd450
movups %xmm0, 0x29e726(%rip)   # 0x2bd440
movw $0xffff, 0x29e747(%rip) # imm = 0xFFFF
leaq 0x12f4e6(%rip), %rbx    # 0x14e210
xorl %r14d, %r14d
movl $0x88000, %edx          # imm = 0x88000
movq %rbx, %rdi
xorl %esi, %esi
callq 0x8440
leaq 0xc3acd(%rip), %rdi     # 0xe2810
xorl %esi, %esi
callq 0x32dbc
cmpl $-0x1, %eax
je 0x1f04d
movl %eax, %ebp
movl %eax, %edi
movl $0xffffffde, %esi       # imm = 0xFFFFFFDE
movl $0x2, %edx
callq 0x33214
xorps %xmm0, %xmm0
movups %xmm0, 0x29e6fc(%rip)   # 0x2bd46c
movups %xmm0, 0x29e705(%rip)   # 0x2bd47c
movw $0x0, 0x29e70c(%rip)    # 0x2bd48c
leaq 0x29e6e5(%rip), %rsi    # 0x2bd46c
movl %ebp, %edi
movl $0x22, %edx
callq 0x3302e
movabsq $0x58455f50414d2a2a, %rax # imm = 0x58455F50414D2A2A
xorq 0x29e6dd(%rip), %rax    # 0x2bd481
movabsq $0x2a2a535458455f, %rcx # imm = 0x2A2A535458455F
xorq 0x29e6d1(%rip), %rcx    # 0x2bd486
orq %rax, %rcx
je 0x1f059
movl %ebp, %edi
callq 0x334dd
leaq 0x10f238(%rip), %rax    # 0x12e004
movl (%rax), %eax
cmpq $0x3, %rax
ja 0x1ede4
leaq 0x6eb65(%rip), %rcx     # 0x8d940
movl (%rcx,%rax,4), %eax
movl %eax, 0x29e6d0(%rip)    # 0x2bd4b4
movzwl 0x29e6c9(%rip), %eax    # 0x2bd4b4
xorl %ecx, %ecx
leaq 0x40bd1c(%rip), %r14    # 0x42ab10
xorl %edx, %edx
movswq 0x2a(%r14,%rdx), %rsi
cmpq $-0x1, %rsi
je 0x1ee66
movq %rsi, %rdi
shlq $0x5, %rdi
leaq (%rdi,%rsi,2), %rsi
movzwl 0x8(%rbx,%rsi), %esi
addl $0xffffff35, %esi       # imm = 0xFFFFFF35
cmpl $0x3, %esi
ja 0x1ee66
cmpl $0x2, %esi
je 0x1ee66
movzwl 0x20(%r14,%rdx), %esi
addw %ax, %si
testw %si, %si
movl $0x0, %edi
cmovgl %esi, %edi
movw %di, 0x20(%r14,%rdx)
movzwl 0x22(%r14,%rdx), %esi
addw %ax, %si
testw %si, %si
cmovlel %ecx, %esi
movw %si, 0x22(%r14,%rdx)
movzwl 0x24(%r14,%rdx), %esi
addw %ax, %si
testw %si, %si
cmovlel %ecx, %esi
movw %si, 0x24(%r14,%rdx)
addq $0x2c, %rdx
cmpq $0xb0000, %rdx          # imm = 0xB0000
jne 0x1edf6
leaq 0xafafe(%rip), %rax     # 0xce978
cmpb $0x0, 0x4(%rax)
je 0x1eec7
addq $0x2a, %r14
xorl %r15d, %r15d
movswq (%r14), %rax
cmpq $-0x1, %rax
je 0x1eeb7
cmpw $0xce, -0x10(%r14)
jne 0x1eeae
movq %rax, %rcx
shlq $0x5, %rcx
leaq (%rcx,%rax,2), %rax
cmpw $0xce, 0x8(%rbx,%rax)
je 0x1eeb7
movswl %r15w, %edi
callq 0x1e99d
incq %r15
addq $0x2c, %r14
cmpq $0x4000, %r15           # imm = 0x4000
jne 0x1ee87
leaq 0x10f146(%rip), %rax    # 0x12e014
cmpl $0x0, (%rax)
je 0x1eefb
xorl %ebx, %ebx
leaq 0x10f334(%rip), %r14    # 0x12e210
movq (%r14,%rbx,8), %rax
cmpw $-0x1, 0x2a(%rax)
je 0x1eeef
movswl %bx, %edi
callq 0x1e99d
incq %rbx
cmpq $0x4000, %rbx           # imm = 0x4000
jne 0x1eedc
leaq 0x10f116(%rip), %rax    # 0x12e018
cmpl $0x0, (%rax)
je 0x1ef4e
xorl %ebx, %ebx
leaq 0x10f300(%rip), %r14    # 0x12e210
leaq 0x1b72f9(%rip), %r15    # 0x1d6210
movq (%r14,%rbx,8), %rax
cmpw $0xcb, 0x1a(%rax)
je 0x1ef3a
movswq 0x2a(%rax), %rax
cmpq $-0x1, %rax
je 0x1ef42
movq (%r15,%rax,8), %rax
cmpw $0xcb, 0x8(%rax)
jne 0x1ef42
movswl %bx, %edi
callq 0x1e99d
incq %rbx
cmpq $0x4000, %rbx           # imm = 0x4000
jne 0x1ef17
leaq 0x10f0c7(%rip), %rax    # 0x12e01c
cmpl $0x0, (%rax)
je 0x1efa1
xorl %ebx, %ebx
leaq 0x10f2ad(%rip), %r14    # 0x12e210
leaq 0x1b72a6(%rip), %r15    # 0x1d6210
movq (%r14,%rbx,8), %rax
cmpw $0xcc, 0x1a(%rax)
je 0x1ef8d
movswq 0x2a(%rax), %rax
cmpq $-0x1, %rax
je 0x1ef95
movq (%r15,%rax,8), %rax
cmpw $0xcc, 0x8(%rax)
jne 0x1ef95
movswl %bx, %edi
callq 0x1e99d
incq %rbx
cmpq $0x4000, %rbx           # imm = 0x4000
jne 0x1ef6a
leaq 0x10f078(%rip), %rax    # 0x12e020
cmpl $0x0, (%rax)
je 0x1eff4
xorl %ebx, %ebx
leaq 0x10f25a(%rip), %r14    # 0x12e210
leaq 0x1b7253(%rip), %r15    # 0x1d6210
movq (%r14,%rbx,8), %rax
cmpw $0xce, 0x1a(%rax)
je 0x1efe0
movswq 0x2a(%rax), %rax
cmpq $-0x1, %rax
je 0x1efe8
movq (%r15,%rax,8), %rax
cmpw $0xce, 0x8(%rax)
jne 0x1efe8
movswl %bx, %edi
callq 0x1e99d
incq %rbx
cmpq $0x4000, %rbx           # imm = 0x4000
jne 0x1efbd
leaq 0x10f029(%rip), %rax    # 0x12e024
movl $0x1, %r14d
cmpl $0x0, (%rax)
je 0x1f04d
xorl %ebx, %ebx
leaq 0x10f201(%rip), %r15    # 0x12e210
leaq 0x1b71fa(%rip), %r12    # 0x1d6210
movq (%r15,%rbx,8), %rax
cmpw $0xd1, 0x1a(%rax)
je 0x1f039
movswq 0x2a(%rax), %rax
cmpq $-0x1, %rax
je 0x1f041
movq (%r12,%rax,8), %rax
cmpw $0xd1, 0x8(%rax)
jne 0x1f041
movswl %bx, %edi
callq 0x1e99d
incq %rbx
cmpq $0x4000, %rbx           # imm = 0x4000
jne 0x1f016
movl %r14d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl 0x29e411(%rip), %esi    # 0x2bd470
xorl %r15d, %r15d
movl %ebp, %edi
xorl %edx, %edx
callq 0x33214
cmpl $0x0, 0x29e3fa(%rip)    # 0x2bd46c
jle 0x1edbe
leaq 0x29e40f(%rip), %r14    # 0x2bd48e
movl %ebp, %edi
movq %r14, %rsi
movl $0x24, %edx
callq 0x3302e
cmpl $0x24, %eax
jne 0x1edbe
movswq 0x29e3ef(%rip), %rax    # 0x2bd48e
movq %rax, %rcx
shlq $0x5, %rcx
leaq (%rcx,%rax,2), %rax
movzwl 0x29e3ff(%rip), %ecx    # 0x2bd4b0
movw %cx, 0x20(%rbx,%rax)
movups 0x29e3e3(%rip), %xmm0   # 0x2bd4a0
movups %xmm0, 0x10(%rbx,%rax)
movups 0x29e3c7(%rip), %xmm0   # 0x2bd490
movups %xmm0, (%rbx,%rax)
incl %r15d
cmpl 0x29e395(%rip), %r15d   # 0x2bd46c
jl 0x1f07f
jmp 0x1edbe