// File: /workspace/github_c_makefile_star2_O1/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 0xb82e2(%rip), %rax     # 0xcea60
cmpl $0x0, 0x14(%rax)
je 0x168f2
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0x569433(%rip), %rax    # 0x57fbd0
movl (%rax), %eax
movl %eax, 0x14(%rsp)
leaq 0x59f696(%rip), %rax    # 0x5b5e40
movl (%rax), %eax
movl %eax, 0x10(%rsp)
leaq 0x56b229(%rip), %rax    # 0x5819e0
movl (%rax), %eax
movl %eax, 0xc(%rsp)
leaq 0x59f680(%rip), %rax    # 0x5b5e44
movl (%rax), %eax
movl %eax, 0x8(%rsp)
movslq %edi, %r12
leaq 0xcacdc(%rip), %rax     # 0xe14b0
movzwl (%rax,%r12,2), %r13d
leaq (,%r12,4), %r14
leaq 0xcc268(%rip), %rax     # 0xe2a50
movswl (%rax,%r12,4), %ebp
movq %rax, %rbx
movl $0x43, %edi
movl $0x9, %esi
movl $0x82, %edx
movl $0x28, %ecx
callq 0x44922
movl %r13d, %ecx
andl $0x7ff, %ecx            # imm = 0x7FF
xorl $0x400, %ecx            # imm = 0x400
leaq 0xcc2b1(%rip), %rax     # 0xe2ad0
movw %cx, (%rax,%r12,2)
movl $0xc8, %r8d
subl %ebp, %r8d
movl %r8d, (%rbx,%r12,4)
leaq 0xcc158(%rip), %rax     # 0xe2990
addq %r14, %rax
leaq 0xcac8e(%rip), %rdx     # 0xe14d0
leaq (%rdx,%r12,4), %r15
leaq 0xcc183(%rip), %rsi     # 0xe29d0
addq %r14, %rsi
leaq 0xcc1b9(%rip), %rdx     # 0xe2a10
addq %r14, %rdx
addq 0xb7777(%rip), %r14     # 0xcdfd8
leaq 0xcaca8(%rip), %rdi     # 0xe1510
leaq 0xb8291(%rip), %r9      # 0xceb00
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 0xcbe8f(%rip), %rax     # 0xe2720
movswl (%rax,%r12,2), %r9d
callq 0x36ada
movb $0x1, 0x117766(%rip)    # 0x12e008
movl (%r15), %edi
movl (%rbx), %esi
callq 0x1d30d
movb $0x0, 0x117755(%rip)    # 0x12e008
callq 0x3a5fa
leaq 0xcc211(%rip), %rax     # 0xe2ad0
movw %r13w, (%rax,%r12,2)
leaq 0xcc185(%rip), %rax     # 0xe2a50
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 0x44922
retq