// File: /workspace/github_c_makefile_star2_O1/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 0x1ea05
testl %eax, %eax
je 0x21962
leaq 0x6bcf3(%rip), %rdi     # 0x8d64e
xorl %eax, %eax
callq 0x2d800
movslq %r14d, %rax
leaq 0x10c8a4(%rip), %rcx    # 0x12e210
movq (%rcx,%rax,8), %rcx
movzwl 0x2a(%rcx), %eax
movzwl 0x1a(%rcx), %ecx
xorl %ebx, %ebx
cmpl $0x18f, %ecx            # imm = 0x18F
jg 0x219ae
leal -0x12d(%rcx), %edx
cmpl $0x15, %edx
ja 0x2199b
movl $0x200007, %esi         # imm = 0x200007
btl %edx, %esi
jb 0x21ab2
testl %ecx, %ecx
je 0x21a7c
cmpl $0x64, %ecx
je 0x21ab2
jmp 0x219f8
leal -0x190(%rcx), %edx
cmpl $0x7, %edx
ja 0x219c7
movl $0x87, %esi
btl %edx, %esi
jb 0x21ab2
cmpl $0x320, %ecx            # imm = 0x320
je 0x21a93
cmpl $0x321, %ecx            # imm = 0x321
jne 0x219f8
movswl %r14w, %ebp
movl %ebp, %edi
movl $0x64, %esi
callq 0x4703b
movl %r14d, %edi
callq 0x21c1a
jmp 0x21aab
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x21ab2
leaq 0x10c5fa(%rip), %rcx    # 0x12e004
cmpl $0x0, (%rcx)
sete %cl
shll %cl, %ebp
movl %ebp, %edx
negl %edx
cmovsl %ebp, %edx
leaq 0x1b47f0(%rip), %rcx    # 0x1d6210
movq (%rcx,%rax,8), %rsi
movsbq 0x1(%rsi), %rdi
movl %edi, %r8d
subb %bpl, %r8b
xorl %r9d, %r9d
cmpq %rdi, %rdx
movzbl %r8b, %edx
cmovgl %r9d, %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 0x21a6a
orb $0x8, 0x6(%rdx)
movq (%rcx,%rax,8), %rdx
cmpb $0x0, 0x1(%rdx)
jle 0x21ab9
orb $0x20, 0x4(%rdx)
xorl %ebx, %ebx
jmp 0x21ab2
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x21ab2
movswl %r14w, %edi
movl $0x12d, %esi            # imm = 0x12D
callq 0x1fc27
jmp 0x21ab2
movswl %r14w, %ebp
movl %ebp, %edi
movl $0x64, %esi
callq 0x4703b
movl %r14d, %edi
callq 0x21acd
movl %ebp, %edi
callq 0x1e99d
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 0x21ab2