double ts2gst(tsec)
double tsec;
{
  double gst;
  double tsd, eqnx, dj;
  int its;
  if (tsec >= 0.0) {
    its = (int)(tsec + 0.5);
    tsd = (double)(its % 86400);
  } else {
    its = (int)(-tsec + 0.5);
    tsd = (double)(86400 - (its % 86400));
  }
  gst = ts2mst(tsec);
  dj = ts2jd(tsec);
  eqnx = eqeqnx(dj);
  gst = gst + eqnx;
  gst = gst + (tsd * 1.0027379093);
  gst = dmod(gst, 86400.0);
  return (gst);
}


x86 assembly (clang, -O0):
<ts2gst>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     118c <ts2gst+0x4c>
movsd  0xe99(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11d6 <ts2gst+0x96>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe50(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    $0x15180,%eax
sub    %edx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    $0x1,%al
call   1040 <ts2mst@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    $0x1,%al
call   1060 <ts2jd@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    $0x1,%al
call   1030 <eqeqnx@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  0xdda(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xdb8(%rip),%xmm1
mov    $0x2,%al
call   1050 <dmod@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ts2gst>:
sub    $0x18,%rsp
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jae    1187 <ts2gst+0x47>
movsd  0xeaa(%rip),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%eax
movslq %eax,%rcx
imul   $0xffffffffc22e4507,%rcx,%rax
shr    $0x20,%rax
add    %ecx,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0x10,%eax
add    %edx,%eax
imul   $0x15180,%eax,%eax
sub    %ecx,%eax
add    $0x15180,%eax
jmp    11b8 <ts2gst+0x78>
movsd  0xe71(%rip),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%eax
cltq
imul   $0xffffffffc22e4507,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x10,%ecx
add    %edx,%ecx
imul   $0x15180,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  %xmm1,0x10(%rsp)
mov    $0x1,%al
movsd  %xmm0,(%rsp)
call   1040 <ts2mst@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1060 <ts2jd@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    $0x1,%al
call   1030 <eqeqnx@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  0xdf5(%rip),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
movsd  0xded(%rip),%xmm1
mov    $0x2,%al
call   1050 <dmod@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @ts2gst(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
store double %0, double* %2
%8 = load double, double* %2
%9 = fcmp oge double %8, 0.000000e+00
br i1 %9, label %10, label %17
10: ; preds = %1
%11 = load double, double* %2
%12 = fadd double %11, 5.000000e-01
%13 = fptosi double %12 to i32
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = srem i32 %14, 86400
%16 = sitofp i32 %15 to double
store double %16, double* %4
br label %26
17: ; preds = %1
%18 = load double, double* %2
%19 = fneg double %18
%20 = fadd double %19, 5.000000e-01
%21 = fptosi double %20 to i32
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = srem i32 %22, 86400
%24 = sub nsw i32 86400, %23
%25 = sitofp i32 %24 to double
store double %25, double* %4
br label %26
26: ; preds = %17, %10
%27 = load double, double* %2
%28 = call i32 (double, ...) bitcast (i32 (...)* @ts2mst to i32 (double, ...)*)(double %27)
%29 = sitofp i32 %28 to double
store double %29, double* %3
%30 = load double, double* %2
%31 = call i32 (double, ...) bitcast (i32 (...)* @ts2jd to i32 (double, ...)*)(double %30)
%32 = sitofp i32 %31 to double
store double %32, double* %6
%33 = load double, double* %6
%34 = call i32 (double, ...) bitcast (i32 (...)* @eqeqnx to i32 (double, ...)*)(double %33)
%35 = sitofp i32 %34 to double
store double %35, double* %5
%36 = load double, double* %3
%37 = load double, double* %5
%38 = fadd double %36, %37
store double %38, double* %3
%39 = load double, double* %3
%40 = load double, double* %4
%41 = call double @llvm.fmuladd.f64(double %40, double 0x3FF00B36E7EE7256, double %39)
store double %41, double* %3
%42 = load double, double* %3
%43 = call i32 (double, double, ...) bitcast (i32 (...)* @dmod to i32 (double, double, ...)*)(double %42, double 8.640000e+04)
%44 = sitofp i32 %43 to double
store double %44, double* %3
%45 = load double, double* %3
ret double %45
}

LLVM IR (-O2):
define double @ts2gst(double %0) {
%2 = fcmp ult double %0, 0.000000e+00
br i1 %2, label %7, label %3
3: ; preds = %1
%4 = fadd double %0, 5.000000e-01
%5 = fptosi double %4 to i32
%6 = srem i32 %5, 86400
br label %12
7: ; preds = %1
%8 = fsub double 5.000000e-01, %0
%9 = fptosi double %8 to i32
%10 = srem i32 %9, 86400
%11 = sub nsw i32 86400, %10
br label %12
12: ; preds = %7, %3
%13 = phi i32 [ %6, %3 ], [ %11, %7 ]
%14 = sitofp i32 %13 to double
%15 = tail call i32 (double, ...) bitcast (i32 (...)* @ts2mst to i32 (double, ...)*)(double %0)
%16 = sitofp i32 %15 to double
%17 = tail call i32 (double, ...) bitcast (i32 (...)* @ts2jd to i32 (double, ...)*)(double %0)
%18 = sitofp i32 %17 to double
%19 = tail call i32 (double, ...) bitcast (i32 (...)* @eqeqnx to i32 (double, ...)*)(double %18)
%20 = sitofp i32 %19 to double
%21 = fadd double %16, %20
%22 = tail call double @llvm.fmuladd.f64(double %14, double 0x3FF00B36E7EE7256, double %21)
%23 = tail call i32 (double, double, ...) bitcast (i32 (...)* @dmod to i32 (double, double, ...)*)(double %22, double 8.640000e+04)
%24 = sitofp i32 %23 to double
ret double %24
}