#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 /*<<< orphan*/ Date_ymd(long, int *, int *, int *);
long Ymd_date(int, int, int);
long fixInvalidDate(long);
long Add_year(long date, int years) {
  int y, m, d;
  if (date <= 0L)
    return (0L);
  Date_ymd(date, &y, &m, &d);
  y += years;
  date = Ymd_date(y, m, d);
  return fixInvalidDate(date);
}


x86 assembly (clang, -O0):
<Add_year>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jg     1157 <Add_year+0x27>
movq   $0x0,-0x8(%rbp)
jmp    1194 <Add_year+0x64>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1050 <Date_ymd@plt>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1030 <Ymd_date@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <fixInvalidDate@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Add_year>:
test   %rdi,%rdi
jle    1175 <Add_year+0x45>
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
lea    0x4(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1050 <Date_ymd@plt>
add    0x4(%rsp),%ebx
mov    %ebx,0x4(%rsp)
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %ebx,%edi
call   1030 <Ymd_date@plt>
mov    %rax,%rdi
call   1040 <fixInvalidDate@plt>
add    $0x10,%rsp
pop    %rbx
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i64 @Add_year(i64 %0, i32 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i64 %0, i64* %4
store i32 %1, i32* %5
%9 = load i64, i64* %4
%10 = icmp sle i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
store i64 0, i64* %3
br label %24
12: ; preds = %2
%13 = load i64, i64* %4
%14 = call i32 @Date_ymd(i64 %13, i32* %6, i32* %7, i32* %8)
%15 = load i32, i32* %5
%16 = load i32, i32* %6
%17 = add nsw i32 %16, %15
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = load i32, i32* %8
%21 = call i64 @Ymd_date(i32 %18, i32 %19, i32 %20)
store i64 %21, i64* %4
%22 = load i64, i64* %4
%23 = call i64 @fixInvalidDate(i64 %22)
store i64 %23, i64* %3
br label %24
24: ; preds = %12, %11
%25 = load i64, i64* %3
ret i64 %25
}

LLVM IR (-O2):
define i64 @Add_year(i64 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = icmp slt i64 %0, 1
br i1 %9, label %18, label %10
10: ; preds = %2
%11 = call i32 @Date_ymd(i64 %0, i32* %3, i32* %4, i32* %5)
%12 = load i32, i32* %3
%13 = add nsw i32 %12, %1
store i32 %13, i32* %3
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = call i64 @Ymd_date(i32 %13, i32 %14, i32 %15)
%17 = call i64 @fixInvalidDate(i64 %16)
br label %18
18: ; preds = %2, %10
%19 = phi i64 [ %17, %10 ], [ 0, %2 ]
ret i64 %19
}