// File: /workspace/github_c_makefile_star2_O2/hyc[P]trek73c/trekx.c
// Function: Distrib
Void Distrib(V, X)
int V;
double X;
{
  double H, H1, Q;
  reg int I;
  reg Srec *WITH;

  H = Objects[V]->Fuel + Ships[V]->Regen * X;
  WITH = Ships[V];
  for (I = 0; I < Phasers; I++) {
    if (WITH->Pstat[I] >= 0 && WITH->PCrts[I] < 0) {
      Q = -WITH->PCrts[I] * X;
      if (Q > WITH->PChrg[I])
	Q = WITH->PChrg[I];
      if (Q < 0)
	Q = 0.0;
      WITH->PChrg[I] -= Q;
      H += Q;
    }
  }
  for (I = 0; I <= 3; I++) {
    if (WITH->Seff[I] > 0) {
      H1 = WITH->Sdrns[I] * X;
      if (H1 > H)
	H1 = H;
      H -= H1;
      WITH->Sdrns[I] = H1 / X;
    }
  }
  if (H > 0) {
    for (I = 0; I < Phasers; I++) {
      if (WITH->PChrg[I] < 10 && WITH->Pstat[I] >= 0 && WITH->PCrts[I] >= 0) {
	H1 = H;
	if (H1 > 10 - WITH->PChrg[I])
	  H1 = 10 - WITH->PChrg[I];
	if (H1 > WITH->PCrts[I] * X)
	  H1 = WITH->PCrts[I] * X;
	H -= H1;
	WITH->PChrg[I] += H1;
      }
    }
  }
  Objects[V]->Fuel = H;
  if (Objects[V]->Fuel > WITH->Fcap)
    Objects[V]->Fuel = WITH->Fcap;
  H -= Objects[V]->Fuel;
  if (H <= 0)
    return;
  for (I = 0; I < Phasers; I++) {
    if (H > 0 && WITH->Pstat[I] >= 0) {
      H1 = 10 - WITH->PChrg[I];
      if (H1 > H)
	H1 = H;
      WITH->PChrg[I] += H1;
      H -= H1;
    }
  }
}

// Assembly:
movslq %edi, %rax
leaq 0xe6b0(%rip), %rcx      # 0x125e0
movq (%rcx,%rax,8), %rdx
leaq 0xea45(%rip), %rcx      # 0x12980
movq (%rcx,%rax,8), %rax
movsd (%rax), %xmm1
mulsd %xmm0, %xmm1
addsd 0x20(%rdx), %xmm1
movzbl 0xe25d(%rip), %ecx      # 0x121b0
xorl %esi, %esi
xorpd %xmm2, %xmm2
movapd 0x728f(%rip), %xmm3     # 0xb1f0
cmpq %rsi, %rcx
je 0x3fae
cmpw $0x0, 0xd2(%rax,%rsi,2)
js 0x3fa9
movsd 0x40(%rax,%rsi,8), %xmm4
ucomisd %xmm4, %xmm2
jbe 0x3fa9
xorpd %xmm3, %xmm4
mulsd %xmm0, %xmm4
movsd 0x20(%rax,%rsi,8), %xmm5
movapd %xmm5, %xmm6
minsd %xmm4, %xmm6
xorpd %xmm4, %xmm4
maxsd %xmm6, %xmm4
subsd %xmm4, %xmm5
movsd %xmm5, 0x20(%rax,%rsi,8)
addsd %xmm4, %xmm1
incq %rsi
jmp 0x3f61
pushq $-0x20
popq %rsi
xorpd %xmm2, %xmm2
testq %rsi, %rsi
je 0x3ff5
movsd 0xc0(%rax,%rsi), %xmm3
ucomisd %xmm2, %xmm3
jbe 0x3fef
movsd 0xa0(%rax,%rsi), %xmm3
mulsd %xmm0, %xmm3
movapd %xmm1, %xmm4
minsd %xmm3, %xmm4
subsd %xmm4, %xmm1
divsd %xmm0, %xmm4
movsd %xmm4, 0xa0(%rax,%rsi)
addq $0x8, %rsi
jmp 0x3fb5
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
jbe 0x4058
xorl %esi, %esi
movsd 0x6fff(%rip), %xmm3     # 0xb008
cmpq %rsi, %rcx
je 0x4058
movsd 0x20(%rax,%rsi,8), %xmm4
ucomisd %xmm4, %xmm3
jbe 0x4053
cmpw $0x0, 0xd2(%rax,%rsi,2)
js 0x4053
movsd 0x40(%rax,%rsi,8), %xmm5
ucomisd %xmm2, %xmm5
jb 0x4053
movapd %xmm3, %xmm6
subsd %xmm4, %xmm6
minsd %xmm1, %xmm6
mulsd %xmm0, %xmm5
minsd %xmm6, %xmm5
subsd %xmm5, %xmm1
addsd %xmm4, %xmm5
movsd %xmm5, 0x20(%rax,%rsi,8)
incq %rsi
jmp 0x4009
movsd %xmm1, 0x20(%rdx)
movzbl 0x18(%rax), %esi
cvtsi2sd %esi, %xmm0
ucomisd %xmm0, %xmm1
movapd %xmm1, %xmm2
jbe 0x4078
movsd %xmm0, 0x20(%rdx)
movapd %xmm0, %xmm2
subsd %xmm2, %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jae 0x40cf
xorl %edx, %edx
movsd 0x6f78(%rip), %xmm2     # 0xb008
cmpq %rdx, %rcx
je 0x40cf
ucomisd %xmm0, %xmm1
jbe 0x40ca
cmpw $0x0, 0xd2(%rax,%rdx,2)
js 0x40ca
movsd 0x20(%rax,%rdx,8), %xmm3
movapd %xmm2, %xmm4
subsd %xmm3, %xmm4
movapd %xmm1, %xmm5
minsd %xmm4, %xmm5
addsd %xmm5, %xmm3
movsd %xmm3, 0x20(%rax,%rdx,8)
subsd %xmm5, %xmm1
incq %rdx
jmp 0x4090
retq