#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 _mday(int, int);
int _mon(int, int);
scalar_t__ floor(double);
int _wday(int year, int yday) {
  int cent = (((year + 1900) & 1000) / 2);
  year %= 100;
  return ((_mday(year, yday) + _mon(year, yday) + year +
           (int)floor((double)year / 4.0) + cent) %
          (6 + 1));
}


x86 assembly (clang, -O0):
<_wday>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x76c,%eax
and    $0x3e8,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <_mday@plt>
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <_mon@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xe69(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <floor@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%eax
add    %ecx,%eax
add    -0xc(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_wday>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
lea    0x36c(%rdi),%ebp
shr    %ebp
and    $0x1f4,%ebp
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
mov    %ebx,%edi
call   1030 <_mday@plt>
mov    %eax,%r14d
mov    %ebx,%edi
mov    %r15d,%esi
call   1040 <_mon@plt>
mov    %eax,%r15d
cvtsi2sd %ebx,%xmm0
mulsd  0xe76(%rip),%xmm0
call   1050 <floor@plt>
add    %ebp,%ebx
add    %r14d,%ebx
add    %r15d,%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    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @_wday(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = add nsw i32 %6, 1900
%8 = and i32 %7, 1000
%9 = sdiv i32 %8, 2
store i32 %9, i32* %5
%10 = load i32, i32* %3
%11 = srem i32 %10, 100
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = call i32 @_mday(i32 %12, i32 %13)
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = call i32 @_mon(i32 %15, i32 %16)
%18 = add nsw i32 %14, %17
%19 = load i32, i32* %3
%20 = add nsw i32 %18, %19
%21 = load i32, i32* %3
%22 = sitofp i32 %21 to double
%23 = fdiv double %22, 4.000000e+00
%24 = call i64 @floor(double %23)
%25 = trunc i64 %24 to i32
%26 = add nsw i32 %20, %25
%27 = load i32, i32* %5
%28 = add nsw i32 %26, %27
%29 = srem i32 %28, 7
ret i32 %29
}

LLVM IR (-O2):
define i32 @_wday(i32 %0, i32 %1) {
%3 = add i32 %0, 876
%4 = lshr i32 %3, 1
%5 = and i32 %4, 500
%6 = srem i32 %0, 100
%7 = tail call i32 @_mday(i32 %6, i32 %1)
%8 = tail call i32 @_mon(i32 %6, i32 %1)
%9 = sitofp i32 %6 to double
%10 = fmul double %9, 2.500000e-01
%11 = tail call i64 @floor(double %10)
%12 = trunc i64 %11 to i32
%13 = add nsw i32 %5, %6
%14 = add i32 %13, %7
%15 = add i32 %14, %8
%16 = add i32 %15, %12
%17 = srem i32 %16, 7
ret i32 %17
}