char *dayOfTheWeek(int day, int month, int year) {
  int D, W;
  D = CalDay(year, month, day);
  W = year - 1 + (int)((year - 1) / 4) - (int)((year - 1) / 100) +
      (int)((year - 1) / 400) + D;
  static char weekday[7][10] = {"Sunday",   "Monday", "Tuesday", "Wednesday",
                                "Thursday", "Friday", "Saturday"};
  return weekday[W % 7];
}


x86 assembly (clang, -O0):
<dayOfTheWeek>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    $0x0,%al
call   1030 <CalDay@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
add    %ecx,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
lea    0x2e93(%rip),%rax
imul   $0xa,%rcx,%rcx
add    %rcx,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dayOfTheWeek>:
push   %rbx
mov    %edx,%ebx
mov    %edi,%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1030 <CalDay@plt>
lea    -0x1(%rbx),%ecx
lea    0x2(%rbx),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
sar    $0x2,%edx
add    %ebx,%edx
add    $0xffffffff,%edx
movslq %ecx,%rcx
imul   $0xffffffffae147ae1,%rcx,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
shr    $0x20,%rsi
sar    $0x5,%esi
add    %edi,%esi
add    %edx,%esi
imul   $0x51eb851f,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x7,%ecx
add    %edx,%ecx
add    %esi,%ecx
add    %eax,%ecx
movslq %ecx,%rax
imul   $0xffffffff92492493,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x2,%ecx
add    %edx,%ecx
lea    0x0(,%rcx,8),%edx
sub    %edx,%ecx
add    %eax,%ecx
movslq %ecx,%rax
lea    (%rax,%rax,4),%rax
lea    0x2e95(%rip),%rcx
lea    (%rcx,%rax,2),%rax
pop    %rbx
ret

LLVM IR (-O0):
@dayOfTheWeek.weekday = internal global [7 x [10 x i8]] [[10 x i8] c"Sunday\00\00\00\00", [10 x i8] c"Monday\00\00\00\00", [10 x i8] c"Tuesday\00\00\00", [10 x i8] c"Wednesday\00", [10 x i8] c"Thursday\00\00", [10 x i8] c"Friday\00\00\00\00", [10 x i8] c"Saturday\00\00"]
define i8* @dayOfTheWeek(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %6
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @CalDay to i32 (i32, i32, i32, ...)*)(i32 %9, i32 %10, i32 %11)
store i32 %12, i32* %7
%13 = load i32, i32* %6
%14 = sub nsw i32 %13, 1
%15 = load i32, i32* %6
%16 = sub nsw i32 %15, 1
%17 = sdiv i32 %16, 4
%18 = add nsw i32 %14, %17
%19 = load i32, i32* %6
%20 = sub nsw i32 %19, 1
%21 = sdiv i32 %20, 100
%22 = sub nsw i32 %18, %21
%23 = load i32, i32* %6
%24 = sub nsw i32 %23, 1
%25 = sdiv i32 %24, 400
%26 = add nsw i32 %22, %25
%27 = load i32, i32* %7
%28 = add nsw i32 %26, %27
store i32 %28, i32* %8
%29 = load i32, i32* %8
%30 = srem i32 %29, 7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [7 x [10 x i8]], [7 x [10 x i8]]* @dayOfTheWeek.weekday, i64 0, i64 %31
%33 = getelementptr inbounds [10 x i8], [10 x i8]* %32, i64 0, i64 0
ret i8* %33
}

LLVM IR (-O2):
@dayOfTheWeek.weekday = internal global [7 x [10 x i8]] [[10 x i8] c"Sunday\00\00\00\00", [10 x i8] c"Monday\00\00\00\00", [10 x i8] c"Tuesday\00\00\00", [10 x i8] c"Wednesday\00", [10 x i8] c"Thursday\00\00", [10 x i8] c"Friday\00\00\00\00", [10 x i8] c"Saturday\00\00"]
define i8* @dayOfTheWeek(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @CalDay to i32 (i32, i32, i32, ...)*)(i32 %2, i32 %1, i32 %0)
%5 = add nsw i32 %2, -1
%6 = sdiv i32 %5, 4
%7 = add nsw i32 %6, %5
%8 = sdiv i32 %5, -100
%9 = add i32 %7, %8
%10 = sdiv i32 %5, 400
%11 = add nsw i32 %9, %10
%12 = add nsw i32 %11, %4
%13 = srem i32 %12, 7
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [7 x [10 x i8]], [7 x [10 x i8]]* @dayOfTheWeek.weekday, i64 0, i64 %14, i64 0
ret i8* %15
}