// File: /workspace/github_c_makefile_star2_O1/jrrk[P]cbzone/c_move.c
// Function: placeobjects
void placeobjects(o, missilerun, score)
     Genericp o;
     Bool missilerun;
     LONG score;
{
  static int lander = 1000;
  static int landercount = 0;
  static struct timeval clock = {0, 40000};
  float odds, scale, r, dazm, ca, sa;
  Genericp g;
  Genericp pl = o;
  int nta = 0;
  int nsu = 0;
  int nmi = 0;
  int nco = 0;
  int nla = 0;

  landercount++;
  for (g=o; g<o+opt->mobjects; g++)
    if (g->attr & STILL_THERE)
      switch (g->type) {
      case IS_TANK:
        nta++; break;
      case IS_SUPER:
        nsu++; break;
      case IS_MISSILE:
        nmi++; break;
      case IS_COPTER:
        nco++; break;
      case IS_LANDER:
        nla++; break;
      }

  if (pl->attr & IS_ALIVE &&
      (missilerun && nta + nsu == 0 && nmi + nco < opt->mmissiles ||
       !missilerun && nmi + nco == 0 && nta + nsu < opt->mtanks)) {
    for (g=o+opt->estart; g<o+opt->lstart; g++)
      if (!(g->attr & STILL_THERE))
        break;
    if (g == o+opt->lstart) {
      printf("Help! Did not have space available for enemy!\n");
      printf("Should not have been possible.\n");
#ifdef WIN32
      return;
#else //X11
      exit(1);
#endif
    }

    if (missilerun) {
      /* reset clock usec just in case they change select to return the
         amount of time remaining after the select finishes.   The
         man page mentions this might occur in future releases.
       */
      tonetime();
      clock.tv_usec = 40000;
      select(0, 0, 0, 0, &clock);
      tonetime();
      clock.tv_usec = 40000;
      select(0, 0, 0, 0, &clock);
      tonetime();
      odds = score / 500000.0;
      if (score < 75000)
        odds = 0.0;
      if (odds > 0.333)
        odds = 0.333;
      if (opt->copters || frand() < odds) {
        g->type = IS_COPTER;
        g->lntype = LN_COPTER;
        scale = 0.2;
        g->z = 150.0;
        r = 1900;
      }
      else {
        g->type = IS_MISSILE;
        g->lntype = LN_MISSILE;
        scale = 0.1;
        g->z = 250.0;
        r = 1750;
      }
      dazm = frand() * scale;
      if (frand() > 0.5)
        dazm = - dazm;
      dazm += pl->azm;
      ca = cos(dazm);
      sa = sin(dazm);
      g->x = pl->x - r * sa;
      g->y = pl->y + r * ca;
      g->attr = START_LIVING;
      dazm = frand() * 0.015 / scale;
      if (frand() > 0.5)
        dazm = - dazm;
      g->azm = pl->azm - PI + dazm;
    }
    else {
      odds = (60000.0 - score) / 30000.0;
      if (odds < 0.10)
        odds = 0.10;
      if (frand() < odds) {
        g->type = IS_TANK;
        g->lntype = LN_TANK;
      }
      else {
        g->type = IS_SUPER;
        g->lntype = LN_SUPER;
      }
      r = 800.0 + 1200.0 * frand();
      dazm = frand() * PI2;
      g->x = pl->x + r * cos(dazm);
      g->y = pl->y + r * sin(dazm);
      g->z = 0.0;
      g->azm = frand() * PI2;
      g->attr = START_LIVING;
    }
    g->criticalx = 45.0;
    g->criticaly = 70.0;
  }

  if (landercount > lander && nla < opt->mlanders) {
    for (g=o+opt->lstart; g<o+opt->sstart; g++)
      if (!(g->attr & STILL_THERE))
        break;
    if (g == o+opt->sstart) {
      printf("Help! Did not have space available for lander!\n");
      printf("Should not have been possible.\n");
#ifdef WIN32
      return;
#else //X11
      exit(1);
#endif
    }

    r = 1500.0 + 500.0 * frand();
    dazm = frand() * PI2;
    g->x = pl->x + r * cos(dazm);
    g->y = pl->y + r * sin(dazm);
    g->z = 0.0;
    g->azm = frand() * PI2;
    g->speed = frand() * 10.0;
    g->criticalx = g->criticaly = 6400.0;
    g->type = IS_LANDER;
    g->lntype = LN_LANDER;
    g->attr = START_LIVING;
  }

  for (g=o+opt->bstart; g<o+opt->mobjects; g++)
    if (!(g->attr & IS_ALIVE)) {
      if (frand() > 0.5) {
        g->type = IS_CUBE;
        g->lntype = LN_CUBE;
        g->criticalx = g->criticaly = 50.0;
      }
      else {
        g->type = IS_PYRAMID;
        g->lntype = LN_PYRAMID;
        g->criticalx = g->criticaly = 35.0;
      }
      g->attr = START_LIVING;
      if (pl->attr & IS_NEW)
        r = 400 + frand() * 1800.0;
      else
        r = 2000.0;
      dazm = frand() * PI2;
      g->x = pl->x + r * cos(dazm);
      g->y = pl->y + r * sin(dazm);
      g->z = 0.0;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
incl 0x9b49(%rip)            # 0x14910
leaq 0x97c2(%rip), %r12      # 0x14590
movq (%r12), %rax
movslq 0x1c(%rax), %rcx
testq %rcx, %rcx
jle 0xae4b
imulq $0x660, %rcx, %r9       # imm = 0x660
addq %rbx, %r9
xorl %ebp, %ebp
xorl %r8d, %r8d
xorl %edi, %edi
xorl %ecx, %ecx
xorl %r14d, %r14d
movq %rbx, %r10
movzwl 0x8(%r10), %r11d
testl $0x119, %r11d           # imm = 0x119
je 0xae3d
movl (%r10), %r11d
cmpl $0xf, %r11d
jle 0xae21
cmpl $0x10, %r11d
je 0xae31
cmpl $0x20, %r11d
je 0xae35
cmpl $0x40, %r11d
jne 0xae3d
incl %ebp
jmp 0xae3d
cmpl $0x4, %r11d
je 0xae3a
cmpl $0x8, %r11d
jne 0xae3d
incl %ecx
jmp 0xae3d
incl %edi
jmp 0xae3d
incl %r8d
jmp 0xae3d
incl %r14d
addq $0x660, %r10            # imm = 0x660
cmpq %r9, %r10
jb 0xadf4
jmp 0xae57
xorl %r14d, %r14d
xorl %ecx, %ecx
xorl %edi, %edi
xorl %r8d, %r8d
xorl %ebp, %ebp
testb $0x1, 0x8(%rbx)
je 0xb30d
testl %esi, %esi
je 0xae7a
movl %ecx, %r9d
negl %r9d
cmpl %r9d, %r14d
jne 0xae7a
leal (%r8,%rdi), %r9d
cmpl 0xc(%rax), %r9d
jl 0xae94
negl %r8d
xorl %r8d, %edi
orl %esi, %edi
jne 0xb30d
addl %r14d, %ecx
cmpl 0x14(%rax), %ecx
jge 0xb30d
movslq 0x20(%rax), %rcx
imulq $0x660, %rcx, %r13      # imm = 0x660
addq %rbx, %r13
movslq 0x24(%rax), %rdi
imulq $0x660, %rdi, %rax      # imm = 0x660
addq %rbx, %rax
cmpl %edi, %ecx
jge 0xaecd
movzwl 0x8(%r13), %ecx
testl $0x119, %ecx            # imm = 0x119
je 0xaecd
addq $0x660, %r13            # imm = 0x660
cmpq %rax, %r13
jb 0xaeb4
cmpq %rax, %r13
je 0xb62a
testl %esi, %esi
je 0xb080
movq %rdx, 0x10(%rsp)
xorl %eax, %eax
callq 0x723e
movl $0x9c40, %r14d          # imm = 0x9C40
movq %r14, 0x96a9(%rip)      # 0x145a0
leaq 0x969a(%rip), %r15      # 0x14598
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r15, %r8
callq 0x4100
xorl %eax, %eax
callq 0x723e
movq %r14, 0x9684(%rip)      # 0x145a0
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r15, %r8
callq 0x4100
xorl %eax, %eax
callq 0x723e
movq (%r12), %rax
movsd 0x3bc9(%rip), %xmm0     # 0xeb08
movsd %xmm0, (%rsp)
movss 0x3cbc(%rip), %xmm0     # 0xec08
movss %xmm0, 0x28(%rsp)
movss 0x3cb2(%rip), %xmm0     # 0xec0c
movl $0x5, %r14d
movl $0x20, %r15d
cmpl $0x0, 0x30(%rax)
jne 0xb018
xorps %xmm0, %xmm0
movq 0x10(%rsp), %rax
cmpq $0x124f8, %rax          # imm = 0x124F8
jl 0xaf94
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x3b80(%rip), %xmm0     # 0xeb10
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
callq 0x4510
movzwl %ax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x30ac(%rip), %xmm0     # 0xe060
movsd 0x3b5c(%rip), %xmm1     # 0xeb18
movapd 0x10(%rsp), %xmm3
cmpltsd %xmm3, %xmm1
movsd 0x3b51(%rip), %xmm2     # 0xeb20
andpd %xmm1, %xmm2
andnpd %xmm3, %xmm1
orpd %xmm1, %xmm2
ucomisd %xmm0, %xmm2
movss 0x3c25(%rip), %xmm0     # 0xec0c
ja 0xb018
movsd 0x3b37(%rip), %xmm0     # 0xeb28
movsd %xmm0, (%rsp)
movss 0x3c12(%rip), %xmm0     # 0xec10
movss %xmm0, 0x28(%rsp)
movss 0x3c08(%rip), %xmm0     # 0xec14
movl $0x4, %r14d
movl $0x10, %r15d
movl %r15d, (%r13)
movl %r14d, 0x4(%r13)
movss %xmm0, 0x14(%r13)
callq 0x4510
movl $0xffff, %r14d          # imm = 0xFFFF
andl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x301d(%rip), %xmm0     # 0xe060
mulsd (%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
callq 0x4510
andl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2ff8(%rip), %xmm0     # 0xe060
ucomisd 0x3ac0(%rip), %xmm0     # 0xeb30
ja 0xb209
movaps 0x10(%rsp), %xmm0
jmp 0xb215
cvtsi2sd %rdx, %xmm0
movsd 0x3abb(%rip), %xmm1     # 0xeb48
subsd %xmm0, %xmm1
divsd 0x3ab7(%rip), %xmm1     # 0xeb50
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movaps %xmm0, (%rsp)
callq 0x4510
movl $0xffff, %r14d          # imm = 0xFFFF
andl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2f9b(%rip), %xmm0     # 0xe060
movapd (%rsp), %xmm3
movapd %xmm3, %xmm1
cmpltsd 0x3a81(%rip), %xmm1     # 0xeb58
movsd 0x3a49(%rip), %xmm2     # 0xeb28
andpd %xmm1, %xmm2
andnpd %xmm3, %xmm1
orpd %xmm1, %xmm2
xorl %eax, %eax
xorl %ecx, %ecx
ucomisd %xmm0, %xmm2
seta %al
setbe %cl
leal 0x4(,%rcx,4), %ecx
xorl $0x3, %eax
movl %ecx, (%r13)
movl %eax, 0x4(%r13)
callq 0x4510
andl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2f3e(%rip), %xmm0     # 0xe060
mulsd 0x3a36(%rip), %xmm0     # 0xeb60
addsd 0x3a36(%rip), %xmm0     # 0xeb68
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rsp)
callq 0x4510
andl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2f0e(%rip), %xmm0     # 0xe060
mulsd 0x38c6(%rip), %xmm0     # 0xea20
cvtsd2ss %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0xc(%rbx), %xmm1
movsd %xmm1, 0x10(%rsp)
xorps %xmm1, %xmm1
cvtss2sd (%rsp), %xmm1
movsd %xmm1, (%rsp)
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x28(%rsp)
callq 0x41e0
mulsd (%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xc(%r13)
xorps %xmm0, %xmm0
cvtss2sd 0x10(%rbx), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x28(%rsp), %xmm0
callq 0x4590
mulsd (%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x10(%r13)
movl $0x0, 0x14(%r13)
callq 0x4510
andl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2e76(%rip), %xmm0     # 0xe060
mulsd 0x382e(%rip), %xmm0     # 0xea20
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x20(%r13)
movl $0x3, 0x8(%r13)
jmp 0xb2ff
movaps 0x10(%rsp), %xmm0
xorps 0x2e0b(%rip), %xmm0     # 0xe020
addss 0x20(%rbx), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
callq 0x41e0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x10(%rsp)
movsd 0x30(%rsp), %xmm0
callq 0x4590
cvtsd2ss %xmm0, %xmm0
movss 0xc(%rbx), %xmm1
movss 0x28(%rsp), %xmm2
mulss %xmm2, %xmm0
subss %xmm0, %xmm1
movss %xmm1, 0xc(%r13)
movss 0x10(%rsp), %xmm0
mulss %xmm2, %xmm0
addss 0x10(%rbx), %xmm0
movss %xmm0, 0x10(%r13)
movl $0x3, 0x8(%r13)
callq 0x4510
andl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x2dd1(%rip), %xmm1     # 0xe060
divsd %xmm1, %xmm0
mulsd 0x389d(%rip), %xmm0     # 0xeb38
divsd (%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movaps %xmm0, (%rsp)
callq 0x4510
andl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2da1(%rip), %xmm0     # 0xe060
ucomisd 0x3869(%rip), %xmm0     # 0xeb30
ja 0xb2cf
movaps (%rsp), %xmm1
jmp 0xb2da
movaps (%rsp), %xmm1
xorps 0x2d46(%rip), %xmm1     # 0xe020
xorps %xmm0, %xmm0
cvtss2sd 0x20(%rbx), %xmm0
addsd 0x3856(%rip), %xmm0     # 0xeb40
cvtss2sd %xmm1, %xmm1
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x20(%r13)
movabsq $0x428c000042340000, %rax # imm = 0x428C000042340000
movq %rax, 0x38(%r13)
cmpl $0x3e9, 0x95f9(%rip)    # imm = 0x3E9
jl 0xb4aa
movq (%r12), %rax
cmpl 0x8(%rax), %ebp
jge 0xb4aa
movslq 0x24(%rax), %rcx
imulq $0x660, %rcx, %r14      # imm = 0x660
addq %rbx, %r14
movslq 0x28(%rax), %rdx
imulq $0x660, %rdx, %rax      # imm = 0x660
addq %rbx, %rax
cmpl %edx, %ecx
jge 0xb363
movzwl 0x8(%r14), %ecx
testl $0x119, %ecx            # imm = 0x119
je 0xb363
addq $0x660, %r14            # imm = 0x660
cmpq %rax, %r14
jb 0xb34a
cmpq %rax, %r14
je 0xb621
callq 0x4510
movl $0xffff, %ebp           # imm = 0xFFFF
andl %ebp, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2cd9(%rip), %xmm0     # 0xe060
mulsd 0x3259(%rip), %xmm0     # 0xe5e8
addsd 0x37d9(%rip), %xmm0     # 0xeb70
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rsp)
callq 0x4510
andl %ebp, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2caa(%rip), %xmm0     # 0xe060
mulsd 0x3662(%rip), %xmm0     # 0xea20
cvtsd2ss %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0xc(%rbx), %xmm1
movsd %xmm1, 0x10(%rsp)
xorps %xmm1, %xmm1
cvtss2sd (%rsp), %xmm1
movsd %xmm1, (%rsp)
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x28(%rsp)
callq 0x41e0
mulsd (%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xc(%r14)
xorps %xmm0, %xmm0
cvtss2sd 0x10(%rbx), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x28(%rsp), %xmm0
callq 0x4590
mulsd (%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x10(%r14)
movl $0x0, 0x14(%r14)
callq 0x4510
andl %ebp, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2c13(%rip), %xmm0     # 0xe060
mulsd 0x35cb(%rip), %xmm0     # 0xea20
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x20(%r14)
callq 0x4510
andl %ebp, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2beb(%rip), %xmm0     # 0xe060
mulsd 0x3133(%rip), %xmm0     # 0xe5b0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x2c(%r14)
movabsq $0x45c8000045c80000, %rax # imm = 0x45C8000045C80000
movq %rax, 0x38(%r14)
movabsq $0x600000040, %rax      # imm = 0x600000040
movq %rax, (%r14)
movl $0x3, 0x8(%r14)
movq (%r12), %rcx
movslq 0x2c(%rcx), %rax
cmpl 0x1c(%rcx), %eax
jge 0xb612
imulq $0x660, %rax, %r14      # imm = 0x660
addq %rbx, %r14
leaq 0x36ac(%rip), %r15      # 0xeb78
testb $0x1, 0x8(%r14)
jne 0xb5f0
callq 0x4510
movzwl %ax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2b72(%rip), %xmm0     # 0xe060
xorl %eax, %eax
ucomisd 0x3638(%rip), %xmm0     # 0xeb30
seta %al
leal 0x1(%rax), %ecx
movss (%r15,%rax,4), %xmm0
movl %ecx, (%r14)
movl %eax, 0x4(%r14)
movss %xmm0, 0x3c(%r14)
movss %xmm0, 0x38(%r14)
movl $0x3, 0x8(%r14)
testb $0x2, 0x8(%rbx)
movsd 0x2b05(%rip), %xmm0     # 0xe030
je 0xb55c
callq 0x4510
movzwl %ax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2b1c(%rip), %xmm0     # 0xe060
mulsd 0x3634(%rip), %xmm0     # 0xeb80
addsd 0x3634(%rip), %xmm0     # 0xeb88
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, (%rsp)
callq 0x4510
movzwl %ax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x2ae8(%rip), %xmm1     # 0xe060
divsd %xmm1, %xmm0
mulsd 0x349c(%rip), %xmm0     # 0xea20
cvtsd2ss %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0xc(%rbx), %xmm1
movsd %xmm1, 0x10(%rsp)
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x28(%rsp)
callq 0x41e0
mulsd (%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xc(%r14)
xorps %xmm0, %xmm0
cvtss2sd 0x10(%rbx), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x28(%rsp), %xmm0
callq 0x4590
mulsd (%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x10(%r14)
movl $0x0, 0x14(%r14)
addq $0x660, %r14            # imm = 0x660
movq (%r12), %rax
movslq 0x1c(%rax), %rax
imulq $0x660, %rax, %rax      # imm = 0x660
addq %rbx, %rax
cmpq %rax, %r14
jb 0xb4cc
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3630(%rip), %rdi      # 0xec58
jmp 0xb631
leaq 0x3656(%rip), %rdi      # 0xec87
callq 0x40c0
leaq 0x3678(%rip), %rdi      # 0xecb5
callq 0x40c0
movl $0x1, %edi
callq 0x4110