// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x10, %rsp
movw %si, %ax
movw %di, %cx
movw %cx, -0x6(%rbp)
movw %ax, -0x8(%rbp)
movswl -0x6(%rbp), %edi
callq 0x11c50
cmpl $0x0, %eax
jne 0x9d72
leaq 0xcf03d(%rip), %rdi     # 0xd8da8
movb $0x0, %al
callq 0x44240
leaq 0x110287(%rip), %rax    # 0x11a000
cmpl $0x0, 0x1c(%rax)
je 0x9d8b
movl $0x0, -0x4(%rbp)
jmp 0x9f58
movswq -0x6(%rbp), %rcx
leaq 0x123b79(%rip), %rax    # 0x12d910
cmpl $0x0, (%rax,%rcx,4)
jg 0x9da9
movl $0x1, -0x4(%rbp)
jmp 0x9f58
leaq 0x110168(%rip), %rax    # 0x119f18
movzbl 0x4(%rax), %eax
cmpl $0x0, %eax
jne 0x9e1c
movswl -0x8(%rbp), %eax
cmpl $0x0, %eax
jge 0x9e1a
leaq 0x1701ff(%rip), %rax    # 0x179fc8
movl (%rax), %eax
movl %eax, -0x10(%rbp)
subl $0x2, %eax
jb 0x9de9
jmp 0x9dd5
movl -0x10(%rbp), %eax
subl $0x2, %eax
je 0x9e01
jmp 0x9ddf
movl -0x10(%rbp), %eax
subl $0x3, %eax
je 0x9e0e
jmp 0x9e18
movswl -0x8(%rbp), %eax
sarl $0x3, %eax
movw %ax, -0x8(%rbp)
movswl -0x8(%rbp), %eax
subl $0x5, %eax
movw %ax, -0x8(%rbp)
jmp 0x9e18
movswl -0x8(%rbp), %eax
sarl $0x2, %eax
movw %ax, -0x8(%rbp)
jmp 0x9e18
movswl -0x8(%rbp), %eax
sarl %eax
movw %ax, -0x8(%rbp)
jmp 0x9e1a
jmp 0x9e1c
movl $0x3e8, -0xc(%rbp)      # imm = 0x3E8
movswl -0x6(%rbp), %eax
leaq 0x1239b0(%rip), %rcx    # 0x12d7de
movswl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x9e62
movswl -0x8(%rbp), %eax
cmpl $0x0, %eax
jge 0x9e59
movswl -0x8(%rbp), %eax
cmpl $-0x5a, %eax
jg 0x9e50
movb $0x0, %al
callq 0x19ba0
jmp 0x9e57
movb $0x0, %al
callq 0x19b90
jmp 0x9e60
movb $0x0, %al
callq 0x19bb0
jmp 0x9e62
movswq -0x6(%rbp), %rcx
leaq 0x123aa2(%rip), %rax    # 0x12d910
cmpl $0x0, (%rax,%rcx,4)
jle 0x9f12
movswl -0x8(%rbp), %edx
movswq -0x6(%rbp), %rcx
leaq 0x123a88(%rip), %rax    # 0x12d910
addl (%rax,%rcx,4), %edx
leaq 0x123a7e(%rip), %rax    # 0x12d910
movl %edx, (%rax,%rcx,4)
movswq -0x6(%rbp), %rcx
leaq 0x123a6f(%rip), %rax    # 0x12d910
movl (%rax,%rcx,4), %eax
cmpl -0xc(%rbp), %eax
jle 0x9ebb
movl -0xc(%rbp), %edx
movswq -0x6(%rbp), %rcx
leaq 0x123a58(%rip), %rax    # 0x12d910
movl %edx, (%rax,%rcx,4)
movswq -0x6(%rbp), %rcx
leaq 0x123a49(%rip), %rax    # 0x12d910
cmpl $0x0, (%rax,%rcx,4)
jg 0x9f10
movswq -0x6(%rbp), %rcx
leaq 0x123a37(%rip), %rax    # 0x12d910
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movswq -0x6(%rbp), %rcx
leaq 0x123964(%rip), %rax    # 0x12d850
movl (%rax,%rcx,4), %esi
movswq -0x6(%rbp), %rcx
leaq 0x123995(%rip), %rax    # 0x12d890
movl (%rax,%rcx,4), %edx
movl $0x80, %edi
xorl %ecx, %ecx
movl $0x4, %r8d
callq 0x26af0
jmp 0x9f12
movswq -0x6(%rbp), %rcx
leaq 0x1239f2(%rip), %rax    # 0x12d910
cmpl $0x0, (%rax,%rcx,4)
jg 0x9f3d
leaq 0x10ffed(%rip), %rax    # 0x119f18
movzbl 0x4(%rax), %eax
cmpl $0x0, %eax
je 0x9f3d
movswl -0x6(%rbp), %edi
callq 0x2a7b0
movswq -0x6(%rbp), %rcx
leaq 0x1239c7(%rip), %rax    # 0x12d910
cmpl $0x0, (%rax,%rcx,4)
setle %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)