// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/src/tekstat.c
// Function: damagesprite
int
damagesprite(int hitsprite, int points)
{
     short     ext;

    #ifdef PLRSPRDEBUG
     if( isaplayersprite(hitsprite) ) {
          crashgame("messing w plrsprite at 12");
     }
    #else
     if( isaplayersprite(hitsprite) ) {
          return(0);
     }
    #endif

     ext=sprptr[hitsprite]->extra;

     switch( sprptr[hitsprite]->statnum ) {
     case INANIMATE:
          if( validext(ext) ) {
               newstatus(hitsprite, DEATH);
          }
          return(0);
     case GENEXPLODE1:
          changespritestat(hitsprite,INACTIVE);
          genexplosion1(hitsprite);
          //changespritestat(hitsprite,VANISH);
          jsdeletesprite(hitsprite);
          return(0);
     case GENEXPLODE2:
          changespritestat(hitsprite,INACTIVE);
          genexplosion2(hitsprite);
          //changespritestat(hitsprite,VANISH);
          jsdeletesprite(hitsprite);
          return(0);
     case INACTIVE:
     case FLOATING:
          return(0);
     case PROJHIT:
     case PROJECTILE:
     case TOSS:
     case PAIN:
     case RUNTHRU:
     case TWITCH:
     case DEATH:
          return(0);
     default:
          break;
     }

     if( difficulty == 0 ) {
          points<<=1;
     }

     if( validext(ext) ) {
          if( (labs(points)) > sprXTptr[ext]->hitpoints ) {
               sprXTptr[ext]->hitpoints=0;
          }
          else {
               sprXTptr[ext]->hitpoints-=points;
          }
          sprXTptr[ext]->aimask|=AI_JUSTSHOTAT;
          sprXTptr[ext]->aimask|=AI_TIMETODODGE;
          sprXTptr[ext]->aimask|=AI_WASATTACKED;
          if( sprXTptr[ext]->hitpoints < ENEMYCRITICALCONDITION )
               sprXTptr[ext]->aimask|=AI_CRITICAL;
          if( sprXTptr[ext]->hitpoints <= 0 ) {
               sprXTptr[ext]->hitpoints=0;
               //newstatus(hitsprite,DEATH);
               sprXTptr[ext]->fxmask|=FX_NXTSTTDEATH;
               return(1);
          }
          else {
               //newstatus(hitsprite,PAIN);
               sprXTptr[ext]->fxmask|=FX_NXTSTTPAIN;
          }
     }

     return(0);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movl %edi, %r14d
callq 0x1eb81
testl %eax, %eax
je 0x21bc2
leaq 0x6ebb7(%rip), %rdi     # 0x90772
xorl %eax, %eax
callq 0x2eb88
movslq %r14d, %rax
leaq 0x10f664(%rip), %rcx    # 0x131230
movq (%rcx,%rax,8), %rcx
movzwl 0x2a(%rcx), %eax
movzwl 0x1a(%rcx), %ecx
xorl %ebx, %ebx
cmpl $0x18f, %ecx            # imm = 0x18F
jg 0x21c0e
leal -0x12d(%rcx), %edx
cmpl $0x15, %edx
ja 0x21bfb
movl $0x200007, %esi         # imm = 0x200007
btl %edx, %esi
jb 0x21d0e
testl %ecx, %ecx
je 0x21cd8
cmpl $0x64, %ecx
je 0x21d0e
jmp 0x21c58
leal -0x190(%rcx), %edx
cmpl $0x7, %edx
ja 0x21c27
movl $0x87, %esi
btl %edx, %esi
jb 0x21d0e
cmpl $0x320, %ecx            # imm = 0x320
je 0x21cef
cmpl $0x321, %ecx            # imm = 0x321
jne 0x21c58
movswl %r14w, %ebp
movl %ebp, %edi
movl $0x64, %esi
callq 0x48fa7
movl %r14d, %edi
callq 0x21e6b
jmp 0x21d07
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x21d0e
leaq 0x10f3ba(%rip), %rcx    # 0x131024
cmpl $0x0, (%rcx)
sete %cl
shll %cl, %ebp
movl %ebp, %edx
negl %edx
cmovsl %ebp, %edx
leaq 0x1b75b0(%rip), %rcx    # 0x1d9230
movq (%rcx,%rax,8), %rsi
movsbq 0x1(%rsi), %rdi
movl %edi, %r8d
subb %bpl, %r8b
xorl %ebx, %ebx
cmpq %rdi, %rdx
movzbl %r8b, %edx
cmovgl %ebx, %edx
movb %dl, 0x1(%rsi)
movq (%rcx,%rax,8), %rdx
orw $0x4, 0x6(%rdx)
movq (%rcx,%rax,8), %rdx
orw $0x800, 0x6(%rdx)       # imm = 0x800
movq (%rcx,%rax,8), %rdx
orw $0x20, 0x6(%rdx)
movq (%rcx,%rax,8), %rdx
cmpb $0x18, 0x1(%rdx)
jg 0x21cd2
orb $0x8, 0x6(%rdx)
movq (%rcx,%rax,8), %rdx
cmpb $0x0, 0x1(%rdx)
jle 0x21d15
orb $0x20, 0x4(%rdx)
jmp 0x21d0e
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x21d0e
movswl %r14w, %edi
movl $0x12d, %esi            # imm = 0x12D
callq 0x1fe98
jmp 0x21d0e
movswl %r14w, %ebp
movl %ebp, %edi
movl $0x64, %esi
callq 0x48fa7
movl %r14d, %edi
callq 0x21d29
movl %ebp, %edi
callq 0x1eb19
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
movb $0x0, 0x1(%rdx)
movq (%rcx,%rax,8), %rax
orw $0x40, 0x4(%rax)
movl $0x1, %ebx
jmp 0x21d0e