#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 daynumber(int date, int month, int year) {
  int yearnum, cent, day;
  month = month - 2;
  if (month < 1) {
    month += 12;
    year--;
  }
  yearnum = year % 100;
  cent = year / 100;
  day = (int)floor((double)(2.6 * month - 0.2)) + date + yearnum + yearnum / 4 +
        cent / 4 - 2 * cent;
  while (day < 0)
    day += 7;
  return day % 7;
}


x86 assembly (clang, -O0):
<daynumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    1146 <daynumber+0x36>
mov    -0x8(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe91(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe8d(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <floor@plt>
add    -0x4(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
sub    %ecx,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11d7 <daynumber+0xc7>
mov    -0x18(%rbp),%eax
add    $0x7,%eax
mov    %eax,-0x18(%rbp)
jmp    11bf <daynumber+0xaf>
mov    -0x18(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<daynumber>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %edi,%r14d
lea    -0x2(%rsi),%ecx
lea    0xa(%rsi),%eax
xor    %edi,%edi
cmp    $0x3,%esi
setl   %dil
cmovge %ecx,%eax
sub    %edi,%edx
movslq %edx,%r13
imul   $0x51eb851f,%r13,%r12
mov    %r12,%rbx
shr    $0x20,%rbx
mov    %ebx,%ecx
sar    $0x5,%ecx
shr    $0x3f,%r12
add    %r12d,%ecx
imul   $0x64,%ecx,%ecx
imul   $0xffffffffae147ae1,%r13,%r15
sub    %ecx,%r13d
mov    %r15,%rcx
shr    $0x3f,%rcx
shr    $0x20,%r15
sar    $0x5,%r15d
add    %ecx,%r15d
cvtsi2sd %eax,%xmm0
mulsd  0xe88(%rip),%xmm0
addsd  0xe88(%rip),%xmm0
call   1030 <floor@plt>
mov    %r13d,%ecx
sar    $0x7,%cl
shr    $0x6,%cl
add    %r13b,%cl
sar    $0x2,%cl
movsbl %cl,%ecx
sar    $0x7,%ebx
add    %r12d,%ebx
lea    (%r14,%r13,1),%edx
add    %ebx,%edx
lea    (%rdx,%r15,2),%edx
add    %ecx,%edx
add    %eax,%edx
add    %r13d,%ebx
add    %r14d,%ebx
xor    %esi,%esi
test   %edx,%edx
cmovg  %edx,%esi
mov    %edx,%edi
shr    $0x1f,%edi
add    %edi,%edx
sub    %edx,%esi
imul   $0x24924925,%rsi,%rdx
shr    $0x20,%rdx
sub    %edx,%esi
shr    %esi
add    %edx,%esi
shr    $0x2,%esi
add    %edi,%esi
lea    0x0(,%rsi,8),%edx
sub    %esi,%edx
add    %ebx,%edx
lea    (%rdx,%r15,2),%edx
add    %ecx,%edx
add    %edx,%eax
imul   $0x24924925,%rax,%rcx
shr    $0x20,%rcx
mov    %eax,%edx
sub    %ecx,%edx
shr    %edx
add    %ecx,%edx
shr    $0x2,%edx
lea    0x0(,%rdx,8),%ecx
sub    %ecx,%edx
add    %edx,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @daynumber(i32 %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %1, 3
%5 = sext i1 %4 to i32
%6 = add nsw i32 %5, %2
%7 = select i1 %4, i32 10, i32 -2
%8 = add nsw i32 %7, %1
%9 = srem i32 %6, 100
%10 = sdiv i32 %6, -100
%11 = sitofp i32 %8 to double
%12 = tail call double @llvm.fmuladd.f64(double %11, double 2.600000e+00, double -2.000000e-01)
%13 = tail call i64 @floor(double %12)
%14 = trunc i64 %13 to i32
%15 = trunc i32 %9 to i8
%16 = sdiv i8 %15, 4
%17 = sext i8 %16 to i32
%18 = sdiv i32 %6, 400
%19 = shl nsw i32 %10, 1
%20 = add i32 %9, %0
%21 = add i32 %20, %18
%22 = add i32 %21, %19
%23 = add i32 %22, %17
%24 = add i32 %23, %14
%25 = add nsw i32 %9, %18
%26 = add i32 %25, %0
%27 = call i32 @llvm.smax.i32(i32 %24, i32 0)
%28 = lshr i32 %24, 31
%29 = add i32 %28, %24
%30 = sub i32 %27, %29
%31 = udiv i32 %30, 7
%32 = add nuw nsw i32 %28, %31
%33 = mul i32 %32, 7
%34 = add i32 %26, %33
%35 = add i32 %34, %19
%36 = add i32 %35, %17
%37 = add i32 %36, %14
%38 = urem i32 %37, 7
ret i32 %38
}