#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 */
scalar_t__ is_leap_year(int);
int /*<<< orphan*/ printf(char *, ...);
int validate_data(int year, int day) {
  int limit_day = 365;
  if (is_leap_year(year))
    limit_day++;
  if (year <= 0) {
    printf("The year is not in AD >= 0\n");
    return 0;
  }
  if (day <= 0) {
    printf("The day must be strictly positive\n");
    return 0;
  }
  if (day > limit_day) {
    printf("Not a valid day bigger than %d\n", limit_day);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<validate_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x16d,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <is_leap_year@plt>
cmp    $0x0,%rax
je     1150 <validate_data+0x30>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jg     1174 <validate_data+0x54>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c8 <validate_data+0xa8>
cmpl   $0x0,-0xc(%rbp)
jg     1198 <validate_data+0x78>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c8 <validate_data+0xa8>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11c1 <validate_data+0xa1>
mov    -0x10(%rbp),%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c8 <validate_data+0xa8>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validate_data>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
call   1050 <is_leap_year@plt>
cmp    $0x1,%rax
mov    $0x16e,%esi
sbb    $0x0,%esi
test   %ebx,%ebx
jle    116b <validate_data+0x3b>
test   %ebp,%ebp
jle    1174 <validate_data+0x44>
mov    $0x1,%ebx
cmp    %ebp,%esi
jae    1182 <validate_data+0x52>
lea    0xea0(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1182 <validate_data+0x52>
lea    0xed0(%rip),%rdi
jmp    117b <validate_data+0x4b>
lea    0xea5(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"The year is not in AD >= 0\0A\00"
@.str.1 = [35 x i8] c"The day must be strictly positive\0A\00"
@.str.2 = [32 x i8] c"Not a valid day bigger than %d\0A\00"
define i32 @validate_data(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 365, i32* %6
%7 = load i32, i32* %4
%8 = call i64 @is_leap_year(i32 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* %6
%12 = add nsw i32 %11, 1
store i32 %12, i32* %6
br label %13
13: ; preds = %10, %2
%14 = load i32, i32* %4
%15 = icmp sle i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %31
18: ; preds = %13
%19 = load i32, i32* %5
%20 = icmp sle i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %31
23: ; preds = %18
%24 = load i32, i32* %5
%25 = load i32, i32* %6
%26 = icmp sgt i32 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i32, i32* %6
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %28)
store i32 0, i32* %3
br label %31
30: ; preds = %23
store i32 1, i32* %3
br label %31
31: ; preds = %30, %27, %21, %16
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@.str.2 = [32 x i8] c"Not a valid day bigger than %d\0A\00"
@str = [34 x i8] c"The day must be strictly positive\00"
@str.3 = [27 x i8] c"The year is not in AD >= 0\00"
define i32 @validate_data(i32 %0, i32 %1) {
%3 = tail call i64 @is_leap_year(i32 %0)
%4 = icmp eq i64 %3, 0
%5 = select i1 %4, i32 365, i32 366
%6 = icmp slt i32 %0, 1
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.3, i64 0, i64 0))
br label %17
9: ; preds = %2
%10 = icmp slt i32 %1, 1
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %17
13: ; preds = %9
%14 = icmp ult i32 %5, %1
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %5)
br label %17
17: ; preds = %13, %15, %11, %7
%18 = phi i32 [ 0, %7 ], [ 0, %11 ], [ 0, %15 ], [ 1, %13 ]
ret i32 %18
}