// File: /workspace/github_c_makefile_star2_O2/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, 0xba19(%rip)      # 0x13794
jne 0x7dab
leaq 0xb80c(%rip), %rax      # 0x13590
movq (%rax), %rax
movslq 0x1c(%rax), %rdi
shlq $0x4, %rdi
callq 0x4190
movq %rax, 0xb9fd(%rip)      # 0x13798
testq %rax, %rax
je 0x7f82
movb $0x1, 0xb9e9(%rip)      # 0x13794
xorl %ebx, %ebx
xorl %edi, %edi
xorl %eax, %eax
callq 0x6cb6
leaq 0xb7d3(%rip), %r12      # 0x13590
movq (%r12), %rax
movl 0xf0(%rax), %edi
xorl %eax, %eax
callq 0x7092
leaq 0xb5bf(%rip), %rdi      # 0x13394
pushq $0x1
popq %rsi
xorl %eax, %eax
callq 0x6abd
movl 0xb9bf(%rip), %esi      # 0x137a4
testl %esi, %esi
je 0x7df7
movq 0xb9a8(%rip), %rdi      # 0x13798
xorl %eax, %eax
callq 0x6abd
movss 0xb59d(%rip), %xmm0     # 0x1339c
movss 0xb999(%rip), %xmm1     # 0x137a0
movaps %xmm1, %xmm2
unpcklps %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
mulps 0x586c(%rip), %xmm2     # 0xd680
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
mulps 0x5872(%rip), %xmm0     # 0xd690
addps %xmm2, %xmm0
movss %xmm0, 0xb573(%rip)     # 0x1339c
cvtps2pd %xmm0, %xmm1
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
mulpd 0x5868(%rip), %xmm1     # 0xd6a0
addpd 0x5870(%rip), %xmm1     # 0xd6b0
movss %xmm0, 0xb958(%rip)     # 0x137a0
cvttpd2dq %xmm1, %xmm0
pshuflw $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3,4,5,6,7]
movd %xmm0, 0xb53f(%rip)     # 0x13398
leaq 0xb534(%rip), %r15      # 0x13394
movq (%r12), %rax
movl 0x11c(%rax), %edi
xorl %eax, %eax
callq 0x7092
pushq $0x1
popq %rsi
movq %r15, %rdi
xorl %eax, %eax
callq 0x6abd
andl $0x0, 0xb91f(%rip)      # 0x137a4
movq 0xb90c(%rip), %rdi      # 0x13798
movq (%r12), %rcx
movslq 0x20(%rcx), %rax
imulq $0x660, %rax, %rax      # imm = 0x660
addq %r14, %rax
movslq 0x24(%rcx), %rcx
imulq $0x660, %rcx, %rcx      # imm = 0x660
addq %r14, %rcx
movss 0x584c(%rip), %xmm0     # 0xd700
xorpd %xmm1, %xmm1
movaps 0x5151(%rip), %xmm2     # 0xd010
movaps 0x57fa(%rip), %xmm3     # 0xd6c0
movsd 0x5802(%rip), %xmm4     # 0xd6d0
movsd 0x580a(%rip), %xmm5     # 0xd6e0
movd 0x5812(%rip), %xmm6     # 0xd6f0
movq %rdi, %rdx
cmpq %rcx, %rax
jae 0x7f60
testb $0x1, 0x8(%rax)
je 0x7f58
movss 0x34(%rax), %xmm7
ucomiss %xmm7, %xmm0
jb 0x7f58
ucomiss %xmm1, %xmm7
jne 0x7efd
jnp 0x7f58
movss 0x18(%rax), %xmm7
movss 0x1c(%rax), %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, 0xb850(%rip)      # 0x137a4
addq $0x10, %rdx
addq $0x660, %rax            # imm = 0x660
jmp 0x7ee1
testl %ebx, %ebx
je 0x7f6d
movl %ebx, %esi
xorl %eax, %eax
callq 0x6abd
pushq $0x1
popq %rdi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x6cb6
leaq 0x5b23(%rip), %rdi      # 0xdaac
callq 0x40c0
pushq $0x1
popq %rdi
callq 0x4110