void jd2doy(dj, year, doy) double dj;
int *year;
double *doy;
{
  double date;
  double time;
  double dj0;
  double dyear;
  jd2dt(dj, &date, &time);
  *year = (int)date;
  dyear = (double)*year;
  dj0 = dt2jd(dyear + 0.0101, 0.0);
  *doy = dj - dj0 + 1.0;
  return;
}


x86 assembly (clang, -O0):
<jd2doy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x1,%al
call   1040 <jd2dt@plt>
cvttsd2si -0x20(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe9f(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
mov    $0x2,%al
call   1030 <dt2jd@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  0xe6d(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jd2doy>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm0,(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x1,%al
call   1040 <jd2dt@plt>
movsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,(%rbx)
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
addsd  0xea1(%rip),%xmm0
xorps  %xmm1,%xmm1
mov    $0x2,%al
call   1030 <dt2jd@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
addsd  0xe87(%rip),%xmm1
movsd  %xmm1,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @jd2doy(double %0, i32* %1, double* %2) {
%4 = alloca double
%5 = alloca i32*
%6 = alloca double*
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double %0, double* %4
store i32* %1, i32** %5
store double* %2, double** %6
%11 = load double, double* %4
%12 = call i32 (double, double*, double*, ...) bitcast (i32 (...)* @jd2dt to i32 (double, double*, double*, ...)*)(double %11, double* %7, double* %8)
%13 = load double, double* %7
%14 = fptosi double %13 to i32
%15 = load i32*, i32** %5
store i32 %14, i32* %15
%16 = load i32*, i32** %5
%17 = load i32, i32* %16
%18 = sitofp i32 %17 to double
store double %18, double* %10
%19 = load double, double* %10
%20 = fadd double %19, 1.010000e-02
%21 = call i32 (double, double, ...) bitcast (i32 (...)* @dt2jd to i32 (double, double, ...)*)(double %20, double 0.000000e+00)
%22 = sitofp i32 %21 to double
store double %22, double* %9
%23 = load double, double* %4
%24 = load double, double* %9
%25 = fsub double %23, %24
%26 = fadd double %25, 1.000000e+00
%27 = load double*, double** %6
store double %26, double* %27
ret void
}

LLVM IR (-O2):
define void @jd2doy(double %0, i32* nocapture writeonly %1, double* nocapture writeonly %2) {
%4 = alloca double
%5 = alloca double
%6 = bitcast double* %4 to i8*
%7 = bitcast double* %5 to i8*
%8 = call i32 (double, double*, double*, ...) bitcast (i32 (...)* @jd2dt to i32 (double, double*, double*, ...)*)(double %0, double* %4, double* %5)
%9 = load double, double* %4
%10 = fptosi double %9 to i32
store i32 %10, i32* %1
%11 = sitofp i32 %10 to double
%12 = fadd double %11, 1.010000e-02
%13 = call i32 (double, double, ...) bitcast (i32 (...)* @dt2jd to i32 (double, double, ...)*)(double %12, double 0.000000e+00)
%14 = sitofp i32 %13 to double
%15 = fsub double %0, %14
%16 = fadd double %15, 1.000000e+00
store double %16, double* %2
ret void
}