// File: /workspace/github_c_makefile_star2_O1/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movl %edi, %ebx
movslq %edi, %r12
leaq 0xdc5e(%rip), %r15      # 0x135f0
movq (%r15,%r12,8), %rax
movswl 0x4a(%rax), %ecx
imull $0x6667, %ecx, %ebp     # imm = 0x6667
movl %ebp, %ecx
shrl $0x1f, %ecx
shrl $0x12, %ebp
addl %ecx, %ebp
andw $0xff, %bp
jne 0x5b08
leaq 0xdfd4(%rip), %rcx      # 0x13990
movq (%rcx,%r12,8), %rcx
cmpw $0x0, 0x1a(%rcx)
jne 0x59cf
movq $0x0, 0x8(%rax)
cmpb $0x0, 0xc0(%rcx)
je 0x59de
movw $0x0, 0x48(%rax)
cmpb $0x0, 0xc3(%rcx)
je 0x5a2e
movsd 0x8(%rax), %xmm0
movapd 0x781c(%rip), %xmm1     # 0xd210
andpd %xmm0, %xmm1
movsd 0x76d8(%rip), %xmm2     # 0xd0d8
minsd %xmm1, %xmm2
movapd 0x77b4(%rip), %xmm1     # 0xd1c0
xorpd %xmm2, %xmm1
xorpd %xmm3, %xmm3
cmpltsd %xmm3, %xmm0
movapd %xmm0, %xmm3
andnpd %xmm2, %xmm3
andpd %xmm1, %xmm0
orpd %xmm3, %xmm0
movlpd %xmm0, 0x8(%rax)
movsd 0x8(%rax), %xmm0
andpd 0x77d5(%rip), %xmm0     # 0xd210
ucomisd 0x761d(%rip), %xmm0     # 0xd060
jb 0x5b08
mulsd 0x8(%rcx), %xmm0
movsd 0x20(%rax), %xmm1
mulsd 0xd755(%rip), %xmm0     # 0x131b0
subsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rax)
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jb 0x5b08
xorl %ecx, %ecx
movq %rcx, 0x20(%rax)
movq %rcx, 0x8(%rax)
callq 0x3c58
leaq 0xdea8(%rip), %rax      # 0x13930
movq (%rax,%r12,8), %rdx
leaq 0xda1d(%rip), %r14      # 0x134b0
leaq 0x85d8(%rip), %rsi      # 0xe072
movq %r14, %rdi
xorl %eax, %eax
callq 0x21a0
movq 0xdf4d(%rip), %rdi      # 0x139f8
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2210
callq 0x3c58
movq (%r15,%r12,8), %rax
movsd 0x8(%rax), %xmm0
movapd 0x7742(%rip), %xmm1     # 0xd210
andpd %xmm0, %xmm1
movsd 0x75fe(%rip), %xmm2     # 0xd0d8
minsd %xmm1, %xmm2
movapd 0x76da(%rip), %xmm1     # 0xd1c0
xorpd %xmm2, %xmm1
cmpltsd 0x755d(%rip), %xmm0     # 0xd050
movapd %xmm0, %xmm3
andnpd %xmm2, %xmm3
andpd %xmm1, %xmm0
orpd %xmm3, %xmm0
movlpd %xmm0, 0x8(%rax)
movq (%r15,%r12,8), %r15
testw %bp, %bp
jne 0x5d8e
movzwl 0x48(%r15), %eax
testw %ax, %ax
je 0x5bca
movl %eax, %ecx
negw %cx
cmovsw %ax, %cx
movzwl %cx, %esi
decl %esi
movl %ebx, %edi
callq 0x3d75
movsd %xmm0, 0x18(%r15)
cmpw $0x0, 0x48(%r15)
jns 0x5bca
addsd 0x74c6(%rip), %xmm0     # 0xd018
movsd 0x74c6(%rip), %xmm1     # 0xd020
movsd %xmm0, (%rsp)
divsd %xmm1, %xmm0
leaq 0x18(%rsp), %r14
movq %r14, %rdi
callq 0x22b0
movsd 0x74b0(%rip), %xmm0     # 0xd028
movsd (%r14), %xmm1
mulsd %xmm0, %xmm1
addsd (%rsp), %xmm1
addsd %xmm1, %xmm0
movsd 0x748e(%rip), %xmm3     # 0xd020
movapd %xmm3, %xmm2
cmpnlesd %xmm1, %xmm2
andpd %xmm2, %xmm1
andnpd %xmm0, %xmm2
orpd %xmm1, %xmm2
addsd %xmm2, %xmm3
xorpd %xmm0, %xmm0
movapd %xmm2, %xmm1
cmpltsd %xmm0, %xmm1
andpd %xmm1, %xmm3
andnpd %xmm2, %xmm1
orpd %xmm3, %xmm1
movlpd %xmm1, 0x18(%r15)
movsd 0x10(%r15), %xmm0
movsd 0x18(%r15), %xmm1
ucomisd %xmm0, %xmm1
jne 0x5be2
jnp 0x5d8e
movsd %xmm0, (%rsp)
subsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x7427(%rip), %xmm2     # 0xd020
movapd %xmm1, %xmm0
divsd %xmm2, %xmm0
leaq 0x18(%rsp), %r14
movq %r14, %rdi
callq 0x22b0
movsd 0x7412(%rip), %xmm3     # 0xd028
movsd (%r14), %xmm0
mulsd %xmm3, %xmm0
addsd 0x10(%rsp), %xmm0
movapd %xmm0, %xmm1
addsd %xmm3, %xmm1
movsd 0x73eb(%rip), %xmm5     # 0xd020
movapd %xmm5, %xmm2
cmpnlesd %xmm0, %xmm2
andpd %xmm2, %xmm0
andnpd %xmm1, %xmm2
orpd %xmm0, %xmm2
movapd %xmm2, %xmm0
movapd %xmm5, %xmm4
addsd %xmm5, %xmm0
xorpd %xmm5, %xmm5
movapd %xmm2, %xmm1
cmpltsd %xmm5, %xmm1
andpd %xmm1, %xmm0
andnpd %xmm2, %xmm1
orpd %xmm0, %xmm1
movsd 0x73a1(%rip), %xmm0     # 0xd018
cmpnlesd %xmm1, %xmm0
movapd %xmm0, %xmm2
andpd %xmm1, %xmm2
addsd %xmm3, %xmm1
andnpd %xmm1, %xmm0
orpd %xmm2, %xmm0
xorl %eax, %eax
testl %ebx, %ebx
setg %al
leaq 0x7582(%rip), %rcx      # 0xd220
movsd (%rcx,%rax,8), %xmm1
movsd (%r15), %xmm3
movapd 0x7560(%rip), %xmm2     # 0xd210
andpd %xmm2, %xmm3
subsd %xmm3, %xmm1
mulsd 0x7410(%rip), %xmm1     # 0xd0d0
mulsd 0xd4e8(%rip), %xmm1     # 0x131b0
leaq 0xdcc1(%rip), %rax      # 0x13990
movq (%rax,%r12,8), %rax
cmpb $0x0, 0xc3(%rax)
je 0x5ce4
mulsd 0x7364(%rip), %xmm1     # 0xd048
andpd %xmm0, %xmm2
minsd %xmm2, %xmm1
movapd 0x74cc(%rip), %xmm2     # 0xd1c0
xorpd %xmm1, %xmm2
cmpltsd %xmm5, %xmm0
movapd %xmm0, %xmm3
andnpd %xmm1, %xmm3
andpd %xmm2, %xmm0
orpd %xmm3, %xmm0
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movapd %xmm1, %xmm0
divsd %xmm4, %xmm0
leaq 0x18(%rsp), %r14
movq %r14, %rdi
callq 0x22b0
movsd (%r14), %xmm0
movsd 0x72eb(%rip), %xmm2     # 0xd028
mulsd %xmm2, %xmm0
addsd (%rsp), %xmm0
addsd %xmm0, %xmm2
movsd 0x72ce(%rip), %xmm3     # 0xd020
movapd %xmm3, %xmm1
cmpnlesd %xmm0, %xmm1
andpd %xmm1, %xmm0
andnpd %xmm2, %xmm1
orpd %xmm0, %xmm1
movapd %xmm3, %xmm2
addsd %xmm1, %xmm2
movapd %xmm1, %xmm0
cmpltsd 0x72d4(%rip), %xmm0     # 0xd050
andpd %xmm0, %xmm2
andnpd %xmm1, %xmm0
orpd %xmm2, %xmm0
movlpd %xmm0, 0x10(%r15)
cmpw $0x1, %bp
ja 0x5dbb
movsd 0x8(%r15), %xmm2
subsd (%r15), %xmm2
movapd 0x7469(%rip), %xmm0     # 0xd210
andpd %xmm2, %xmm0
xorpd %xmm3, %xmm3
ucomisd %xmm3, %xmm0
jb 0x5ddb
sqrtsd %xmm0, %xmm0
jmp 0x5dee
cmpw $0x2, %bp
jne 0x5e1d
movswl 0x48(%r15), %esi
testl %esi, %esi
jle 0x5e1d
decl %esi
movl %ebx, %edi
callq 0x3d75
movsd %xmm0, 0x10(%r15)
jmp 0x5e1d
movapd %xmm2, (%rsp)
callq 0x22f0
xorpd %xmm3, %xmm3
movapd (%rsp), %xmm2
movapd 0x73ca(%rip), %xmm1     # 0xd1c0
xorpd %xmm0, %xmm1
cmpltsd %xmm3, %xmm2
andpd %xmm2, %xmm1
andnpd %xmm0, %xmm2
orpd %xmm1, %xmm2
mulsd 0xd39d(%rip), %xmm2     # 0x131b0
addsd (%r15), %xmm2
movsd %xmm2, (%r15)
movsd 0x10(%r15), %xmm0
movsd %xmm0, (%rsp)
movsd 0x71f0(%rip), %xmm1     # 0xd020
divsd %xmm1, %xmm0
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x22b0
movsd 0x71df(%rip), %xmm0     # 0xd028
movsd (%rbx), %xmm1
mulsd %xmm0, %xmm1
addsd (%rsp), %xmm1
addsd %xmm1, %xmm0
movsd 0x71be(%rip), %xmm3     # 0xd020
movapd %xmm3, %xmm2
cmpnlesd %xmm1, %xmm2
andpd %xmm2, %xmm1
andnpd %xmm0, %xmm2
orpd %xmm1, %xmm2
movapd %xmm3, %xmm1
addsd %xmm2, %xmm1
xorpd %xmm3, %xmm3
movapd %xmm2, %xmm0
cmpltsd %xmm3, %xmm0
andpd %xmm0, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
movlpd %xmm0, 0x10(%r15)
mulsd 0x716a(%rip), %xmm0     # 0xd010
divsd 0x716a(%rip), %xmm0     # 0xd018
movapd %xmm0, (%rsp)
movsd (%r15), %xmm1
movsd %xmm1, 0x10(%rsp)
callq 0x20f0
mulsd 0x10(%rsp), %xmm0
mulsd 0xd2df(%rip), %xmm0     # 0x131b0
mulsd 0x71b7(%rip), %xmm0     # 0xd090
addsd 0x38(%r15), %xmm0
movsd %xmm0, 0x38(%r15)
movsd (%r15), %xmm0
movsd %xmm0, 0x10(%rsp)
movapd (%rsp), %xmm0
callq 0x2310
mulsd 0x10(%rsp), %xmm0
mulsd 0xd2a8(%rip), %xmm0     # 0x131b0
movsd 0x40(%r15), %xmm1
mulsd 0x717a(%rip), %xmm0     # 0xd090
subsd %xmm0, %xmm1
movsd %xmm1, 0x40(%r15)
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq