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

  g->pcount++;
  if (!(pl->attr & IS_ALIVE)) {
    g->pcount = 0;
    g->attr &= ~CAN_SHOOT;
  }

  if (g->attr & IS_NEW) {
    g->pcount = 10;
    g->ecount = 0;
    g->attr |= CAN_SHOOT;
    g->attr &= ~IS_NEW;
    if (frand() > 0.5)
      g->orientation = PI / 2.0;
    else
      g->orientation = -PI / 2.0;
  }

  s = g->salvo;
  if (g->ecount < 150 && g->range > 400.0)
    if (!(s->attr & STILL_THERE))
      g->z -= 5.0;
    else
      g->z += 5.0;
  else
    g->z += 5.0;

  if (g->z <= 40.0)
    g->z = 40.0;
  if (g->z > 150.0)
    g->z = 150.0;
  if (g->attr & IS_BLOCKED && g->z < 90.0) {
    g->z = 90.0;
    g->attr &= ~IS_BLOCKED;
  }

  g->speed = 20.0;
  if (g->pcount >= 10) {
    g->pcount = 0;
    if (g->range > 400.0 && g->ecount < 150) {
      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) / 10.0;
      t3 = (tazm - (g->azm - PI2)) /10.0;
      if (fabs(t3) < fabs(t1))
        t1 = t3;
      if (fabs(t1) > 0.06)
        t1 = sign (0.06, t1);
      g->rotate = t1;
    }
    else {
      tazm = g->orientation;
      if (tazm < 0.0)
        tazm += PI2;
      if (tazm > PI2)
        tazm -= PI2;
      if (g->azm < 0.0)
        g->azm += PI2;
      if (g->azm > PI2)
        g->azm -= PI2;
      t1 = (tazm - g->azm) / 10.0;
      t2 = (tazm - (g->azm - PI2)) / 10.0;
      if (fabs(t2) < fabs(t1))
        t1 = t2;
      if (fabs(t1) > 0.06)
        t1 = sign (0.06, t1);
      g->rotate = t1;
      g->speed = 30.0;
    }
  }

  if (g->attr & CAN_SHOOT && g->z < 50.0 &&
      !(s->attr & STILL_THERE)) {
    /*
     * the original Fortran had the following
     *    sp = pl->sa     and    cp = pl->ca
     *
     * however, sa and ca were undefined...fortran was really good
     * about making these 0, C doesn't guarantee this will occur.
     * the two choices to fix this are to make sp and cp
     * 0 initially or to make them the sin/cos of azm.
     * the first method makes the copter fire as it hits
     * the ground, the second method the copter won't fire
     * until it is very close unless you are moving straight
     * toward it or straight away from it.
     */
    cp = sp = 0;
    dcp = cos(pl->rotate);
    dsp = sin(pl->rotate);
    cm = cos(g->azm);
    sm = sin(g->azm);
    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 <= BMC_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 $0x20, %rsp
movq %rdi, %rbx
incl 0x4c(%rdi)
movq %rsi, %r14
testb $0x1, 0x8(%rsi)
jne 0xc0db
movl $0x0, 0x4c(%rbx)
andb $-0x21, 0x8(%rbx)
movl 0x8(%rbx), %eax
testb $0x2, %al
je 0xc12b
movl $0xa, 0x4c(%rbx)
movl $0x0, 0x44(%rbx)
andl $-0x23, %eax
orl $0x20, %eax
movl %eax, 0x8(%rbx)
callq 0x4510
movzwl %ax, %eax
cvtsi2sd %eax, %xmm0
divsd 0x1f53(%rip), %xmm0     # 0xe060
xorl %eax, %eax
ucomisd 0x2a19(%rip), %xmm0     # 0xeb30
seta %al
leaq 0x2abf(%rip), %rcx      # 0xebe0
movss (%rcx,%rax,4), %xmm0
movss %xmm0, 0x40(%rbx)
movq 0x650(%rbx), %r15
movl 0x44(%rbx), %eax
cmpl $0x95, %eax
jg 0xc166
movss 0x34(%rbx), %xmm0
ucomiss 0x2af8(%rip), %xmm0     # 0xec40
jbe 0xc166
movzwl 0x8(%r15), %ecx
movss 0x14(%rbx), %xmm0
testl $0x119, %ecx            # imm = 0x119
jne 0xc16b
addss 0x2ae0(%rip), %xmm0     # 0xec44
jmp 0xc173
movss 0x14(%rbx), %xmm0
addss 0x2aa5(%rip), %xmm0     # 0xec18
movss %xmm0, 0x14(%rbx)
movss 0x2aa4(%rip), %xmm0     # 0xec24
ucomiss 0x14(%rbx), %xmm0
jb 0xc18d
movl $0x42200000, 0x14(%rbx) # imm = 0x42200000
movss 0x14(%rbx), %xmm0
ucomiss 0x2a73(%rip), %xmm0     # 0xec0c
jbe 0xc1a2
movl $0x43160000, 0x14(%rbx) # imm = 0x43160000
movl 0x8(%rbx), %ecx
testl $0x600, %ecx            # imm = 0x600
je 0xc1cb
movss 0x2a7f(%rip), %xmm0     # 0xec34
ucomiss 0x14(%rbx), %xmm0
jbe 0xc1cb
movl $0x42b40000, 0x14(%rbx) # imm = 0x42B40000
andl $0xfffff9ff, %ecx       # imm = 0xFFFFF9FF
movl %ecx, 0x8(%rbx)
movl $0x41a00000, 0x2c(%rbx) # imm = 0x41A00000
cmpl $0xa, 0x4c(%rbx)
jl 0xc47c
movl $0x0, 0x4c(%rbx)
cmpl $0x95, %eax
jg 0xc360
movss 0x34(%rbx), %xmm0
ucomiss 0x2a46(%rip), %xmm0     # 0xec40
jbe 0xc360
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 0x1e18(%rip), %xmm1     # 0xe040
andps %xmm3, %xmm1
cvtss2sd %xmm1, %xmm1
movsd 0x2959(%rip), %xmm2     # 0xeb90
ucomisd %xmm1, %xmm2
jbe 0xc24b
movb %cl, %al
leaq 0x2952(%rip), %rcx      # 0xeb98
movss (%rcx,%rax,4), %xmm3
movaps %xmm3, 0x10(%rsp)
divss %xmm3, %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x4270
movaps 0x10(%rsp), %xmm5
movsd 0x2936(%rip), %xmm1     # 0xeba0
subsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm1
xorps %xmm2, %xmm2
cvtsd2ss %xmm0, %xmm2
xorps 0x1da0(%rip), %xmm2     # 0xe020
cmpnless 0x29a3(%rip), %xmm5     # 0xec2c
andps %xmm5, %xmm2
andnps %xmm1, %xmm5
xorps %xmm0, %xmm0
cvtss2sd 0x20(%rbx), %xmm0
orps %xmm2, %xmm5
ucomisd 0x277e(%rip), %xmm0     # 0xea20
jbe 0xc2b5
addsd 0x277c(%rip), %xmm0     # 0xea28
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x20(%rbx)
movss 0x20(%rbx), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm1, %xmm0
jbe 0xc2d7
cvtss2sd %xmm1, %xmm1
addsd 0x2752(%rip), %xmm1     # 0xea20
cvtsd2ss %xmm1, %xmm1
movss %xmm1, 0x20(%rbx)
movss 0x20(%rbx), %xmm1
xorps %xmm2, %xmm2
cvtss2sd %xmm5, %xmm2
subss %xmm1, %xmm5
divss 0x1d15(%rip), %xmm5     # 0xe004
cvtss2sd %xmm1, %xmm1
addsd 0x272d(%rip), %xmm1     # 0xea28
subsd %xmm1, %xmm2
divsd 0x22a9(%rip), %xmm2     # 0xe5b0
cvtsd2ss %xmm2, %xmm2
movaps 0x1d2e(%rip), %xmm3     # 0xe040
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
xorps %xmm0, %xmm0
cvtss2sd %xmm3, %xmm0
ucomisd 0x28a2(%rip), %xmm0     # 0xebe8
jbe 0xc356
movb %cl, %al
leaq 0x289f(%rip), %rcx      # 0xebf0
movss (%rcx,%rax,4), %xmm1
movss %xmm1, 0x30(%rbx)
jmp 0xc47c
movss 0x20(%rbx), %xmm1
movss 0x40(%rbx), %xmm3
xorps %xmm0, %xmm0
cvtss2sd %xmm3, %xmm0
movsd 0x26a7(%rip), %xmm4     # 0xea20
addsd %xmm4, %xmm0
cvtsd2ss %xmm0, %xmm5
xorps %xmm2, %xmm2
movaps %xmm3, %xmm0
cmpltss %xmm2, %xmm0
andps %xmm0, %xmm5
andnps %xmm3, %xmm0
orps %xmm5, %xmm0
xorps %xmm3, %xmm3
cvtss2sd %xmm0, %xmm3
ucomisd %xmm4, %xmm3
jbe 0xc3b1
addsd 0x267e(%rip), %xmm3     # 0xea28
xorps %xmm0, %xmm0
cvtsd2ss %xmm3, %xmm0
ucomiss %xmm1, %xmm2
jbe 0xc3cb
cvtss2sd %xmm1, %xmm1
addsd 0x265e(%rip), %xmm1     # 0xea20
cvtsd2ss %xmm1, %xmm1
movss %xmm1, 0x20(%rbx)
xorps %xmm1, %xmm1
cvtss2sd 0x20(%rbx), %xmm1
ucomisd 0x2645(%rip), %xmm1     # 0xea20
jbe 0xc3ee
addsd 0x2643(%rip), %xmm1     # 0xea28
cvtsd2ss %xmm1, %xmm1
movss %xmm1, 0x20(%rbx)
movss 0x20(%rbx), %xmm1
xorps %xmm2, %xmm2
cvtss2sd %xmm0, %xmm2
subss %xmm1, %xmm0
divss 0x1bfe(%rip), %xmm0     # 0xe004
cvtss2sd %xmm1, %xmm1
addsd 0x2616(%rip), %xmm1     # 0xea28
subsd %xmm1, %xmm2
divsd 0x2192(%rip), %xmm2     # 0xe5b0
cvtsd2ss %xmm2, %xmm2
movaps 0x1c17(%rip), %xmm3     # 0xe040
movaps %xmm2, %xmm1
andps %xmm3, %xmm1
movaps %xmm0, %xmm4
andps %xmm3, %xmm4
cmpltss %xmm4, %xmm1
andps %xmm1, %xmm2
andnps %xmm0, %xmm1
orps %xmm2, %xmm1
xorps %xmm0, %xmm0
xorl %eax, %eax
ucomiss %xmm1, %xmm0
seta %cl
andps %xmm1, %xmm3
xorps %xmm0, %xmm0
cvtss2sd %xmm3, %xmm0
ucomisd 0x2788(%rip), %xmm0     # 0xebe8
jbe 0xc470
movb %cl, %al
leaq 0x2785(%rip), %rcx      # 0xebf0
movss (%rcx,%rax,4), %xmm1
movss %xmm1, 0x30(%rbx)
movl $0x41f00000, 0x2c(%rbx) # imm = 0x41F00000
testb $0x20, 0x8(%rbx)
je 0xc5e2
movss 0x25e2(%rip), %xmm0     # 0xea70
ucomiss 0x14(%rbx), %xmm0
jbe 0xc5e2
movzwl 0x8(%r15), %eax
testl $0x119, %eax            # imm = 0x119
jne 0xc5e2
xorps %xmm0, %xmm0
cvtss2sd 0x30(%r14), %xmm0
callq 0x41e0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x10(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x30(%r14), %xmm0
callq 0x4590
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xc(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x20(%rbx), %xmm0
callq 0x41e0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x8(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x20(%rbx), %xmm0
callq 0x4590
movss 0x8(%rsp), %xmm15
movss 0xc(%rsp), %xmm14
movss 0x10(%rsp), %xmm13
xorps %xmm2, %xmm2
cvtsd2ss %xmm0, %xmm2
movss 0xc(%rbx), %xmm0
movss 0x10(%rbx), %xmm1
movss 0xc(%r14), %xmm3
movss 0x10(%r14), %xmm10
xorps 0x1aeb(%rip), %xmm2     # 0xe020
movss 0x2c(%r14), %xmm4
xorps %xmm5, %xmm5
movl $0x32, %eax
movss 0x26d9(%rip), %xmm6     # 0xec24
mulss %xmm6, %xmm2
mulss %xmm6, %xmm15
movss 0x26ec(%rip), %xmm6     # 0xec48
movaps %xmm1, %xmm7
movaps %xmm0, %xmm8
xorps %xmm9, %xmm9
movaps %xmm10, %xmm11
movaps %xmm5, %xmm10
addss %xmm15, %xmm7
addss %xmm2, %xmm8
movaps %xmm14, %xmm12
mulss %xmm9, %xmm12
mulss %xmm13, %xmm5
subss %xmm12, %xmm5
mulss %xmm14, %xmm10
mulss %xmm13, %xmm9
addss %xmm10, %xmm9
movaps %xmm9, %xmm10
mulss %xmm4, %xmm10
subss %xmm10, %xmm3
movaps %xmm5, %xmm10
mulss %xmm4, %xmm10
addss %xmm11, %xmm10
movaps %xmm3, %xmm11
subss %xmm8, %xmm11
movaps %xmm7, %xmm12
subss %xmm10, %xmm12
mulss %xmm12, %xmm12
mulss %xmm11, %xmm11
addss %xmm12, %xmm11
ucomiss %xmm11, %xmm6
jae 0xc5ec
decl %eax
jne 0xc567
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
movl $0x3, 0x8(%r15)
movss %xmm0, 0xc(%r15)
movss %xmm1, 0x10(%r15)
xorl %eax, %eax
movl %eax, 0x14(%r15)
movss 0x18(%rbx), %xmm0
movss %xmm0, 0x18(%r15)
movss 0x1c(%rbx), %xmm0
movss %xmm0, 0x1c(%r15)
movss 0x20(%rbx), %xmm0
movss %xmm0, 0x20(%r15)
movl $0x42200000, 0x2c(%r15) # imm = 0x42200000
movl %eax, 0x44(%r15)
movl $0x3, %edi
movl $0x1, %esi
xorl %eax, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x7a44