int get_doomsday(unsigned int year) {
  int doomsday = 3;
  int two_digit_year = year % 100;
  int difference = ((year / 100) - 19) % 4;
  switch (difference) {
  case 0:
    doomsday = 3;
    break;
  case 1:
    doomsday = 2;
    break;
  case 2:
    doomsday = 0;
    break;
  case 3:
    doomsday = 5;
    break;
  }
  doomsday += two_digit_year / 12;
  doomsday += two_digit_year % 12;
  doomsday += (two_digit_year % 12) / 4;
  doomsday %= 7;
  return doomsday;
}


x86 assembly (clang, -O0):
<get_doomsday>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
mov    %ecx,%eax
imul   $0x51eb851f,%rcx,%rcx
shr    $0x25,%rcx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
imul   $0x51eb851f,%rax,%rax
shr    $0x25,%rax
add    $0x1,%eax
and    $0x3,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x3,%rax
ja     118f <get_doomsday+0x8f>
mov    -0x18(%rbp),%rax
lea    0xea5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x3,-0x8(%rbp)
jmp    118f <get_doomsday+0x8f>
movl   $0x2,-0x8(%rbp)
jmp    118f <get_doomsday+0x8f>
movl   $0x0,-0x8(%rbp)
jmp    118f <get_doomsday+0x8f>
movl   $0x5,-0x8(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
add    -0x8(%rbp),%edx
mov    %edx,-0x8(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_doomsday>:
mov    %edi,%eax
imul   $0x51eb851f,%rax,%rax
shr    $0x25,%rax
lea    0x0(,%rax,8),%ecx
add    $0x8,%cl
mov    $0x5000203,%edx
shr    %cl,%edx
imul   $0x64,%eax,%eax
sub    %eax,%edi
imul   $0xab,%edi,%eax
movzwl %ax,%eax
shr    $0xb,%eax
lea    0x0(,%rax,4),%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %cl,%dil
add    %dil,%al
mov    %edi,%ecx
shr    $0x2,%cl
add    %cl,%al
add    %dl,%al
movzbl %al,%eax
lea    (%rax,%rax,8),%ecx
lea    (%rax,%rcx,4),%ecx
shr    $0x8,%ecx
mov    %eax,%edx
sub    %cl,%dl
shr    %dl
add    %cl,%dl
shr    $0x2,%dl
movzbl %dl,%ecx
lea    0x0(,%rcx,8),%edx
sub    %ecx,%edx
sub    %dl,%al
movzbl %al,%eax
ret

LLVM IR (-O0):
define i32 @get_doomsday(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 3, i32* %3
%6 = load i32, i32* %2
%7 = urem i32 %6, 100
store i32 %7, i32* %4
%8 = load i32, i32* %2
%9 = udiv i32 %8, 100
%10 = sub i32 %9, 19
%11 = urem i32 %10, 4
store i32 %11, i32* %5
%12 = load i32, i32* %5
switch i32 %12, label %17 [
i32 0, label %13
i32 1, label %14
i32 2, label %15
i32 3, label %16
]
13: ; preds = %1
store i32 3, i32* %3
br label %17
14: ; preds = %1
store i32 2, i32* %3
br label %17
15: ; preds = %1
store i32 0, i32* %3
br label %17
16: ; preds = %1
store i32 5, i32* %3
br label %17
17: ; preds = %1, %16, %15, %14, %13
%18 = load i32, i32* %4
%19 = sdiv i32 %18, 12
%20 = load i32, i32* %3
%21 = add nsw i32 %20, %19
store i32 %21, i32* %3
%22 = load i32, i32* %4
%23 = srem i32 %22, 12
%24 = load i32, i32* %3
%25 = add nsw i32 %24, %23
store i32 %25, i32* %3
%26 = load i32, i32* %4
%27 = srem i32 %26, 12
%28 = sdiv i32 %27, 4
%29 = load i32, i32* %3
%30 = add nsw i32 %29, %28
store i32 %30, i32* %3
%31 = load i32, i32* %3
%32 = srem i32 %31, 7
store i32 %32, i32* %3
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
define i32 @get_doomsday(i32 %0) {
%2 = udiv i32 %0, 100
%3 = shl nuw nsw i32 %2, 3
%4 = add nuw nsw i32 %3, 8
%5 = and i32 %4, 24
%6 = lshr i32 83886595, %5
%7 = trunc i32 %6 to i8
%8 = urem i32 %0, 100
%9 = trunc i32 %8 to i8
%10 = udiv i8 %9, 12
%11 = urem i8 %9, 12
%12 = lshr i8 %11, 2
%13 = add nuw nsw i8 %11, %10
%14 = add nuw nsw i8 %13, %12
%15 = add nuw nsw i8 %14, %7
%16 = urem i8 %15, 7
%17 = zext i8 %16 to i32
ret i32 %17
}