// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/src/tekstat.c
// Function: deathdropitem
void
deathdropitem(short sprnum)
{
     short       j,ext;
     int         pic;

    #ifdef PLRSPRDEBUG
     if( isaplayersprite(sprnum) ) {
          crashgame("messing w plrsprite at 7");
     }
    #endif

     if( option[4] != 0 ) {
          return;
     }

     ext=sprptr[sprnum]->extra;
     if( !validext(ext) ) {
          return;
     }

     if( sprXTptr[ext]->fxmask&FX_HASREDCARD ) {
           pic=RED_KEYCARD;
           sprXTptr[ext]->fxmask&=(~FX_HASREDCARD);
     }
     else if( sprXTptr[ext]->fxmask&FX_HASBLUECARD ) {
           pic=BLUE_KEYCARD;
           sprXTptr[ext]->fxmask&=(~FX_HASBLUECARD);
     }
     else if( sprXTptr[ext]->fxmask&FX_ANDROID ) {
          showmessage("WAS AN ANDROID");
          return;
     }
     else {
           switch( sprXTptr[ext]->weapon ) {
           case 4:
           case 5:
                 pic=KLIPPIC;
                 break;
           default:
                 return;
           }
     }

     j=jsinsertsprite(sprptr[sprnum]->sectnum, DROPSIES);
     if( j != -1 ) {
	     fillsprite(j,sprptr[sprnum]->x,sprptr[sprnum]->y,sprptr[sprnum]->z-(tilesizy[sprptr[sprnum]->picnum]<<6),128,
                     0,0,12,16,16,0,0,pic,sprptr[sprnum]->ang,
		           sintable[(sprptr[sprnum]->ang+2560)&2047]>>6,sintable[(sprptr[sprnum]->ang+2048)&2047]>>6,
		           30L,sprnum+4096,sprptr[sprnum]->sectnum,DROPSIES,0,0,0);
     }
     else {
           return;
     }

     // tweak the size of the pic
     switch( sprptr[j]->picnum ) {
     case KLIPPIC:
           sprptr[j]->xrepeat-=2;
           sprptr[j]->yrepeat-=2;
           break;
     case RED_KEYCARD:
     case BLUE_KEYCARD:
           sprptr[j]->xrepeat>>=1;
           sprptr[j]->yrepeat>>=1;
           break;
     default:
           break;
     }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
callq 0x1eb81
testl %eax, %eax
je 0x212a0
leaq 0x6f3a6(%rip), %rdi     # 0x9063f
xorl %eax, %eax
callq 0x2eb88
leaq 0xb06d1(%rip), %rax     # 0xd1978
cmpb $0x0, 0x4(%rax)
jne 0x21444
movswq %bx, %r14
leaq 0x10ff74(%rip), %rbx    # 0x131230
movq (%rbx,%r14,8), %rax
movzwl 0x2a(%rax), %eax
cmpq $0x3fff, %rax           # imm = 0x3FFF
ja 0x21444
leaq 0x1b7f59(%rip), %rcx    # 0x1d9230
movq (%rcx,%rax,8), %rax
movzwl 0x4(%rax), %ecx
testb $0x1, %cl
jne 0x21304
testb $0x2, %cl
jne 0x2130e
testb $0x4, %cl
jne 0x2144f
movb 0x1f(%rax), %al
andb $-0x2, %al
movw $0x39c, %bp             # imm = 0x39C
cmpb $0x4, %al
je 0x2131f
jmp 0x21444
movw $0x15a, %bp             # imm = 0x15A
movw $0xfffe, %dx            # imm = 0xFFFE
jmp 0x21316
movw $0x15b, %bp             # imm = 0x15B
movw $0xfffc, %dx            # imm = 0xFFFC
movswl %dx, %edx
andl %edx, %ecx
movw %cx, 0x4(%rax)
movq (%rbx,%r14,8), %rax
movswl 0x18(%rax), %edi
movl $0x196, %esi            # imm = 0x196
callq 0x1eac8
cmpw $-0x1, %ax
je 0x21444
movswq %ax, %r15
imulq $0x2c, %r15, %rax
leaq 0x40c7e6(%rip), %rcx    # 0x42db30
leaq (%rcx,%rax), %rdi
movq (%rbx,%r14,8), %rdx
movl (%rdx), %esi
movl %esi, (%rcx,%rax)
movl 0x4(%rdx), %esi
movl %esi, 0x4(%rcx,%rax)
movl 0x8(%rdx), %esi
movswq 0xe(%rdx), %r8
leaq 0x5912f3(%rip), %r9     # 0x5b2660
movswl (%r9,%r8,2), %r8d
shll $0x6, %r8d
subl %r8d, %esi
movl %esi, 0x8(%rcx,%rax)
movw $0x80, 0xc(%rcx,%rax)
movw $0x0, 0x10(%rcx,%rax)
movb $0xc, 0x12(%rcx,%rax)
movl $0x1010, 0x14(%rcx,%rax) # imm = 0x1010
movw %bp, 0xe(%rcx,%rax)
movl 0x1c(%rdx), %esi
movw %si, 0x1c(%rcx,%rax)
addl $0x200, %esi            # imm = 0x200
movl $0x7ff, %r8d            # imm = 0x7FF
andl %r8d, %esi
leaq 0x55e815(%rip), %r9     # 0x57fbd0
movswl (%r9,%rsi,2), %esi
shrl $0x6, %esi
movw %si, 0x20(%rcx,%rax)
movzwl 0x1c(%rdx), %edx
andl %r8d, %edx
movswl (%r9,%rdx,2), %edx
shrl $0x6, %edx
movw %dx, 0x22(%rcx,%rax)
addl $0x1000, %r14d          # imm = 0x1000
movw %r14w, 0x1e(%rcx,%rax)
movabsq $-0xffffffffffe2, %rdx  # imm = 0xFFFF00000000001E
movq %rdx, 0x24(%rcx,%rax)
leaq (%r15,%r15,2), %rsi
shlq $0x2, %rsi
addq 0xafba9(%rip), %rsi     # 0xd0fb0
movl $0x3, %edx
callq 0x6110e
movq (%rbx,%r15,8), %rax
movzwl 0xe(%rax), %ecx
leal -0x15a(%rcx), %edx
cmpl $0x2, %edx
jae 0x21430
shrb 0x14(%rax)
movq (%rbx,%r15,8), %rax
shrb 0x15(%rax)
jmp 0x21444
cmpl $0x39c, %ecx            # imm = 0x39C
jne 0x21444
addb $-0x2, 0x14(%rax)
movq (%rbx,%r15,8), %rax
addb $-0x2, 0x15(%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6e024(%rip), %rdi     # 0x8f47a
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x14be7