void mjd2ymd(int mjd, int *year, int *month, int *day) {
  int jd, temp1, temp2;
  jd = mjd + 2400001;
  temp1 = 4 * (jd + ((6 * (((4 * jd - 17918) / 146097))) / 4 + 1) / 2 - 37);
  temp2 = 10 * (((temp1 - 237) % 1461) / 4) + 5;
  *year = temp1 / 1461 - 4712;
  *month = ((temp2 / 306 + 2) % 12) + 1;
  *day = (temp2 % 306) / 10 + 1;
}


x86 assembly (clang, -O0):
<mjd2ymd>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x4(%rbp),%eax
add    $0x249f01,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
shl    $0x2,%eax
sub    $0x45fe,%eax
mov    $0x23ab1,%ecx
cltd
idiv   %ecx
imul   $0x6,%eax,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
sub    $0x25,%eax
shl    $0x2,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
sub    $0xed,%eax
mov    $0x5b5,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
imul   $0xa,%eax,%eax
add    $0x5,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x5b5,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
sub    $0x1268,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%eax
mov    $0x132,%ecx
cltd
idiv   %ecx
add    $0x2,%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    -0x18(%rbp),%rax
mov    %edx,(%rax)
mov    -0x2c(%rbp),%eax
mov    $0x132,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<mjd2ymd>:
lea    0x923606(,%rdi,4),%eax
cltq
imul   $0x396b06bd,%rax,%rax
mov    %rax,%r8
shr    $0x3f,%r8
sar    $0x2f,%rax
add    %r8d,%eax
add    %eax,%eax
lea    (%rax,%rax,2),%r8d
lea    (%rax,%rax,2),%eax
add    $0x3,%eax
test   %r8d,%r8d
cmovns %r8d,%eax
shr    $0x2,%eax
add    $0x1,%eax
movzwl %ax,%r8d
mov    %r8d,%eax
shr    $0xf,%eax
add    %r8d,%eax
cwtl
sar    %eax
add    %edi,%eax
add    $0x249f01,%eax
lea    -0x94(,%rax,4),%r8d
ff
lea    -0x181(,%rax,4),%eax
cltq
imul   $0x166db073,%rax,%rdi
mov    %rdi,%r9
shr    $0x3f,%r9
sar    $0x27,%rdi
add    %r9d,%edi
imul   $0x5b5,%edi,%edi
sub    %edi,%eax
lea    0x3(%rax),%edi
test   %ax,%ax
cmovns %eax,%edi
movswl %di,%eax
sar    $0x2,%eax
lea    (%rax,%rax,4),%eax
lea    (%rax,%rax,1),%r9d
add    $0x5,%r9d
movslq %r8d,%rdi
imul   $0x166db073,%rdi,%rdi
mov    %rdi,%rax
sar    $0x27,%rax
shr    $0x3f,%rdi
add    %edi,%eax
add    $0xffffed98,%eax
mov    %eax,(%rsi)
movswl %r9w,%eax
imul   $0x358b,%eax,%esi
mov    %esi,%eax
shr    $0x1f,%eax
sar    $0x16,%esi
add    %eax,%esi
lea    0x2(%rsi),%eax
movsbl %al,%eax
imul   $0x2b,%eax,%r8d
movzwl %r8w,%edi
shr    $0x9,%r8d
shr    $0xf,%edi
add    %r8b,%dil
movzbl %dil,%edi
shl    $0x2,%edi
lea    (%rdi,%rdi,2),%edi
sub    %dil,%al
add    $0x1,%al
movsbl %al,%eax
mov    %eax,(%rdx)
imul   $0x132,%esi,%eax
sub    %eax,%r9d
movswl %r9w,%eax
imul   $0x6667,%eax,%eax
mov    %eax,%edx
sar    $0x12,%edx
shr    $0x1f,%eax
add    %edx,%eax
add    $0x1,%eax
cwtl
mov    %eax,(%rcx)
ret

LLVM IR (-O0):
define void @mjd2ymd(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
store i32 %0, i32* %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%12 = load i32, i32* %5
%13 = add nsw i32 %12, 2400001
store i32 %13, i32* %9
%14 = load i32, i32* %9
%15 = load i32, i32* %9
%16 = mul nsw i32 4, %15
%17 = sub nsw i32 %16, 17918
%18 = sdiv i32 %17, 146097
%19 = mul nsw i32 6, %18
%20 = sdiv i32 %19, 4
%21 = add nsw i32 %20, 1
%22 = sdiv i32 %21, 2
%23 = add nsw i32 %14, %22
%24 = sub nsw i32 %23, 37
%25 = mul nsw i32 4, %24
store i32 %25, i32* %10
%26 = load i32, i32* %10
%27 = sub nsw i32 %26, 237
%28 = srem i32 %27, 1461
%29 = sdiv i32 %28, 4
%30 = mul nsw i32 10, %29
%31 = add nsw i32 %30, 5
store i32 %31, i32* %11
%32 = load i32, i32* %10
%33 = sdiv i32 %32, 1461
%34 = sub nsw i32 %33, 4712
%35 = load i32*, i32** %6
store i32 %34, i32* %35
%36 = load i32, i32* %11
%37 = sdiv i32 %36, 306
%38 = add nsw i32 %37, 2
%39 = srem i32 %38, 12
%40 = add nsw i32 %39, 1
%41 = load i32*, i32** %7
store i32 %40, i32* %41
%42 = load i32, i32* %11
%43 = srem i32 %42, 306
%44 = sdiv i32 %43, 10
%45 = add nsw i32 %44, 1
%46 = load i32*, i32** %8
store i32 %45, i32* %46
ret void
}

LLVM IR (-O2):
define void @mjd2ymd(i32 %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = add nsw i32 %0, 2400001
%6 = shl nsw i32 %5, 2
%7 = add nsw i32 %6, -17918
%8 = sdiv i32 %7, 146097
%9 = mul nsw i32 %8, 6
%10 = sdiv i32 %9, 4
%11 = trunc i32 %10 to i16
%12 = add nsw i16 %11, 1
%13 = sdiv i16 %12, 2
%14 = sext i16 %13 to i32
%15 = add nsw i32 %5, %14
%16 = shl i32 %15, 2
%17 = add i32 %16, -148
%18 = add i32 %16, -385
%19 = srem i32 %18, 1461
%20 = trunc i32 %19 to i16
%21 = sdiv i16 %20, 4
%22 = mul nsw i16 %21, 10
%23 = add nsw i16 %22, 5
%24 = sdiv i32 %17, 1461
%25 = add nsw i32 %24, -4712
store i32 %25, i32* %1
%26 = sdiv i16 %23, 306
%27 = trunc i16 %26 to i8
%28 = add nsw i8 %27, 2
%29 = srem i8 %28, 12
%30 = add nsw i8 %29, 1
%31 = sext i8 %30 to i32
store i32 %31, i32* %2
%32 = srem i16 %23, 306
%33 = sdiv i16 %32, 10
%34 = add nsw i16 %33, 1
%35 = sext i16 %34 to i32
store i32 %35, i32* %3
ret void
}