// File: /workspace/github_c_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edi, %ebx
movslq %edi, %r12
leaq 0xdc4b(%rip), %rbp      # 0x135f0
movq (%rbp,%r12,8), %r15
movswl 0x4a(%r15), %eax
imull $0x6667, %eax, %eax     # imm = 0x6667
movl %eax, %ecx
shrl $0x1f, %ecx
sarl $0x12, %eax
addl %ecx, %eax
testb %al, %al
je 0x59e4
cmpb $0x2, %al
je 0x5bf4
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x5e35
movsd 0xd7d1(%rip), %xmm5     # 0x131b0
jmp 0x5de4
leaq 0xdfa5(%rip), %r13      # 0x13990
movq (%r13,%r12,8), %rax
cmpw $0x0, 0x1a(%rax)
jne 0x59ff
movq $0x0, 0x8(%r15)
cmpb $0x0, 0xc0(%rax)
je 0x5a0f
movw $0x0, 0x48(%r15)
cmpb $0x0, 0xc3(%rax)
movsd 0x8(%r15), %xmm0
je 0x5a61
movapd 0x76da(%rip), %xmm1     # 0xd100
andpd %xmm0, %xmm1
movsd 0x77e6(%rip), %xmm2     # 0xd218
minsd %xmm1, %xmm2
movapd 0x7672(%rip), %xmm1     # 0xd0b0
xorpd %xmm2, %xmm1
xorpd %xmm3, %xmm3
cmpltsd %xmm3, %xmm0
movapd %xmm0, %xmm3
andnpd %xmm2, %xmm3
andpd %xmm1, %xmm0
orpd %xmm3, %xmm0
movlpd %xmm0, 0x8(%r15)
andpd 0x7697(%rip), %xmm0     # 0xd100
ucomisd 0x76c7(%rip), %xmm0     # 0xd138
jb 0x5b3b
mulsd 0x8(%rax), %xmm0
movsd 0x20(%r15), %xmm1
mulsd 0xd726(%rip), %xmm0     # 0x131b0
subsd %xmm0, %xmm1
movsd %xmm1, 0x20(%r15)
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jb 0x5b3b
xorl %eax, %eax
movq %rax, 0x20(%r15)
movq %rax, 0x8(%r15)
callq 0x3d76
leaq 0xde78(%rip), %rax      # 0x13930
movq (%rax,%r12,8), %rdx
leaq 0xd9ed(%rip), %r14      # 0x134b0
leaq 0x8660(%rip), %rsi      # 0xe12a
movq %r14, %rdi
xorl %eax, %eax
callq 0x21a0
movq 0xdf1d(%rip), %rdi      # 0x139f8
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2210
callq 0x3d76
movq (%rbp,%r12,8), %r15
movsd 0x8(%r15), %xmm0
movapd 0x7600(%rip), %xmm1     # 0xd100
andpd %xmm0, %xmm1
movsd 0x770c(%rip), %xmm2     # 0xd218
minsd %xmm1, %xmm2
movapd 0x7598(%rip), %xmm1     # 0xd0b0
xorpd %xmm2, %xmm1
cmpltsd 0x765b(%rip), %xmm0     # 0xd180
movapd %xmm0, %xmm3
andnpd %xmm2, %xmm3
andpd %xmm1, %xmm0
orpd %xmm3, %xmm0
movlpd %xmm0, 0x8(%r15)
movzwl 0x48(%r15), %eax
testw %ax, %ax
je 0x5c15
movl %eax, %ecx
negw %cx
cmovsw %ax, %cx
movzwl %cx, %esi
decl %esi
movl %ebx, %edi
callq 0x3e93
movsd %xmm0, 0x18(%r15)
cmpw $0x0, 0x48(%r15)
jns 0x5c1b
addsd 0x75d0(%rip), %xmm0     # 0xd148
movapd %xmm0, 0x30(%rsp)
movsd 0x75ca(%rip), %xmm2     # 0xd150
divsd %xmm2, %xmm0
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x22b0
movsd 0x75b9(%rip), %xmm0     # 0xd158
movsd (%r14), %xmm1
mulsd %xmm0, %xmm1
addsd 0x30(%rsp), %xmm1
addsd %xmm1, %xmm0
movsd 0x7596(%rip), %xmm3     # 0xd150
movapd %xmm3, %xmm2
cmpnlesd %xmm1, %xmm2
andpd %xmm2, %xmm1
andnpd %xmm0, %xmm2
orpd %xmm1, %xmm2
addsd %xmm2, %xmm3
xorpd %xmm1, %xmm1
movapd %xmm2, %xmm0
cmpltsd %xmm1, %xmm0
andpd %xmm0, %xmm3
andnpd %xmm2, %xmm0
orpd %xmm3, %xmm0
movlpd %xmm0, 0x18(%r15)
jmp 0x5c1b
movswl 0x48(%r15), %esi
testl %esi, %esi
jle 0x5e35
decl %esi
movl %ebx, %edi
callq 0x3e93
movsd %xmm0, 0x10(%r15)
jmp 0x5e35
movsd 0x18(%r15), %xmm0
movsd 0x10(%r15), %xmm1
ucomisd %xmm1, %xmm0
movsd 0xd583(%rip), %xmm5     # 0x131b0
jne 0x5c35
jnp 0x5de4
movsd %xmm1, 0x10(%rsp)
subsd %xmm1, %xmm0
movapd %xmm0, 0x30(%rsp)
movsd 0x7503(%rip), %xmm2     # 0xd150
divsd %xmm2, %xmm0
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movsd %xmm5, 0x8(%rsp)
callq 0x22b0
movsd 0x74ec(%rip), %xmm3     # 0xd158
movsd (%r14), %xmm0
mulsd %xmm3, %xmm0
addsd 0x30(%rsp), %xmm0
movapd %xmm0, %xmm1
addsd %xmm3, %xmm1
movsd 0x74c5(%rip), %xmm5     # 0xd150
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 0x747b(%rip), %xmm0     # 0xd148
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 0x741c(%rip), %rcx      # 0xd110
movsd (%rcx,%rax,8), %xmm1
movsd (%r15), %xmm3
movapd 0x73fa(%rip), %xmm2     # 0xd100
andpd %xmm2, %xmm3
subsd %xmm3, %xmm1
mulsd 0x74fa(%rip), %xmm1     # 0xd210
mulsd 0x8(%rsp), %xmm1
movq (%r13,%r12,8), %rax
cmpb $0x0, 0xc3(%rax)
je 0x5d32
mulsd 0x7446(%rip), %xmm1     # 0xd178
andpd %xmm0, %xmm2
minsd %xmm2, %xmm1
movapd 0x736e(%rip), %xmm2     # 0xd0b0
xorpd %xmm1, %xmm2
cmpltsd %xmm5, %xmm0
movapd %xmm0, %xmm3
andnpd %xmm1, %xmm3
andpd %xmm2, %xmm0
orpd %xmm3, %xmm0
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movapd %xmm1, %xmm0
divsd %xmm4, %xmm0
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0x22b0
movsd (%rbx), %xmm0
movsd 0x73cc(%rip), %xmm2     # 0xd158
mulsd %xmm2, %xmm0
addsd 0x10(%rsp), %xmm0
addsd %xmm0, %xmm2
movsd 0x73ae(%rip), %xmm3     # 0xd150
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 0x73b4(%rip), %xmm0     # 0xd180
andpd %xmm0, %xmm2
andnpd %xmm1, %xmm0
orpd %xmm2, %xmm0
movlpd %xmm0, 0x10(%r15)
movsd 0x8(%rsp), %xmm5
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
subsd %xmm0, %xmm1
movapd 0x7305(%rip), %xmm2     # 0xd100
andpd %xmm1, %xmm2
sqrtsd %xmm2, %xmm2
movapd 0x72a5(%rip), %xmm3     # 0xd0b0
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, (%r15)
movsd 0x10(%r15), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x7307(%rip), %xmm1     # 0xd150
divsd %xmm1, %xmm0
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0x22b0
movsd 0x72f6(%rip), %xmm0     # 0xd158
movsd (%rbx), %xmm1
mulsd %xmm0, %xmm1
addsd 0x10(%rsp), %xmm1
addsd %xmm1, %xmm0
movsd 0x72d4(%rip), %xmm3     # 0xd150
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 0x7280(%rip), %xmm0     # 0xd140
divsd 0x7280(%rip), %xmm0     # 0xd148
movapd %xmm0, 0x10(%rsp)
movsd (%r15), %xmm1
movsd %xmm1, 0x8(%rsp)
callq 0x20f0
mulsd 0x8(%rsp), %xmm0
mulsd 0xd2c4(%rip), %xmm0     # 0x131b0
mulsd 0x72b4(%rip), %xmm0     # 0xd1a8
addsd 0x38(%r15), %xmm0
movsd %xmm0, 0x38(%r15)
movsd (%r15), %xmm0
movsd %xmm0, 0x8(%rsp)
movapd 0x10(%rsp), %xmm0
callq 0x2310
mulsd 0x8(%rsp), %xmm0
mulsd 0xd28c(%rip), %xmm0     # 0x131b0
movsd 0x40(%r15), %xmm1
mulsd 0x7276(%rip), %xmm0     # 0xd1a8
subsd %xmm0, %xmm1
movsd %xmm1, 0x40(%r15)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq