// File: /workspace/github_c_makefile_star2_O3/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 0xf1a7(%rip), %rcx      # 0x135f0
movq (%rcx,%rax,8), %rdx
leaq 0xf53c(%rip), %rcx      # 0x13990
movq (%rcx,%rax,8), %rax
movsd (%rax), %xmm1
mulsd %xmm0, %xmm1
addsd 0x20(%rdx), %xmm1
movzbl 0xed54(%rip), %ecx      # 0x131c0
testq %rcx, %rcx
je 0x44ca
xorl %esi, %esi
xorpd %xmm2, %xmm2
movapd 0x8c31(%rip), %xmm3     # 0xd0b0
cmpw $0x0, 0xd2(%rax,%rsi,2)
js 0x44c2
movsd 0x40(%rax,%rsi,8), %xmm4
ucomisd %xmm4, %xmm2
jbe 0x44c2
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 0x447f
movq $-0x4, %rsi
xorpd %xmm2, %xmm2
movsd 0xc0(%rax,%rsi,8), %xmm3
ucomisd %xmm2, %xmm3
jbe 0x450a
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 0x44d5
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
setbe %sil
testq %rcx, %rcx
sete %dil
orb %sil, %dil
jne 0x457e
xorl %esi, %esi
movsd 0x8bff(%rip), %xmm3     # 0xd130
movsd 0x20(%rax,%rsi,8), %xmm4
ucomisd %xmm4, %xmm3
jbe 0x4576
cmpw $0x0, 0xd2(%rax,%rsi,2)
js 0x4576
movsd 0x40(%rax,%rsi,8), %xmm5
ucomisd %xmm2, %xmm5
jb 0x4576
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 0x4531
movsd %xmm1, 0x20(%rdx)
movzbl 0x18(%rax), %esi
xorps %xmm2, %xmm2
cvtsi2sd %esi, %xmm2
ucomisd %xmm2, %xmm1
movapd %xmm1, %xmm0
jbe 0x45a1
movsd %xmm2, 0x20(%rdx)
movapd %xmm2, %xmm0
testq %rcx, %rcx
sete %dl
subsd %xmm0, %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
setae %sil
orb %dl, %sil
jne 0x4603
xorl %edx, %edx
movsd 0x8b6a(%rip), %xmm2     # 0xd130
ucomisd %xmm0, %xmm1
jbe 0x45fb
cmpw $0x0, 0xd2(%rax,%rdx,2)
js 0x45fb
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 0x45c6
retq