double thetag(double EP, double *DS50) {
  int JY, N, I;
  double YR, D, THETA, TEMP, THETAG;
  YR = (EP + 2.0E-7) * 1.0E-3;
  JY = (int)YR;
  YR = JY;
  D = EP - YR * 1.0E3;
  if (JY < 10)
    JY += 80;
  N = (JY - 69) / 4;
  if (JY < 70)
    N = (JY - 72) / 4;
  *DS50 = 7305.0 + 365.0 * (JY - 70) + N + D;
  THETA = 1.72944494 + 6.3003880987 * *DS50;
  TEMP = THETA / (6.2831853071795864770);
  I = (int)TEMP;
  TEMP = I;
  THETAG = THETA - TEMP * (6.2831853071795864770);
  if (THETAG < 0.0)
    THETAG += (6.2831853071795864770);
  return THETAG;
}


x86 assembly (clang, -O0):
<thetag>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  0xefb(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  0xee6(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cvttsd2si -0x28(%rbp),%eax
mov    %eax,-0x14(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe9a(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    1186 <thetag+0x86>
mov    -0x14(%rbp),%eax
add    $0x50,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x45,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
cmpl   $0x46,-0x14(%rbp)
jge    11b2 <thetag+0xb2>
mov    -0x14(%rbp),%eax
sub    $0x48,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x46,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe6c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe68(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
addsd  %xmm1,%xmm0
addsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe26(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe22(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xdfc(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
cvttsd2si -0x40(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xdb8(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    128d <thetag+0x18d>
movsd  0xd95(%rip),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<thetag>:
movsd  0xef8(%rip),%xmm1
addsd  %xmm0,%xmm1
mulsd  0xef4(%rip),%xmm1
cvttsd2si %xmm1,%eax
cvttpd2dq %xmm1,%xmm1
cvtdq2pd %xmm1,%xmm1
mulsd  0xee8(%rip),%xmm1
lea    0x50(%rax),%ecx
cmp    $0xa,%eax
cmovge %eax,%ecx
xor    %eax,%eax
cmp    $0x46,%ecx
setge  %al
lea    (%rax,%rax,2),%eax
lea    (%rcx,%rax,1),%edx
add    $0xffffffb8,%edx
add    %ecx,%eax
add    $0xffffffbb,%eax
test   %edx,%edx
cmovns %edx,%eax
addsd  %xmm0,%xmm1
add    $0xffffffba,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
mulsd  0xeb6(%rip),%xmm0
addsd  0xeb6(%rip),%xmm0
sar    $0x2,%eax
cvtsi2sd %eax,%xmm2
addsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,(%rdi)
mulsd  0xea3(%rip),%xmm2
addsd  0xea3(%rip),%xmm2
movsd  0xea3(%rip),%xmm1
movapd %xmm2,%xmm0
divsd  %xmm1,%xmm0
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
mulsd  %xmm1,%xmm0
subsd  %xmm0,%xmm2
addsd  %xmm2,%xmm1
xorpd  %xmm3,%xmm3
movapd %xmm2,%xmm0
cmpltsd %xmm3,%xmm0
andpd  %xmm0,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @thetag(double %0, double* %1) {
%3 = alloca double
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store double %0, double* %3
store double* %1, double** %4
%13 = load double, double* %3
%14 = fadd double %13, 2.000000e-07
%15 = fmul double %14, 1.000000e-03
store double %15, double* %8
%16 = load double, double* %8
%17 = fptosi double %16 to i32
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = sitofp i32 %18 to double
store double %19, double* %8
%20 = load double, double* %3
%21 = load double, double* %8
%22 = fneg double %21
%23 = call double @llvm.fmuladd.f64(double %22, double 1.000000e+03, double %20)
store double %23, double* %9
%24 = load i32, i32* %5
%25 = icmp slt i32 %24, 10
br i1 %25, label %26, label %29
26: ; preds = %2
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 80
store i32 %28, i32* %5
br label %29
29: ; preds = %26, %2
%30 = load i32, i32* %5
%31 = sub nsw i32 %30, 69
%32 = sdiv i32 %31, 4
store i32 %32, i32* %6
%33 = load i32, i32* %5
%34 = icmp slt i32 %33, 70
br i1 %34, label %35, label %39
35: ; preds = %29
%36 = load i32, i32* %5
%37 = sub nsw i32 %36, 72
%38 = sdiv i32 %37, 4
store i32 %38, i32* %6
br label %39
39: ; preds = %35, %29
%40 = load i32, i32* %5
%41 = sub nsw i32 %40, 70
%42 = sitofp i32 %41 to double
%43 = call double @llvm.fmuladd.f64(double 3.650000e+02, double %42, double 7.305000e+03)
%44 = load i32, i32* %6
%45 = sitofp i32 %44 to double
%46 = fadd double %43, %45
%47 = load double, double* %9
%48 = fadd double %46, %47
%49 = load double*, double** %4
store double %48, double* %49
%50 = load double*, double** %4
%51 = load double, double* %50
%52 = call double @llvm.fmuladd.f64(double 0x40193398F01018B3, double %51, double 0x3FFBABCE751885DE)
store double %52, double* %10
%53 = load double, double* %10
%54 = fdiv double %53, 0x401921FB54442D18
store double %54, double* %11
%55 = load double, double* %11
%56 = fptosi double %55 to i32
store i32 %56, i32* %7
%57 = load i32, i32* %7
%58 = sitofp i32 %57 to double
store double %58, double* %11
%59 = load double, double* %10
%60 = load double, double* %11
%61 = fneg double %60
%62 = call double @llvm.fmuladd.f64(double %61, double 0x401921FB54442D18, double %59)
store double %62, double* %12
%63 = load double, double* %12
%64 = fcmp olt double %63, 0.000000e+00
br i1 %64, label %65, label %68
65: ; preds = %39
%66 = load double, double* %12
%67 = fadd double %66, 0x401921FB54442D18
store double %67, double* %12
br label %68
68: ; preds = %65, %39
%69 = load double, double* %12
ret double %69
}

LLVM IR (-O2):
define double @thetag(double %0, double* nocapture writeonly %1) {
%3 = fadd double %0, 2.000000e-07
%4 = fmul double %3, 1.000000e-03
%5 = fptosi double %4 to i32
%6 = sitofp i32 %5 to double
%7 = fneg double %6
%8 = tail call double @llvm.fmuladd.f64(double %7, double 1.000000e+03, double %0)
%9 = icmp slt i32 %5, 10
%10 = add nsw i32 %5, 80
%11 = select i1 %9, i32 %10, i32 %5
%12 = icmp slt i32 %11, 70
%13 = select i1 %12, i32 -72, i32 -69
%14 = add nsw i32 %13, %11
%15 = sdiv i32 %14, 4
%16 = add nsw i32 %11, -70
%17 = sitofp i32 %16 to double
%18 = tail call double @llvm.fmuladd.f64(double %17, double 3.650000e+02, double 7.305000e+03)
%19 = sitofp i32 %15 to double
%20 = fadd double %18, %19
%21 = fadd double %8, %20
store double %21, double* %1
%22 = tail call double @llvm.fmuladd.f64(double %21, double 0x40193398F01018B3, double 0x3FFBABCE751885DE)
%23 = fdiv double %22, 0x401921FB54442D18
%24 = fptosi double %23 to i32
%25 = sitofp i32 %24 to double
%26 = fneg double %25
%27 = tail call double @llvm.fmuladd.f64(double %26, double 0x401921FB54442D18, double %22)
%28 = fcmp olt double %27, 0.000000e+00
%29 = fadd double %27, 0x401921FB54442D18
%30 = select i1 %28, double %29, double %27
ret double %30
}