// File: /workspace/github_c_makefile_star2_O2/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 %rdx, %r14
movq %rdi, %rbx
movl 0x96ee(%rip), %ecx      # 0x13910
incl %ecx
movl %ecx, 0x96e6(%rip)      # 0x13910
leaq 0x935f(%rip), %r12      # 0x13590
movq (%r12), %rax
movslq 0x1c(%rax), %rdx
imulq $0x660, %rdx, %r10      # imm = 0x660
addq %rdi, %r10
xorl %edx, %edx
movq %rdi, %r11
xorl %r9d, %r9d
xorl %edi, %edi
xorl %r8d, %r8d
xorl %ebp, %ebp
cmpq %r10, %r11
jae 0xa2a2
movzwl 0x8(%r11), %r15d
testw $0x119, %r15w           # imm = 0x119
je 0xa299
movl (%r11), %r15d
cmpl $0x40, %r15d
je 0xa297
cmpl $0x8, %r15d
je 0xa289
cmpl $0x10, %r15d
je 0xa293
cmpl $0x20, %r15d
je 0xa28e
cmpl $0x4, %r15d
jne 0xa299
incl %edx
jmp 0xa299
incl %r9d
jmp 0xa299
incl %r8d
jmp 0xa299
incl %edi
jmp 0xa299
incl %ebp
addq $0x660, %r11            # imm = 0x660
jmp 0xa252
testb $0x1, 0x8(%rbx)
je 0xa723
testl %esi, %esi
sete %r10b
addl %r9d, %edx
setne %r9b
orb %r10b, %r9b
je 0xa2d6
negl %r8d
xorl %r8d, %edi
orl %esi, %edi
jne 0xa723
cmpl 0x14(%rax), %edx
jl 0xa2e3
jmp 0xa723
addl %edi, %r8d
cmpl 0xc(%rax), %r8d
jge 0xa723
movslq 0x20(%rax), %rcx
imulq $0x660, %rcx, %rdx      # imm = 0x660
leaq (%rbx,%rdx), %r13
movslq 0x24(%rax), %rax
imulq $0x660, %rax, %rax      # imm = 0x660
leaq (%rbx,%rax), %rcx
subq %rdx, %rax
cmpq %rcx, %r13
jae 0xa324
movzwl 0x8(%r13), %edx
testw $0x119, %dx             # imm = 0x119
je 0xa324
addq $0x660, %r13            # imm = 0x660
addq $-0x660, %rax           # imm = 0xF9A0
jmp 0xa304
testq %rax, %rax
je 0xaa12
testl %esi, %esi
je 0xa4be
xorl %eax, %eax
callq 0x6d41
movl $0x9c40, %r15d          # imm = 0x9C40
movq %r15, 0x9257(%rip)      # 0x135a0
leaq 0x9248(%rip), %r8       # 0x13598
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x4100
xorl %eax, %eax
callq 0x6d41
movq %r15, 0x9235(%rip)      # 0x135a0
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
leaq 0x921e(%rip), %r8       # 0x13598
callq 0x4100
xorl %eax, %eax
callq 0x6d41
movq (%r12), %rax
movsd 0x384e(%rip), %xmm1     # 0xdbe0
movsd 0x3886(%rip), %xmm0     # 0xdc20
movsd %xmm0, (%rsp)
movss 0x3979(%rip), %xmm0     # 0xdd20
movaps %xmm0, 0x20(%rsp)
movss 0x3970(%rip), %xmm0     # 0xdd24
cmpl $0x0, 0x30(%rax)
jne 0xa45f
xorps %xmm0, %xmm0
cmpq $0x124f8, %r14          # imm = 0x124F8
jl 0xa3df
cvtsi2sd %r14, %xmm0
divsd 0x3851(%rip), %xmm0     # 0xdc28
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
callq 0x4520
movzwl %ax, %eax
cvtsi2sd %eax, %xmm0
divsd 0x2c78(%rip), %xmm0     # 0xd070
movsd 0x3830(%rip), %xmm1     # 0xdc30
movapd 0x10(%rsp), %xmm3
cmpltsd %xmm3, %xmm1
movsd 0x3825(%rip), %xmm2     # 0xdc38
andpd %xmm1, %xmm2
andnpd %xmm3, %xmm1
orpd %xmm1, %xmm2
ucomisd %xmm0, %xmm2
movsd 0x37b5(%rip), %xmm1     # 0xdbe0
movss 0x38f1(%rip), %xmm0     # 0xdd24
ja 0xa45f
movsd 0x37b3(%rip), %xmm1     # 0xdbf0
movsd 0x37fb(%rip), %xmm0     # 0xdc40
movsd %xmm0, (%rsp)
movss 0x38d6(%rip), %xmm0     # 0xdd28
movaps %xmm0, 0x20(%rsp)
movss 0x38cd(%rip), %xmm0     # 0xdd2c
movlps %xmm1, (%r13)
movss %xmm0, 0x14(%r13)
callq 0x4520
movl $0xffff, %r14d          # imm = 0xFFFF
andl %r14d, %eax
cvtsi2sd %eax, %xmm0
divsd 0x2bec(%rip), %xmm0     # 0xd070
mulsd (%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
callq 0x4520
andl %r14d, %eax
cvtsi2sd %eax, %xmm0
divsd 0x2bca(%rip), %xmm0     # 0xd070
ucomisd 0x379a(%rip), %xmm0     # 0xdc48
ja 0xa62c
movaps 0x10(%rsp), %xmm0
jmp 0xa638
cvtsi2sd %r14, %xmm0
movsd 0x3795(%rip), %xmm1     # 0xdc60
subsd %xmm0, %xmm1
divsd 0x3791(%rip), %xmm1     # 0xdc68
cvtsd2ss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movaps %xmm0, (%rsp)
callq 0x4520
movl $0xffff, %r14d          # imm = 0xFFFF
andl %r14d, %eax
cvtsi2sd %eax, %xmm0
divsd 0x2b73(%rip), %xmm0     # 0xd070
movapd (%rsp), %xmm3
movapd %xmm3, %xmm1
cmpltsd 0x3761(%rip), %xmm1     # 0xdc70
movsd 0x3729(%rip), %xmm2     # 0xdc40
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 0x4520
andl %r14d, %eax
cvtsi2sd %eax, %xmm0
divsd 0x2b19(%rip), %xmm0     # 0xd070
mulsd 0x3719(%rip), %xmm0     # 0xdc78
addsd 0x3719(%rip), %xmm0     # 0xdc80
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rsp)
callq 0x4520
andl %r14d, %eax
cvtsi2sd %eax, %xmm0
divsd 0x2aec(%rip), %xmm0     # 0xd070
mulsd 0x3564(%rip), %xmm0     # 0xdaf0
cvtsd2ss %xmm0, %xmm0
cvtss2sd 0xc(%rbx), %xmm1
movsd %xmm1, 0x10(%rsp)
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)
cvtss2sd 0x10(%rbx), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x20(%rsp), %xmm0
callq 0x45a0
mulsd (%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x10(%r13)
andl $0x0, 0x14(%r13)
callq 0x4520
andl %r14d, %eax
cvtsi2sd %eax, %xmm0
divsd 0x2a63(%rip), %xmm0     # 0xd070
mulsd 0x34db(%rip), %xmm0     # 0xdaf0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x20(%r13)
movl $0x3, 0x8(%r13)
jmp 0xa70b
movaps 0x10(%rsp), %xmm0
xorps 0x29d8(%rip), %xmm0     # 0xd010
addss 0x20(%rbx), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
callq 0x41e0
movaps %xmm0, 0x10(%rsp)
movsd 0x30(%rsp), %xmm0
callq 0x45a0
movaps 0x20(%rsp), %xmm3
movaps %xmm3, %xmm1
xorps 0x29a5(%rip), %xmm1     # 0xd010
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 0x4520
andl %r14d, %eax
cvtsi2sd %eax, %xmm0
movsd 0x29cc(%rip), %xmm1     # 0xd070
divsd %xmm1, %xmm0
mulsd 0x35a0(%rip), %xmm0     # 0xdc50
divsd (%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movaps %xmm0, (%rsp)
callq 0x4520
andl %r14d, %eax
cvtsi2sd %eax, %xmm0
divsd 0x299f(%rip), %xmm0     # 0xd070
ucomisd 0x356f(%rip), %xmm0     # 0xdc48
ja 0xa6e1
movaps (%rsp), %xmm1
jmp 0xa6ec
movaps (%rsp), %xmm1
xorps 0x2924(%rip), %xmm1     # 0xd010
cvtss2sd 0x20(%rbx), %xmm0
addsd 0x355f(%rip), %xmm0     # 0xdc58
cvtss2sd %xmm1, %xmm1
addsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x20(%r13)
movsd 0x33bd(%rip), %xmm0     # 0xdad0
movsd %xmm0, 0x38(%r13)
movl 0x91f1(%rip), %ecx      # 0x13910
movq (%r12), %rax
cmpl $0x3e9, %ecx            # imm = 0x3E9
jl 0xa8ac
cmpl 0x8(%rax), %ebp
jge 0xa8ac
movslq 0x24(%rax), %rcx
imulq $0x660, %rcx, %rdx      # imm = 0x660
leaq (%rbx,%rdx), %r14
movslq 0x28(%rax), %rax
imulq $0x660, %rax, %rax      # imm = 0x660
leaq (%rbx,%rax), %rcx
subq %rdx, %rax
cmpq %rcx, %r14
jae 0xa779
movzwl 0x8(%r14), %edx
testw $0x119, %dx             # imm = 0x119
je 0xa779
addq $0x660, %r14            # imm = 0x660
addq $-0x660, %rax           # imm = 0xF9A0
jmp 0xa759
testq %rax, %rax
je 0xaa09
callq 0x4520
movl $0xffff, %ebp           # imm = 0xFFFF
andl %ebp, %eax
cvtsi2sd %eax, %xmm0
divsd 0x28d6(%rip), %xmm0     # 0xd070
mulsd 0x2e3e(%rip), %xmm0     # 0xd5e0
addsd 0x34de(%rip), %xmm0     # 0xdc88
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rsp)
callq 0x4520
andl %ebp, %eax
cvtsi2sd %eax, %xmm0
divsd 0x28aa(%rip), %xmm0     # 0xd070
mulsd 0x3322(%rip), %xmm0     # 0xdaf0
cvtsd2ss %xmm0, %xmm0
cvtss2sd 0xc(%rbx), %xmm1
movsd %xmm1, 0x10(%rsp)
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)
cvtss2sd 0x10(%rbx), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x20(%rsp), %xmm0
callq 0x45a0
mulsd (%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x10(%r14)
andl $0x0, 0x14(%r14)
callq 0x4520
andl %ebp, %eax
cvtsi2sd %eax, %xmm0
divsd 0x2822(%rip), %xmm0     # 0xd070
mulsd 0x329a(%rip), %xmm0     # 0xdaf0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x20(%r14)
callq 0x4520
andl %ebp, %eax
cvtsi2sd %eax, %xmm0
divsd 0x27fd(%rip), %xmm0     # 0xd070
mulsd 0x2d45(%rip), %xmm0     # 0xd5c0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x2c(%r14)
movsd 0x3373(%rip), %xmm0     # 0xdc00
movsd %xmm0, 0x38(%r14)
movabsq $0x600000040, %rax      # imm = 0x600000040
movq %rax, (%r14)
movl $0x3, 0x8(%r14)
movq (%r12), %rax
movslq 0x2c(%rax), %rcx
imulq $0x660, %rcx, %r14      # imm = 0x660
addq %rbx, %r14
leaq 0x33cf(%rip), %r15      # 0xdc90
movslq 0x1c(%rax), %rcx
imulq $0x660, %rcx, %rcx      # imm = 0x660
addq %rbx, %rcx
cmpq %rcx, %r14
jae 0xa9fa
testb $0x1, 0x8(%r14)
jne 0xa9ee
callq 0x4520
movzwl %ax, %eax
cvtsi2sd %eax, %xmm0
divsd 0x2779(%rip), %xmm0     # 0xd070
xorl %eax, %eax
ucomisd 0x3347(%rip), %xmm0     # 0xdc48
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 0x270c(%rip), %xmm0     # 0xd040
je 0xa962
callq 0x4520
movzwl %ax, %eax
cvtsi2sd %eax, %xmm0
divsd 0x2726(%rip), %xmm0     # 0xd070
mulsd 0x3346(%rip), %xmm0     # 0xdc98
addsd 0x3346(%rip), %xmm0     # 0xdca0
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, (%rsp)
callq 0x4520
movzwl %ax, %eax
cvtsi2sd %eax, %xmm0
movsd 0x26f5(%rip), %xmm1     # 0xd070
divsd %xmm1, %xmm0
mulsd 0x3169(%rip), %xmm0     # 0xdaf0
cvtsd2ss %xmm0, %xmm0
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)
cvtss2sd 0x10(%rbx), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x20(%rsp), %xmm0
callq 0x45a0
mulsd (%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x10(%r14)
andl $0x0, 0x14(%r14)
movq (%r12), %rax
addq $0x660, %r14            # imm = 0x660
jmp 0xa8c1
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3360(%rip), %rdi      # 0xdd70
jmp 0xaa19
leaq 0x3386(%rip), %rdi      # 0xdd9f
callq 0x40c0
leaq 0x33a8(%rip), %rdi      # 0xddcd
callq 0x40c0
pushq $0x1
popq %rdi
callq 0x4110