#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 calendar_dpy(int);
int days_per_year(int calendar, int year) {
  int daysperyear;
  int dpy;
  dpy = calendar_dpy(calendar);
  if (dpy == 0) {
    if (calendar == 0) {
      if (year == 1582)
        dpy = 355;
      else if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
        dpy = 366;
      else
        dpy = 365;
    } else {
      if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
        dpy = 366;
      else
        dpy = 365;
    }
  }
  daysperyear = dpy;
  return (daysperyear);
}


x86 assembly (clang, -O0):
<days_per_year>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <calendar_dpy@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1208 <days_per_year+0xf8>
cmpl   $0x0,-0x4(%rbp)
jne    11af <days_per_year+0x9f>
cmpl   $0x62e,-0x8(%rbp)
jne    1156 <days_per_year+0x46>
movl   $0x163,-0x10(%rbp)
jmp    11aa <days_per_year+0x9a>
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    117e <days_per_year+0x6e>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1192 <days_per_year+0x82>
mov    -0x8(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    119e <days_per_year+0x8e>
movl   $0x16e,-0x10(%rbp)
jmp    11a5 <days_per_year+0x95>
movl   $0x16d,-0x10(%rbp)
jmp    11aa <days_per_year+0x9a>
jmp    1203 <days_per_year+0xf3>
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11d7 <days_per_year+0xc7>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11eb <days_per_year+0xdb>
mov    -0x8(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11f7 <days_per_year+0xe7>
movl   $0x16e,-0x10(%rbp)
jmp    11fe <days_per_year+0xee>
movl   $0x16d,-0x10(%rbp)
jmp    1203 <days_per_year+0xf3>
jmp    1208 <days_per_year+0xf8>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<days_per_year>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
call   1030 <calendar_dpy@plt>
test   %eax,%eax
jne    1169 <days_per_year+0x59>
test   %ebp,%ebp
jne    1131 <days_per_year+0x21>
mov    $0x163,%eax
cmp    $0x62e,%ebx
je     1169 <days_per_year+0x59>
test   $0x3,%bl
sete   %al
imul   $0xc28f5c29,%ebx,%ecx
add    $0x51eb850,%ecx
mov    %ecx,%edx
ror    $0x2,%edx
cmp    $0x28f5c29,%edx
setae  %dl
and    %al,%dl
ror    $0x4,%ecx
cmp    $0xa3d70b,%ecx
setb   %al
or     %dl,%al
movzbl %al,%eax
add    $0x16d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @days_per_year(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = call i32 @calendar_dpy(i32 %7)
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %50
11: ; preds = %2
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %34
14: ; preds = %11
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 1582
br i1 %16, label %17, label %18
17: ; preds = %14
store i32 355, i32* %6
br label %33
18: ; preds = %14
%19 = load i32, i32* %4
%20 = srem i32 %19, 4
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i32, i32* %4
%24 = srem i32 %23, 100
%25 = icmp ne i32 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %22, %18
%27 = load i32, i32* %4
%28 = srem i32 %27, 400
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26, %22
store i32 366, i32* %6
br label %32
31: ; preds = %26
store i32 365, i32* %6
br label %32
32: ; preds = %31, %30
br label %33
33: ; preds = %32, %17
br label %49
34: ; preds = %11
%35 = load i32, i32* %4
%36 = srem i32 %35, 4
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %34
%39 = load i32, i32* %4
%40 = srem i32 %39, 100
%41 = icmp ne i32 %40, 0
br i1 %41, label %46, label %42
42: ; preds = %38, %34
%43 = load i32, i32* %4
%44 = srem i32 %43, 400
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %42, %38
store i32 366, i32* %6
br label %48
47: ; preds = %42
store i32 365, i32* %6
br label %48
48: ; preds = %47, %46
br label %49
49: ; preds = %48, %33
br label %50
50: ; preds = %49, %2
%51 = load i32, i32* %6
store i32 %51, i32* %5
%52 = load i32, i32* %5
ret i32 %52
}

LLVM IR (-O2):
define i32 @days_per_year(i32 %0, i32 %1) {
%3 = tail call i32 @calendar_dpy(i32 %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %29
5: ; preds = %2
%6 = icmp eq i32 %0, 0
br i1 %6, label %7, label %19
7: ; preds = %5
%8 = icmp eq i32 %1, 1582
br i1 %8, label %29, label %9
9: ; preds = %7
%10 = and i32 %1, 3
%11 = icmp eq i32 %10, 0
%12 = srem i32 %1, 100
%13 = icmp ne i32 %12, 0
%14 = and i1 %11, %13
%15 = srem i32 %1, 400
%16 = icmp eq i32 %15, 0
%17 = or i1 %16, %14
%18 = select i1 %17, i32 366, i32 365
br label %29
19: ; preds = %5
%20 = and i32 %1, 3
%21 = icmp eq i32 %20, 0
%22 = srem i32 %1, 100
%23 = icmp ne i32 %22, 0
%24 = and i1 %21, %23
%25 = srem i32 %1, 400
%26 = icmp eq i32 %25, 0
%27 = or i1 %26, %24
%28 = select i1 %27, i32 366, i32 365
br label %29
29: ; preds = %19, %9, %7, %2
%30 = phi i32 [ %3, %2 ], [ 355, %7 ], [ %18, %9 ], [ %28, %19 ]
ret i32 %30
}