// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/src/tektag.c
// Function: movesprelevs
void
movesprelevs(int e)
{
     int            i,j,n,tics;
     int           goalz;
     struct    spriteelev     *s;
     spritetype     *spr;

     s=sprelevptr[e];
     tics=TICSPERFRAME<<6;
     switch (s->state) {
     case E_WAITING:
          s->delay-=TICSPERFRAME;
          if (s->delay <= 0) {
               s->state=E_CLOSINGDOOR;
          }
          return;
     case E_CLOSINGDOOR:
          s->doorpos-=tics;
          if (s->doorpos <= 0) {
               s->doorpos=0;
               s->state=E_NEXTFLOOR;
          }
          break;
     case E_OPENINGDOOR:
          s->doorpos+=tics;
          if (s->doorpos >= E_DOOROPENPOS) {
               s->doorpos=E_DOOROPENPOS;
               s->state=E_WAITING;
               s->delay=E_WAITDELAY;
          }
       break;
     case E_MOVING:
          goalz=s->floorz[s->curfloor];
          if (s->curdir == E_GOINGUP) {
               s->floorpos-=tics;
               if (s->floorpos <= goalz) {
                    s->floorpos+=labs(s->floorpos-goalz);
                    s->state=E_OPENINGDOOR;
               }
          }
          else {
               s->floorpos+=tics;
               if (s->floorpos >= goalz) {
                    s->floorpos-=labs(s->floorpos-goalz);
                    s->state=E_OPENINGDOOR;
               }
          }
          break;
     case E_NEXTFLOOR:
          if (s->curdir == E_GOINGUP) {
               s->curfloor++;
               if (s->curfloor > s->floors) {
                    s->curfloor-=2;
                    s->curdir=E_GOINGDOWN;
                    //playsound(S_COPSEE1,sprptr[s->sprnum[0]]->x,sprptr[s->sprnum[0]]->y,0,ST_UNIQUE);
               }
          }
          else if (s->curdir == E_GOINGDOWN) {
               s->curfloor--;
               if (s->curfloor < 0) {
                    s->curfloor+=2;
                    s->curdir=E_GOINGUP;
                    //playsound(S_COPSEE2,sprptr[s->sprnum[0]]->x,sprptr[s->sprnum[0]]->y,0,ST_UNIQUE);
               }
          }
          s->state=E_MOVING;
          break;
     }
     for (i=0 ; i < s->parts ; i++) {
          j=s->sprnum[i];
          spr=sprptr[j];
          spr->z=s->startz[i]+s->floorpos-s->floorz[0];
          for (n=0 ; n < s->doors ; n++) {
               if (j == s->door[n]) {
                    spr->z-=s->doorpos;
               }
          }
     }
}

// Assembly:
movslq %edi, %rax
leaq 0x2ee812(%rip), %rcx    # 0x31b990
movq (%rcx,%rax,8), %rax
movl (%rax), %ecx
cmpq $0x4, %rcx
ja 0x2d2ce
leaq 0x639c7(%rip), %rdx     # 0x90b5c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl 0x68(%rax), %ecx
leal 0xc0(%rcx), %edx
movl %edx, 0x68(%rax)
cmpl $0x3b40, %ecx           # imm = 0x3B40
jl 0x2d2ce
movl $0x3c00, 0x68(%rax)     # imm = 0x3C00
movl $0x2, (%rax)
movl $0x1e0, 0x114(%rax)     # imm = 0x1E0
jmp 0x2d2ce
movl 0x110(%rax), %ecx
cmpl $0x1, %ecx
je 0x2d2a5
testl %ecx, %ecx
jne 0x2d2c8
movl 0x10c(%rax), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x10c(%rax)
cmpl 0x118(%rax), %ecx
jl 0x2d2c8
decl %ecx
movl %ecx, 0x10c(%rax)
movl $0x1, %ecx
jmp 0x2d2c2
movl 0x114(%rax), %ecx
leal -0x3(%rcx), %edx
movl %edx, 0x114(%rax)
cmpl $0x3, %ecx
jg 0x2d335
movl $0x1, (%rax)
retq
movslq 0x10c(%rax), %rcx
movl 0xbc(%rax,%rcx,4), %ecx
cmpl $0x0, 0x110(%rax)
movl 0x11c(%rax), %edx
je 0x2d287
addl $0xc0, %edx
movl %edx, 0x11c(%rax)
cmpl %ecx, %edx
jge 0x2d297
jmp 0x2d2ce
movl 0x68(%rax), %ecx
leal -0xc0(%rcx), %edx
movl %edx, 0x68(%rax)
cmpl $0xc0, %ecx
jg 0x2d2ce
movl $0x0, 0x68(%rax)
movl $0x4, (%rax)
jmp 0x2d2ce
addl $0xffffff40, %edx       # imm = 0xFFFFFF40
movl %edx, 0x11c(%rax)
cmpl %ecx, %edx
jg 0x2d2ce
movl %ecx, 0x11c(%rax)
movl $0x0, (%rax)
jmp 0x2d2ce
movl 0x10c(%rax), %ecx
leal -0x1(%rcx), %edx
movl %edx, 0x10c(%rax)
testl %ecx, %ecx
jg 0x2d2c8
incl %ecx
movl %ecx, 0x10c(%rax)
xorl %ecx, %ecx
movl %ecx, 0x110(%rax)
movl $0x3, (%rax)
cmpl $0x0, 0x4(%rax)
jle 0x2d335
xorl %ecx, %ecx
leaq 0x103f53(%rip), %rdx    # 0x131230
movslq 0x8(%rax,%rcx,4), %rsi
movl 0x11c(%rax), %edi
addl 0x6c(%rax,%rcx,4), %edi
subl 0xbc(%rax), %edi
movq (%rdx,%rsi,8), %r8
movl %edi, 0x8(%r8)
movl 0x120(%rax), %r9d
testl %r9d, %r9d
jle 0x2d329
xorl %r10d, %r10d
cmpl 0x58(%rax,%r10,4), %esi
jne 0x2d31e
subl 0x68(%rax), %edi
movl %edi, 0x8(%r8)
movl 0x120(%rax), %r9d
incq %r10
movslq %r9d, %r11
cmpq %r11, %r10
jl 0x2d309
incq %rcx
movslq 0x4(%rax), %rsi
cmpq %rsi, %rcx
jl 0x2d2dd
retq