// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x4(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x32334e(%rip), %rax    # 0x364940
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
movl $0xc0, -0x14(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x30(%rbp)
subq $0x4, %rax
ja 0x41867
movq -0x30(%rbp), %rax
leaq 0x993cc(%rip), %rcx     # 0xda9ec
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x20(%rbp), %rax
movl 0x114(%rax), %ecx
subl $0x3, %ecx
movl %ecx, 0x114(%rax)
movq -0x20(%rbp), %rax
cmpl $0x0, 0x114(%rax)
jg 0x41653
movq -0x20(%rbp), %rax
movl $0x1, (%rax)
jmp 0x4191e
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rax
movl 0x68(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x68(%rax)
movq -0x20(%rbp), %rax
cmpl $0x0, 0x68(%rax)
jg 0x41686
movq -0x20(%rbp), %rax
movl $0x0, 0x68(%rax)
movq -0x20(%rbp), %rax
movl $0x4, (%rax)
jmp 0x41867
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %rax
addl 0x68(%rax), %ecx
movl %ecx, 0x68(%rax)
movq -0x20(%rbp), %rax
cmpl $0x3c00, 0x68(%rax)     # imm = 0x3C00
jl 0x416c8
movq -0x20(%rbp), %rax
movl $0x3c00, 0x68(%rax)     # imm = 0x3C00
movq -0x20(%rbp), %rax
movl $0x2, (%rax)
movq -0x20(%rbp), %rax
movl $0x1e0, 0x114(%rax)     # imm = 0x1E0
jmp 0x41867
movq -0x20(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq 0x10c(%rcx), %rcx
movl 0xbc(%rax,%rcx,4), %eax
movl %eax, -0x18(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, 0x110(%rax)
jne 0x41751
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rax
movl 0x11c(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x11c(%rax)
movq -0x20(%rbp), %rax
movl 0x11c(%rax), %eax
cmpl -0x18(%rbp), %eax
jg 0x4174f
movq -0x20(%rbp), %rax
movl 0x11c(%rax), %eax
subl -0x18(%rbp), %eax
movslq %eax, %rdx
movq %rdx, %rax
negq %rax
cmovnsq %rax, %rdx
movq -0x20(%rbp), %rax
movslq 0x11c(%rax), %rcx
addq %rdx, %rcx
movl %ecx, 0x11c(%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0x417ad
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %rax
addl 0x11c(%rax), %ecx
movl %ecx, 0x11c(%rax)
movq -0x20(%rbp), %rax
movl 0x11c(%rax), %eax
cmpl -0x18(%rbp), %eax
jl 0x417ab
movq -0x20(%rbp), %rax
movl 0x11c(%rax), %eax
subl -0x18(%rbp), %eax
movslq %eax, %rdx
movq %rdx, %rax
negq %rax
cmovnsq %rax, %rdx
movq -0x20(%rbp), %rax
movslq 0x11c(%rax), %rcx
subq %rdx, %rcx
movl %ecx, 0x11c(%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0x417ad
jmp 0x41867
movq -0x20(%rbp), %rax
cmpl $0x0, 0x110(%rax)
jne 0x4180b
movq -0x20(%rbp), %rax
movl 0x10c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10c(%rax)
movq -0x20(%rbp), %rax
movl 0x10c(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl 0x118(%rcx), %eax
jle 0x41809
movq -0x20(%rbp), %rax
movl 0x10c(%rax), %ecx
subl $0x2, %ecx
movl %ecx, 0x10c(%rax)
movq -0x20(%rbp), %rax
movl $0x1, 0x110(%rax)
jmp 0x4185d
movq -0x20(%rbp), %rax
cmpl $0x1, 0x110(%rax)
jne 0x4185b
movq -0x20(%rbp), %rax
movl 0x10c(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x10c(%rax)
movq -0x20(%rbp), %rax
cmpl $0x0, 0x10c(%rax)
jge 0x41859
movq -0x20(%rbp), %rax
movl 0x10c(%rax), %ecx
addl $0x2, %ecx
movl %ecx, 0x10c(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x110(%rax)
jmp 0x4185b
jmp 0x4185d
movq -0x20(%rbp), %rax
movl $0x3, (%rax)
movl $0x0, -0x8(%rbp)
movl -0x8(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x4191e
movq -0x20(%rbp), %rax
movslq -0x8(%rbp), %rcx
movl 0x8(%rax,%rcx,4), %eax
movl %eax, -0xc(%rbp)
movslq -0xc(%rbp), %rcx
leaq 0x138948(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movslq -0x8(%rbp), %rcx
movl 0x6c(%rax,%rcx,4), %ecx
movq -0x20(%rbp), %rax
addl 0x11c(%rax), %ecx
movq -0x20(%rbp), %rax
subl 0xbc(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x8(%rax)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x120(%rcx), %eax
jge 0x4190e
movl -0xc(%rbp), %eax
movq -0x20(%rbp), %rcx
movslq -0x10(%rbp), %rdx
cmpl 0x58(%rcx,%rdx,4), %eax
jne 0x41901
movq -0x20(%rbp), %rax
movl 0x68(%rax), %edx
movq -0x28(%rbp), %rax
movl 0x8(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x8(%rax)
jmp 0x41903
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x418ce
jmp 0x41910
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x4186e
popq %rbp
retq