// File: /workspace/github_c_makefile_star2_O1/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 0x11aa1a(%rip), %r14    # 0x12c2e0
cmpl $0x0, (%r14,%rbx,4)
je 0x11976
leaq 0xbd188(%rip), %rax     # 0xcea60
cmpl $0x0, (%rax)
je 0x1194c
leaq 0x791220(%rip), %rax    # 0x7a2b04
movslq (%rax), %rax
leaq 0xd0fd2(%rip), %rcx     # 0xe28c0
cmpb $0x3, (%rcx,%rax)
jne 0x1194c
leaq 0x11c709(%rip), %rax    # 0x12e004
xorl %edx, %edx
cmpl $0x2, (%rax)
setl %dl
leaq 0x56e2c6(%rip), %rax    # 0x57fbd0
movl (%rax), %eax
leaq 0x5a452d(%rip), %rcx    # 0x5b5e40
movl (%rcx), %edi
subl %eax, %edi
sarl %edi
addl %eax, %edi
leaq 0x5700be(%rip), %rax    # 0x5819e0
movl (%rax), %eax
leaq 0x5a4519(%rip), %rcx    # 0x5b5e44
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 0xa09d
leaq 0x11aa5d(%rip), %rax    # 0x12c3b0
movslq (%rax,%rbx,4), %rax
leaq 0x11aa92(%rip), %rcx    # 0x12c3f0
cmpl $0x0, (%rcx,%rbx,4)
jle 0x1197e
leaq (%rax,%rax,8), %rax
leaq 0xbd2e1(%rip), %rcx     # 0xcec50
movswl 0x2(%rcx,%rax,2), %eax
jmp 0x11995
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq (%rax,%rax,8), %rax
leaq 0xbd2c7(%rip), %rcx     # 0xcec50
movswl (%rcx,%rax,2), %eax
movl (%r14,%rbx,4), %ecx
addl %ecx, %eax
decl %eax
cmpl $0xf8d, %eax            # imm = 0xF8D
jne 0x11a99
leaq 0xd0bd9(%rip), %rcx     # 0xe2580
cmpw $0x0, (%rcx,%rbx,2)
js 0x119df
je 0x11a0e
leaq 0xd0d69(%rip), %rax     # 0xe2720
movswq (%rax,%rbx,2), %rax
leaq 0x1e484d(%rip), %rcx    # 0x1f6210
movq (%rcx,%rax,8), %rax
movsbl 0x1c(%rax), %ecx
movl $0xa0, %edi
movl $0x64, %esi
movl $0xf92, %edx            # imm = 0xF92
jmp 0x11b6a
leaq 0xd0d3a(%rip), %rax     # 0xe2720
movswq (%rax,%rbx,2), %rax
leaq 0x1e481e(%rip), %rcx    # 0x1f6210
movq (%rcx,%rax,8), %rax
movsbl 0x1c(%rax), %ecx
movl $0xa0, %edi
movl $0x64, %esi
movl $0xf96, %edx            # imm = 0xF96
jmp 0x11b6a
leaq 0xd0bcb(%rip), %rcx     # 0xe25e0
cmpw $0x0, (%rcx,%rbx,2)
js 0x11a4d
je 0x11a7c
leaq 0xd0cfb(%rip), %rax     # 0xe2720
movswq (%rax,%rbx,2), %rax
leaq 0x1e47df(%rip), %rcx    # 0x1f6210
movq (%rcx,%rax,8), %rax
movsbl 0x1c(%rax), %ecx
movl $0xa0, %edi
movl $0x64, %esi
movl $0xf95, %edx            # imm = 0xF95
jmp 0x11b6a
leaq 0xd0ccc(%rip), %rax     # 0xe2720
movswq (%rax,%rbx,2), %rax
leaq 0x1e47b0(%rip), %rcx    # 0x1f6210
movq (%rcx,%rax,8), %rax
movsbl 0x1c(%rax), %ecx
movl $0xa0, %edi
movl $0x64, %esi
movl $0xf91, %edx            # imm = 0xF91
jmp 0x11b6a
leaq 0xcfa0d(%rip), %rcx     # 0xe1490
movzwl (%rcx,%rbx,2), %edx
testb $0x1, %dl
jne 0x11b7f
testb $0x2, %dl
jne 0x11b8d
leaq 0xd0aa0(%rip), %rcx     # 0xe2540
movsbl (%rcx,%rbx), %ecx
leaq 0xd0ad5(%rip), %rdx     # 0xe2580
orw (%rdx,%rbx,2), %cx
je 0x11b29
leal -0x503(%rax), %ecx
cmpl $0x1b, %ecx
jbe 0x11adc
leal -0x440(%rax), %ecx
cmpl $0xe, %ecx
ja 0x11ad1
movl $0x4081, %edx           # imm = 0x4081
btl %ecx, %edx
jb 0x11ae6
xorl %ecx, %ecx
cmpl $0x1da, %eax            # imm = 0x1DA
je 0x11ae6
jmp 0x11b23
movl $0x8000421, %edx        # imm = 0x8000421
btl %ecx, %edx
jae 0x11abc
leaq 0xcf9a3(%rip), %rcx     # 0xe1490
movzwl (%rcx,%rbx,2), %ecx
shrl $0x6, %ecx
andl $0x4, %ecx
movl 0x11a973(%rip), %edx    # 0x12c470
addl %edx, %ecx
incl %ecx
movl %ecx, 0x11a969(%rip)    # 0x12c470
cmpl $0x4, %ecx
jl 0x11b29
xorl %edx, %edx
movl %edx, 0x11a95c(%rip)    # 0x12c470
movl 0x11a95a(%rip), %esi    # 0x12c474
leal 0x1(%rsi), %ecx
cmpl $0x9, %esi
cmovgel %edx, %ecx
movl %ecx, 0x11a94b(%rip)    # 0x12c474
movslq 0x11a944(%rip), %rcx    # 0x12c474
leaq 0xbd1a9(%rip), %rdx     # 0xcece0
movl $0xa0, %edi
addl (%rdx,%rcx,4), %edi
leaq 0xbd1ca(%rip), %rdx     # 0xced10
movl (%rdx,%rcx,4), %esi
addl $0x64, %esi
leaq 0xd0bcd(%rip), %rcx     # 0xe2720
movswq (%rcx,%rbx,2), %rcx
leaq 0x1e46b1(%rip), %rdx    # 0x1f6210
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 0xa09d
shll $0x17, %edx
sarl $0x1f, %edx
addl $0xf9b, %edx            # imm = 0xF9B
jmp 0x11b99
shll $0x17, %edx
sarl $0x1f, %edx
addl $0xf9f, %edx            # imm = 0xF9F
leaq 0xd0b80(%rip), %rax     # 0xe2720
movswq (%rax,%rbx,2), %rax
leaq 0x1e4664(%rip), %rcx    # 0x1f6210
movq (%rcx,%rax,8), %rax
movsbl 0x1c(%rax), %ecx
movl $0xa0, %edi
movl $0x64, %esi
jmp 0x11b6a