// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/src/tekchng.c
// Function: changehealth
int
changehealth(short snum, short deltahealth)
{
     int       healthmax;

     if( !validplayer(snum) ) {
          crashgame("chnghlth bad plrnum");
     }
     if( toggles[TOGGLE_GODMODE] != 0 ) {
          return(0);
     }
     if( health[snum] <= 0 ) {
          return(1);
     }

     if( option[4] == 0 ) {
          if( deltahealth < 0 ) {
               switch( difficulty ) {
               case 0:
               case 1:
                    deltahealth>>=3;
                    deltahealth-=5;
                    break;
               case 2:
                    deltahealth>>=2;
                    break;
               case 3:
                    deltahealth>>=1;
                    break;
               }
          }
     }

     healthmax=MAXHEALTH;

     if( snum == screenpeek ) {
          if( deltahealth < 0 ) {
               if( deltahealth <= -90 ) {
                    criticalflash();
               }
               else {
                    woundflash();
               }
          }
          else {
               bonusflash();
          }
     }

     if (health[snum] > 0)
     {
          health[snum] += deltahealth;
          if( health[snum] > healthmax )
               health[snum]=healthmax;

          if (health[snum] <= 0)
          {
               health[snum] = -1;
               playsound(S_PLAYERDIE, posx[snum],posy[snum], 0,ST_NOUPDATE);
          }
     }

     if( (health[snum] <= 0) && (option[4] != 0) ) {
          playerdropitems(snum);
     }

     return(health[snum] <= 0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebp
movl %edi, %ebx
callq 0xe2e0
testl %eax, %eax
jne 0x99cb
leaq 0x773e4(%rip), %rdi     # 0x80da8
xorl %eax, %eax
callq 0x2acb8
leaq 0xbe08e(%rip), %rcx     # 0xc7a60
xorl %eax, %eax
cmpl $0x0, 0x1c(%rcx)
jne 0x9ad3
movswq %bx, %r14
leaq 0xd0ba7(%rip), %r15     # 0xda590
cmpl $0x0, (%r15,%r14,4)
jle 0x9a20
leaq 0xbdf81(%rip), %r12     # 0xc7978
testw %bp, %bp
jns 0x9a39
cmpb $0x0, 0x4(%r12)
jne 0x9a39
leaq 0x11d619(%rip), %rax    # 0x127024
movl (%rax), %eax
cmpl $0x2, %eax
jb 0x9a28
je 0x9a33
cmpl $0x3, %eax
jne 0x9a39
movswl %bp, %ebp
shrl %ebp
jmp 0x9a39
pushq $0x1
popq %rax
jmp 0x9ad3
movswl %bp, %ebp
sarl $0x3, %ebp
addl $-0x5, %ebp
jmp 0x9a39
movswl %bp, %ebp
shrl $0x2, %ebp
leaq 0xd0a1e(%rip), %rax     # 0xda45e
cmpw %bx, (%rax)
jne 0x9a65
xorl %eax, %eax
testw %bp, %bp
js 0x9a53
callq 0x1339b
jmp 0x9a65
cmpw $-0x5a, %bp
ja 0x9a60
callq 0x13386
jmp 0x9a65
callq 0x13371
movl (%r15,%r14,4), %ecx
testl %ecx, %ecx
jle 0x9ab5
movswl %bp, %eax
addl %eax, %ecx
movl $0x3e8, %eax            # imm = 0x3E8
cmpl %eax, %ecx
cmovll %ecx, %eax
movl %eax, (%r15,%r14,4)
testl %ecx, %ecx
movl %eax, %ecx
jg 0x9ab5
orl $-0x1, (%r15,%r14,4)
leaq 0xd0a3e(%rip), %rax     # 0xda4d0
movl (%rax,%r14,4), %esi
leaq 0xd0a73(%rip), %rax     # 0xda510
movl (%rax,%r14,4), %edx
pushq $0x4
popq %r8
movl $0x80, %edi
xorl %ecx, %ecx
callq 0x1ab2a
movl (%r15,%r14,4), %ecx
testl %ecx, %ecx
jg 0x9acc
cmpb $0x0, 0x4(%r12)
je 0x9acc
movl %ebx, %edi
callq 0x1cc35
movl (%r15,%r14,4), %ecx
xorl %eax, %eax
testl %ecx, %ecx
setle %al
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq