int Julian2Gregorian(int *d, int *m, int *y, int jd) {
  int l = 0, n = 0, i = 0, j = 0;
  l = jd + 68569;
  n = (4 * l) / 146097;
  l = l - (146097 * n + 3) / 4;
  i = (4000 * (l + 1)) / 1461001;
  l = l - (1461 * i) / 4 + 31;
  j = (80 * l) / 2447;
  *d = l - (2447 * j) / 80;
  l = j / 11;
  *m = j + 2 - (12 * l);
  *y = 100 * (n - 49) + i + l;
  return 0;
}


x86 assembly (clang, -O0):
<Julian2Gregorian>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x10bd9,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
shl    $0x2,%eax
mov    $0x23ab1,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x34(%rbp)
imul   $0x23ab1,-0x24(%rbp),%eax
add    $0x3,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
imul   $0xfa0,%eax,%eax
mov    $0x164b09,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x30(%rbp)
imul   $0x5b5,-0x28(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
sub    %ecx,%eax
add    $0x1f,%eax
mov    %eax,-0x20(%rbp)
imul   $0x50,-0x20(%rbp),%eax
mov    $0x98f,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%ecx
imul   $0x98f,-0x2c(%rbp),%eax
mov    $0x50,%esi
cltd
idiv   %esi
sub    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%eax
mov    $0xb,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
mov    -0x2c(%rbp),%ecx
add    $0x2,%ecx
imul   $0xc,-0x20(%rbp),%eax
sub    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x24(%rbp),%eax
sub    $0x31,%eax
imul   $0x64,%eax,%ecx
add    -0x28(%rbp),%ecx
add    -0x20(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<Julian2Gregorian>:
push   %rbx
lea    0x42f64(,%rcx,4),%r8d
mov    %ecx,%r10d
add    $0x10bd9,%r10d
movslq %r8d,%rcx
imul   $0x396b06bd,%rcx,%r8
mov    %r8,%rcx
shr    $0x3f,%rcx
shr    $0x20,%r8
sar    $0xf,%r8d
add    %ecx,%r8d
imul   $0x23ab1,%r8d,%ecx
lea    0x3(%rcx),%eax
add    $0x6,%ecx
test   %eax,%eax
cmovns %eax,%ecx
sar    $0x2,%ecx
sub    %ecx,%r10d
imul   $0xfa0,%r10d,%eax
mov    %eax,%ecx
add    $0xfa0,%ecx
movslq %ecx,%rcx
imul   $0xffffffffb7bbe2dd,%rcx,%rcx
shr    $0x20,%rcx
lea    (%rcx,%rax,1),%r9d
add    $0xfa0,%r9d
mov    %r9d,%eax
shr    $0x1f,%eax
sar    $0x14,%r9d
add    %eax,%r9d
imul   $0x5b5,%r9d,%eax
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
sar    $0x2,%ecx
neg    %ecx
add    %ecx,%r10d
add    $0x1f,%r10d
mov    %r10d,%eax
shl    $0x4,%eax
lea    (%rax,%rax,4),%eax
movslq %eax,%rbx
imul   $0x1ac83d19,%rbx,%rcx
mov    %rcx,%r11
shr    $0x3f,%r11
shr    $0x20,%rcx
sar    $0x8,%ecx
add    %r11d,%ecx
imul   $0x98f,%ecx,%eax
cltq
imul   $0xffffffff99999999,%rax,%rax
mov    %rax,%r11
shr    $0x3f,%r11
shr    $0x20,%rax
sar    $0x5,%eax
add    %r11d,%eax
add    %r10d,%eax
mov    %eax,(%rdi)
imul   $0xffffffff9bd2d7d7,%rbx,%rax
shr    $0x20,%rax
add    %eax,%ebx
mov    %ebx,%eax
shr    $0x1f,%eax
sar    $0xe,%ebx
add    %eax,%ebx
lea    0x0(,%rbx,4),%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%ecx
add    $0x2,%ecx
mov    %ecx,(%rsi)
imul   $0x64,%r8d,%eax
add    %r9d,%eax
add    %ebx,%eax
add    $0xffffecdc,%eax
mov    %eax,(%rdx)
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @Julian2Gregorian(i32* %0, i32* %1, i32* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
%13 = load i32, i32* %8
%14 = add nsw i32 %13, 68569
store i32 %14, i32* %9
%15 = load i32, i32* %9
%16 = mul nsw i32 4, %15
%17 = sdiv i32 %16, 146097
store i32 %17, i32* %10
%18 = load i32, i32* %9
%19 = load i32, i32* %10
%20 = mul nsw i32 146097, %19
%21 = add nsw i32 %20, 3
%22 = sdiv i32 %21, 4
%23 = sub nsw i32 %18, %22
store i32 %23, i32* %9
%24 = load i32, i32* %9
%25 = add nsw i32 %24, 1
%26 = mul nsw i32 4000, %25
%27 = sdiv i32 %26, 1461001
store i32 %27, i32* %11
%28 = load i32, i32* %9
%29 = load i32, i32* %11
%30 = mul nsw i32 1461, %29
%31 = sdiv i32 %30, 4
%32 = sub nsw i32 %28, %31
%33 = add nsw i32 %32, 31
store i32 %33, i32* %9
%34 = load i32, i32* %9
%35 = mul nsw i32 80, %34
%36 = sdiv i32 %35, 2447
store i32 %36, i32* %12
%37 = load i32, i32* %9
%38 = load i32, i32* %12
%39 = mul nsw i32 2447, %38
%40 = sdiv i32 %39, 80
%41 = sub nsw i32 %37, %40
%42 = load i32*, i32** %5
store i32 %41, i32* %42
%43 = load i32, i32* %12
%44 = sdiv i32 %43, 11
store i32 %44, i32* %9
%45 = load i32, i32* %12
%46 = add nsw i32 %45, 2
%47 = load i32, i32* %9
%48 = mul nsw i32 12, %47
%49 = sub nsw i32 %46, %48
%50 = load i32*, i32** %6
store i32 %49, i32* %50
%51 = load i32, i32* %10
%52 = sub nsw i32 %51, 49
%53 = mul nsw i32 100, %52
%54 = load i32, i32* %11
%55 = add nsw i32 %53, %54
%56 = load i32, i32* %9
%57 = add nsw i32 %55, %56
%58 = load i32*, i32** %7
store i32 %57, i32* %58
ret i32 0
}

LLVM IR (-O2):
define i32 @Julian2Gregorian(i32* nocapture writeonly %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32 %3) {
%5 = add nsw i32 %3, 68569
%6 = shl nsw i32 %5, 2
%7 = sdiv i32 %6, 146097
%8 = mul nsw i32 %7, 146097
%9 = add nsw i32 %8, 3
%10 = sdiv i32 %9, -4
%11 = add i32 %10, %5
%12 = mul i32 %11, 4000
%13 = add i32 %12, 4000
%14 = sdiv i32 %13, 1461001
%15 = mul nsw i32 %14, 1461
%16 = sdiv i32 %15, -4
%17 = add i32 %11, 31
%18 = add i32 %17, %16
%19 = mul nsw i32 %18, 80
%20 = sdiv i32 %19, 2447
%21 = mul nsw i32 %20, 2447
%22 = sdiv i32 %21, -80
%23 = add i32 %22, %18
store i32 %23, i32* %0
%24 = sdiv i32 %19, 26917
%25 = add nsw i32 %20, 2
%26 = mul nsw i32 %24, -12
%27 = add nsw i32 %25, %26
store i32 %27, i32* %1
%28 = mul nsw i32 %7, 100
%29 = add nsw i32 %28, -4900
%30 = add nsw i32 %29, %14
%31 = add nsw i32 %30, %24
store i32 %31, i32* %2
ret i32 0
}