// File: /workspace/github_c_makefile_star2_O1/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 0xf210
testl %eax, %eax
jne 0xa5fb
leaq 0x817b4(%rip), %rdi     # 0x8bda8
xorl %eax, %eax
callq 0x2d800
leaq 0xc445e(%rip), %rcx     # 0xcea60
xorl %eax, %eax
cmpl $0x0, 0x1c(%rcx)
jne 0xa706
movswq %bx, %r14
leaq 0xd6f77(%rip), %r15     # 0xe1590
cmpl $0x0, (%r15,%r14,4)
jle 0xa650
leaq 0xc4351(%rip), %r12     # 0xce978
testw %bp, %bp
jns 0xa66b
cmpb $0x0, 0x4(%r12)
jne 0xa66b
leaq 0x1239c9(%rip), %rax    # 0x12e004
movl (%rax), %eax
cmpl $0x2, %eax
jb 0xa65a
je 0xa665
cmpl $0x3, %eax
jne 0xa66b
movswl %bp, %ebp
shrl %ebp
jmp 0xa66b
movl $0x1, %eax
jmp 0xa706
movswl %bp, %ebp
sarl $0x3, %ebp
addl $-0x5, %ebp
jmp 0xa66b
movswl %bp, %ebp
shrl $0x2, %ebp
leaq 0xd6dec(%rip), %rax     # 0xe145e
cmpw %bx, (%rax)
jne 0xa697
xorl %eax, %eax
testw %bp, %bp
js 0xa685
callq 0x14768
jmp 0xa697
cmpw $-0x5a, %bp
jg 0xa692
callq 0x14753
jmp 0xa697
callq 0x1473e
movl (%r15,%r14,4), %eax
testl %eax, %eax
jle 0xa6e6
movswl %bp, %ecx
addl %ecx, %eax
movl $0x3e8, %ecx            # imm = 0x3E8
cmpl %ecx, %eax
cmovll %eax, %ecx
movl %ecx, (%r15,%r14,4)
testl %eax, %eax
jg 0xa6e6
movl $0xffffffff, (%r15,%r14,4) # imm = 0xFFFFFFFF
leaq 0xd6e0b(%rip), %rax     # 0xe14d0
movl (%rax,%r14,4), %esi
leaq 0xd6e40(%rip), %rax     # 0xe1510
movl (%rax,%r14,4), %edx
movl $0x80, %edi
xorl %ecx, %ecx
movl $0x4, %r8d
callq 0x1c1f1
cmpl $0x0, (%r15,%r14,4)
jg 0xa6fc
cmpb $0x0, 0x4(%r12)
je 0xa6fc
movl %ebx, %edi
callq 0x1e671
xorl %eax, %eax
cmpl $0x0, (%r15,%r14,4)
setle %al
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq