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

/* Variables and functions */
scalar_t__ is_leap_year(int);
void from_century_day_number(uint16_t cdn, uint16_t *year, uint16_t *ydn) {
  uint16_t y, days_per_year;
  y = 2000;
  for (;;) {
    days_per_year = 365;
    days_per_year += is_leap_year(y);
    if (cdn >= days_per_year) {
      cdn -= days_per_year;
      y++;
    } else
      break;
  }
  cdn++;
  *year = y;
  *ydn = cdn;
}


x86 assembly (clang, -O0):
<from_century_day_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x7d0,-0x1c(%rbp)
movl   $0x16d,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <is_leap_year@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x20(%rbp),%eax
jl     116b <from_century_day_number+0x5b>
mov    -0x20(%rbp),%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1170 <from_century_day_number+0x60>
jmp    1175 <from_century_day_number+0x65>
jmp    112a <from_century_day_number+0x1a>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<from_century_day_number>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%ebp
mov    $0x7d0,%ebx
mov    $0x7d0,%edi
call   1030 <is_leap_year@plt>
add    $0x16d,%eax
cmp    %ebp,%eax
jg     1155 <from_century_day_number+0x45>
mov    $0x7d0,%ebx
nopl   0x0(%rax)
sub    %eax,%ebp
add    $0x1,%ebx
mov    %ebx,%edi
call   1030 <is_leap_year@plt>
add    $0x16d,%eax
cmp    %eax,%ebp
jge    1140 <from_century_day_number+0x30>
add    $0x1,%ebp
mov    %ebx,(%r15)
mov    %ebp,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @from_century_day_number(i32 %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32* %2, i32** %6
store i32 2000, i32* %7
br label %9
9: ; preds = %26, %3
store i32 365, i32* %8
%10 = load i32, i32* %7
%11 = call i64 @is_leap_year(i32 %10)
%12 = load i32, i32* %8
%13 = sext i32 %12 to i64
%14 = add nsw i64 %13, %11
%15 = trunc i64 %14 to i32
store i32 %15, i32* %8
%16 = load i32, i32* %4
%17 = load i32, i32* %8
%18 = icmp sge i32 %16, %17
br i1 %18, label %19, label %25
19: ; preds = %9
%20 = load i32, i32* %8
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, %20
store i32 %22, i32* %4
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
store i32 %24, i32* %7
br label %26
25: ; preds = %9
br label %27
26: ; preds = %19
br label %9
27: ; preds = %25
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
%30 = load i32, i32* %7
%31 = load i32*, i32** %5
store i32 %30, i32* %31
%32 = load i32, i32* %4
%33 = load i32*, i32** %6
store i32 %32, i32* %33
ret void
}

LLVM IR (-O2):
define void @from_century_day_number(i32 %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = tail call i64 @is_leap_year(i32 2000)
%5 = trunc i64 %4 to i32
%6 = add i32 %5, 365
%7 = icmp sgt i32 %6, %0
br i1 %7, label %18, label %8
8: ; preds = %3, %8
%9 = phi i32 [ %16, %8 ], [ %6, %3 ]
%10 = phi i32 [ %13, %8 ], [ 2000, %3 ]
%11 = phi i32 [ %12, %8 ], [ %0, %3 ]
%12 = sub nsw i32 %11, %9
%13 = add nuw nsw i32 %10, 1
%14 = tail call i64 @is_leap_year(i32 %13)
%15 = trunc i64 %14 to i32
%16 = add i32 %15, 365
%17 = icmp slt i32 %12, %16
br i1 %17, label %18, label %8
18: ; preds = %8, %3
%19 = phi i32 [ %0, %3 ], [ %12, %8 ]
%20 = phi i32 [ 2000, %3 ], [ %13, %8 ]
%21 = add nsw i32 %19, 1
store i32 %20, i32* %1
store i32 %21, i32* %2
ret void
}