// File: /workspace/github_c_makefile_star2_O2/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 0x2e84cb(%rip), %rcx    # 0x311990
movq (%rcx,%rax,8), %rax
movl (%rax), %ecx
cmpq $0x4, %rcx
ja 0x29609
leaq 0x59548(%rip), %rdx     # 0x82a24
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 0x29609
movl $0x3c00, 0x68(%rax)     # imm = 0x3C00
movl $0x2, (%rax)
movl $0x1e0, 0x114(%rax)     # imm = 0x1E0
jmp 0x29609
movl 0x110(%rax), %ecx
cmpl $0x1, %ecx
je 0x295e0
testl %ecx, %ecx
jne 0x29603
movl 0x10c(%rax), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x10c(%rax)
cmpl 0x118(%rax), %ecx
jl 0x29603
decl %ecx
movl %ecx, 0x10c(%rax)
pushq $0x1
popq %rcx
jmp 0x295fd
movl 0x114(%rax), %ecx
leal -0x3(%rcx), %edx
movl %edx, 0x114(%rax)
cmpl $0x3, %ecx
jg 0x29575
movl $0x1, (%rax)
retq
movslq 0x10c(%rax), %rcx
movl 0xbc(%rax,%rcx,4), %ecx
cmpl $0x0, 0x110(%rax)
movl 0x11c(%rax), %edx
je 0x295c5
addl $0xc0, %edx
movl %edx, 0x11c(%rax)
cmpl %ecx, %edx
jge 0x295d5
jmp 0x29609
movl 0x68(%rax), %ecx
leal -0xc0(%rcx), %edx
movl %edx, 0x68(%rax)
cmpl $0xc0, %ecx
jg 0x29609
andl $0x0, 0x68(%rax)
movl $0x4, (%rax)
jmp 0x29609
addl $0xffffff40, %edx       # imm = 0xFFFFFF40
movl %edx, 0x11c(%rax)
cmpl %ecx, %edx
jg 0x29609
movl %ecx, 0x11c(%rax)
andl $0x0, (%rax)
jmp 0x29609
movl 0x10c(%rax), %ecx
leal -0x1(%rcx), %edx
movl %edx, 0x10c(%rax)
testl %ecx, %ecx
jg 0x29603
incl %ecx
movl %ecx, 0x10c(%rax)
xorl %ecx, %ecx
movl %ecx, 0x110(%rax)
movl $0x3, (%rax)
xorl %ecx, %ecx
leaq 0xfdc1e(%rip), %rdx     # 0x127230
movslq 0x4(%rax), %rsi
cmpq %rsi, %rcx
jge 0x29575
movslq 0x8(%rax,%rcx,4), %rsi
movq (%rdx,%rsi,8), %rdi
movl 0x11c(%rax), %r8d
addl 0x6c(%rax,%rcx,4), %r8d
subl 0xbc(%rax), %r8d
movl %r8d, 0x8(%rdi)
xorl %r9d, %r9d
movslq 0x120(%rax), %r10
cmpq %r10, %r9
jge 0x29662
cmpl 0x58(%rax,%r9,4), %esi
jne 0x2965d
subl 0x68(%rax), %r8d
movl %r8d, 0x8(%rdi)
incq %r9
jmp 0x29642
incq %rcx
jmp 0x29612