// File: /workspace/github_c_makefile_star2_O3/jrrk[P]cbzone/c_graphics.c
// Function: scanner
void scanner(o)
     Genericp o;
{
  static float scale = 0.03;
  static XSegment scanline[] = {500, 560, 500, 560};
  static Bool init = True;
  static XSegment* dot;
  static float ca = 1.0;        /* keep track of where the scanner line */
  static float sa = 0.0;        /* is currently positioned */
  static float sda = 0.087156;
  static float cda = 0.996195;
  static int ind = 0;           /* number of enemies last on scanner */
  float temp;
  Genericp g;
  XSegment* nextdot;
  XSegment* curdot;

  if (init) {
    dot = (XSegment*) malloc(sizeof(XSegment)*2*opt->mobjects);
    if (dot == NULL) {
      printf("Malloc failed...too many objects?\n");
#ifdef WIN32
      return;
#else //X11
      exit(1);
#endif
    }
    init = False;
  }

  gprsetclippingactive(False);
  gprsetdrawvalue(opt->cpi[COLOR_BG]);
  multiline(scanline, 1);               /*       erase scan line       */
  if (ind)                              /* erase enemies, if necessary */
    multiline(dot, ind);
  temp = ca;
  ca = ca * cda - sa * sda;
  sa = sa * cda + sda * temp;
  scanline->x2 = 60.0 * ca + 500;
  scanline->y2 = 60.0 * sa + 560;
  gprsetdrawvalue(opt->cpi[COLOR_SCANNER]);
  multiline(scanline, 1);               /*     draw scanline           */
  ind = 0;
  curdot = dot;
  for (g=o+opt->estart; g<o+opt->lstart; g++)
    if (g->attr & IS_ALIVE && g->range <= 2000.0 && g->range != 0.0) {
      nextdot = curdot + 1;
      nextdot->x1 = curdot->x1 = 500 + g->prox * scale - 1;
      nextdot->y2 = curdot->y1 = 560 - g->proy * scale + 1;
      nextdot->x2 = curdot->x2 = curdot->x1 + 2;
      nextdot->y1 = curdot->y2 = curdot->y1 - 2;
      ind += 2;
      curdot += 2;
    }
  if (ind)
    multiline(dot, ind);                /* draw enemies, if necessary  */
  gprsetclippingactive(True);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
cmpb $0x0, 0xc2b2(%rip)      # 0x14784
jne 0x8502
leaq 0xc0a5(%rip), %rax      # 0x14580
movq (%rax), %rax
movslq 0x1c(%rax), %rdi
shlq $0x4, %rdi
callq 0x4190
movq %rax, 0xc296(%rip)      # 0x14788
testq %rax, %rax
je 0x86e9
movb $0x1, 0xc282(%rip)      # 0x14784
xorl %edi, %edi
xorl %eax, %eax
callq 0x7212
leaq 0xc06e(%rip), %r12      # 0x14580
movq (%r12), %rax
movl 0xf0(%rax), %edi
xorl %eax, %eax
callq 0x7660
leaq 0xbe5a(%rip), %rdi      # 0x14384
movl $0x1, %esi
xorl %eax, %eax
callq 0x6ed0
movl 0xc258(%rip), %esi      # 0x14794
testl %esi, %esi
je 0x854e
movq 0xc241(%rip), %rdi      # 0x14788
xorl %eax, %eax
callq 0x6ed0
movss 0xbe36(%rip), %xmm0     # 0x1438c
movss 0xc232(%rip), %xmm1     # 0x14790
movaps %xmm1, %xmm2
unpcklps %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
mulps 0x6145(%rip), %xmm2     # 0xe6b0
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
mulps 0x614b(%rip), %xmm0     # 0xe6c0
addps %xmm2, %xmm0
movss %xmm0, 0xbe0c(%rip)     # 0x1438c
cvtps2pd %xmm0, %xmm1
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
mulpd 0x6141(%rip), %xmm1     # 0xe6d0
addpd 0x6149(%rip), %xmm1     # 0xe6e0
movss %xmm0, 0xc1f1(%rip)     # 0x14790
cvttpd2dq %xmm1, %xmm0
pshuflw $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3,4,5,6,7]
movd %xmm0, 0xbdd8(%rip)     # 0x14388
leaq 0xbdcd(%rip), %r15      # 0x14384
movq (%r12), %rax
movl 0x11c(%rax), %edi
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x7660
movq %r15, %rdi
movl $0x1, %esi
xorl %eax, %eax
callq 0x6ed0
movl $0x0, 0xc1b1(%rip)      # 0x14794
movq (%r12), %rax
movslq 0x20(%rax), %rcx
movslq 0x24(%rax), %rax
cmpl %eax, %ecx
jge 0x86d2
movq 0xc18a(%rip), %rdi      # 0x14788
imulq $0x660, %rax, %rax      # imm = 0x660
addq %r14, %rax
imulq $0x660, %rcx, %rcx      # imm = 0x660
addq %r14, %rcx
movss 0x6116(%rip), %xmm0     # 0xe730
xorpd %xmm1, %xmm1
movaps 0x59eb(%rip), %xmm2     # 0xe010
movaps 0x60c4(%rip), %xmm3     # 0xe6f0
movsd 0x60cc(%rip), %xmm4     # 0xe700
movsd 0x60d4(%rip), %xmm5     # 0xe710
movd 0x60dc(%rip), %xmm6     # 0xe720
movq %rdi, %rdx
testb $0x1, 0x8(%rcx)
je 0x86b9
movss 0x34(%rcx), %xmm7
ucomiss %xmm7, %xmm0
jb 0x86b9
ucomiss %xmm1, %xmm7
jne 0x865e
jnp 0x86b9
movss 0x18(%rcx), %xmm7
movss 0x1c(%rcx), %xmm8
xorps %xmm2, %xmm8
unpcklps %xmm8, %xmm7            # xmm7 = xmm7[0],xmm8[0],xmm7[1],xmm8[1]
mulps %xmm3, %xmm7
addps %xmm4, %xmm7
addps %xmm5, %xmm7
cvttps2dq %xmm7, %xmm7
movd %xmm7, %esi
pextrw $0x2, %xmm7, %r8d
movw %si, 0x8(%rdx)
packssdw %xmm7, %xmm7
movd %xmm7, (%rdx)
movw %r8w, 0xe(%rdx)
paddw %xmm6, %xmm7
movd %xmm7, 0x4(%rdx)
pshuflw $0xe1, %xmm7, %xmm7     # xmm7 = xmm7[1,0,2,3,4,5,6,7]
movd %xmm7, 0xa(%rdx)
addl $0x2, %ebx
movl %ebx, 0xc0df(%rip)      # 0x14794
addq $0x10, %rdx
addq $0x660, %rcx            # imm = 0x660
cmpq %rax, %rcx
jb 0x8647
testl %ebx, %ebx
je 0x86d2
movl %ebx, %esi
xorl %eax, %eax
callq 0x6ed0
movl $0x1, %edi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x7212
leaq 0x63ec(%rip), %rdi      # 0xeadc
callq 0x40c0
movl $0x1, %edi
callq 0x4110