// File: /workspace/github_c_makefile_star2_O1/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 0x2ecaba(%rip), %rcx    # 0x318970
movq (%rcx,%rax,8), %rax
movl (%rax), %ecx
cmpq $0x4, %rcx
ja 0x2c006
leaq 0x61abf(%rip), %rdx     # 0x8d98c
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 0x2c006
movl $0x3c00, 0x68(%rax)     # imm = 0x3C00
movl $0x2, (%rax)
movl $0x1e0, 0x114(%rax)     # imm = 0x1E0
jmp 0x2c006
movl 0x110(%rax), %ecx
cmpl $0x1, %ecx
je 0x2bfdd
testl %ecx, %ecx
jne 0x2c000
movl 0x10c(%rax), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x10c(%rax)
cmpl 0x118(%rax), %ecx
jl 0x2c000
decl %ecx
movl %ecx, 0x10c(%rax)
movl $0x1, %ecx
jmp 0x2bffa
movl 0x114(%rax), %ecx
leal -0x3(%rcx), %edx
movl %edx, 0x114(%rax)
cmpl $0x3, %ecx
jg 0x2c06b
movl $0x1, (%rax)
retq
movslq 0x10c(%rax), %rcx
movl 0xbc(%rax,%rcx,4), %ecx
cmpl $0x0, 0x110(%rax)
movl 0x11c(%rax), %edx
je 0x2bfbf
addl $0xc0, %edx
movl %edx, 0x11c(%rax)
cmpl %ecx, %edx
jge 0x2bfcf
jmp 0x2c006
movl 0x68(%rax), %ecx
leal -0xc0(%rcx), %edx
movl %edx, 0x68(%rax)
cmpl $0xc0, %ecx
jg 0x2c006
movl $0x0, 0x68(%rax)
movl $0x4, (%rax)
jmp 0x2c006
addl $0xffffff40, %edx       # imm = 0xFFFFFF40
movl %edx, 0x11c(%rax)
cmpl %ecx, %edx
jg 0x2c006
movl %ecx, 0x11c(%rax)
movl $0x0, (%rax)
jmp 0x2c006
movl 0x10c(%rax), %ecx
leal -0x1(%rcx), %edx
movl %edx, 0x10c(%rax)
testl %ecx, %ecx
jg 0x2c000
incl %ecx
movl %ecx, 0x10c(%rax)
xorl %ecx, %ecx
movl %ecx, 0x110(%rax)
movl $0x3, (%rax)
cmpl $0x0, 0x4(%rax)
jle 0x2c06b
xorl %ecx, %ecx
leaq 0x1021fb(%rip), %rdx    # 0x12e210
movslq 0x8(%rax,%rcx,4), %rsi
movl 0x11c(%rax), %r8d
addl 0x6c(%rax,%rcx,4), %r8d
subl 0xbc(%rax), %r8d
movq (%rdx,%rsi,8), %rdi
movl %r8d, 0x8(%rdi)
cmpl $0x0, 0x120(%rax)
jle 0x2c05f
xorl %r8d, %r8d
cmpl 0x58(%rax,%r8,4), %esi
jne 0x2c050
movl 0x68(%rax), %r9d
subl %r9d, 0x8(%rdi)
incq %r8
movslq 0x120(%rax), %r9
cmpq %r9, %r8
jl 0x2c041
incq %rcx
movslq 0x4(%rax), %rsi
cmpq %rsi, %rcx
jl 0x2c015
retq