#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 */
scalar_t__ floor(double);
int day_of_week(int year, int month, int day) {
  double m = (double)((month - 3) % 12 + 1);
  if (m > 10) {
    year--;
  }
  year %= 100;
  int c = (year - (year % 100)) / 100;
  int w =
      ((day + (int)floor(2.6 * m - 0.2) + year + year / 4 + c / 4 - 2 * c) % 7);
  return w;
}


x86 assembly (clang, -O0):
<day_of_week>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x3,%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
cvtsi2sd %edx,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xeb8(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    115b <day_of_week+0x4b>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    -0x30(%rbp),%eax
sub    %edx,%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe6b(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe67(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <floor@plt>
mov    %rax,%rcx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
sub    %ecx,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<day_of_week>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
add    $0xfffffffd,%esi
movslq %esi,%rax
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
shl    $0x2,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
xor    %ecx,%ecx
cmp    $0xa,%eax
setge  %cl
sub    %ecx,%edi
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movslq %edi,%rbx
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebx
mulsd  0xe91(%rip),%xmm0
addsd  0xe91(%rip),%xmm0
call   1030 <floor@plt>
mov    %ebx,%ecx
sar    $0x7,%cl
shr    $0x6,%cl
add    %bl,%cl
sar    $0x2,%cl
movsbl %cl,%ecx
add    %ebp,%ebx
add    %ecx,%ebx
add    %eax,%ebx
movslq %ebx,%rcx
imul   $0xffffffff92492493,%rcx,%rax
shr    $0x20,%rax
add    %ecx,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0x2,%eax
add    %edx,%eax
lea    0x0(,%rax,8),%edx
sub    %edx,%eax
add    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @day_of_week(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %5
%11 = sub nsw i32 %10, 3
%12 = srem i32 %11, 12
%13 = add nsw i32 %12, 1
%14 = sitofp i32 %13 to double
store double %14, double* %7
%15 = load double, double* %7
%16 = fcmp ogt double %15, 1.000000e+01
br i1 %16, label %17, label %20
17: ; preds = %3
%18 = load i32, i32* %4
%19 = add nsw i32 %18, -1
store i32 %19, i32* %4
br label %20
20: ; preds = %17, %3
%21 = load i32, i32* %4
%22 = srem i32 %21, 100
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = load i32, i32* %4
%25 = srem i32 %24, 100
%26 = sub nsw i32 %23, %25
%27 = sdiv i32 %26, 100
store i32 %27, i32* %8
%28 = load i32, i32* %6
%29 = load double, double* %7
%30 = call double @llvm.fmuladd.f64(double 2.600000e+00, double %29, double -2.000000e-01)
%31 = call i64 @floor(double %30)
%32 = trunc i64 %31 to i32
%33 = add nsw i32 %28, %32
%34 = load i32, i32* %4
%35 = add nsw i32 %33, %34
%36 = load i32, i32* %4
%37 = sdiv i32 %36, 4
%38 = add nsw i32 %35, %37
%39 = load i32, i32* %8
%40 = sdiv i32 %39, 4
%41 = add nsw i32 %38, %40
%42 = load i32, i32* %8
%43 = mul nsw i32 2, %42
%44 = sub nsw i32 %41, %43
%45 = srem i32 %44, 7
store i32 %45, i32* %9
%46 = load i32, i32* %9
ret i32 %46
}

LLVM IR (-O2):
define i32 @day_of_week(i32 %0, i32 %1, i32 %2) {
%4 = add nsw i32 %1, -3
%5 = srem i32 %4, 12
%6 = icmp sgt i32 %5, 9
%7 = sext i1 %6 to i32
%8 = add nsw i32 %7, %0
%9 = add nsw i32 %5, 1
%10 = sitofp i32 %9 to double
%11 = srem i32 %8, 100
%12 = tail call double @llvm.fmuladd.f64(double %10, double 2.600000e+00, double -2.000000e-01)
%13 = tail call i64 @floor(double %12)
%14 = trunc i64 %13 to i32
%15 = trunc i32 %11 to i8
%16 = sdiv i8 %15, 4
%17 = sext i8 %16 to i32
%18 = add i32 %11, %2
%19 = add i32 %18, %17
%20 = add i32 %19, %14
%21 = srem i32 %20, 7
ret i32 %21
}