// File: /workspace/github_c_makefile_star2_O2/jrrk[P]cbzone/c_move.c
// Function: movesuper
void movesuper(g, pl)
     Genericp g;
     Genericp pl;
{
  int i;
  float dx, dy, tazm, t1, t3, scrot, sctot, scale, cp, sp, dcp;
  float dsp, cm, sm, xmt, ymt, xpt, ypt, rate, temp, dist;
  Genericp s;

  g->pcount++;
  g->fcount++;
  if (g->attr & IS_NEW) {
    g->attr &=  ~(IS_NEW | IS_PRESET);
    g->bcount = 0;
    g->ecount = 0;
    g->pcount = 10;
    g->fcount = 15;
    g->orientation = 1.0;
  }
  if (g->attr & IS_BLOCKED && g->attr & LAST_BLOCKED)
    g->orientation = -g->orientation;
  g->attr &= ~LAST_BLOCKED;

  if (g->attr & IS_BLOCKED) {
    if (g->attr & BLOCKED_BY_ENEMY)
      g->attr |= IS_EVADING;
    else
      g->attr &= ~IS_EVADING;
    g->attr |= IS_PRESET | LAST_BLOCKED;
    g->bcount  = 0;
  }
  if (g->attr & IS_PRESET) {
    g->bcount++;
    if (!(g->attr & IS_EVADING)) {
      if (g->bcount == 1) {
        g->speed = -12.0 * g->orientation;
        g->rotate = 0.045;
        if (frand() > 0.5)
          g->rotate = -g->rotate;
      }
      else if (g->bcount == 30) {
        g->speed  = 12.0 * g->orientation;
        g->rotate = 0.0;
      }
      else if (g->bcount > 60)
        g->attr &= ~IS_PRESET;
    }
    else {
      if (g->bcount == 1) {
        g->speed  = -12.0 * g->orientation;
        g->rotate = 0.0;
      }
      else if (g->bcount == 10 || g->bcount == 15 ||
               g->bcount == 20 || g->bcount == 25) {
        dx = pl->x - g->x;
        dy = pl->y - g->y;
        if (fabs(dy) < 1.e-7)
          dy = sign(1.e-7, dy);
        if (dy <= 0.0)
          tazm = - atan(dx / dy) + ra (180.0);
        else
          tazm = - atan(dx / dy) ;
        if (g->azm > PI2)
          g->azm -= PI2;
        if (g->azm < 0.0)
          g->azm += PI2;
        t1 = (tazm - g->azm) / 5.0;
        t3 = (tazm - (g->azm - PI2)) / 5.0;
        if (fabs(t3) < fabs(t1))
          t1 = t3;
        if (fabs(t1) > 0.045)
          t1 = sign (.045, t1);
        g->rotate = t1;
        g->speed = 0.0;
      }
      else if (g->bcount > 30)
        g->attr &= ~IS_PRESET;
    }
  }
  else if (g->pcount >= 5) {
    g->orientation = 1.0;
    g->pcount = 0;
    dx = pl->x - g->x;
    dy = pl->y - g->y;
    if (fabs(dy) < 1.e-7) dy =
      sign(1.e-7, dy);
    if (dy <= 0.0)
      tazm = - atan(dx / dy) + ra (180.0);
    else
      tazm = - atan(dx / dy);
    if (g->azm > PI2)
      g->azm -= PI2;
    if (g->azm < 0.0)
      g->azm += PI2;
    t1 = (tazm - g->azm) / 5.0;
    t3 = (tazm - (g->azm - PI2)) / 5.0;
    if (fabs(t3) < fabs(t1))
      t1 = t3;
    g->speed = 12.0 * (PI - fabs(t1) * 5.0) / PI;
    if (fabs(t1) > 0.045)
      t1 = sign (0.045, t1);
    g->rotate = t1;
  }

  scrot = g->rotate / 0.045 * 12.0;
  sctot = sqrt (g->speed*g->speed + scrot*scrot);
  if (sctot > 12.0) {
    scale = 12.0 / sctot;
    g->speed *= scale;
    g->rotate *= scale;
  }

  s = g->salvo;
  if (pl->attr & IS_ALIVE && g->fcount>10 && g->ecount>50 &&
      !(s->attr & STILL_THERE)) {
    g->fcount = 0;
    cp = pl->ca;
    sp = pl->sa;
    dcp = cos(pl->rotate);
    dsp = sin(pl->rotate);
    cm = cos(g->azm);
    sm = sin(g->azm);
    i = 0;
    xmt = g->x;
    ymt = g->y;
    xpt = pl->x;
    ypt = pl->y;
    rate = 40.0;

    for (i=0; i<50; i++) {
      temp = cp;
      cp = cp * dcp - sp * dsp;
      sp = sp * dcp + dsp * temp;
      xmt -= sm * rate;
      ymt += cm * rate;
      xpt -= sp * pl->speed;
      ypt += cp * pl->speed;
      dist = (xpt-xmt)*(xpt-xmt) + (ymt-ypt)*(ymt-ypt);
      if (dist <= BMS_TOL) {
        s->attr = START_LIVING;
        s->x = g->x;
        s->y = g->y;
        s->z = 0.0;
        s->prox = g->prox;
        s->proy = g->proy;
        s->azm = g->azm;
        s->speed = 40.0;
        s->ecount = 0;
        message(3, True);
        break;
      }
    }
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x30, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl 0x8(%rdi), %edx
movl 0x4c(%rdi), %ecx
incl %ecx
movl %ecx, 0x4c(%rdi)
incl 0x54(%rdi)
testb $0x2, %dl
je 0xaa71
andl $-0x43, %edx
movq $0xa, 0x4c(%rbx)
movl $0xf, 0x54(%rbx)
movq $0x3f800000, 0x40(%rbx) # imm = 0x3F800000
pushq $0xa
popq %rcx
testw $0x600, %dx             # imm = 0x600
sete %al
btl $0xb, %edx
setae %sil
orb %al, %sil
je 0xaa99
movl %edx, %eax
andl $0xfffff7ff, %eax       # imm = 0xFFFFF7FF
movl %eax, 0x8(%rbx)
testw $0x600, %dx             # imm = 0x600
jne 0xaab2
jmp 0xaad2
movss 0x40(%rbx), %xmm0
xorpd 0x256a(%rip), %xmm0     # 0xd010
movss %xmm0, 0x40(%rbx)
movl %edx, %eax
andl $0xfffff7ff, %eax       # imm = 0xFFFFF7FF
movl %edx, %esi
andl $0xfffff53f, %esi       # imm = 0xFFFFF53F
orl $0x80, %eax
btl $0x9, %edx
cmovael %esi, %eax
orl $0x840, %eax            # imm = 0x840
movl %eax, 0x8(%rbx)
andl $0x0, 0x50(%rbx)
testb $0x40, %al
jne 0xac69
cmpl $0x5, %ecx
jl 0xae7d
movl $0x3f800000, 0x40(%rbx) # imm = 0x3F800000
andl $0x0, 0x4c(%rbx)
movss 0xc(%r14), %xmm0
movss 0x10(%r14), %xmm3
subss 0xc(%rbx), %xmm0
subss 0x10(%rbx), %xmm3
xorps %xmm1, %xmm1
xorl %eax, %eax
ucomiss %xmm3, %xmm1
seta %cl
movaps 0x253a(%rip), %xmm1     # 0xd050
andps %xmm3, %xmm1
cvtss2sd %xmm1, %xmm1
movsd 0x3183(%rip), %xmm2     # 0xdca8
ucomisd %xmm1, %xmm2
jbe 0xab39
movb %cl, %al
leaq 0x317c(%rip), %rcx      # 0xdcb0
movss (%rcx,%rax,4), %xmm3
movaps %xmm3, 0x10(%rsp)
divss %xmm3, %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x4270
movaps 0x10(%rsp), %xmm6
movsd 0x3160(%rip), %xmm1     # 0xdcb8
subsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm1
cvtsd2ss %xmm0, %xmm0
xorps 0x24a5(%rip), %xmm0     # 0xd010
cmpnless 0x31cc(%rip), %xmm6     # 0xdd40
andps %xmm6, %xmm0
andnps %xmm1, %xmm6
orps %xmm0, %xmm6
movss 0x20(%rbx), %xmm1
cvtss2sd %xmm1, %xmm0
ucomisd 0x2f62(%rip), %xmm0     # 0xdaf0
jbe 0xaba1
addsd 0x2f60(%rip), %xmm0     # 0xdaf8
cvtsd2ss %xmm0, %xmm1
movss %xmm1, 0x20(%rbx)
xorps %xmm0, %xmm0
ucomiss %xmm1, %xmm0
jbe 0xabbe
cvtss2sd %xmm1, %xmm1
addsd 0x2f3b(%rip), %xmm1     # 0xdaf0
cvtsd2ss %xmm1, %xmm1
movss %xmm1, 0x20(%rbx)
cvtss2sd %xmm6, %xmm2
subss %xmm1, %xmm6
divss 0x3162(%rip), %xmm6     # 0xdd30
cvtss2sd %xmm1, %xmm1
addsd 0x2f1e(%rip), %xmm1     # 0xdaf8
subsd %xmm1, %xmm2
movsd 0x24ca(%rip), %xmm3     # 0xd0b0
divsd %xmm3, %xmm2
cvtsd2ss %xmm2, %xmm2
movaps 0x245b(%rip), %xmm4     # 0xd050
movaps %xmm2, %xmm1
andps %xmm4, %xmm1
movaps %xmm6, %xmm5
andps %xmm4, %xmm5
cmpltss %xmm5, %xmm1
andps %xmm1, %xmm2
andnps %xmm6, %xmm1
orps %xmm2, %xmm1
xorl %eax, %eax
ucomiss %xmm1, %xmm0
seta %cl
andps %xmm1, %xmm4
cvtss2sd %xmm4, %xmm0
mulsd %xmm0, %xmm3
movsd 0x30a6(%rip), %xmm2     # 0xdcd0
movapd %xmm2, %xmm4
subsd %xmm3, %xmm4
mulsd 0x309e(%rip), %xmm4     # 0xdcd8
divsd %xmm2, %xmm4
cvtsd2ss %xmm4, %xmm2
movss %xmm2, 0x2c(%rbx)
ucomisd 0x3071(%rip), %xmm0     # 0xdcc0
jbe 0xac5f
movb %cl, %al
leaq 0x306e(%rip), %rcx      # 0xdcc8
movss (%rcx,%rax,4), %xmm1
movss %xmm1, 0x30(%rbx)
jmp 0xae7d
movl 0x50(%rbx), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x50(%rbx)
testb %al, %al
js 0xac99
testl %ecx, %ecx
je 0xadff
cmpl $0x1e, %edx
jne 0xae4a
movss 0x40(%rbx), %xmm0
mulss 0x30a4(%rip), %xmm0     # 0xdd38
jmp 0xae67
cmpl $0x18, %ecx
ja 0xae72
movl $0x1084200, %edx        # imm = 0x1084200
btl %ecx, %edx
jae 0xae56
movss 0xc(%r14), %xmm0
movss 0x10(%r14), %xmm3
subss 0xc(%rbx), %xmm0
subss 0x10(%rbx), %xmm3
xorps %xmm1, %xmm1
xorl %eax, %eax
ucomiss %xmm3, %xmm1
seta %cl
movaps 0x2378(%rip), %xmm1     # 0xd050
andps %xmm3, %xmm1
cvtss2sd %xmm1, %xmm1
movsd 0x2fc1(%rip), %xmm2     # 0xdca8
ucomisd %xmm1, %xmm2
jbe 0xacfb
movb %cl, %al
leaq 0x2fba(%rip), %rcx      # 0xdcb0
movss (%rcx,%rax,4), %xmm3
movaps %xmm3, 0x10(%rsp)
divss %xmm3, %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x4270
movaps 0x10(%rsp), %xmm5
movsd 0x2f9e(%rip), %xmm1     # 0xdcb8
subsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm1
cvtsd2ss %xmm0, %xmm0
xorps 0x22e3(%rip), %xmm0     # 0xd010
cmpnless 0x300a(%rip), %xmm5     # 0xdd40
andps %xmm5, %xmm0
andnps %xmm1, %xmm5
orps %xmm0, %xmm5
movss 0x20(%rbx), %xmm1
cvtss2sd %xmm1, %xmm0
ucomisd 0x2da0(%rip), %xmm0     # 0xdaf0
jbe 0xad63
addsd 0x2d9e(%rip), %xmm0     # 0xdaf8
cvtsd2ss %xmm0, %xmm1
movss %xmm1, 0x20(%rbx)
xorps %xmm0, %xmm0
ucomiss %xmm1, %xmm0
jbe 0xad80
cvtss2sd %xmm1, %xmm1
addsd 0x2d79(%rip), %xmm1     # 0xdaf0
cvtsd2ss %xmm1, %xmm1
movss %xmm1, 0x20(%rbx)
cvtss2sd %xmm5, %xmm2
subss %xmm1, %xmm5
divss 0x2fa0(%rip), %xmm5     # 0xdd30
cvtss2sd %xmm1, %xmm1
addsd 0x2d5c(%rip), %xmm1     # 0xdaf8
subsd %xmm1, %xmm2
divsd 0x2308(%rip), %xmm2     # 0xd0b0
cvtsd2ss %xmm2, %xmm2
movaps 0x229d(%rip), %xmm3     # 0xd050
movaps %xmm2, %xmm1
andps %xmm3, %xmm1
movaps %xmm5, %xmm4
andps %xmm3, %xmm4
cmpltss %xmm4, %xmm1
andps %xmm1, %xmm2
andnps %xmm5, %xmm1
orps %xmm2, %xmm1
xorl %eax, %eax
ucomiss %xmm1, %xmm0
seta %cl
andps %xmm1, %xmm3
cvtss2sd %xmm3, %xmm0
ucomisd 0x2edc(%rip), %xmm0     # 0xdcc0
jbe 0xadf4
movb %cl, %al
leaq 0x2ed9(%rip), %rcx      # 0xdcc8
movss (%rcx,%rax,4), %xmm1
movss %xmm1, 0x30(%rbx)
andl $0x0, 0x2c(%rbx)
jmp 0xae7d
movss 0x40(%rbx), %xmm0
mulss 0x2f28(%rip), %xmm0     # 0xdd34
movss %xmm0, 0x2c(%rbx)
movl $0x3d3851ec, 0x30(%rbx) # imm = 0x3D3851EC
callq 0x4520
movzwl %ax, %eax
cvtsi2sd %eax, %xmm0
divsd 0x2244(%rip), %xmm0     # 0xd070
ucomisd 0x2e14(%rip), %xmm0     # 0xdc48
jbe 0xae7d
movss 0x30(%rbx), %xmm0
xorpd 0x21cd(%rip), %xmm0     # 0xd010
movss %xmm0, 0x30(%rbx)
jmp 0xae7d
cmpl $0x3c, %ecx
jl 0xae7d
andl $0xffffff3f, %eax       # imm = 0xFFFFFF3F
jmp 0xae7a
testl %ecx, %ecx
jne 0xae72
movss 0x40(%rbx), %xmm0
mulss 0x2ecd(%rip), %xmm0     # 0xdd34
movss %xmm0, 0x2c(%rbx)
andl $0x0, 0x30(%rbx)
jmp 0xae7d
cmpl $0x1e, %ecx
jl 0xae7d
andl $-0x41, %eax
movl %eax, 0x8(%rbx)
movsd 0x2c(%rbx), %xmm0
movaps %xmm0, %xmm1
shufps $0x55, %xmm0, %xmm1     # xmm1 = xmm1[1,1],xmm0[1,1]
cvtss2sd %xmm1, %xmm1
divsd 0x2e2b(%rip), %xmm1     # 0xdcc0
mulsd 0x2e3b(%rip), %xmm1     # 0xdcd8
cvtsd2ss %xmm1, %xmm1
mulss %xmm1, %xmm1
movaps %xmm0, %xmm2
mulss %xmm0, %xmm2
addss %xmm1, %xmm2
sqrtss %xmm2, %xmm1
ucomiss 0x2e7d(%rip), %xmm1     # 0xdd38
jbe 0xaed3
movss 0x2e73(%rip), %xmm2     # 0xdd38
divss %xmm1, %xmm2
unpcklps %xmm2, %xmm2            # xmm2 = xmm2[0,0,1,1]
mulps %xmm0, %xmm2
movlps %xmm2, 0x2c(%rbx)
testb $0x1, 0x8(%r14)
je 0xaef8
cmpl $0xb, 0x54(%rbx)
jl 0xaef8
cmpl $0x33, 0x44(%rbx)
jl 0xaef8
movq 0x650(%rbx), %r15
movzwl 0x8(%r15), %eax
testw $0x119, %ax             # imm = 0x119
je 0xaf02
addq $0x30, %rsp
popq %rbx
popq %r14
popq %r15
retq
andl $0x0, 0x54(%rbx)
movss 0x24(%r14), %xmm0
movss %xmm0, 0x10(%rsp)
movss 0x28(%r14), %xmm0
movss %xmm0, 0xc(%rsp)
cvtss2sd 0x30(%r14), %xmm0
callq 0x41e0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x8(%rsp)
cvtss2sd 0x30(%r14), %xmm0
callq 0x45a0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x4(%rsp)
cvtss2sd 0x20(%rbx), %xmm0
callq 0x41e0
cvtsd2ss %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
cvtss2sd 0x20(%rbx), %xmm0
callq 0x45a0
movss 0x10(%rsp), %xmm9
movss 0x4(%rsp), %xmm12
movss 0x8(%rsp), %xmm11
movss 0xc(%rsp), %xmm10
cvtsd2ss %xmm0, %xmm1
movsd 0xc(%rbx), %xmm0
movss 0xc(%r14), %xmm2
xorps 0x2079(%rip), %xmm1     # 0xd010
movss 0x10(%r14), %xmm3
unpcklps 0x20(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
movss 0x2c(%r14), %xmm4
pushq $0x33
popq %rax
mulps 0x2c5e(%rip), %xmm1     # 0xdc10
movss 0x2d82(%rip), %xmm5     # 0xdd3c
movaps %xmm0, %xmm6
decl %eax
je 0xaef8
movaps %xmm12, %xmm8
mulss %xmm10, %xmm8
movaps %xmm9, %xmm7
mulss %xmm11, %xmm7
subss %xmm8, %xmm7
mulss %xmm12, %xmm9
mulss %xmm11, %xmm10
addss %xmm9, %xmm10
addps %xmm1, %xmm6
movaps %xmm6, %xmm8
shufps $0x55, %xmm6, %xmm8     # xmm8 = xmm8[1,1],xmm6[1,1]
movaps %xmm10, %xmm9
mulss %xmm4, %xmm9
subss %xmm9, %xmm2
movaps %xmm7, %xmm9
mulss %xmm4, %xmm7
addss %xmm7, %xmm3
movaps %xmm2, %xmm7
subss %xmm6, %xmm7
subss %xmm3, %xmm8
mulss %xmm8, %xmm8
mulss %xmm7, %xmm7
addss %xmm8, %xmm7
ucomiss %xmm7, %xmm5
jb 0xafbd
movl $0x3, 0x8(%r15)
movlps %xmm0, 0xc(%r15)
andl $0x0, 0x14(%r15)
movsd 0x18(%rbx), %xmm0
movsd %xmm0, 0x18(%r15)
movss 0x20(%rbx), %xmm0
movss %xmm0, 0x20(%r15)
movl $0x42200000, 0x2c(%r15) # imm = 0x42200000
andl $0x0, 0x44(%r15)
pushq $0x3
popq %rdi
pushq $0x1
popq %rsi
xorl %eax, %eax
addq $0x30, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x73a4