int DayofWeek(year, month, day, dowstr)
int year, month, day;
char dowstr[];
{
  double JD, A, Afrac, jd();
  int n, iA;
  JD = jd(year, month, day, 0.0);
  A = (JD + 1.5) / 7.0;
  iA = (int)A;
  Afrac = A - (double)iA;
  n = (int)(Afrac * 7.0 + 0.5);
  switch (n) {
  case 0:
    strcpy(dowstr, "Sunday");
    break;
  case 1:
    strcpy(dowstr, "Monday");
    break;
  case 2:
    strcpy(dowstr, "Tuesday");
    break;
  case 3:
    strcpy(dowstr, "Wednesday");
    break;
  case 4:
    strcpy(dowstr, "Thursday");
    break;
  case 5:
    strcpy(dowstr, "Friday");
    break;
  case 6:
    strcpy(dowstr, "Saturday");
    break;
  }
  return (n);
}


x86 assembly (clang, -O0):
<DayofWeek>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
xorps  %xmm0,%xmm0
mov    $0x1,%al
call   1040 <jd@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xea6(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xea2(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cvttsd2si -0x28(%rbp),%eax
mov    %eax,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x38(%rbp),%xmm2
subsd  %xmm2,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe75(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %rax,-0x40(%rbp)
sub    $0x6,%rax
ja     1259 <DayofWeek+0x139>
mov    -0x40(%rbp),%rax
lea    0xe56(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1259 <DayofWeek+0x139>
mov    -0x18(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1259 <DayofWeek+0x139>
mov    -0x18(%rbp),%rdi
lea    0xe42(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1259 <DayofWeek+0x139>
mov    -0x18(%rbp),%rdi
lea    0xe35(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1259 <DayofWeek+0x139>
mov    -0x18(%rbp),%rdi
lea    0xe2a(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1259 <DayofWeek+0x139>
mov    -0x18(%rbp),%rdi
lea    0xe1e(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1259 <DayofWeek+0x139>
mov    -0x18(%rbp),%rdi
lea    0xe10(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DayofWeek>:
push   %rbx
mov    %rcx,%rbx
xorpd  %xmm0,%xmm0
mov    $0x1,%al
call   1030 <jd@plt>
addsd  0xed9(%rip),%xmm0
movsd  0xed9(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttpd2dq %xmm0,%xmm2
cvtdq2pd %xmm2,%xmm2
subsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
addsd  0xec5(%rip),%xmm0
cvttsd2si %xmm0,%eax
cmp    $0x6,%eax
ja     1171 <DayofWeek+0x61>
lea    0xebd(%rip),%rcx
movslq (%rcx,%rax,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
movl   $0x796164,0x3(%rbx)
movl   $0x646e7553,(%rbx)
pop    %rbx
ret
movl   $0x796164,0x3(%rbx)
movl   $0x646e6f4d,(%rbx)
pop    %rbx
ret
movabs $0x79616473657554,%rcx
mov    %rcx,(%rbx)
pop    %rbx
ret
movabs $0x616473656e646557,%rcx
73 64 61
mov    %rcx,(%rbx)
movw   $0x79,0x8(%rbx)
pop    %rbx
ret
movabs $0x7961647372756854,%rcx
64 61 79
jmp    11cb <DayofWeek+0xbb>
movl   $0x796164,0x3(%rbx)
movl   $0x64697246,(%rbx)
pop    %rbx
ret
movabs $0x7961647275746153,%rcx
64 61 79
mov    %rcx,(%rbx)
movb   $0x0,0x8(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Sunday\00"
@.str.1 = [7 x i8] c"Monday\00"
@.str.2 = [8 x i8] c"Tuesday\00"
@.str.3 = [10 x i8] c"Wednesday\00"
@.str.4 = [9 x i8] c"Thursday\00"
@.str.5 = [7 x i8] c"Friday\00"
@.str.6 = [9 x i8] c"Saturday\00"
define i32 @DayofWeek(i32 %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = call double (i32, i32, i32, double, ...) bitcast (double (...)* @jd to double (i32, i32, i32, double, ...)*)(i32 %14, i32 %15, i32 %16, double 0.000000e+00)
store double %17, double* %9
%18 = load double, double* %9
%19 = fadd double %18, 1.500000e+00
%20 = fdiv double %19, 7.000000e+00
store double %20, double* %10
%21 = load double, double* %10
%22 = fptosi double %21 to i32
store i32 %22, i32* %13
%23 = load double, double* %10
%24 = load i32, i32* %13
%25 = sitofp i32 %24 to double
%26 = fsub double %23, %25
store double %26, double* %11
%27 = load double, double* %11
%28 = call double @llvm.fmuladd.f64(double %27, double 7.000000e+00, double 5.000000e-01)
%29 = fptosi double %28 to i32
store i32 %29, i32* %12
%30 = load i32, i32* %12
switch i32 %30, label %52 [
i32 0, label %31
i32 1, label %34
i32 2, label %37
i32 3, label %40
i32 4, label %43
i32 5, label %46
i32 6, label %49
]
31: ; preds = %4
%32 = load i8*, i8** %8
%33 = call i8* @strcpy(i8* %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %52
34: ; preds = %4
%35 = load i8*, i8** %8
%36 = call i8* @strcpy(i8* %35, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %52
37: ; preds = %4
%38 = load i8*, i8** %8
%39 = call i8* @strcpy(i8* %38, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %52
40: ; preds = %4
%41 = load i8*, i8** %8
%42 = call i8* @strcpy(i8* %41, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %52
43: ; preds = %4
%44 = load i8*, i8** %8
%45 = call i8* @strcpy(i8* %44, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %52
46: ; preds = %4
%47 = load i8*, i8** %8
%48 = call i8* @strcpy(i8* %47, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %52
49: ; preds = %4
%50 = load i8*, i8** %8
%51 = call i8* @strcpy(i8* %50, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %52
52: ; preds = %4, %49, %46, %43, %40, %37, %34, %31
%53 = load i32, i32* %12
ret i32 %53
}

LLVM IR (-O2):
@.str = [7 x i8] c"Sunday\00"
@.str.1 = [7 x i8] c"Monday\00"
@.str.3 = [10 x i8] c"Wednesday\00"
@.str.4 = [9 x i8] c"Thursday\00"
@.str.5 = [7 x i8] c"Friday\00"
@.str.6 = [9 x i8] c"Saturday\00"
define i32 @DayofWeek(i32 %0, i32 %1, i32 %2, i8* nocapture writeonly %3) {
%5 = tail call double (i32, i32, i32, double, ...) bitcast (double (...)* @jd to double (i32, i32, i32, double, ...)*)(i32 %0, i32 %1, i32 %2, double 0.000000e+00)
%6 = fadd double %5, 1.500000e+00
%7 = fdiv double %6, 7.000000e+00
%8 = fptosi double %7 to i32
%9 = sitofp i32 %8 to double
%10 = fsub double %7, %9
%11 = tail call double @llvm.fmuladd.f64(double %10, double 7.000000e+00, double 5.000000e-01)
%12 = fptosi double %11 to i32
switch i32 %12, label %21 [
i32 0, label %13
i32 1, label %14
i32 2, label %15
i32 3, label %17
i32 4, label %18
i32 5, label %19
i32 6, label %20
]
13: ; preds = %4
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(7) %3, i8* align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 7, i1 false)
br label %21
14: ; preds = %4
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(7) %3, i8* align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 7, i1 false)
br label %21
15: ; preds = %4
%16 = bitcast i8* %3 to i64*
store i64 34165556242642260, i64* %16
br label %21
17: ; preds = %4
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(10) %3, i8* align 1 dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i64 10, i1 false)
br label %21
18: ; preds = %4
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(9) %3, i8* align 1 dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i64 9, i1 false)
br label %21
19: ; preds = %4
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(7) %3, i8* align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i64 7, i1 false)
br label %21
20: ; preds = %4
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(9) %3, i8* align 1 dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i64 9, i1 false)
br label %21
21: ; preds = %4, %20, %19, %18, %17, %15, %14, %13
ret i32 %12
}