// File: /workspace/github_c_makefile_star2_O2/hyc[P]trek73c/trekx.c
// Function: Movem
void Movem(i)
int i;
{
  uchar Otp;
  double Accel, Crs1, Rate, Turn, Temp;
  reg Object *WITH;

  WITH = Objects[i];
  Otp = WITH->ObTyp / 10;
  if (!Otp) {
    if (Ships[i]->Crew == 0)
      WITH->Des_Spd = 0.0;
    if (Ships[i]->Dmge[(long)Comp])
      WITH->Trgt = 0;
    if (Ships[i]->Dmge[(long)Warp])
      Nowarp(i);
    if (fabs(WITH->Des_Spd) >= 1) {
      WITH->Fuel -= fabs(WITH->Des_Spd) * Ships[i]->Weff * Iter;
      if (WITH->Fuel <= 0) {
	WITH->Fuel = 0.0;
	WITH->Des_Spd = 0.0;
	Endln();
	sprintf(scrstr,"%s's warp drive shutting down.", Snams[i]);
	SEndln();
	Nowarp(i);
      }
    }
  }
  WITH = Objects[i];
  if (!Otp) {
    if (WITH->Trgt != 0) {
      WITH->Des_Crs = Bearing(i, abs(WITH->Trgt)-1);
      if (WITH->Trgt < 0)
	WITH->Des_Crs = RMod(WITH->Des_Crs + 180);
    }
    if (WITH->Des_Crs != WITH->Act_Crs) {
      Crs1 = RMod(WITH->Des_Crs - WITH->Act_Crs);
      if (Crs1 >= 180)
	Crs1 -= 360;
      Rate = 10.0;
      if (i > 0)
	Rate = 12.0;
      Turn = (Rate - fabs(WITH->Act_Spd)) * 5 * Iter;
      if (Ships[i]->Dmge[(long)Warp])
	Turn /= 2;
      Temp = fabs(Crs1);
      if (Temp > Turn)
	Temp = Turn;
      Temp = Sign(Crs1) * Temp;
      WITH->Act_Crs = RMod(WITH->Act_Crs + Temp);
    }
  }
  if (Otp < 2) {
    Accel = WITH->Des_Spd - WITH->Act_Spd;
    WITH->Act_Spd += Sign(Accel) * sqrt(fabs(Accel)) * Iter;
  } else if (Otp == 2) {
    if (WITH->Trgt > 0)
      WITH->Act_Crs = Bearing(i, WITH->Trgt-1);
  }
  WITH->Act_Crs = RMod(WITH->Act_Crs);
  Crs1 = Radians(WITH->Act_Crs);
  WITH->XPos += WITH->Act_Spd * cos(Crs1) * Iter * 100;
  WITH->YPos -= WITH->Act_Spd * sin(Crs1) * Iter * 100;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %edi, %ebx
movslq %edi, %r15
leaq 0xd5c4(%rip), %r13      # 0x125e0
movq (%r13,%r15,8), %r14
movzwl 0x4a(%r14), %eax
cwtd
movw $0xa, %cx
idivw %cx
testb %al, %al
je 0x5054
cmpb $0x2, %al
je 0x514f
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x52ac
movsd 0xd151(%rip), %xmm5     # 0x121a0
jmp 0x525b
leaq 0xd925(%rip), %r12      # 0x12980
movq (%r12,%r15,8), %rax
cmpw $0x0, 0x1a(%rax)
jne 0x506b
andq $0x0, 0x8(%r14)
cmpb $0x0, 0xc0(%rax)
je 0x507a
andw $0x0, 0x48(%r14)
cmpb $0x0, 0xc3(%rax)
je 0x508a
movl %ebx, %edi
callq 0x534b
movsd 0x8(%r14), %xmm0
andpd 0x61a8(%rip), %xmm0     # 0xb240
ucomisd 0x5f70(%rip), %xmm0     # 0xb010
jb 0x5108
movq (%r12,%r15,8), %rax
mulsd 0x8(%rax), %xmm0
movsd 0x20(%r14), %xmm1
mulsd 0xd0e7(%rip), %xmm0     # 0x121a0
subsd %xmm0, %xmm1
movsd %xmm1, 0x20(%r14)
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jb 0x5108
andq $0x0, 0x20(%r14)
andq $0x0, 0x8(%r14)
callq 0x3933
leaq 0xd83d(%rip), %rax      # 0x12920
movq (%rax,%r15,8), %rdx
leaq 0xd3b2(%rip), %rdi      # 0x124a0
leaq 0x6fbd(%rip), %rsi      # 0xc0b2
xorl %eax, %eax
callq 0x2190
callq 0x399b
movl %ebx, %edi
callq 0x534b
movq (%r13,%r15,8), %r14
movzwl 0x48(%r14), %eax
testw %ax, %ax
je 0x5170
movl %eax, %ecx
negw %cx
cmovsw %ax, %cx
movzwl %cx, %esi
decl %esi
movl %ebx, %edi
callq 0x3a49
movsd %xmm0, 0x18(%r14)
cmpw $0x0, 0x48(%r14)
jns 0x5176
addsd 0x5ede(%rip), %xmm0     # 0xb020
callq 0x39cd
movsd %xmm0, 0x18(%r14)
jmp 0x5176
movswl 0x48(%r14), %esi
testl %esi, %esi
jle 0x52ac
decl %esi
movl %ebx, %edi
callq 0x3a49
movsd %xmm0, 0x10(%r14)
jmp 0x52ac
movsd 0x18(%r14), %xmm0
movsd 0x10(%r14), %xmm1
ucomisd %xmm1, %xmm0
movsd 0xd018(%rip), %xmm5     # 0x121a0
jne 0x5190
jnp 0x525b
movsd %xmm1, (%rsp)
subsd %xmm1, %xmm0
movsd %xmm5, 0x8(%rsp)
callq 0x39cd
movsd 0x5e84(%rip), %xmm2     # 0xb030
addsd %xmm0, %xmm2
movsd 0x5e68(%rip), %xmm1     # 0xb020
cmpnlesd %xmm0, %xmm1
andpd %xmm1, %xmm0
andnpd %xmm2, %xmm1
orpd %xmm0, %xmm1
xorl %eax, %eax
testl %ebx, %ebx
setg %al
leaq 0x6079(%rip), %rcx      # 0xb250
movsd (%rcx,%rax,8), %xmm0
movsd (%r14), %xmm3
movapd 0x6057(%rip), %xmm2     # 0xb240
andpd %xmm2, %xmm3
subsd %xmm3, %xmm0
mulsd 0x5edf(%rip), %xmm0     # 0xb0d8
mulsd 0x8(%rsp), %xmm0
movq (%r12,%r15,8), %rax
cmpb $0x0, 0xc3(%rax)
je 0x5214
mulsd 0x5e34(%rip), %xmm0     # 0xb048
andpd %xmm1, %xmm2
minsd %xmm2, %xmm0
movapd 0x5fcc(%rip), %xmm2     # 0xb1f0
xorpd %xmm0, %xmm2
xorpd %xmm3, %xmm3
cmpltsd %xmm3, %xmm1
movapd %xmm1, %xmm3
andnpd %xmm0, %xmm3
andpd %xmm2, %xmm1
orpd %xmm3, %xmm1
movsd (%rsp), %xmm0
addsd %xmm1, %xmm0
callq 0x39cd
movsd %xmm0, 0x10(%r14)
movsd 0x8(%rsp), %xmm5
movsd (%r14), %xmm0
movsd 0x8(%r14), %xmm1
subsd %xmm0, %xmm1
movapd 0x5fce(%rip), %xmm2     # 0xb240
andpd %xmm1, %xmm2
sqrtsd %xmm2, %xmm2
movapd 0x5f6e(%rip), %xmm3     # 0xb1f0
xorpd %xmm2, %xmm3
xorpd %xmm4, %xmm4
cmpltsd %xmm4, %xmm1
movapd %xmm1, %xmm4
andnpd %xmm2, %xmm4
andpd %xmm3, %xmm1
orpd %xmm4, %xmm1
mulsd %xmm5, %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%r14)
movsd 0x10(%r14), %xmm0
callq 0x39cd
movsd %xmm0, 0x10(%r14)
mulsd 0x5d53(%rip), %xmm0     # 0xb018
divsd 0x5d53(%rip), %xmm0     # 0xb020
movsd %xmm0, 0x8(%rsp)
movsd (%r14), %xmm1
movsd %xmm1, (%rsp)
callq 0x20e0
mulsd (%rsp), %xmm0
mulsd 0xceb1(%rip), %xmm0     # 0x121a0
mulsd 0x5d79(%rip), %xmm0     # 0xb070
addsd 0x38(%r14), %xmm0
movsd %xmm0, 0x38(%r14)
movsd (%r14), %xmm0
movsd %xmm0, (%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x2300
mulsd (%rsp), %xmm0
mulsd 0xce7b(%rip), %xmm0     # 0x121a0
movsd 0x40(%r14), %xmm1
mulsd 0x5d3d(%rip), %xmm0     # 0xb070
subsd %xmm0, %xmm1
movsd %xmm1, 0x40(%r14)
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq