#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;

/* Variables and functions */
scalar_t__ _is_leap_year(int);
int _yday(int day, int month, int year) {
  static const uint8_t d[] = {0,   31,  59,  90, 120, 151,
                              181, 212, 243, 17, 48,  78};
  if (month > 1) {
    day += _is_leap_year(year);
  }
  if (month > 8) {
    day |= 0x100;
  }
  return d[month] + day - 1;
}


x86 assembly (clang, -O0):
<_yday>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1140 <_yday+0x30>
mov    -0xc(%rbp),%edi
call   1030 <_is_leap_year@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
cmpl   $0x8,-0x8(%rbp)
jle    1155 <_yday+0x45>
mov    -0x4(%rbp),%eax
or     $0x100,%eax
mov    %eax,-0x4(%rbp)
movslq -0x8(%rbp),%rcx
lea    0xea0(%rip),%rax
mov    (%rax,%rcx,4),%eax
add    -0x4(%rbp),%eax
sub    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_yday>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
cmp    $0x2,%esi
jl     1127 <_yday+0x17>
mov    %edx,%edi
call   1030 <_is_leap_year@plt>
add    %ebp,%eax
mov    %eax,%ebp
mov    %ebp,%eax
or     $0x100,%eax
cmp    $0x9,%ebx
cmovl  %ebp,%eax
movslq %ebx,%rcx
lea    0xec2(%rip),%rdx
mov    (%rdx,%rcx,4),%ecx
add    %ecx,%eax
add    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@_yday.d = internal constant [12 x i32] [i32 0, i32 31, i32 59, i32 90, i32 120, i32 151, i32 181, i32 212, i32 243, i32 17, i32 48, i32 78]
define i32 @_yday(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %5
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %16
9: ; preds = %3
%10 = load i32, i32* %6
%11 = call i64 @_is_leap_year(i32 %10)
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = add nsw i64 %13, %11
%15 = trunc i64 %14 to i32
store i32 %15, i32* %4
br label %16
16: ; preds = %9, %3
%17 = load i32, i32* %5
%18 = icmp sgt i32 %17, 8
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* %4
%21 = or i32 %20, 256
store i32 %21, i32* %4
br label %22
22: ; preds = %19, %16
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [12 x i32], [12 x i32]* @_yday.d, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = load i32, i32* %4
%28 = add nsw i32 %26, %27
%29 = sub nsw i32 %28, 1
ret i32 %29
}

LLVM IR (-O2):
@_yday.d = internal unnamed_addr constant [12 x i32] [i32 0, i32 31, i32 59, i32 90, i32 120, i32 151, i32 181, i32 212, i32 243, i32 17, i32 48, i32 78]
define i32 @_yday(i32 %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, 1
br i1 %4, label %5, label %9
5: ; preds = %3
%6 = tail call i64 @_is_leap_year(i32 %2)
%7 = trunc i64 %6 to i32
%8 = add i32 %7, %0
br label %9
9: ; preds = %5, %3
%10 = phi i32 [ %8, %5 ], [ %0, %3 ]
%11 = icmp sgt i32 %1, 8
%12 = or i32 %10, 256
%13 = select i1 %11, i32 %12, i32 %10
%14 = sext i32 %1 to i64
%15 = getelementptr inbounds [12 x i32], [12 x i32]* @_yday.d, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = add i32 %16, -1
%18 = add i32 %17, %13
ret i32 %18
}