void juliadtodate(jday, year, tmon, tday) short jday;
short year;
short *tmon;
short *tday;
{
  static short nrofdays[14] = {0,   0,   31,  59,  90,  120, 151,
                               181, 212, 243, 273, 304, 334, 365};
  short int a;
  if ((year % 4) == 0) {
    for (a = 3; a <= 13; a++)
      nrofdays[a]++;
  }
  a = 0;
  while (nrofdays[a] < jday)
    a++;
  (*tmon) = a - 1;
  (*tday) = jday - nrofdays[a - 1];
  if ((year % 4) == 0) {
    for (a = 3; a <= 13; a++)
      nrofdays[a]--;
  }
}


x86 assembly (clang, -O0):
<juliadtodate>:
push   %rbp
mov    %rsp,%rbp
mov    %esi,%eax
mov    %di,%si
mov    %si,-0x2(%rbp)
mov    %ax,-0x4(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movswl -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1176 <juliadtodate+0x76>
movw   $0x3,-0x1a(%rbp)
movswl -0x1a(%rbp),%eax
cmp    $0xd,%eax
jg     1171 <juliadtodate+0x71>
movswq -0x1a(%rbp),%rcx
lea    0x2ee3(%rip),%rax
mov    (%rax,%rcx,2),%dx
add    $0x1,%dx
lea    0x2ed4(%rip),%rax
mov    %dx,(%rax,%rcx,2)
mov    -0x1a(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x1a(%rbp)
jmp    1134 <juliadtodate+0x34>
jmp    1176 <juliadtodate+0x76>
movw   $0x0,-0x1a(%rbp)
movswq -0x1a(%rbp),%rcx
lea    0x2ea8(%rip),%rax
movswl (%rax,%rcx,2),%eax
movswl -0x2(%rbp),%ecx
cmp    %ecx,%eax
jge    11a9 <juliadtodate+0xa9>
mov    -0x1a(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x1a(%rbp)
jmp    117c <juliadtodate+0x7c>
movswl -0x1a(%rbp),%eax
sub    $0x1,%eax
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
movswl -0x2(%rbp),%eax
movswl -0x1a(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rdx
lea    0x2e61(%rip),%rcx
movswl (%rcx,%rdx,2),%ecx
sub    %ecx,%eax
mov    %ax,%cx
mov    -0x18(%rbp),%rax
mov    %cx,(%rax)
movswl -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    123c <juliadtodate+0x13c>
movw   $0x3,-0x1a(%rbp)
movswl -0x1a(%rbp),%eax
cmp    $0xd,%eax
jg     1237 <juliadtodate+0x137>
movswq -0x1a(%rbp),%rcx
lea    0x2e1d(%rip),%rax
mov    (%rax,%rcx,2),%dx
add    $0xffff,%dx
lea    0x2e0e(%rip),%rax
mov    %dx,(%rax,%rcx,2)
mov    -0x1a(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x1a(%rbp)
jmp    11fa <juliadtodate+0xfa>
jmp    123c <juliadtodate+0x13c>
pop    %rbp
ret

x86 assembly (clang, -O2):
<juliadtodate>:
test   $0x3,%sil
jne    1136 <juliadtodate+0x36>
movdqu 0x2f28(%rip),%xmm0
pcmpeqd %xmm1,%xmm1
psubw  %xmm1,%xmm0
movdqu %xmm0,0x2f18(%rip)
addw   $0x1,0x2f20(%rip)
01
addw   $0x1,0x2f1a(%rip)
01
addw   $0x1,0x2f14(%rip)
01
movswl %di,%r9d
mov    $0xffff,%r10w
lea    0x2eea(%rip),%r8
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r10d
movswq %r10w,%rax
movswl (%r8,%rax,2),%eax
cmp    %eax,%r9d
jg     1150 <juliadtodate+0x50>
lea    -0x1(%r10),%eax
mov    %ax,(%rdx)
movswq %r10w,%rax
sub    -0x2(%r8,%rax,2),%di
mov    %di,(%rcx)
test   $0x3,%sil
je     117d <juliadtodate+0x7d>
ret
movdqu 0x2eb1(%rip),%xmm0
pcmpeqd %xmm1,%xmm1
paddw  %xmm0,%xmm1
movdqu %xmm1,0x2ea1(%rip)
addw   $0xffff,0x2ea9(%rip)
ff
addw   $0xffff,0x2ea3(%rip)
ff
addw   $0xffff,0x2e9d(%rip)
ff
ret

LLVM IR (-O0):
@juliadtodate.nrofdays = internal global [14 x i16] [i16 0, i16 0, i16 31, i16 59, i16 90, i16 120, i16 151, i16 181, i16 212, i16 243, i16 273, i16 304, i16 334, i16 365]
define void @juliadtodate(i32 %0, i32 %1, i16* %2, i16* %3) {
%5 = alloca i16
%6 = alloca i16
%7 = alloca i16*
%8 = alloca i16*
%9 = alloca i16
%10 = trunc i32 %0 to i16
%11 = trunc i32 %1 to i16
store i16 %10, i16* %5
store i16 %11, i16* %6
store i16* %2, i16** %7
store i16* %3, i16** %8
%12 = load i16, i16* %6
%13 = sext i16 %12 to i32
%14 = srem i32 %13, 4
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %31
16: ; preds = %4
store i16 3, i16* %9
br label %17
17: ; preds = %27, %16
%18 = load i16, i16* %9
%19 = sext i16 %18 to i32
%20 = icmp sle i32 %19, 13
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = load i16, i16* %9
%23 = sext i16 %22 to i64
%24 = getelementptr inbounds [14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 %23
%25 = load i16, i16* %24
%26 = add i16 %25, 1
store i16 %26, i16* %24
br label %27
27: ; preds = %21
%28 = load i16, i16* %9
%29 = add i16 %28, 1
store i16 %29, i16* %9
br label %17
30: ; preds = %17
br label %31
31: ; preds = %30, %4
store i16 0, i16* %9
br label %32
32: ; preds = %41, %31
%33 = load i16, i16* %9
%34 = sext i16 %33 to i64
%35 = getelementptr inbounds [14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 %34
%36 = load i16, i16* %35
%37 = sext i16 %36 to i32
%38 = load i16, i16* %5
%39 = sext i16 %38 to i32
%40 = icmp slt i32 %37, %39
br i1 %40, label %41, label %44
41: ; preds = %32
%42 = load i16, i16* %9
%43 = add i16 %42, 1
store i16 %43, i16* %9
br label %32
44: ; preds = %32
%45 = load i16, i16* %9
%46 = sext i16 %45 to i32
%47 = sub nsw i32 %46, 1
%48 = trunc i32 %47 to i16
%49 = load i16*, i16** %7
store i16 %48, i16* %49
%50 = load i16, i16* %5
%51 = sext i16 %50 to i32
%52 = load i16, i16* %9
%53 = sext i16 %52 to i32
%54 = sub nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 %55
%57 = load i16, i16* %56
%58 = sext i16 %57 to i32
%59 = sub nsw i32 %51, %58
%60 = trunc i32 %59 to i16
%61 = load i16*, i16** %8
store i16 %60, i16* %61
%62 = load i16, i16* %6
%63 = sext i16 %62 to i32
%64 = srem i32 %63, 4
%65 = icmp eq i32 %64, 0
br i1 %65, label %66, label %81
66: ; preds = %44
store i16 3, i16* %9
br label %67
67: ; preds = %77, %66
%68 = load i16, i16* %9
%69 = sext i16 %68 to i32
%70 = icmp sle i32 %69, 13
br i1 %70, label %71, label %80
71: ; preds = %67
%72 = load i16, i16* %9
%73 = sext i16 %72 to i64
%74 = getelementptr inbounds [14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 %73
%75 = load i16, i16* %74
%76 = add i16 %75, -1
store i16 %76, i16* %74
br label %77
77: ; preds = %71
%78 = load i16, i16* %9
%79 = add i16 %78, 1
store i16 %79, i16* %9
br label %67
80: ; preds = %67
br label %81
81: ; preds = %80, %44
ret void
}

LLVM IR (-O2):
@juliadtodate.nrofdays = internal unnamed_addr global [14 x i16] [i16 0, i16 0, i16 31, i16 59, i16 90, i16 120, i16 151, i16 181, i16 212, i16 243, i16 273, i16 304, i16 334, i16 365]
define void @juliadtodate(i32 %0, i32 %1, i16* nocapture writeonly %2, i16* nocapture writeonly %3) {
%5 = and i32 %1, 3
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %4
%8 = load <8 x i16>, <8 x i16>* bitcast (i16* getelementptr inbounds ([14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 3) to <8 x i16>*)
%9 = add <8 x i16> %8, <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>
store <8 x i16> %9, <8 x i16>* bitcast (i16* getelementptr inbounds ([14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 3) to <8 x i16>*)
%10 = load i16, i16* getelementptr inbounds ([14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 11)
%11 = add i16 %10, 1
store i16 %11, i16* getelementptr inbounds ([14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 11)
%12 = load i16, i16* getelementptr inbounds ([14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 12)
%13 = add i16 %12, 1
store i16 %13, i16* getelementptr inbounds ([14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 12)
%14 = load i16, i16* getelementptr inbounds ([14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 13)
%15 = add i16 %14, 1
store i16 %15, i16* getelementptr inbounds ([14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 13)
br label %16
16: ; preds = %7, %4
%17 = shl i32 %0, 16
%18 = ashr exact i32 %17, 16
br label %19
19: ; preds = %19, %16
%20 = phi i16 [ 0, %16 ], [ %26, %19 ]
%21 = sext i16 %20 to i64
%22 = getelementptr inbounds [14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 %21
%23 = load i16, i16* %22
%24 = sext i16 %23 to i32
%25 = icmp sgt i32 %18, %24
%26 = add i16 %20, 1
br i1 %25, label %19, label %27
27: ; preds = %19
%28 = sext i16 %20 to i32
%29 = add nsw i32 %28, -1
%30 = trunc i32 %29 to i16
store i16 %30, i16* %2
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds [14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 %31
%33 = load i16, i16* %32
%34 = trunc i32 %0 to i16
%35 = sub i16 %34, %33
store i16 %35, i16* %3
br i1 %6, label %36, label %45
36: ; preds = %27
%37 = load <8 x i16>, <8 x i16>* bitcast (i16* getelementptr inbounds ([14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 3) to <8 x i16>*)
%38 = add <8 x i16> %37, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
store <8 x i16> %38, <8 x i16>* bitcast (i16* getelementptr inbounds ([14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 3) to <8 x i16>*)
%39 = load i16, i16* getelementptr inbounds ([14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 11)
%40 = add i16 %39, -1
store i16 %40, i16* getelementptr inbounds ([14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 11)
%41 = load i16, i16* getelementptr inbounds ([14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 12)
%42 = add i16 %41, -1
store i16 %42, i16* getelementptr inbounds ([14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 12)
%43 = load i16, i16* getelementptr inbounds ([14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 13)
%44 = add i16 %43, -1
store i16 %44, i16* getelementptr inbounds ([14 x i16], [14 x i16]* @juliadtodate.nrofdays, i64 0, i64 13)
br label %45
45: ; preds = %36, %27
ret void
}