void print_day(int day) {
  char days[8][10] = {"",         "Monday", "Tuesday",  "Wednesday",
                      "Thursday", "Friday", "Saturday", "Sunday"};
  if (day < 1 || day > 7)
    printf("Illegal day number!\n");
  printf("%s\n", days[day]);
}


x86 assembly (clang, -O0):
<print_day>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xeca(%rip),%rsi
mov    $0x50,%edx
call   1040 <memcpy@plt>
cmpl   $0x1,-0x4(%rbp)
jl     1154 <print_day+0x34>
cmpl   $0x7,-0x4(%rbp)
jle    1162 <print_day+0x42>
lea    0xef5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x4(%rbp),%rax
lea    -0x60(%rbp),%rsi
imul   $0xa,%rax,%rax
add    %rax,%rsi
lea    0xeed(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_day>:
push   %rbx
sub    $0x50,%rsp
mov    %edi,%ebx
movaps 0xf22(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xf06(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeea(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xece(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb2(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    -0x8(%rbx),%eax
cmp    $0xfffffff8,%eax
ja     1166 <print_day+0x56>
lea    0xeef(%rip),%rdi
call   1030 <puts@plt>
movslq %ebx,%rax
lea    (%rax,%rax,4),%rax
lea    (%rsp,%rax,2),%rdi
call   1030 <puts@plt>
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.print_day.days = [8 x [10 x i8]] [[10 x i8] zeroinitializer, [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", [10 x i8] c"Sunday\00\00\00\00"]
@.str = [21 x i8] c"Illegal day number!\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @print_day(i32 %0) {
%2 = alloca i32
%3 = alloca [8 x [10 x i8]]
store i32 %0, i32* %2
%4 = bitcast [8 x [10 x i8]]* %3 to i8*
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 1
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 7
br i1 %9, label %10, label %12
10: ; preds = %7, %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [8 x [10 x i8]], [8 x [10 x i8]]* %3, i64 0, i64 %14
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %15, i64 0, i64 0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %16)
ret void
}

LLVM IR (-O2):
@__const.print_day.days = [8 x [10 x i8]] [[10 x i8] zeroinitializer, [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", [10 x i8] c"Sunday\00\00\00\00"]
@str = [20 x i8] c"Illegal day number!\00"
define void @print_day(i32 %0) {
%2 = alloca [8 x [10 x i8]]
%3 = getelementptr inbounds [8 x [10 x i8]], [8 x [10 x i8]]* %2, i64 0, i64 0, i64 0
%4 = add i32 %0, -8
%5 = icmp ult i32 %4, -7
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %8
8: ; preds = %1, %6
%9 = sext i32 %0 to i64
%10 = getelementptr inbounds [8 x [10 x i8]], [8 x [10 x i8]]* %2, i64 0, i64 %9, i64 0
%11 = call i32 @puts(i8* %10)
ret void
}