// File: /workspace/github_c_makefile_star2_O2/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 0xb2642(%rip), %rax     # 0xc7a60
cmpl $0x0, 0x14(%rax)
je 0x1558c
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0x5637b3(%rip), %rax    # 0x578bf0
movl (%rax), %eax
movl %eax, 0x14(%rsp)
leaq 0x599a16(%rip), %rax    # 0x5aee60
movl (%rax), %eax
movl %eax, 0x10(%rsp)
leaq 0x5655a9(%rip), %rax    # 0x57aa00
movl (%rax), %eax
movl %eax, 0xc(%rsp)
leaq 0x599a00(%rip), %rax    # 0x5aee64
movl (%rax), %eax
movl %eax, 0x8(%rsp)
movslq %edi, %r12
leaq 0xc503c(%rip), %rax     # 0xda4b0
movzwl (%rax,%r12,2), %r13d
leaq (,%r12,4), %r14
leaq 0xc65c8(%rip), %rax     # 0xdba50
movswl (%rax,%r12,4), %ebp
movq %rax, %rbx
pushq $0x43
popq %rdi
pushq $0x9
popq %rsi
pushq $0x28
popq %rcx
movl $0x82, %edx
callq 0x41e1e
movl %r13d, %ecx
andl $0x7ff, %ecx            # imm = 0x7FF
xorl $0x400, %ecx            # imm = 0x400
leaq 0xc6617(%rip), %rax     # 0xdbad0
movw %cx, (%rax,%r12,2)
movl $0xc8, %r8d
subl %ebp, %r8d
movl %r8d, (%rbx,%r12,4)
leaq 0xc64be(%rip), %rax     # 0xdb990
addq %r14, %rax
leaq 0xc4ff4(%rip), %rdx     # 0xda4d0
leaq (%rdx,%r12,4), %r15
leaq 0xc64e9(%rip), %rsi     # 0xdb9d0
addq %r14, %rsi
leaq 0xc651f(%rip), %rdx     # 0xdba10
addq %r14, %rdx
addq 0xb1add(%rip), %r14     # 0xc6fd8
leaq 0xc500e(%rip), %rdi     # 0xda510
leaq 0xb25f7(%rip), %r9      # 0xc7b00
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 0xc61f5(%rip), %rax     # 0xdb720
movswl (%rax,%r12,2), %r9d
callq 0x33b95
movb $0x1, 0x111aec(%rip)    # 0x127028
movl (%r15), %edi
movl (%rbx), %esi
callq 0x1bbe9
movb $0x0, 0x111adb(%rip)    # 0x127028
callq 0x3709d
leaq 0xc6577(%rip), %rax     # 0xdbad0
movw %r13w, (%rax,%r12,2)
leaq 0xc64eb(%rip), %rax     # 0xdba50
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 0x41e1e
retq