// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/src/tekmsc.c
// Function: rearview
void
rearview(int snum)
{
     int      cposx, cposy, cposz, choriz, czoom;
     short     cang;
     short     plrang,plrhoriz;
     int       oldwx1,oldwx2,oldwy1,oldwy2;

     if( toggles[TOGGLE_REARVIEW] == 0 ) {
          return;
     }

     oldwx1=windowx1; oldwx2=windowx2;
     oldwy1=windowy1; oldwy2=windowy2;

     plrang=ang[snum];
     plrhoriz=ohoriz[snum];
     setview(67,9,130,40);

     oang[snum]=(plrang+1024)&2047;
     ohoriz[snum]=(200-plrhoriz);

     cposx = oposx[snum]+mulscale(posx[snum]-oposx[snum],0,16);
     cposy = oposy[snum]+mulscale(posy[snum]-oposy[snum],0,16);
     cposz = oposz[snum]+mulscale(posz[snum]-oposz[snum],0,16);
     if (frameinterpolate == 0)
          { cposx = posx[snum]; cposy = posy[snum]; cposz = posz[snum]; }
     choriz = ohoriz[snum]+mulscale(horiz[snum]-ohoriz[snum],0,16);
     czoom = ozoom[snum]+mulscale(zoom[snum]-ozoom[snum],0,16);
     cang = oang[snum]+mulscale(((ang[snum]+1024-oang[snum])&2047)-1024,0,16);

     drawrooms(cposx,cposy,cposz,cang,choriz,cursectnum[snum]);
     rearviewdraw=1;
     analyzesprites(posx[snum],posy[snum]);
     rearviewdraw=0;
     drawmasks();

     oang[snum]=plrang;
     ohoriz[snum]=plrhoriz;
     setview(oldwx1,oldwy1, oldwx2,oldwy2);
}

// Assembly:
leaq 0xbb226(%rip), %rax     # 0xd1a60
cmpl $0x0, 0x14(%rax)
je 0x169ae
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0x56c397(%rip), %rax    # 0x582bf0
movl (%rax), %eax
movl %eax, 0x14(%rsp)
leaq 0x5a25fa(%rip), %rax    # 0x5b8e60
movl (%rax), %eax
movl %eax, 0x10(%rsp)
leaq 0x56e18d(%rip), %rax    # 0x584a00
movl (%rax), %eax
movl %eax, 0xc(%rsp)
leaq 0x5a25e4(%rip), %rax    # 0x5b8e64
movl (%rax), %eax
movl %eax, 0x8(%rsp)
movslq %edi, %r12
leaq 0xcdc20(%rip), %rax     # 0xe44b0
movzwl (%rax,%r12,2), %r13d
leaq (,%r12,4), %r14
leaq 0xcf1ac(%rip), %rax     # 0xe5a50
movswl (%rax,%r12,4), %ebp
movq %rax, %rbx
movl $0x43, %edi
movl $0x9, %esi
movl $0x82, %edx
movl $0x28, %ecx
callq 0x4624e
movl %r13d, %ecx
andl $0x7ff, %ecx            # imm = 0x7FF
xorl $0x400, %ecx            # imm = 0x400
leaq 0xcf1f5(%rip), %rax     # 0xe5ad0
movw %cx, (%rax,%r12,2)
movl $0xc8, %r8d
subl %ebp, %r8d
movl %r8d, (%rbx,%r12,4)
leaq 0xcf09c(%rip), %rax     # 0xe5990
addq %r14, %rax
leaq 0xcdbd2(%rip), %rdx     # 0xe44d0
leaq (%rdx,%r12,4), %r15
leaq 0xcf0c7(%rip), %rsi     # 0xe59d0
addq %r14, %rsi
leaq 0xcf0fd(%rip), %rdx     # 0xe5a10
addq %r14, %rdx
addq 0xba6bb(%rip), %r14     # 0xd0fd8
leaq 0xcdbec(%rip), %rdi     # 0xe4510
leaq 0xbb1d5(%rip), %r9      # 0xd1b00
cmpb $0x0, (%r9)
leaq (%rdi,%r12,4), %rbx
cmovneq %rdx, %r14
movl (%r14), %edx
cmoveq %rbx, %rsi
cmoveq %r15, %rax
movl (%rsi), %esi
movl (%rax), %edi
leaq 0xcedd3(%rip), %rax     # 0xe5720
movswl (%rax,%r12,2), %r9d
callq 0x37f0d
movb $0x1, 0x11a6ca(%rip)    # 0x131028
movl (%r15), %edi
movl (%rbx), %esi
callq 0x1d484
movb $0x0, 0x11a6b9(%rip)    # 0x131028
callq 0x3bc88
leaq 0xcf155(%rip), %rax     # 0xe5ad0
movw %r13w, (%rax,%r12,2)
leaq 0xcf0c9(%rip), %rax     # 0xe5a50
movl %ebp, (%rax,%r12,4)
movl 0x14(%rsp), %edi
movl 0xc(%rsp), %esi
movl 0x10(%rsp), %edx
movl 0x8(%rsp), %ecx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4624e
retq