// File: /workspace/github_c_makefile_star2_O1/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 %rbx
movq %rdi, %rbx
cmpb $0x0, 0xc29d(%rip)      # 0x14794
jne 0x8527
leaq 0xc090(%rip), %rax      # 0x14590
movq (%rax), %rax
movslq 0x1c(%rax), %rdi
shlq $0x4, %rdi
callq 0x4190
movq %rax, 0xc281(%rip)      # 0x14798
testq %rax, %rax
je 0x8756
movb $0x1, 0xc26d(%rip)      # 0x14794
xorl %edi, %edi
xorl %eax, %eax
callq 0x71ba
leaq 0xc059(%rip), %r15      # 0x14590
movq (%r15), %rax
movl 0xf0(%rax), %edi
xorl %eax, %eax
callq 0x7608
leaq 0xbe42(%rip), %rdi      # 0x14390
movl $0x1, %esi
xorl %eax, %eax
callq 0x6e78
movl 0xc244(%rip), %esi      # 0x147a4
testl %esi, %esi
je 0x8572
movq 0xc22d(%rip), %rdi      # 0x14798
xorl %eax, %eax
callq 0x6e78
movss 0xbe1e(%rip), %xmm0     # 0x14398
movss 0xc21e(%rip), %xmm1     # 0x147a0
movss 0x60be(%rip), %xmm2     # 0xe648
mulss %xmm1, %xmm2
movss 0x60b6(%rip), %xmm3     # 0xe64c
movaps %xmm0, %xmm4
mulss %xmm3, %xmm4
addss %xmm2, %xmm4
movss %xmm4, 0xbdef(%rip)     # 0x14398
mulss 0x609f(%rip), %xmm0     # 0xe650
mulss %xmm3, %xmm1
addss %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtss2sd %xmm4, %xmm0
movsd 0x6018(%rip), %xmm2     # 0xe5e0
mulsd %xmm2, %xmm0
addsd 0x6014(%rip), %xmm0     # 0xe5e8
cvttsd2si %xmm0, %eax
movss %xmm1, 0xc1c0(%rip)     # 0x147a0
movw %ax, 0xbdad(%rip)       # 0x14394
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
mulsd %xmm2, %xmm0
addsd 0x5ff6(%rip), %xmm0     # 0xe5f0
cvttsd2si %xmm0, %eax
leaq 0xbd8b(%rip), %r14      # 0x14390
movw %ax, 0xbd8a(%rip)       # 0x14396
movq (%r15), %rax
movl 0x11c(%rax), %edi
xorl %eax, %eax
callq 0x7608
movq %r14, %rdi
movl $0x1, %esi
xorl %eax, %eax
callq 0x6e78
movl $0x0, 0xc16f(%rip)      # 0x147a4
movq 0xc15c(%rip), %rdi      # 0x14798
movq (%r15), %rax
movslq 0x20(%rax), %rdx
movslq 0x24(%rax), %rax
cmpl %eax, %edx
jge 0x8734
imulq $0x660, %rax, %rax      # imm = 0x660
addq %rbx, %rax
movl 0xc145(%rip), %ecx      # 0x147a4
imulq $0x660, %rdx, %rdx      # imm = 0x660
addq %rbx, %rdx
movss 0x5fe3(%rip), %xmm0     # 0xe654
xorps %xmm1, %xmm1
movss 0x5fdc(%rip), %xmm2     # 0xe658
movss 0x5988(%rip), %xmm3     # 0xe00c
movss 0x59cc(%rip), %xmm4     # 0xe058
movss 0x5fc8(%rip), %xmm5     # 0xe65c
movss 0x59b8(%rip), %xmm6     # 0xe054
movq %rdi, %rsi
testb $0x1, 0x8(%rdx)
je 0x8724
movss 0x34(%rdx), %xmm7
ucomiss %xmm7, %xmm0
jb 0x8724
ucomiss %xmm1, %xmm7
jne 0x86b6
jnp 0x8724
movss 0x18(%rdx), %xmm7
mulss %xmm2, %xmm7
addss %xmm3, %xmm7
addss %xmm4, %xmm7
cvttss2si %xmm7, %r8d
movw %r8w, (%rsi)
movw %r8w, 0x8(%rsi)
movss 0x1c(%rdx), %xmm7
mulss %xmm2, %xmm7
movaps %xmm5, %xmm8
subss %xmm7, %xmm8
addss %xmm6, %xmm8
cvttss2si %xmm8, %r9d
movw %r9w, 0x2(%rsi)
movw %r9w, 0xe(%rsi)
addl $0x2, %r8d
movw %r8w, 0x4(%rsi)
movw %r8w, 0xc(%rsi)
addl $-0x2, %r9d
movw %r9w, 0x6(%rsi)
movw %r9w, 0xa(%rsi)
addl $0x2, %ecx
movl %ecx, 0xc084(%rip)      # 0x147a4
addq $0x10, %rsi
addq $0x660, %rdx            # imm = 0x660
cmpq %rax, %rdx
jb 0x869f
movl 0xc06a(%rip), %esi      # 0x147a4
testl %esi, %esi
je 0x8745
xorl %eax, %eax
callq 0x6e78
movl $0x1, %edi
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
jmp 0x71ba
leaq 0x629f(%rip), %rdi      # 0xe9fc
callq 0x40c0
movl $0x1, %edi
callq 0x4110