// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/src/tekspr.c
// Function: movesprite
short
movesprite(short spritenum, int dx, int dy, int dz, int ceildist, int flordist, char cliptype)
{
     int           daz,zoffs;
     int           jumpz,deltaz;
     int           px,py,pz;
     short          retval,dasectnum,tempshort;
     short          failedsectnum;
     unsigned int dcliptype;
     spritetype     *spr;

    #ifdef PLRSPRDEBUG
     if( isaplayersprite(spritenum) ) {
          crashgame("messing w plrsprite at 19");
     }
    #endif

     switch (cliptype) {
          case NORMALCLIP: dcliptype = CLIPMASK0; break;
          case PROJECTILECLIP: dcliptype = CLIPMASK1; break;
          case CLIFFCLIP: dcliptype = CLIPMASK0; break;
     }

     spr = &sprite[spritenum];

     if ((spr->cstat&128) == 0)
          zoffs = -((tilesizy[spr->picnum]*spr->yrepeat)<<1);
     else
          zoffs = 0;

     dasectnum = spr->sectnum;
     px=spr->x;
     py=spr->y;
     pz=spr->z;
     daz = spr->z+zoffs;
     retval = clipmove(&spr->x,&spr->y,&daz,&dasectnum,dx,dy,
                                   ((int)spr->clipdist)<<2,ceildist,flordist,dcliptype);
     if( (dasectnum != spr->sectnum) && (dasectnum >= 0) ) {
          changespritesect(spritenum,dasectnum);
     }

     if( dasectnum >= 0 && (sectptr[dasectnum]->lotag == 4) && (spr->extra != -1) ) {
          switch( spr->statnum ) {
          case FLOATING:
               break;
          default:
               spr->z=sectptr[spr->sectnum]->floorz-zoffs;
               break;
          }
          return(retval);
     }

     tempshort = spr->cstat; spr->cstat &= ~1;
     getzrange(spr->x,spr->y,spr->z-1,spr->sectnum,
                     &globhiz,&globhihit,&globloz,&globlohit,
                     ((int)spr->clipdist)<<2,dcliptype);
     spr->cstat = tempshort;
     daz = spr->z+zoffs + dz;
     if( (daz <= globhiz) || (daz > globloz) ) {
          if( retval != 0 ) {
               return(retval);
          }
          else {
               return(16384+dasectnum);
          }
     }
     if( (globloz != pz) && (spr->extra >= 0) && (spr->extra < MAXSPRITES) ) {
          spr->z=globloz;
          deltaz=abs(pz-globloz);
          jumpz=tilesizy[spr->picnum]+(spr->yrepeat-64);
          jumpz<<=8;
          if( deltaz > jumpz ) {
               failedsectnum=spr->sectnum;
               setsprite(spritenum,px,py,pz);
               retval=failedsectnum+16384;
          }
     }
     else {
          spr->z = daz-zoffs;
     }

     return(retval);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x78, %rsp
movw %di, %ax
movb 0x10(%rbp), %dil
movw %ax, -0xc(%rbp)
movl %esi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movl %r9d, -0x20(%rbp)
movsbl 0x10(%rbp), %eax
movl %eax, -0x54(%rbp)
testl %eax, %eax
je 0x28716
jmp 0x28702
movl -0x54(%rbp), %eax
subl $0x1, %eax
je 0x2871f
jmp 0x2870c
movl -0x54(%rbp), %eax
subl $0x2, %eax
je 0x28728
jmp 0x2872f
movl $0x10001, -0x48(%rbp)   # imm = 0x10001
jmp 0x2872f
movl $0x1000040, -0x48(%rbp) # imm = 0x1000040
jmp 0x2872f
movl $0x10001, -0x48(%rbp)   # imm = 0x10001
movswq -0xc(%rbp), %rcx
leaq 0x44e3a5(%rip), %rax    # 0x476ae0
imulq $0x2c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movswl 0xc(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x28782
movq -0x50(%rbp), %rax
movswq 0xe(%rax), %rcx
leaq 0x5d10a8(%rip), %rax    # 0x5f9810
movswl (%rax,%rcx,2), %ecx
movq -0x50(%rbp), %rax
movzbl 0x15(%rax), %eax
imull %eax, %ecx
shll %ecx
xorl %eax, %eax
subl %ecx, %eax
movl %eax, -0x28(%rbp)
jmp 0x28789
movl $0x0, -0x28(%rbp)
movq -0x50(%rbp), %rax
movw 0x18(%rax), %ax
movw %ax, -0x40(%rbp)
movq -0x50(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x50(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x50(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x50(%rbp), %rax
movl 0x8(%rax), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x50(%rbp), %rdi
movq -0x50(%rbp), %rsi
addq $0x4, %rsi
movl -0x10(%rbp), %r8d
movl -0x14(%rbp), %r9d
movq -0x50(%rbp), %rax
movzbl 0x12(%rax), %ebx
shll $0x2, %ebx
movl -0x1c(%rbp), %r11d
movl -0x20(%rbp), %r10d
movl -0x48(%rbp), %eax
leaq -0x24(%rbp), %rdx
leaq -0x40(%rbp), %rcx
movl %ebx, (%rsp)
movl %r11d, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movl %eax, 0x18(%rsp)
callq 0x6d430
movw %ax, -0x3e(%rbp)
movswl -0x40(%rbp), %eax
movq -0x50(%rbp), %rcx
movswl 0x18(%rcx), %ecx
cmpl %ecx, %eax
je 0x28834
movswl -0x40(%rbp), %eax
cmpl $0x0, %eax
jl 0x28834
movw -0xc(%rbp), %ax
movswl %ax, %edi
movswl -0x40(%rbp), %esi
callq 0x69bd0
movswl -0x40(%rbp), %eax
cmpl $0x0, %eax
jl 0x288a3
movswq -0x40(%rbp), %rcx
leaq 0x219997(%rip), %rax    # 0x2421e0
movq (%rax,%rcx,8), %rax
movswl 0x22(%rax), %eax
cmpl $0x4, %eax
jne 0x288a3
movq -0x50(%rbp), %rax
movswl 0x2a(%rax), %eax
cmpl $-0x1, %eax
je 0x288a3
movq -0x50(%rbp), %rax
movw 0x1a(%rax), %ax
subw $0x142, %ax             # imm = 0x142
jne 0x28875
jmp 0x28873
jmp 0x28896
movq -0x50(%rbp), %rax
movswq 0x18(%rax), %rcx
leaq 0x21995b(%rip), %rax    # 0x2421e0
movq (%rax,%rcx,8), %rax
movl 0x8(%rax), %ecx
subl -0x28(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x8(%rax)
movw -0x3e(%rbp), %ax
movw %ax, -0xa(%rbp)
jmp 0x28a59
movq -0x50(%rbp), %rax
movw 0xc(%rax), %ax
movw %ax, -0x42(%rbp)
movq -0x50(%rbp), %rax
movswl 0xc(%rax), %ecx
andl $-0x2, %ecx
movw %cx, 0xc(%rax)
movq -0x50(%rbp), %rax
movl (%rax), %edi
movq -0x50(%rbp), %rax
movl 0x4(%rax), %esi
movq -0x50(%rbp), %rax
movl 0x8(%rax), %edx
subl $0x1, %edx
movq -0x50(%rbp), %rax
movw 0x18(%rax), %cx
movq -0x50(%rbp), %rax
movzbl 0x12(%rax), %r10d
shll $0x2, %r10d
movl -0x48(%rbp), %eax
leaq 0x105e3c(%rip), %r8     # 0x12e730
leaq 0x105e39(%rip), %r9     # 0x12e734
leaq 0x105e36(%rip), %rbx    # 0x12e738
leaq 0x105e33(%rip), %r11    # 0x12e73c
movswl %cx, %ecx
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movl %eax, 0x18(%rsp)
callq 0x70760
movw -0x42(%rbp), %cx
movq -0x50(%rbp), %rax
movw %cx, 0xc(%rax)
movq -0x50(%rbp), %rax
movl 0x8(%rax), %eax
addl -0x28(%rbp), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
leaq 0x105de7(%rip), %rcx    # 0x12e730
cmpl (%rcx), %eax
jle 0x2895b
movl -0x24(%rbp), %eax
leaq 0x105de1(%rip), %rcx    # 0x12e738
cmpl (%rcx), %eax
jle 0x28983
movswl -0x3e(%rbp), %eax
cmpl $0x0, %eax
je 0x28971
movw -0x3e(%rbp), %ax
movw %ax, -0xa(%rbp)
jmp 0x28a59
movswl -0x40(%rbp), %eax
addl $0x4000, %eax           # imm = 0x4000
movw %ax, -0xa(%rbp)
jmp 0x28a59
leaq 0x105dae(%rip), %rax    # 0x12e738
movl (%rax), %eax
cmpl -0x3c(%rbp), %eax
je 0x28a44
movq -0x50(%rbp), %rax
movswl 0x2a(%rax), %eax
cmpl $0x0, %eax
jl 0x28a44
movq -0x50(%rbp), %rax
movswl 0x2a(%rax), %eax
cmpl $0x4000, %eax           # imm = 0x4000
jge 0x28a44
leaq 0x105d78(%rip), %rax    # 0x12e738
movl (%rax), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x3c(%rbp), %eax
leaq 0x105d65(%rip), %rcx    # 0x12e738
subl (%rcx), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movl %eax, -0x30(%rbp)
movq -0x50(%rbp), %rax
movswq 0xe(%rax), %rcx
leaq 0x5d0e21(%rip), %rax    # 0x5f9810
movswl (%rax,%rcx,2), %eax
movq -0x50(%rbp), %rcx
movzbl 0x15(%rcx), %ecx
subl $0x40, %ecx
addl %ecx, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
shll $0x8, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jle 0x28a42
movq -0x50(%rbp), %rax
movw 0x18(%rax), %ax
movw %ax, -0x44(%rbp)
movw -0xc(%rbp), %ax
movl -0x34(%rbp), %esi
movl -0x38(%rbp), %edx
movl -0x3c(%rbp), %ecx
movswl %ax, %edi
callq 0x69af0
movswl -0x44(%rbp), %eax
addl $0x4000, %eax           # imm = 0x4000
movw %ax, -0x3e(%rbp)
jmp 0x28a51
movl -0x24(%rbp), %ecx
subl -0x28(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x8(%rax)
movw -0x3e(%rbp), %ax
movw %ax, -0xa(%rbp)
movw -0xa(%rbp), %ax
addq $0x78, %rsp
popq %rbx
popq %rbp
retq
nopw %cs:(%rax,%rax)