// File: /workspace/github_c_makefile_star2_O1/hyc[P]trek73c/trekx.c
// Function: TLoad
void TLoad()
{
  int I, J, k, X, Y;
  Digs Temp;
  reg Srec *WITH;

  waddstr(Cmdwin,"   [Load or Unload] ");
  getyx(Cmdwin, Y, X);
  mygetstr(Cmdwin,scrstr,false);
  scrstr[0] = toupper(scrstr[0]);
  wmove(Cmdwin, Y, X);
  if (scrstr[0]=='L') {
	waddstr(Cmdwin,"Load");
	I = 0;
  } else if (scrstr[0]=='U') {
	waddstr(Cmdwin,"Unload");
	I = 1;
  } else {
	Whatt();
	return;
  }
  waddstr(Cmdwin,"\n   Tubes [1-6] ");
  Indigits(Temp);
  WITH = Ships[0];
  if (!I) {
    for (I = 0; I <= 5; I++) {
      if (Temp[I] > 0 && Temp[I] < 7) {
	if (WITH->Tstat[Temp[I] - 1] >= 0) {
	  J = WITH->Tstat[7];
	  k = 10 - WITH->Tengy[Temp[I] - 1];
	  if (J > k)
	    J = k;
	  if (J > Objects[0]->Fuel)
	    J = (long)Objects[0]->Fuel;
	  WITH->Tengy[Temp[I] - 1] += J;
	  Objects[0]->Fuel -= J;
	  if (!cheat)
	    WITH->Fcap -= J;
	}
      }
    }
  } else {
    for (I = 0; I <= 5; I++) {
      J = WITH->Tengy[Temp[I] - 1];
      Objects[0]->Fuel += J;
      if (!cheat)
      	WITH->Fcap += J;
      else
	if (Objects[0]->Fuel > WITH->Fcap)
	  Objects[0]->Fuel = WITH->Fcap;
      WITH->Tengy[Temp[I] - 1] = 0;
    }
  }
  Endln();
  waddstr(Cmdwin,"Scott: Tube units now ");
  for (I = 0; I <= 5; I++) {
    if (WITH->Tstat[I] < 0)
      waddstr(Cmdwin,"  --");
    else {
      sprintf(scrstr,"%4d", WITH->Tengy[I]);
      waddstr(Cmdwin,scrstr);
    }
  }
  sprintf(scrstr,"  Fuel @ %0.0f", Objects[0]->Fuel);
  SEndln();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq 0xad22(%rip), %rdi      # 0x139f8
leaq 0x5c8a(%rip), %rsi      # 0xe967
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2210
movq 0xad05(%rip), %rdi      # 0x139f8
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x8d02
movswl (%rdi), %r14d
testq %rdi, %rdi
je 0x8d0b
movswl 0x2(%rdi), %ebp
leaq 0xa79e(%rip), %rbx      # 0x134b0
movq %rbx, %rsi
xorl %edx, %edx
callq 0x249f
callq 0x2110
movq (%rax), %rax
movsbq 0xa784(%rip), %rcx      # 0x134b0
movb (%rax,%rcx,4), %al
movb %al, 0xa77b(%rip)       # 0x134b0
movq 0xacbc(%rip), %rdi      # 0x139f8
movl %r14d, %esi
movl %ebp, %edx
callq 0x21e0
movb 0xa763(%rip), %bpl      # 0x134b0
cmpb $0x4c, %bpl
jne 0x8d5c
leaq 0x5c22(%rip), %rsi      # 0xe97c
jmp 0x8d6d
cmpb $0x55, %bpl
jne 0x8f5e
leaq 0x5c14(%rip), %rsi      # 0xe981
movq 0xac84(%rip), %rdi      # 0x139f8
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2210
movq 0xac73(%rip), %rdi      # 0x139f8
leaq 0x5bfc(%rip), %rsi      # 0xe988
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2210
movq %rsp, %rdi
callq 0x7c6a
movq 0xabeb(%rip), %r15      # 0x13990
cmpb $0x4c, %bpl
jne 0x8e3a
movq 0xa83a(%rip), %rax      # 0x135f0
movb 0xa814(%rip), %cl       # 0x135d0
xorl %edx, %edx
movl (%rsp,%rdx,4), %esi
decl %esi
cmpl $0x5, %esi
ja 0x8e2f
cmpw $0x0, 0x110(%r15,%rsi,2)
js 0x8e2f
movswl 0x11e(%r15), %r8d
movswl 0xc6(%r15,%rsi,2), %r9d
movl $0xa, %edi
subl %r9d, %edi
cmpl %r8d, %edi
cmovgel %r8d, %edi
xorps %xmm1, %xmm1
cvtsi2sd %edi, %xmm1
movsd 0x20(%rax), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x8e0b
cvttsd2si %xmm0, %rdi
movslq %esi, %rsi
addw %di, 0xc6(%r15,%rsi,2)
xorps %xmm1, %xmm1
cvtsi2sd %edi, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rax)
testb %cl, %cl
jne 0x8e2f
subb %dil, 0x18(%r15)
incq %rdx
cmpq $0x6, %rdx
jne 0x8dbe
jmp 0x8ea3
movq 0xa7af(%rip), %rax      # 0x135f0
movb 0xa789(%rip), %cl       # 0x135d0
movsd 0x20(%rax), %xmm0
xorl %edx, %edx
movapd %xmm0, %xmm1
movslq (%rsp,%rdx,4), %rsi
movswl 0xc4(%r15,%rsi,2), %edi
xorps %xmm0, %xmm0
cvtsi2sd %edi, %xmm0
addsd %xmm1, %xmm0
testb %cl, %cl
je 0x8e86
movzbl 0x18(%r15), %edi
xorps %xmm1, %xmm1
cvtsi2sd %edi, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x8e8a
movapd %xmm1, %xmm0
jmp 0x8e8a
addb %dil, 0x18(%r15)
movw $0x0, 0xc4(%r15,%rsi,2)
incq %rdx
cmpq $0x6, %rdx
jne 0x8e4e
movsd %xmm0, 0x20(%rax)
callq 0x3c58
movq 0xab49(%rip), %rdi      # 0x139f8
leaq 0x5ae3(%rip), %rsi      # 0xe999
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2210
movq $-0x6, %r12
leaq 0x6357(%rip), %r13      # 0xf225
leaq 0x5822(%rip), %r14      # 0xe6f7
cmpw $0x0, 0x11c(%r15,%r12,2)
movq %r13, %rsi
js 0x8efd
movswl 0xd2(%r15,%r12,2), %edx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x21a0
movq %rbx, %rsi
movq 0xaaf4(%rip), %rdi      # 0x139f8
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2210
incq %r12
jne 0x8ed5
movq 0xa6d6(%rip), %rax      # 0x135f0
movsd 0x20(%rax), %xmm0
leaq 0xa58a(%rip), %rbx      # 0x134b0
leaq 0x5a83(%rip), %rsi      # 0xe9b0
movq %rbx, %rdi
movb $0x1, %al
callq 0x21a0
movq 0xaaba(%rip), %rdi      # 0x139f8
movq %rbx, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2210
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3c58
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7ab9