// File: /workspace/github_c_makefile_star2_O2/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 0x1cfc4
testl %eax, %eax
je 0x1f448
leaq 0x63162(%rip), %rdi     # 0x825a3
xorl %eax, %eax
callq 0x2acb8
leaq 0xa8529(%rip), %rax     # 0xc7978
cmpb $0x0, 0x4(%rax)
jne 0x1f5e5
movswq %bx, %r14
leaq 0x107dcc(%rip), %rbx    # 0x127230
movq (%rbx,%r14,8), %rax
movzwl 0x2a(%rax), %eax
cmpq $0x3fff, %rax           # imm = 0x3FFF
ja 0x1f5e5
leaq 0x1afdb1(%rip), %rcx    # 0x1cf230
movq (%rcx,%rax,8), %rax
movzwl 0x4(%rax), %ecx
testb $0x1, %cl
jne 0x1f4ac
testb $0x2, %cl
jne 0x1f4b6
testb $0x4, %cl
jne 0x1f5f0
movb 0x1f(%rax), %al
andb $-0x2, %al
movw $0x39c, %bp             # imm = 0x39C
cmpb $0x4, %al
je 0x1f4c7
jmp 0x1f5e5
movw $0x15a, %bp             # imm = 0x15A
movw $0xfffe, %dx            # imm = 0xFFFE
jmp 0x1f4be
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 0x1cf0c
cmpw $-0x1, %ax
je 0x1f5e5
movswq %ax, %r15
imulq $0x2c, %r15, %rax
leaq 0x40463e(%rip), %rcx    # 0x423b30
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 0x58914b(%rip), %r9     # 0x5a8660
movswl (%r9,%r8,2), %r8d
shll $0x6, %r8d
subl %r8d, %esi
movl %esi, 0x8(%rcx,%rax)
movw $0x80, 0xc(%rcx,%rax)
andw $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 0x55666e(%rip), %r9     # 0x575bd0
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)
imulq $0xc, %r15, %rsi
addq 0xa7a0e(%rip), %rsi     # 0xc6fb8
pushq $0x3
popq %rdx
callq 0x56a36
movq (%rbx,%r15,8), %rax
movzwl 0xe(%rax), %ecx
leal -0x15a(%rcx), %edx
cmpl $0x2, %edx
jae 0x1f5d1
shrb 0x14(%rax)
movq (%rbx,%r15,8), %rax
shrb 0x15(%rax)
jmp 0x1f5e5
cmpl $0x39c, %ecx            # imm = 0x39C
jne 0x1f5e5
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 0x61e83(%rip), %rdi     # 0x8147a
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1373a