#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int weekday(int, int, int);
void print_weekday_name(int day, int month, int year) {
  int result = weekday(day, month, year);
  if (result == 1) {
    printf("Monday");
  } else if (result == 2) {
    printf("Tuesday");
  } else if (result == 3) {
    printf("Wednesday");
  } else if (result == 4) {
    printf("Thursday");
  } else if (result == 4) {
    printf("Friday");
  } else if (result == 6) {
    printf("Saturday");
  } else if (result == 7) {
    printf("Sunday");
  } else
    printf("Error");
}


x86 assembly (clang, -O0):
<print_weekday_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <weekday@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    115d <print_weekday_name+0x3d>
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
jmp    1229 <print_weekday_name+0x109>
cmpl   $0x2,-0x10(%rbp)
jne    1178 <print_weekday_name+0x58>
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
jmp    1224 <print_weekday_name+0x104>
cmpl   $0x3,-0x10(%rbp)
jne    1193 <print_weekday_name+0x73>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
jmp    121f <print_weekday_name+0xff>
cmpl   $0x4,-0x10(%rbp)
jne    11ae <print_weekday_name+0x8e>
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
jmp    121a <print_weekday_name+0xfa>
cmpl   $0x4,-0x10(%rbp)
jne    11c9 <print_weekday_name+0xa9>
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
jmp    1215 <print_weekday_name+0xf5>
cmpl   $0x6,-0x10(%rbp)
jne    11e4 <print_weekday_name+0xc4>
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
jmp    1210 <print_weekday_name+0xf0>
cmpl   $0x7,-0x10(%rbp)
jne    11ff <print_weekday_name+0xdf>
lea    0xe3d(%rip),%rdi
call   1030 <printf@plt>
jmp    120b <print_weekday_name+0xeb>
lea    0xe33(%rip),%rdi
call   1030 <printf@plt>
jmp    1210 <print_weekday_name+0xf0>
jmp    1215 <print_weekday_name+0xf5>
jmp    121a <print_weekday_name+0xfa>
jmp    121f <print_weekday_name+0xff>
jmp    1224 <print_weekday_name+0x104>
jmp    1229 <print_weekday_name+0x109>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_weekday_name>:
push   %rax
call   1040 <weekday@plt>
add    $0xffffffff,%eax
cmp    $0x6,%eax
ja     1144 <print_weekday_name+0x24>
cltq
lea    0xf01(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
pop    %rax
jmp    1030 <printf@plt>
lea    0xee7(%rip),%rdi
pop    %rax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"Monday\00"
@.str.1 = [8 x i8] c"Tuesday\00"
@.str.2 = [10 x i8] c"Wednesday\00"
@.str.3 = [9 x i8] c"Thursday\00"
@.str.4 = [7 x i8] c"Friday\00"
@.str.5 = [9 x i8] c"Saturday\00"
@.str.6 = [7 x i8] c"Sunday\00"
@.str.7 = [6 x i8] c"Error\00"
define void @print_weekday_name(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = load i32, i32* %5
%10 = load i32, i32* %6
%11 = call i32 @weekday(i32 %8, i32 %9, i32 %10)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %54
16: ; preds = %3
%17 = load i32, i32* %7
%18 = icmp eq i32 %17, 2
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %53
21: ; preds = %16
%22 = load i32, i32* %7
%23 = icmp eq i32 %22, 3
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %52
26: ; preds = %21
%27 = load i32, i32* %7
%28 = icmp eq i32 %27, 4
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %51
31: ; preds = %26
%32 = load i32, i32* %7
%33 = icmp eq i32 %32, 4
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %50
36: ; preds = %31
%37 = load i32, i32* %7
%38 = icmp eq i32 %37, 6
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %49
41: ; preds = %36
%42 = load i32, i32* %7
%43 = icmp eq i32 %42, 7
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %48
46: ; preds = %41
%47 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %48
48: ; preds = %46, %44
br label %49
49: ; preds = %48, %39
br label %50
50: ; preds = %49, %34
br label %51
51: ; preds = %50, %29
br label %52
52: ; preds = %51, %24
br label %53
53: ; preds = %52, %19
br label %54
54: ; preds = %53, %14
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"Monday\00"
@.str.1 = [8 x i8] c"Tuesday\00"
@.str.2 = [10 x i8] c"Wednesday\00"
@.str.3 = [9 x i8] c"Thursday\00"
@.str.5 = [9 x i8] c"Saturday\00"
@.str.6 = [7 x i8] c"Sunday\00"
@.str.7 = [6 x i8] c"Error\00"
@reltable.print_weekday_name = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([7 x i32]* @reltable.print_weekday_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.print_weekday_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.print_weekday_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.print_weekday_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.7 to i64), i64 ptrtoint ([7 x i32]* @reltable.print_weekday_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.print_weekday_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.6 to i64), i64 ptrtoint ([7 x i32]* @reltable.print_weekday_name to i64)) to i32)]
define void @print_weekday_name(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @weekday(i32 %0, i32 %1, i32 %2)
%5 = add i32 %4, -1
%6 = icmp ult i32 %5, 7
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = sext i32 %5 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.print_weekday_name to i8*), i64 %9)
br label %11
11: ; preds = %3, %7
%12 = phi i8* [ %10, %7 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), %3 ]
%13 = tail call i32 @printf(i8* dereferenceable(1) %12)
ret void
}