// File: /workspace/github_c_makefile_star2_O2/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 0x114b90(%rip), %r14    # 0x1252e0
cmpl $0x0, (%r14,%rbx,4)
je 0x107fc
leaq 0xb72fe(%rip), %rax     # 0xc7a60
cmpl $0x0, (%rax)
je 0x107d2
leaq 0x78b3b6(%rip), %rax    # 0x79bb24
movslq (%rax), %rax
leaq 0xcb148(%rip), %rcx     # 0xdb8c0
cmpb $0x3, (%rcx,%rax)
jne 0x107d2
leaq 0x11689f(%rip), %rax    # 0x127024
xorl %edx, %edx
cmpl $0x2, (%rax)
setl %dl
leaq 0x56845c(%rip), %rax    # 0x578bf0
movl (%rax), %eax
leaq 0x59e6c3(%rip), %rcx    # 0x5aee60
movl (%rcx), %edi
subl %eax, %edi
sarl %edi
addl %eax, %edi
leaq 0x56a254(%rip), %rax    # 0x57aa00
movl (%rax), %eax
leaq 0x59e6af(%rip), %rcx    # 0x5aee64
movl (%rcx), %esi
subl %eax, %esi
sarl %esi
addl %eax, %esi
addl $0x14d, %edx            # imm = 0x14D
pushq $0x10
popq %rcx
pushq $0x1
popq %r8
xorl %r9d, %r9d
callq 0x94b6
leaq 0x114bd7(%rip), %rax    # 0x1253b0
movslq (%rax,%rbx,4), %rax
leaq 0x114c0c(%rip), %rcx    # 0x1253f0
cmpl $0x0, (%rcx,%rbx,4)
jle 0x10804
imulq $0x12, %rax, %rax
leaq 0xb745b(%rip), %rcx     # 0xc7c50
movswl 0x2(%rax,%rcx), %eax
jmp 0x1081b
addq $0x8, %rsp
popq %rbx
popq %r14
retq
imulq $0x12, %rax, %rax
leaq 0xb7441(%rip), %rcx     # 0xc7c50
movswl (%rax,%rcx), %eax
movl (%r14,%rbx,4), %ecx
addl %ecx, %eax
decl %eax
leaq 0xcad5e(%rip), %rcx     # 0xdb580
movzwl (%rcx,%rbx,2), %ecx
cmpl $0xf8d, %eax            # imm = 0xF8D
jne 0x1092b
testw %cx, %cx
js 0x10869
je 0x1089a
leaq 0xcaee1(%rip), %rax     # 0xdb720
movswq (%rax,%rbx,2), %rax
leaq 0x1de9e5(%rip), %rcx    # 0x1ef230
movq (%rcx,%rax,8), %rax
movsbl 0x1c(%rax), %ecx
pushq $0x64
popq %rsi
pushq $0x3
popq %r8
movl $0xa0, %edi
movl $0xf92, %edx            # imm = 0xF92
jmp 0x10a06
leaq 0xcaeb0(%rip), %rax     # 0xdb720
movswq (%rax,%rbx,2), %rax
leaq 0x1de9b4(%rip), %rcx    # 0x1ef230
movq (%rcx,%rax,8), %rax
movsbl 0x1c(%rax), %ecx
pushq $0x64
popq %rsi
pushq $0x3
popq %r8
movl $0xa0, %edi
movl $0xf96, %edx            # imm = 0xF96
jmp 0x10a06
leaq 0xcad3f(%rip), %rcx     # 0xdb5e0
cmpw $0x0, (%rcx,%rbx,2)
js 0x108db
je 0x1090c
leaq 0xcae6f(%rip), %rax     # 0xdb720
movswq (%rax,%rbx,2), %rax
leaq 0x1de973(%rip), %rcx    # 0x1ef230
movq (%rcx,%rax,8), %rax
movsbl 0x1c(%rax), %ecx
pushq $0x64
popq %rsi
pushq $0x3
popq %r8
movl $0xa0, %edi
movl $0xf95, %edx            # imm = 0xF95
jmp 0x10a06
leaq 0xcae3e(%rip), %rax     # 0xdb720
movswq (%rax,%rbx,2), %rax
leaq 0x1de942(%rip), %rcx    # 0x1ef230
movq (%rcx,%rax,8), %rax
movsbl 0x1c(%rax), %ecx
pushq $0x64
popq %rsi
pushq $0x3
popq %r8
movl $0xa0, %edi
movl $0xf91, %edx            # imm = 0xF91
jmp 0x10a06
leaq 0xc9b7d(%rip), %rcx     # 0xda490
movzwl (%rcx,%rbx,2), %edx
testb $0x1, %dl
jne 0x10a15
testb $0x2, %dl
jne 0x10a23
xorl %ecx, %ecx
leaq 0xcac0e(%rip), %rdx     # 0xdb540
movsbl (%rdx,%rbx), %edx
orw %cx, %dx
je 0x1096d
leal -0x503(%rax), %ecx
cmpl $0x1b, %ecx
jbe 0x10975
leal -0x440(%rax), %ecx
cmpl $0xe, %ecx
ja 0x1095b
movl $0x4081, %edx           # imm = 0x4081
btl %ecx, %edx
jb 0x1097f
cmpl $0x1da, %eax            # imm = 0x1DA
je 0x1097f
andl $0x0, 0x114b0b(%rip)    # 0x125474
xorl %ecx, %ecx
jmp 0x109c5
movl 0x114b01(%rip), %ecx    # 0x125474
jmp 0x109c5
movl $0x8000421, %edx        # imm = 0x8000421
btl %ecx, %edx
jae 0x10946
leaq 0xc9b0a(%rip), %rcx     # 0xda490
movzwl (%rcx,%rbx,2), %ecx
shrl $0x6, %ecx
andl $0x4, %ecx
movl 0x114ada(%rip), %edx    # 0x125470
addl %ecx, %edx
incl %edx
movl %edx, 0x114ad0(%rip)    # 0x125470
movl 0x114ace(%rip), %ecx    # 0x125474
cmpl $0x4, %edx
jl 0x109c5
andl $0x0, 0x114abe(%rip)    # 0x125470
leal 0x1(%rcx), %edx
xorl %esi, %esi
cmpl $0x9, %ecx
cmovll %edx, %esi
movl %esi, 0x114ab1(%rip)    # 0x125474
movl %esi, %ecx
movslq %ecx, %rcx
leaq 0xb7311(%rip), %rdx     # 0xc7ce0
movl $0xa0, %edi
addl (%rdx,%rcx,4), %edi
leaq 0xb7332(%rip), %rdx     # 0xc7d10
movl (%rdx,%rcx,4), %esi
addl $0x64, %esi
leaq 0xcad35(%rip), %rcx     # 0xdb720
movswq (%rcx,%rbx,2), %rcx
leaq 0x1de839(%rip), %rdx    # 0x1ef230
movq (%rdx,%rcx,8), %rcx
movsbl 0x1c(%rcx), %ecx
movswl %ax, %edx
pushq $0x3
popq %r8
xorl %r9d, %r9d
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x94b6
shll $0x17, %edx
sarl $0x1f, %edx
addl $0xf9b, %edx            # imm = 0xF9B
jmp 0x10a2f
shll $0x17, %edx
sarl $0x1f, %edx
addl $0xf9f, %edx            # imm = 0xF9F
leaq 0xcacea(%rip), %rax     # 0xdb720
movswq (%rax,%rbx,2), %rax
leaq 0x1de7ee(%rip), %rcx    # 0x1ef230
movq (%rcx,%rax,8), %rax
movsbl 0x1c(%rax), %ecx
pushq $0x64
popq %rsi
pushq $0x3
popq %r8
movl $0xa0, %edi
jmp 0x10a06