#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 */
typedef int uint8_t;
typedef int uint16_t;

/* Variables and functions */
uint8_t get_weekday_by_year_day_number(uint16_t y, uint16_t ydn) {
  uint8_t j, c, tmp8;
  uint16_t tmp16;
  y--;
  j = y % 100;
  c = y / 100;
  tmp16 = c;
  tmp16 *= 5;
  tmp16 += ydn;
  tmp8 = j;
  j >>= 2;
  c >>= 2;
  tmp8 += j;
  tmp8 += c;
  tmp8 += 28;
  tmp16 += tmp8;
  tmp16 %= 7;
  return tmp16;
}


x86 assembly (clang, -O0):
<get_weekday_by_year_day_number>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
imul   $0x5,-0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
sar    $0x2,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1c,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_weekday_by_year_day_number>:
add    $0xffffffff,%edi
movslq %edi,%rcx
imul   $0x51eb851f,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rax
sar    $0x5,%eax
add    %edx,%eax
imul   $0x64,%eax,%edx
sub    %edx,%ecx
lea    (%rax,%rax,4),%edx
sar    $0x2,%eax
add    %ecx,%esi
sar    $0x2,%ecx
add    %edx,%esi
add    %ecx,%esi
lea    (%rax,%rsi,1),%ecx
add    $0x1c,%ecx
add    %eax,%esi
movslq %ecx,%rax
imul   $0xffffffff92492493,%rax,%rax
shr    $0x20,%rax
add    %esi,%eax
add    $0x1c,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x2,%eax
add    %ecx,%eax
lea    0x0(,%rax,8),%ecx
sub    %ecx,%eax
add    %esi,%eax
add    $0x1c,%eax
ret

LLVM IR (-O0):
define i32 @get_weekday_by_year_day_number(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%9 = load i32, i32* %3
%10 = add nsw i32 %9, -1
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = srem i32 %11, 100
store i32 %12, i32* %5
%13 = load i32, i32* %3
%14 = sdiv i32 %13, 100
store i32 %14, i32* %6
%15 = load i32, i32* %6
store i32 %15, i32* %8
%16 = load i32, i32* %8
%17 = mul nsw i32 %16, 5
store i32 %17, i32* %8
%18 = load i32, i32* %4
%19 = load i32, i32* %8
%20 = add nsw i32 %19, %18
store i32 %20, i32* %8
%21 = load i32, i32* %5
store i32 %21, i32* %7
%22 = load i32, i32* %5
%23 = ashr i32 %22, 2
store i32 %23, i32* %5
%24 = load i32, i32* %6
%25 = ashr i32 %24, 2
store i32 %25, i32* %6
%26 = load i32, i32* %5
%27 = load i32, i32* %7
%28 = add nsw i32 %27, %26
store i32 %28, i32* %7
%29 = load i32, i32* %6
%30 = load i32, i32* %7
%31 = add nsw i32 %30, %29
store i32 %31, i32* %7
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 28
store i32 %33, i32* %7
%34 = load i32, i32* %7
%35 = load i32, i32* %8
%36 = add nsw i32 %35, %34
store i32 %36, i32* %8
%37 = load i32, i32* %8
%38 = srem i32 %37, 7
store i32 %38, i32* %8
%39 = load i32, i32* %8
ret i32 %39
}

LLVM IR (-O2):
define i32 @get_weekday_by_year_day_number(i32 %0, i32 %1) {
%3 = add nsw i32 %0, -1
%4 = srem i32 %3, 100
%5 = sdiv i32 %3, 100
%6 = mul nsw i32 %5, 5
%7 = ashr i32 %4, 2
%8 = ashr i32 %5, 2
%9 = add i32 %1, 28
%10 = add i32 %9, %4
%11 = add i32 %10, %6
%12 = add i32 %11, %7
%13 = add i32 %12, %8
%14 = srem i32 %13, 7
ret i32 %14
}