// File: /workspace/github_c_makefile_star2_O2/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, %r14d
movl %edi, %ebp
callq 0x1cfc4
testl %eax, %eax
je 0x1fcae
leaq 0x62a2f(%rip), %rdi     # 0x826d6
xorl %eax, %eax
callq 0x2acb8
movslq %ebp, %rax
leaq 0x107578(%rip), %rcx    # 0x127230
movq (%rcx,%rax,8), %rcx
movzwl 0x2a(%rcx), %eax
movzwl 0x1a(%rcx), %ecx
xorl %ebx, %ebx
leal -0x12d(%rcx), %edx
cmpl $0x15, %edx
jbe 0x1fd14
leal -0x190(%rcx), %edx
cmpl $0x7, %edx
ja 0x1fce6
movl $0x87, %esi
btl %edx, %esi
jb 0x1fd56
cmpl $0x321, %ecx            # imm = 0x321
je 0x1fd20
cmpl $0x64, %ecx
je 0x1fd56
cmpl $0x320, %ecx            # imm = 0x320
je 0x1fd38
testl %ecx, %ecx
jne 0x1fd5d
cmpw $0x3fff, %ax            # imm = 0x3FFF
ja 0x1fd56
movswl %bp, %edi
movl $0x12d, %esi            # imm = 0x12D
callq 0x1e16a
jmp 0x1fd56
movl $0x200007, %esi         # imm = 0x200007
btl %edx, %esi
jb 0x1fd56
jmp 0x1fcd1
movswl %bp, %r14d
pushq $0x64
popq %rsi
movl %r14d, %edi
callq 0x44444
movl %ebp, %edi
callq 0x1ff2b
jmp 0x1fd4e
movswl %bp, %r14d
pushq $0x64
popq %rsi
movl %r14d, %edi
callq 0x44444
movl %ebp, %edi
callq 0x1fdf3
movl %r14d, %edi
callq 0x1cf5e
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
cmpw $0x3fff, %ax            # imm = 0x3FFF
ja 0x1fd56
leaq 0x1072ba(%rip), %rcx    # 0x127024
cmpl $0x0, (%rcx)
sete %cl
shll %cl, %r14d
movl %r14d, %edx
negl %edx
cmovsl %r14d, %edx
leaq 0x1af4ad(%rip), %rcx    # 0x1cf230
movq (%rcx,%rax,8), %rsi
movsbq 0x1(%rsi), %rdi
movl %edi, %r8d
subb %r14b, %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 0x1fdd5
orb $0x8, 0x6(%rdx)
movq (%rcx,%rax,8), %rdx
cmpb $0x0, 0x1(%rdx)
jle 0x1fdde
orb $0x20, 0x4(%rdx)
jmp 0x1fd56
movb $0x0, 0x1(%rdx)
movq (%rcx,%rax,8), %rax
orw $0x40, 0x4(%rax)
pushq $0x1
popq %rbx
jmp 0x1fd56