// File: /workspace/github_c_makefile_star2_O3/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 0xf230
testl %eax, %eax
jne 0xa60b
leaq 0x847a4(%rip), %rdi     # 0x8eda8
xorl %eax, %eax
callq 0x2eb88
leaq 0xc744e(%rip), %rcx     # 0xd1a60
xorl %eax, %eax
cmpl $0x0, 0x1c(%rcx)
jne 0xa71a
movswq %bx, %r14
leaq 0xd9f67(%rip), %r15     # 0xe4590
cmpl $0x0, (%r15,%r14,4)
jle 0xa660
leaq 0xc7341(%rip), %r12     # 0xd1978
testw %bp, %bp
jns 0xa67b
cmpb $0x0, 0x4(%r12)
jne 0xa67b
leaq 0x1269d9(%rip), %rax    # 0x131024
movl (%rax), %eax
cmpl $0x2, %eax
jb 0xa66a
je 0xa675
cmpl $0x3, %eax
jne 0xa67b
movswl %bp, %ebp
shrl %ebp
jmp 0xa67b
movl $0x1, %eax
jmp 0xa71a
movswl %bp, %ebp
sarl $0x3, %ebp
addl $-0x5, %ebp
jmp 0xa67b
movswl %bp, %ebp
shrl $0x2, %ebp
leaq 0xd9ddc(%rip), %rax     # 0xe445e
cmpw %bx, (%rax)
jne 0xa6a7
xorl %eax, %eax
testw %bp, %bp
js 0xa695
callq 0x147e8
jmp 0xa6a7
cmpw $-0x5a, %bp
ja 0xa6a2
callq 0x147d3
jmp 0xa6a7
callq 0x147be
movl (%r15,%r14,4), %ecx
testl %ecx, %ecx
jle 0xa6fc
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 0xa6fc
movl $0xffffffff, (%r15,%r14,4) # imm = 0xFFFFFFFF
leaq 0xd9df9(%rip), %rax     # 0xe44d0
movl (%rax,%r14,4), %esi
leaq 0xd9e2e(%rip), %rax     # 0xe4510
movl (%rax,%r14,4), %edx
movl $0x80, %edi
xorl %ecx, %ecx
movl $0x4, %r8d
callq 0x1c370
movl (%r15,%r14,4), %ecx
testl %ecx, %ecx
jg 0xa713
cmpb $0x0, 0x4(%r12)
je 0xa713
movl %ebx, %edi
callq 0x1e7f4
movl (%r15,%r14,4), %ecx
xorl %eax, %eax
testl %ecx, %ecx
setle %al
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq