int getCenturyAnchorDay(int year) {
  year %= 400;
  if (year >= 0 && year <= 99)
    return 2;
  if (year >= 100 && year <= 199)
    return 0;
  if (year >= 200 && year <= 299)
    return 5;
  if (year >= 300 && year <= 399)
    return 3;
  return 0;
}


x86 assembly (clang, -O0):
<getCenturyAnchorDay>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1135 <getCenturyAnchorDay+0x35>
cmpl   $0x63,-0x8(%rbp)
jg     1135 <getCenturyAnchorDay+0x35>
movl   $0x2,-0x4(%rbp)
jmp    11ab <getCenturyAnchorDay+0xab>
cmpl   $0x64,-0x8(%rbp)
jl     1158 <getCenturyAnchorDay+0x58>
cmpl   $0xc7,-0x8(%rbp)
jg     1158 <getCenturyAnchorDay+0x58>
movl   $0x0,-0x4(%rbp)
jmp    11ab <getCenturyAnchorDay+0xab>
cmpl   $0xc8,-0x8(%rbp)
jl     117e <getCenturyAnchorDay+0x7e>
cmpl   $0x12b,-0x8(%rbp)
jg     117e <getCenturyAnchorDay+0x7e>
movl   $0x5,-0x4(%rbp)
jmp    11ab <getCenturyAnchorDay+0xab>
cmpl   $0x12c,-0x8(%rbp)
jl     11a4 <getCenturyAnchorDay+0xa4>
cmpl   $0x18f,-0x8(%rbp)
jg     11a4 <getCenturyAnchorDay+0xa4>
movl   $0x3,-0x4(%rbp)
jmp    11ab <getCenturyAnchorDay+0xab>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCenturyAnchorDay>:
movslq %edi,%rcx
imul   $0x51eb851f,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x27,%rax
add    %edx,%eax
imul   $0x190,%eax,%eax
sub    %eax,%ecx
mov    $0x2,%eax
cmp    $0x64,%ecx
jb     1151 <getCenturyAnchorDay+0x51>
lea    -0x64(%rcx),%edx
xor    %eax,%eax
cmp    $0x64,%edx
jb     1151 <getCenturyAnchorDay+0x51>
lea    -0xc8(%rcx),%edx
mov    $0x5,%eax
cmp    $0x64,%edx
jb     1151 <getCenturyAnchorDay+0x51>
xor    %eax,%eax
cmp    $0x12c,%ecx
setge  %al
lea    (%rax,%rax,2),%eax
ret

LLVM IR (-O0):
define i32 @getCenturyAnchorDay(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = srem i32 %4, 400
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp sge i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i32, i32* %3
%10 = icmp sle i32 %9, 99
br i1 %10, label %11, label %12
11: ; preds = %8
store i32 2, i32* %2
br label %34
12: ; preds = %8, %1
%13 = load i32, i32* %3
%14 = icmp sge i32 %13, 100
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i32, i32* %3
%17 = icmp sle i32 %16, 199
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 0, i32* %2
br label %34
19: ; preds = %15, %12
%20 = load i32, i32* %3
%21 = icmp sge i32 %20, 200
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load i32, i32* %3
%24 = icmp sle i32 %23, 299
br i1 %24, label %25, label %26
25: ; preds = %22
store i32 5, i32* %2
br label %34
26: ; preds = %22, %19
%27 = load i32, i32* %3
%28 = icmp sge i32 %27, 300
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i32, i32* %3
%31 = icmp sle i32 %30, 399
br i1 %31, label %32, label %33
32: ; preds = %29
store i32 3, i32* %2
br label %34
33: ; preds = %29, %26
store i32 0, i32* %2
br label %34
34: ; preds = %33, %32, %25, %18, %11
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
define i32 @getCenturyAnchorDay(i32 %0) {
%2 = srem i32 %0, 400
%3 = icmp ult i32 %2, 100
br i1 %3, label %13, label %4
4: ; preds = %1
%5 = add nsw i32 %2, -100
%6 = icmp ult i32 %5, 100
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = add nsw i32 %2, -200
%9 = icmp ult i32 %8, 100
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = icmp sgt i32 %2, 299
%12 = select i1 %11, i32 3, i32 0
br label %13
13: ; preds = %10, %7, %4, %1
%14 = phi i32 [ 2, %1 ], [ 0, %4 ], [ 5, %7 ], [ %12, %10 ]
ret i32 %14
}