// File: /workspace/github_c_makefile_star2_O3/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
movl 0x9a45(%rip), %ecx      # 0x14900
incl %ecx
movl %ecx, 0x9a3d(%rip)      # 0x14900
leaq 0x96b6(%rip), %r12      # 0x14580
movq (%r12), %rax
movslq 0x1c(%rax), %rdi
testq %rdi, %rdi
jle 0xaf49
imulq $0x660, %rdi, %r10      # imm = 0x660
addq %rbx, %r10
xorl %ebp, %ebp
xorl %r9d, %r9d
xorl %r8d, %r8d
xorl %r14d, %r14d
xorl %edi, %edi
movq %rbx, %r11
movzwl 0x8(%r11), %r15d
testl $0x119, %r15d           # imm = 0x119
je 0xaf3b
movl (%r11), %r15d
cmpl $0xf, %r15d
jle 0xaf1e
cmpl $0x10, %r15d
je 0xaf2f
cmpl $0x20, %r15d
je 0xaf34
cmpl $0x40, %r15d
jne 0xaf3b
incl %ebp
jmp 0xaf3b
cmpl $0x4, %r15d
je 0xaf39
cmpl $0x8, %r15d
jne 0xaf3b
incl %r14d
jmp 0xaf3b
incl %r8d
jmp 0xaf3b
incl %r9d
jmp 0xaf3b
incl %edi
addq $0x660, %r11            # imm = 0x660
cmpq %r10, %r11
jb 0xaef1
jmp 0xaf56
xorl %edi, %edi
xorl %r14d, %r14d
xorl %r8d, %r8d
xorl %r9d, %r9d
xorl %ebp, %ebp
testb $0x1, 0x8(%rbx)
je 0xb40c
testl %esi, %esi
je 0xaf7d
movl %r14d, %r10d
negl %r10d
cmpl %r10d, %edi
jne 0xaf7d
addl %r8d, %r9d
cmpl 0xc(%rax), %r9d
jl 0xaf99
jmp 0xb40c
negl %r9d
xorl %r9d, %r8d
orl %esi, %r8d
jne 0xb40c
addl %edi, %r14d
cmpl 0x14(%rax), %r14d
jge 0xb40c
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 0xafd2
movzwl 0x8(%r13), %ecx
testl $0x119, %ecx            # imm = 0x119
je 0xafd2
addq $0x660, %r13            # imm = 0x660
cmpq %rax, %r13
jb 0xafb9
cmpq %rax, %r13
je 0xb721
testl %esi, %esi
je 0xb180
movq %rdx, 0x10(%rsp)
xorl %eax, %eax
callq 0x7296
movl $0x9c40, %r14d          # imm = 0x9C40
movq %r14, 0x9594(%rip)      # 0x14590
leaq 0x9585(%rip), %r15      # 0x14588
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r15, %r8
callq 0x4100
xorl %eax, %eax
callq 0x7296
movq %r14, 0x956f(%rip)      # 0x14590
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r15, %r8
callq 0x4100
xorl %eax, %eax
callq 0x7296
movq (%r12), %rax
movsd 0x3bdc(%rip), %xmm1     # 0xec20
movsd 0x3c14(%rip), %xmm0     # 0xec60
movsd %xmm0, (%rsp)
movss 0x3d07(%rip), %xmm0     # 0xed60
movaps %xmm0, 0x20(%rsp)
movss 0x3cfe(%rip), %xmm0     # 0xed64
cmpl $0x0, 0x30(%rax)
jne 0xb11b
xorps %xmm0, %xmm0
movq 0x10(%rsp), %rax
cmpq $0x124f8, %rax          # imm = 0x124F8
jl 0xb098
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x3bd8(%rip), %xmm0     # 0xec68
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
callq 0x4510
movzwl %ax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2fbc(%rip), %xmm0     # 0xe070
movsd 0x3bb4(%rip), %xmm1     # 0xec70
movapd 0x10(%rsp), %xmm3
cmpltsd %xmm3, %xmm1
movsd 0x3ba9(%rip), %xmm2     # 0xec78
andpd %xmm1, %xmm2
andnpd %xmm3, %xmm1
orpd %xmm1, %xmm2
ucomisd %xmm0, %xmm2
movsd 0x3b39(%rip), %xmm1     # 0xec20
movss 0x3c75(%rip), %xmm0     # 0xed64
ja 0xb11b
movsd 0x3b37(%rip), %xmm1     # 0xec30
movsd 0x3b7f(%rip), %xmm0     # 0xec80
movsd %xmm0, (%rsp)
movss 0x3c5a(%rip), %xmm0     # 0xed68
movaps %xmm0, 0x20(%rsp)
movss 0x3c51(%rip), %xmm0     # 0xed6c
movlps %xmm1, (%r13)
movss %xmm0, 0x14(%r13)
callq 0x4510
movl $0xffff, %r14d          # imm = 0xFFFF
andl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2f2d(%rip), %xmm0     # 0xe070
mulsd (%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
callq 0x4510
andl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2f08(%rip), %xmm0     # 0xe070
ucomisd 0x3b18(%rip), %xmm0     # 0xec88
ja 0xb309
movaps 0x10(%rsp), %xmm0
jmp 0xb315
cvtsi2sd %rdx, %xmm0
movsd 0x3b13(%rip), %xmm1     # 0xeca0
subsd %xmm0, %xmm1
divsd 0x3b0f(%rip), %xmm1     # 0xeca8
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 0x2eab(%rip), %xmm0     # 0xe070
movapd (%rsp), %xmm3
movapd %xmm3, %xmm1
cmpltsd 0x3ad9(%rip), %xmm1     # 0xecb0
movsd 0x3aa1(%rip), %xmm2     # 0xec80
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 0x2e4e(%rip), %xmm0     # 0xe070
mulsd 0x3a8e(%rip), %xmm0     # 0xecb8
addsd 0x3a8e(%rip), %xmm0     # 0xecc0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rsp)
callq 0x4510
andl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2e1e(%rip), %xmm0     # 0xe070
mulsd 0x38d6(%rip), %xmm0     # 0xeb30
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, 0x20(%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 0x20(%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 0x2d86(%rip), %xmm0     # 0xe070
mulsd 0x383e(%rip), %xmm0     # 0xeb30
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x20(%r13)
movl $0x3, 0x8(%r13)
jmp 0xb3f4
movaps 0x10(%rsp), %xmm0
xorps 0x2cfb(%rip), %xmm0     # 0xe010
addss 0x20(%rbx), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
callq 0x41e0
movaps %xmm0, 0x10(%rsp)
movsd 0x30(%rsp), %xmm0
callq 0x4590
movaps 0x20(%rsp), %xmm3
movaps %xmm3, %xmm1
xorps 0x2cc8(%rip), %xmm1     # 0xe010
unpcklpd 0x10(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
cvtpd2ps %xmm0, %xmm0
movsd 0xc(%rbx), %xmm2
unpcklps %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
mulps %xmm0, %xmm1
addps %xmm2, %xmm1
movlps %xmm1, 0xc(%r13)
movl $0x3, 0x8(%r13)
callq 0x4510
andl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x2cec(%rip), %xmm1     # 0xe070
divsd %xmm1, %xmm0
mulsd 0x3900(%rip), %xmm0     # 0xec90
divsd (%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movaps %xmm0, (%rsp)
callq 0x4510
andl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2cbc(%rip), %xmm0     # 0xe070
ucomisd 0x38cc(%rip), %xmm0     # 0xec88
ja 0xb3c4
movaps (%rsp), %xmm1
jmp 0xb3cf
movaps (%rsp), %xmm1
xorps 0x2c41(%rip), %xmm1     # 0xe010
xorps %xmm0, %xmm0
cvtss2sd 0x20(%rbx), %xmm0
addsd 0x38b9(%rip), %xmm0     # 0xec98
cvtss2sd %xmm1, %xmm1
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x20(%r13)
movsd 0x3704(%rip), %xmm0     # 0xeb00
movsd %xmm0, 0x38(%r13)
movl 0x94f8(%rip), %ecx      # 0x14900
movq (%r12), %rax
cmpl $0x3e9, %ecx            # imm = 0x3E9
jl 0xb5a5
cmpl 0x8(%rax), %ebp
jge 0xb5a5
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 0xb45a
movzwl 0x8(%r14), %ecx
testl $0x119, %ecx            # imm = 0x119
je 0xb45a
addq $0x660, %r14            # imm = 0x660
cmpq %rax, %r14
jb 0xb441
cmpq %rax, %r14
je 0xb718
callq 0x4510
movl $0xffff, %ebp           # imm = 0xFFFF
andl %ebp, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2bf2(%rip), %xmm0     # 0xe070
mulsd 0x318a(%rip), %xmm0     # 0xe610
addsd 0x383a(%rip), %xmm0     # 0xecc8
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rsp)
callq 0x4510
andl %ebp, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2bc3(%rip), %xmm0     # 0xe070
mulsd 0x367b(%rip), %xmm0     # 0xeb30
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, 0x20(%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 0x20(%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 0x2b2c(%rip), %xmm0     # 0xe070
mulsd 0x35e4(%rip), %xmm0     # 0xeb30
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x20(%r14)
callq 0x4510
andl %ebp, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2b04(%rip), %xmm0     # 0xe070
mulsd 0x307c(%rip), %xmm0     # 0xe5f0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x2c(%r14)
movsd 0x36ba(%rip), %xmm0     # 0xec40
movsd %xmm0, 0x38(%r14)
movabsq $0x600000040, %rax      # imm = 0x600000040
movq %rax, (%r14)
movl $0x3, 0x8(%r14)
movq (%r12), %rax
movslq 0x2c(%rax), %rcx
cmpl 0x1c(%rax), %ecx
jge 0xb709
imulq $0x660, %rcx, %r14      # imm = 0x660
addq %rbx, %r14
leaq 0x370d(%rip), %r15      # 0xecd0
testb $0x1, 0x8(%r14)
jne 0xb6eb
callq 0x4510
movzwl %ax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2a8b(%rip), %xmm0     # 0xe070
xorl %eax, %eax
ucomisd 0x3699(%rip), %xmm0     # 0xec88
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 0x2a1e(%rip), %xmm0     # 0xe040
je 0xb653
callq 0x4510
movzwl %ax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x2a35(%rip), %xmm0     # 0xe070
mulsd 0x3695(%rip), %xmm0     # 0xecd8
addsd 0x3695(%rip), %xmm0     # 0xece0
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, (%rsp)
callq 0x4510
movzwl %ax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x2a01(%rip), %xmm1     # 0xe070
divsd %xmm1, %xmm0
mulsd 0x34b5(%rip), %xmm0     # 0xeb30
cvtsd2ss %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0xc(%rbx), %xmm1
movsd %xmm1, 0x10(%rsp)
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x20(%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 0x20(%rsp), %xmm0
callq 0x4590
mulsd (%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x10(%r14)
movl $0x0, 0x14(%r14)
movq (%r12), %rax
addq $0x660, %r14            # imm = 0x660
movslq 0x1c(%rax), %rcx
imulq $0x660, %rcx, %rcx      # imm = 0x660
addq %rbx, %rcx
cmpq %rcx, %r14
jb 0xb5c3
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3691(%rip), %rdi      # 0xedb0
jmp 0xb728
leaq 0x36b7(%rip), %rdi      # 0xeddf
callq 0x40c0
leaq 0x36d9(%rip), %rdi      # 0xee0d
callq 0x40c0
movl $0x1, %edi
callq 0x4110