// File: /workspace/github_c_makefile_star2_O1/hyc[P]trek73c/trekx.c
// Function: Execute
void Execute()
{
  int I, I0, J, N1, N2;
  boolean Ok;
  double Rn;
  int FORLIM;
  Srec *WITH;

  FORLIM = (long)(SimTim / Iter);
  for (I = 0; I < FORLIM; I++) {
    for (J = 0; J < ObjCount; J++) {
      if (Objects[J] != NULL) {
	I0 = Objects[J]->ObTyp;
	if (I0 < 10) {
	  if (Ships[J]->Crew > 0) {
	    if (I < Phasers)
	      PhaserFire(J);
	    if (I < Tubes)
	      Torpfire(J);
	  }
	}
	Antimatter(J);
	if (Objects[J] != NULL)
	  Movem(J);
      }
    }
  }
  for (I = 0; I <= Enemies; I++) {
    if (Ships[I] != NULL) {
      Distrib(I, 2.0);
      for (J = 0; J < Phasers; J++) {
	if (Ships[I]->Pstat[J] >= 0)
	  TrakPhas(I, J);
      }
      for (J = 0; J < Tubes; J++) {
	if (Ships[I]->Tstat[J] >= 0)
	  TrakTorp(I, J);
      }
    }
  }
  TCount = (-1);
  if (Ships[0] != NULL) {
    I0 = (long)floor((10000 - Objects[0]->Tim_Del) * Iter + 0.5);
    if (I0 != 0 && I0 <= 15) {
      sprintf(scrstr,"Computer: %d seconds to self-destruct.\n", I0);
      SEndln();
    }
  }
  /*
   * Fuses, bluffs, surrenders
   */
  for (I = 0; I <= 3; I++) {
    if (Ct[I] != 0)
      Ct[I]++;
  }
  N1 = 0;
  N2 = 0;
  Win = 0;
  /*
   * Federation disposition
   */
  if ((Ships[0] == NULL) || (Ships[0]->Crew == 0))
    Win = 1;
  else {
    WITH = Ships[0];
    Ok = false;
    if ((WITH->Regen > 1) ||
       ((!WITH->Dmge[(int)Warp] || !WITH->Dmge[(int)Prob]) &&
	Objects[0]->Fuel > 10)) {
      Ok = true;
    } else {
      for (I = 0; I < Phasers; I++) {
        if (WITH->PChrg[I] > 0) {
	  Ok = true; break;
        }
      }
      for (I = 0; (I < Tubes) && !Ok; I++) {
        if (WITH->Tengy[I] > 0) {
	  Ok = true; break;
        }
      }
    }
    if (!Ok)
      Win = 1;
  }
  /*
   * Enemy disposition
   */
  for (I = 1; I <= Enemies; I++) {
    if ((Ships[I] == NULL) || (Ships[I]->Crew == 0)) {
      N1++;
      continue;
    }
    Rn = Range(I, 0);
    if (((Rn > 3500) && Ships[I]->Dmge[(long)Warp]) ||
	((Rn > 20000) && (Objects[0]->Tim_Del > 100))) {
      N2++;
      continue;
    }
    if (Objects[I]->Fuel > 10)
      continue;
    Ok = false;
    for (J = 0; J < Phasers; J++) {
      if (Ships[I]->PChrg[J] > 0) {
	    Ok = true;
	    break;
      }
    }
    if (Ok)
      continue;
    for (J = 0; J < Tubes; J++) {
      if (Ships[I]->Tengy[J] > 0) {
	    Ok = true;
	    break;
      }
    }
    if (!Ok)
      N1++;
  }

  /* Don't quit on all disabled... */
  if (cheat)
    N2 = 0;

  switch (Win) {

  case 0:
    if (N1 == Enemies)
      Win = 2;
    else if (N1 + N2 == Enemies)
      Win = 3;
    break;

  case 1:
    if (N1 == Enemies)
      Win = 6;		/* Nobody won */
/*    else if (N1 + N2 < Enemies)
      Win = 5;		/* No special case needed */
    break;
  }
  if (Win > 0)
    Ender();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movsd 0xcc87(%rip), %xmm0     # 0x131b8
divsd 0xcc77(%rip), %xmm0     # 0x131b0
cvttsd2si %xmm0, %r14
leaq 0xd0ab(%rip), %r15      # 0x135f0
leaq 0xd444(%rip), %r12      # 0x13990
testl %r14d, %r14d
jle 0x65dd
xorl %r13d, %r13d
cmpb $0x0, 0xd083(%rip)      # 0x135e2
je 0x65d1
xorl %ebp, %ebp
xorl %ebx, %ebx
movq (%rbp,%r15), %rax
testq %rax, %rax
je 0x65be
cmpw $0x9, 0x4a(%rax)
jg 0x65a8
movq (%rbp,%r12), %rax
cmpw $0x0, 0x1a(%rax)
jle 0x65a8
movzbl 0xcc37(%rip), %eax      # 0x131c0
cmpl %eax, %r13d
jae 0x6595
movl %ebx, %edi
callq 0x4cfc
movzbl 0xcc25(%rip), %eax      # 0x131c1
cmpl %eax, %r13d
jae 0x65a8
movl %ebx, %edi
callq 0x51a9
movl %ebx, %edi
callq 0x57eb
cmpq $0x0, (%rbp,%r15)
je 0x65be
movl %ebx, %edi
callq 0x597a
incq %rbx
movzbl 0xd01a(%rip), %eax      # 0x135e2
addq $0x8, %rbp
cmpq %rax, %rbx
jb 0x6565
incl %r13d
cmpl %r14d, %r13d
jne 0x6558
xorl %ebx, %ebx
cmpq $0x0, (%r12,%rbx,8)
je 0x665f
movl %ebx, %edi
movsd 0x6af0(%rip), %xmm0     # 0xd0e0
callq 0x4339
cmpb $0x0, 0xcbc4(%rip)      # 0x131c0
je 0x662a
xorl %r14d, %r14d
movq (%r12,%rbx,8), %rax
cmpw $0x0, 0xd2(%rax,%r14,2)
js 0x661b
movl %ebx, %edi
movl %r14d, %esi
callq 0x4977
incq %r14
movzbl 0xcb9b(%rip), %eax      # 0x131c0
cmpq %rax, %r14
jb 0x6601
cmpb $0x0, 0xcb90(%rip)      # 0x131c1
je 0x665f
xorl %r14d, %r14d
movq (%r12,%rbx,8), %rax
cmpw $0x0, 0x110(%rax,%r14,2)
js 0x6650
movl %ebx, %edi
movl %r14d, %esi
callq 0x5030
incq %r14
movzbl 0xcb67(%rip), %eax      # 0x131c1
cmpq %rax, %r14
jb 0x6636
leaq 0x1(%rbx), %rax
movzbl 0xcf76(%rip), %ecx      # 0x135e0
cmpq %rcx, %rbx
movq %rax, %rbx
jb 0x65df
movl $0xffffffff, 0xd3b8(%rip) # imm = 0xFFFFFFFF
cmpq $0x0, 0xd308(%rip)      # 0x13990
je 0x66f8
movq 0xcf5f(%rip), %rax      # 0x135f0
movsd 0x6a2f(%rip), %xmm0     # 0xd0c8
subsd 0x30(%rax), %xmm0
mulsd 0xcb0a(%rip), %xmm0     # 0x131b0
addsd 0x699a(%rip), %xmm0     # 0xd048
callq 0x22d0
cvttsd2si %xmm0, %rdx
testl %edx, %edx
sete %al
cmpl $0x10, %edx
setge %cl
orb %al, %cl
jne 0x66f8
leaq 0xcde2(%rip), %rbx      # 0x134b0
leaq 0x7e99(%rip), %rsi      # 0xe56e
movq %rbx, %rdi
xorl %eax, %eax
callq 0x21a0
movq 0xd312(%rip), %rdi      # 0x139f8
movq %rbx, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2210
callq 0x3c58
xorl %eax, %eax
leaq 0xcee3(%rip), %rcx      # 0x135e4
movb (%rax,%rcx), %dl
testb %dl, %dl
je 0x670d
incb %dl
movb %dl, (%rax,%rcx)
incq %rax
cmpq $0x4, %rax
jne 0x6701
movb $0x0, 0xcecb(%rip)      # 0x135e8
movq 0xd26c(%rip), %rcx      # 0x13990
testq %rcx, %rcx
je 0x680a
cmpw $0x0, 0x1a(%rcx)
je 0x680a
movsd (%rcx), %xmm0
movb $0x1, %al
ucomisd 0x691a(%rip), %xmm0     # 0xd060
ja 0x6806
cmpb $0x0, 0xc3(%rcx)
je 0x675e
cmpb $0x0, 0xc2(%rcx)
jne 0x6778
movq 0xce8b(%rip), %rdx      # 0x135f0
movsd 0x20(%rdx), %xmm0
ucomisd 0x6896(%rip), %xmm0     # 0xd008
ja 0x6806
movzbl 0xca41(%rip), %edi      # 0x131c0
testq %rdi, %rdi
sete %sil
je 0x67bc
movsd 0x20(%rcx), %xmm1
movb $0x1, %dl
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
ja 0x67cc
leaq -0x1(%rdi), %rdx
xorl %r8d, %r8d
movq %r8, %rsi
cmpq %r8, %rdx
je 0x67c0
movsd 0x28(%rcx,%rsi,8), %xmm1
leaq 0x1(%rsi), %r8
ucomisd %xmm0, %xmm1
jbe 0x67a0
movb $0x1, %dl
jmp 0x67c2
xorl %edx, %edx
jmp 0x67cc
xorl %edx, %edx
incq %rsi
cmpq %rdi, %rsi
setae %sil
movzbl 0xc9ee(%rip), %edi      # 0x131c1
testq %rdi, %rdi
sete %r8b
xorb $0x1, %sil
orb %sil, %r8b
jne 0x6804
movl $0x63, %r8d
cmpw $0x0, (%rcx,%r8,2)
jg 0x6806
leaq -0x62(%r8), %r9
cmpq %rdi, %r9
setae %r9b
incq %r8
orb %sil, %r9b
je 0x67e9
movl %edx, %eax
testb %al, %al
jne 0x6811
movb $0x1, 0xcdd7(%rip)      # 0x135e8
movb 0xcdc9(%rip), %al       # 0x135e0
xorl %ebx, %ebx
movl $0x0, %ebp
movl $0x0, %r14d
testb %al, %al
je 0x699a
xorl %r14d, %r14d
movl $0x1, %r13d
movsd 0x67fb(%rip), %xmm2     # 0xd038
movsd 0x68a3(%rip), %xmm3     # 0xd0e8
movsd 0x68a3(%rip), %xmm4     # 0xd0f0
xorpd %xmm5, %xmm5
xorl %ebp, %ebp
movq (%r12,%r13,8), %rax
testq %rax, %rax
je 0x68a3
cmpw $0x0, 0x1a(%rax)
je 0x68a3
movq 0xcd86(%rip), %rax      # 0x135f0
movapd %xmm2, %xmm0
testq %rax, %rax
je 0x68cb
movsd 0x38(%rax), %xmm0
movq (%r15,%r13,8), %rcx
subsd 0x38(%rcx), %xmm0
movsd 0x40(%rcx), %xmm1
subsd 0x40(%rax), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd %xmm5, %xmm0
jb 0x68aa
sqrtsd %xmm0, %xmm0
jmp 0x68cb
incl %ebp
jmp 0x6983
callq 0x22f0
xorpd %xmm5, %xmm5
movsd 0x6835(%rip), %xmm4     # 0xd0f0
movsd 0x6825(%rip), %xmm3     # 0xd0e8
movsd 0x676d(%rip), %xmm2     # 0xd038
ucomisd %xmm3, %xmm0
jbe 0x68de
movq (%r12,%r13,8), %rax
cmpb $0x0, 0xc3(%rax)
jne 0x68fa
ucomisd %xmm4, %xmm0
jbe 0x6902
movq 0xcd05(%rip), %rax      # 0x135f0
movsd 0x30(%rax), %xmm0
ucomisd 0x6798(%rip), %xmm0     # 0xd090
jbe 0x6902
incl %r14d
jmp 0x6983
movq (%r15,%r13,8), %rax
movsd 0x20(%rax), %xmm0
ucomisd 0x66f5(%rip), %xmm0     # 0xd008
ja 0x6983
movzbl 0xc8a4(%rip), %eax      # 0x131c0
testq %rax, %rax
je 0x693b
movq (%r12,%r13,8), %rcx
xorl %edx, %edx
movsd 0x20(%rcx,%rdx,8), %xmm0
ucomisd %xmm5, %xmm0
ja 0x6983
incq %rdx
cmpq %rdx, %rax
jne 0x6927
movzbl 0xc87f(%rip), %eax      # 0x131c1
testq %rax, %rax
sete %dl
je 0x697e
movq (%r12,%r13,8), %rcx
cmpw $0x0, 0xc6(%rcx)
jg 0x697e
leaq -0x1(%rax), %rdx
xorl %edi, %edi
movq %rdi, %rsi
cmpq %rdi, %rdx
je 0x6975
leaq 0x1(%rsi), %rdi
cmpw $0x0, 0xc8(%rcx,%rsi,2)
jle 0x695e
incq %rsi
cmpq %rax, %rsi
setae %dl
movzbl %dl, %eax
addl %eax, %ebp
leaq 0x1(%r13), %rcx
movzbl 0xcc52(%rip), %eax      # 0x135e0
cmpq %rax, %r13
movq %rcx, %r13
jb 0x6853
movzbl %al, %eax
cmpb $0x0, 0xcc2c(%rip)      # 0x135d0
cmovel %r14d, %ebx
movzbl 0xcc39(%rip), %ecx      # 0x135e8
cmpl $0x1, %ecx
je 0x69c8
testl %ecx, %ecx
jne 0x69d4
movb $0x2, %cl
cmpl %eax, %ebp
je 0x69ce
addl %ebp, %ebx
movb $0x3, %cl
cmpl %eax, %ebx
je 0x69ce
jmp 0x69d4
movb $0x6, %cl
cmpl %eax, %ebp
jne 0x69d4
movb %cl, 0xcc14(%rip)       # 0x135e8
cmpb $0x0, 0xcc0d(%rip)      # 0x135e8
je 0x69f0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5f2d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq