// File: /workspace/github_c_makefile_star2_O2/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
subq $0x28, %rsp
movsd 0xc8d3(%rip), %xmm0     # 0x121a8
divsd 0xc8c3(%rip), %xmm0     # 0x121a0
cvttsd2si %xmm0, %r14
xorl %r13d, %r13d
testl %r14d, %r14d
cmovlel %r13d, %r14d
leaq 0xcced(%rip), %r15      # 0x125e0
leaq 0xd086(%rip), %r12      # 0x12980
cmpl %r14d, %r13d
je 0x5976
xorl %ebp, %ebp
xorl %ebx, %ebx
movzbl 0xccc8(%rip), %eax      # 0x125d2
cmpq %rax, %rbx
jae 0x5971
movq (%rbp,%r15), %rax
testq %rax, %rax
je 0x5968
cmpw $0x9, 0x4a(%rax)
jg 0x5952
movq (%rbp,%r12), %rax
cmpw $0x0, 0x1a(%rax)
jle 0x5952
movzbl 0xc87d(%rip), %eax      # 0x121b0
cmpl %eax, %r13d
jae 0x593f
movl %ebx, %edi
callq 0x46b1
movzbl 0xc86b(%rip), %eax      # 0x121b1
cmpl %eax, %r13d
jae 0x5952
movl %ebx, %edi
callq 0x4a40
movl %ebx, %edi
callq 0x4f0c
cmpq $0x0, (%rbp,%r15)
je 0x5968
movl %ebx, %edi
callq 0x5003
incq %rbx
addq $0x8, %rbp
jmp 0x5903
incl %r13d
jmp 0x58fa
xorl %ebx, %ebx
movzbl 0xcc51(%rip), %eax      # 0x125d0
cmpq %rax, %rbx
ja 0x5a12
cmpq $0x0, (%r12,%rbx,8)
je 0x5a0a
movl %ebx, %edi
movsd 0x574f(%rip), %xmm0     # 0xb0e8
callq 0x3f26
movb 0xc80c(%rip), %al       # 0x121b0
xorl %r14d, %r14d
movzbl %al, %ecx
cmpq %rcx, %r14
jae 0x59d4
movq (%r12,%rbx,8), %rcx
cmpw $0x0, 0xd2(%rcx,%r14,2)
js 0x59cf
movl %ebx, %edi
movl %r14d, %esi
callq 0x4474
movb 0xc7e1(%rip), %al       # 0x121b0
incq %r14
jmp 0x59a7
movb 0xc7d7(%rip), %al       # 0x121b1
xorl %r14d, %r14d
movzbl %al, %ecx
cmpq %rcx, %r14
jae 0x5a0a
movq (%r12,%rbx,8), %rcx
cmpw $0x0, 0x110(%rcx,%r14,2)
js 0x5a05
movl %ebx, %edi
movl %r14d, %esi
callq 0x495b
movb 0xc7ac(%rip), %al       # 0x121b1
incq %r14
jmp 0x59dd
incq %rbx
jmp 0x5978
orl $-0x1, 0xd00f(%rip)     # 0x12a28
cmpq $0x0, 0xcf5f(%rip)      # 0x12980
je 0x5a7a
movq 0xcbb6(%rip), %rax      # 0x125e0
movsd 0x569e(%rip), %xmm0     # 0xb0d0
subsd 0x30(%rax), %xmm0
mulsd 0xc761(%rip), %xmm0     # 0x121a0
addsd 0x5601(%rip), %xmm0     # 0xb048
callq 0x22c0
cvttsd2si %xmm0, %rdx
testl %edx, %edx
sete %al
cmpl $0x10, %edx
setge %cl
orb %al, %cl
jne 0x5a7a
leaq 0xca39(%rip), %rdi      # 0x124a0
leaq 0x6b40(%rip), %rsi      # 0xc5ae
xorl %eax, %eax
callq 0x2190
callq 0x399b
xorl %eax, %eax
leaq 0xcb50(%rip), %rcx      # 0x125d3
cmpq $0x4, %rax
je 0x5a9a
movb (%rax,%rcx), %dl
testb %dl, %dl
je 0x5a95
incb %dl
movb %dl, (%rax,%rcx)
incq %rax
jmp 0x5a83
movb $0x0, 0xcb36(%rip)      # 0x125d7
movq 0xced8(%rip), %rax      # 0x12980
testq %rax, %rax
je 0x5b40
cmpw $0x0, 0x1a(%rax)
je 0x5b40
movsd (%rax), %xmm0
ucomisd 0x5548(%rip), %xmm0     # 0xb010
ja 0x5b39
cmpb $0x0, 0xc3(%rax)
je 0x5adc
cmpb $0x0, 0xc2(%rax)
jne 0x5af2
movq 0xcafd(%rip), %rcx      # 0x125e0
movsd 0x20(%rcx), %xmm0
ucomisd 0x5518(%rip), %xmm0     # 0xb008
ja 0x5b39
movzbl 0xc6b7(%rip), %ecx      # 0x121b0
xorl %esi, %esi
xorpd %xmm0, %xmm0
movq %rsi, %rdx
cmpq %rsi, %rcx
je 0x5b17
movsd 0x20(%rax,%rdx,8), %xmm1
leaq 0x1(%rdx), %rsi
ucomisd %xmm0, %xmm1
jbe 0x5aff
cmpq %rcx, %rdx
jb 0x5b39
movzbl 0xc68e(%rip), %ecx      # 0x121b1
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x5b40
cmpw $0x0, 0xc6(%rax,%rdx,2)
leaq 0x1(%rdx), %rdx
jle 0x5b25
movb $0x1, %al
movl %eax, (%rsp)
jmp 0x5b4e
movb $0x1, 0xca90(%rip)      # 0x125d7
movl $0x0, (%rsp)
movzbl 0xca7b(%rip), %eax      # 0x125d0
movq 0xca84(%rip), %rcx      # 0x125e0
movq %rcx, 0x18(%rsp)
movzbl 0xc648(%rip), %edi      # 0x121b0
movzbl 0xc641(%rip), %r13d     # 0x121b1
movq %rax, 0x10(%rsp)
incq %rax
xorl %r14d, %r14d
pushq $0x1
popq %rbx
movl $0x0, 0x4(%rsp)
movq %rdi, 0x20(%rsp)
movq %rax, 0x8(%rsp)
cmpq %rax, %rbx
je 0x5c4f
movq (%r12,%rbx,8), %rbp
testq %rbp, %rbp
je 0x5be9
cmpw $0x0, 0x1a(%rbp)
je 0x5be9
movl %ebx, %edi
xorl %esi, %esi
callq 0x3ae6
ucomisd 0x5536(%rip), %xmm0     # 0xb0f0
jbe 0x5bc5
cmpb $0x0, 0xc3(%rbp)
jne 0x5be3
ucomisd 0x552b(%rip), %xmm0     # 0xb0f8
jbe 0x5bee
movq 0x18(%rsp), %rax
movsd 0x30(%rax), %xmm0
ucomisd 0x548f(%rip), %xmm0     # 0xb070
jbe 0x5bee
incl 0x4(%rsp)
jmp 0x5c42
incl %r14d
jmp 0x5c47
movq (%r15,%rbx,8), %rax
movsd 0x20(%rax), %xmm0
ucomisd 0x5409(%rip), %xmm0     # 0xb008
movq 0x20(%rsp), %rdi
xorpd %xmm1, %xmm1
ja 0x5c42
xorl %eax, %eax
cmpq %rax, %rdi
je 0x5c22
movsd 0x20(%rbp,%rax,8), %xmm0
incq %rax
ucomisd %xmm1, %xmm0
jbe 0x5c0c
jmp 0x5c42
xorl %ecx, %ecx
movq %rcx, %rax
cmpq %rcx, %r13
je 0x5c3b
leaq 0x1(%rax), %rcx
cmpw $0x0, 0xc6(%rbp,%rax,2)
jle 0x5c24
cmpq %r13, %rax
sbbl $-0x1, %r14d
movq 0x8(%rsp), %rax
incq %rbx
jmp 0x5b90
xorl %eax, %eax
cmpb $0x0, 0xc968(%rip)      # 0x125c0
cmovel 0x4(%rsp), %eax
cmpb $0x0, (%rsp)
je 0x5c87
movb $0x2, %cl
movq 0x10(%rsp), %rdx
cmpl %edx, %r14d
je 0x5c90
addl %r14d, %eax
movb $0x3, %cl
cmpl %edx, %eax
je 0x5c90
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x6, %cl
cmpl 0x10(%rsp), %r14d
jne 0x5c96
movb %cl, 0xc941(%rip)       # 0x125d7
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x53a1