// File: /workspace/github_c_makefile_star2_O1/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 0x1ea05
testl %eax, %eax
je 0x21036
leaq 0x6c4ec(%rip), %rdi     # 0x8d51b
xorl %eax, %eax
callq 0x2d800
leaq 0xad93b(%rip), %rax     # 0xce978
cmpb $0x0, 0x4(%rax)
jne 0x211e4
movswq %bx, %r14
leaq 0x10d1be(%rip), %rbx    # 0x12e210
movq (%rbx,%r14,8), %rax
movzwl 0x2a(%rax), %eax
cmpq $0x3fff, %rax           # imm = 0x3FFF
ja 0x211e4
leaq 0x1b51a3(%rip), %rcx    # 0x1d6210
movq (%rcx,%rax,8), %rax
movzwl 0x4(%rax), %ecx
testb $0x1, %cl
jne 0x2109a
testb $0x2, %cl
jne 0x210a4
testb $0x4, %cl
jne 0x211ef
movb 0x1f(%rax), %al
andb $-0x2, %al
movw $0x39c, %bp             # imm = 0x39C
cmpb $0x4, %al
je 0x210b5
jmp 0x211e4
movw $0x15a, %bp             # imm = 0x15A
movw $0xfffe, %dx            # imm = 0xFFFE
jmp 0x210ac
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 0x1e94c
cmpw $-0x1, %ax
je 0x211e4
movswq %ax, %r15
imulq $0x2c, %r15, %rax
leaq 0x409a30(%rip), %rcx    # 0x42ab10
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 0x58e53d(%rip), %r9     # 0x5af640
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)
movzwl 0x1c(%rdx), %esi
movw %si, 0x1c(%rcx,%rax)
movl $0x200, %esi            # imm = 0x200
addl 0x1c(%rdx), %esi
movl $0x7ff, %r8d            # imm = 0x7FF
andl %r8d, %esi
leaq 0x55ba5c(%rip), %r9     # 0x57cbb0
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)
movw $0x1e, 0x24(%rcx,%rax)
addl $0x1000, %r14d          # imm = 0x1000
movw %r14w, 0x1e(%rcx,%rax)
movl $0x0, 0x26(%rcx,%rax)
movw $0xffff, 0x2a(%rcx,%rax) # imm = 0xFFFF
leaq (%r15,%r15,2), %rsi
shlq $0x2, %rsi
addq 0xace11(%rip), %rsi     # 0xcdfb8
movl $0x3, %edx
callq 0x5da55
movq (%rbx,%r15,8), %rax
movzwl 0xe(%rax), %ecx
leal -0x15a(%rcx), %edx
cmpl $0x2, %edx
jae 0x211d0
shrb 0x14(%rax)
movq (%rbx,%r15,8), %rax
shrb 0x15(%rax)
jmp 0x211e4
cmpl $0x39c, %ecx            # imm = 0x39C
jne 0x211e4
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 0x6b270(%rip), %rdi     # 0x8c466
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x14b61