// File: /workspace/github_c_makefile_star2_O1/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 0xf2ad(%rip), %rcx      # 0x135f0
movq (%rcx,%rax,8), %rdx
leaq 0xf642(%rip), %rcx      # 0x13990
movq (%rcx,%rax,8), %rax
movsd (%rax), %xmm1
mulsd %xmm0, %xmm1
addsd 0x20(%rdx), %xmm1
movzbl 0xee5a(%rip), %ecx      # 0x131c0
testq %rcx, %rcx
je 0x43c4
xorl %esi, %esi
xorpd %xmm2, %xmm2
movapd 0x8e47(%rip), %xmm3     # 0xd1c0
cmpw $0x0, 0xd2(%rax,%rsi,2)
js 0x43bc
movsd 0x40(%rax,%rsi,8), %xmm4
ucomisd %xmm4, %xmm2
jbe 0x43bc
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
cmpq %rsi, %rcx
jne 0x4379
movq $-0x4, %rsi
xorpd %xmm2, %xmm2
movsd 0xc0(%rax,%rsi,8), %xmm3
ucomisd %xmm2, %xmm3
jbe 0x4404
movsd 0xa0(%rax,%rsi,8), %xmm3
mulsd %xmm0, %xmm3
movapd %xmm1, %xmm4
minsd %xmm3, %xmm4
subsd %xmm4, %xmm1
divsd %xmm0, %xmm4
movsd %xmm4, 0xa0(%rax,%rsi,8)
incq %rsi
jne 0x43cf
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
setbe %sil
testq %rcx, %rcx
sete %dil
orb %sil, %dil
jne 0x4478
xorl %esi, %esi
movsd 0x8bdd(%rip), %xmm3     # 0xd008
movsd 0x20(%rax,%rsi,8), %xmm4
ucomisd %xmm4, %xmm3
jbe 0x4470
cmpw $0x0, 0xd2(%rax,%rsi,2)
js 0x4470
movsd 0x40(%rax,%rsi,8), %xmm5
ucomisd %xmm2, %xmm5
jb 0x4470
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
cmpq %rsi, %rcx
jne 0x442b
movsd %xmm1, 0x20(%rdx)
movzbl 0x18(%rax), %esi
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
ucomisd %xmm0, %xmm1
jbe 0x4493
movsd %xmm0, 0x20(%rdx)
subsd 0x20(%rdx), %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
setae %dl
testq %rcx, %rcx
sete %sil
orb %dl, %sil
jne 0x44f6
xorl %edx, %edx
movsd 0x8b4f(%rip), %xmm2     # 0xd008
ucomisd %xmm0, %xmm1
jbe 0x44ee
cmpw $0x0, 0xd2(%rax,%rdx,2)
js 0x44ee
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
cmpq %rdx, %rcx
jne 0x44b9
retq