// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/src/tekgun.c
// Function: tekdrawgun
void
tekdrawgun(int gun,short p)
{
     int  pic,x,apic;

     if (fireseq[p] == 0) {
          pic=guntype[gun].pic;
          return;
     }
     apic=AIMPIC;
     if( difficulty <= 1 )
          apic=BIGAIMPIC;
     if( (toggles[TOGGLE_RETICULE]) && (dimensionmode[myconnectindex] == 3) ) {
          overwritesprite(windowx1+((windowx2-windowx1)>>1),
                          windowy1+((windowy2-windowy1)>>1),apic,16,0x01,0);
     }
     gun=lastgun[p];
     if( firedonetics[p] > 0 ) {
          pic=guntype[gun].firepic;
     }
     else {
          pic=guntype[gun].pic+fireseq[p]-1;
     }
     x=160L;

     if( pic == 3981 ) {
          if( syncsvel[p] < 0 ) {
               overwritesprite(x,100L,3990,sectptr[cursectnum[p]]->floorshade,1|2,0);
               return;
          }
          else if( syncsvel[p] > 0 ) {
               overwritesprite(x,100L,3986,sectptr[cursectnum[p]]->floorshade,1|2,0);
               return;
          }
          else if( syncangvel[p] < 0 ) {
               overwritesprite(x,100L,3985,sectptr[cursectnum[p]]->floorshade,1|2,0);
               return;
          }
          else if( syncangvel[p] > 0 ) {
               overwritesprite(x,100L,3989,sectptr[cursectnum[p]]->floorshade,1|2,0);
               return;
          }
          else if( (syncbits[p]&1) != 0 ) {
               overwritesprite(x,100L,3994+((syncbits[p]&256)==0),sectptr[cursectnum[p]]->floorshade,1|2,0);
               return;
          }
          else if( (syncbits[p]&2) != 0 ) {
               overwritesprite(x,100L,3998+((syncbits[p]&256)==0),sectptr[cursectnum[p]]->floorshade,1|2,0);
               return;
          }
     }

     if( (syncvel[p]|syncsvel[p]) != 0 ) {
          switch( pic ) {
          case GUN01FIRESTART:
          case GUN02FIRESTART:
          case GUN03FIRESTART:
          case GUN04FIRESTART:
          case GUN05FIRESTART:
          case GUN06FIRESTART:
          case GUN07FIRESTART:
          case GUN08FIRESTART:
               bobtics+=( 1 + (((syncbits[p]&256)>0)<<2) );
               if( bobtics > TICSPERFRAME ) {
                    bobtics=0;
                    gunbob++;
                    if( gunbob > 9 )
                         gunbob=0;
               }
               break;
          default:
               gunbob=0;
               break;
          }
     }
     overwritesprite(x+gunbobx[gunbob],100L+gunboby[gunbob],pic,sectptr[cursectnum[p]]->floorshade,1|2,0);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movslq %esi, %rbx
leaq 0x11d9bb(%rip), %r14    # 0x12f2e0
cmpl $0x0, (%r14,%rbx,4)
je 0x119d5
leaq 0xc0129(%rip), %rax     # 0xd1a60
cmpl $0x0, (%rax)
je 0x119ab
leaq 0x7941e1(%rip), %rax    # 0x7a5b24
movslq (%rax), %rax
leaq 0xd3f73(%rip), %rcx     # 0xe58c0
cmpb $0x3, (%rcx,%rax)
jne 0x119ab
leaq 0x11f6ca(%rip), %rax    # 0x131024
xorl %edx, %edx
cmpl $0x2, (%rax)
setl %dl
leaq 0x571287(%rip), %rax    # 0x582bf0
movl (%rax), %eax
leaq 0x5a74ee(%rip), %rcx    # 0x5b8e60
movl (%rcx), %edi
subl %eax, %edi
sarl %edi
addl %eax, %edi
leaq 0x57307f(%rip), %rax    # 0x584a00
movl (%rax), %eax
leaq 0x5a74da(%rip), %rcx    # 0x5b8e64
movl (%rcx), %esi
subl %eax, %esi
sarl %esi
addl %eax, %esi
addl $0x14d, %edx            # imm = 0x14D
movl $0x10, %ecx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0xa0bd
leaq 0x11d9fe(%rip), %rax    # 0x12f3b0
movslq (%rax,%rbx,4), %rax
leaq 0x11da33(%rip), %rcx    # 0x12f3f0
cmpl $0x0, (%rcx,%rbx,4)
jle 0x119dd
leaq (%rax,%rax,8), %rax
leaq 0xc0282(%rip), %rcx     # 0xd1c50
movswl 0x2(%rcx,%rax,2), %eax
jmp 0x119f4
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq (%rax,%rax,8), %rax
leaq 0xc0268(%rip), %rcx     # 0xd1c50
movswl (%rcx,%rax,2), %eax
movl (%r14,%rbx,4), %ecx
addl %ecx, %eax
decl %eax
leaq 0xd3b85(%rip), %rcx     # 0xe5580
movzwl (%rcx,%rbx,2), %ecx
cmpl $0xf8d, %eax            # imm = 0xF8D
jne 0x11afc
testw %cx, %cx
js 0x11a40
je 0x11a6f
leaq 0xd3d08(%rip), %rax     # 0xe5720
movswq (%rax,%rbx,2), %rax
leaq 0x1e780c(%rip), %rcx    # 0x1f9230
movq (%rcx,%rax,8), %rax
movsbl 0x1c(%rax), %ecx
movl $0xa0, %edi
movl $0x64, %esi
movl $0xf92, %edx            # imm = 0xF92
jmp 0x11bd3
leaq 0xd3cd9(%rip), %rax     # 0xe5720
movswq (%rax,%rbx,2), %rax
leaq 0x1e77dd(%rip), %rcx    # 0x1f9230
movq (%rcx,%rax,8), %rax
movsbl 0x1c(%rax), %ecx
movl $0xa0, %edi
movl $0x64, %esi
movl $0xf96, %edx            # imm = 0xF96
jmp 0x11bd3
leaq 0xd3b6a(%rip), %rcx     # 0xe55e0
cmpw $0x0, (%rcx,%rbx,2)
js 0x11aae
je 0x11add
leaq 0xd3c9a(%rip), %rax     # 0xe5720
movswq (%rax,%rbx,2), %rax
leaq 0x1e779e(%rip), %rcx    # 0x1f9230
movq (%rcx,%rax,8), %rax
movsbl 0x1c(%rax), %ecx
movl $0xa0, %edi
movl $0x64, %esi
movl $0xf95, %edx            # imm = 0xF95
jmp 0x11bd3
leaq 0xd3c6b(%rip), %rax     # 0xe5720
movswq (%rax,%rbx,2), %rax
leaq 0x1e776f(%rip), %rcx    # 0x1f9230
movq (%rcx,%rax,8), %rax
movsbl 0x1c(%rax), %ecx
movl $0xa0, %edi
movl $0x64, %esi
movl $0xf91, %edx            # imm = 0xF91
jmp 0x11bd3
leaq 0xd29ac(%rip), %rcx     # 0xe4490
movzwl (%rcx,%rbx,2), %edx
testb $0x1, %dl
jne 0x11be8
testb $0x2, %dl
jne 0x11bf6
xorl %ecx, %ecx
leaq 0xd3a3d(%rip), %rdx     # 0xe5540
movsbl (%rdx,%rbx), %edx
orw %cx, %dx
je 0x11b41
leal -0x503(%rax), %ecx
cmpl $0x1b, %ecx
jbe 0x11b49
leal -0x440(%rax), %ecx
cmpl $0xe, %ecx
ja 0x11b2c
movl $0x4081, %edx           # imm = 0x4081
btl %ecx, %edx
jb 0x11b53
cmpl $0x1da, %eax            # imm = 0x1DA
je 0x11b53
movl $0x0, 0x11d937(%rip)    # 0x12f474
xorl %ecx, %ecx
jmp 0x11b96
movl 0x11d92d(%rip), %ecx    # 0x12f474
jmp 0x11b96
movl $0x8000421, %edx        # imm = 0x8000421
btl %ecx, %edx
jae 0x11b17
leaq 0xd2936(%rip), %rcx     # 0xe4490
movzwl (%rcx,%rbx,2), %ecx
shrl $0x6, %ecx
andl $0x4, %ecx
movl 0x11d906(%rip), %edx    # 0x12f470
addl %ecx, %edx
incl %edx
movl %edx, 0x11d8fc(%rip)    # 0x12f470
movl 0x11d8fa(%rip), %ecx    # 0x12f474
cmpl $0x4, %edx
jl 0x11b96
xorl %edx, %edx
movl %edx, 0x11d8e9(%rip)    # 0x12f470
cmpl $0x9, %ecx
leal 0x1(%rcx), %ecx
cmovgel %edx, %ecx
movl %ecx, 0x11d8de(%rip)    # 0x12f474
movslq %ecx, %rcx
leaq 0xc0140(%rip), %rdx     # 0xd1ce0
movl $0xa0, %edi
addl (%rdx,%rcx,4), %edi
leaq 0xc0161(%rip), %rdx     # 0xd1d10
movl (%rdx,%rcx,4), %esi
addl $0x64, %esi
leaq 0xd3b64(%rip), %rcx     # 0xe5720
movswq (%rcx,%rbx,2), %rcx
leaq 0x1e7668(%rip), %rdx    # 0x1f9230
movq (%rdx,%rcx,8), %rcx
movsbl 0x1c(%rcx), %ecx
movswl %ax, %edx
movl $0x3, %r8d
xorl %r9d, %r9d
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xa0bd
shll $0x17, %edx
sarl $0x1f, %edx
addl $0xf9b, %edx            # imm = 0xF9B
jmp 0x11c02
shll $0x17, %edx
sarl $0x1f, %edx
addl $0xf9f, %edx            # imm = 0xF9F
leaq 0xd3b17(%rip), %rax     # 0xe5720
movswq (%rax,%rbx,2), %rax
leaq 0x1e761b(%rip), %rcx    # 0x1f9230
movq (%rcx,%rax,8), %rax
movsbl 0x1c(%rax), %ecx
movl $0xa0, %edi
movl $0x64, %esi
jmp 0x11bd3