#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*/ printf(char *, ...);
int verify_leap_years(int);
int verify_valid_date(int day, int month, int year) {
  bool leap = verify_leap_years(year);
  int days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  if (month > 12) {
    printf("The month %i is invalid\n", month);
    return -1;
  }
  int month_at_index = days_in_month[month - 1];
  if ((leap == true) && (month == 2) && (day <= month_at_index + 1)) {
    printf("%i: Yeap, it is a leap year!\n", year);
  }
  if (!(leap == true) && day <= month_at_index) {
    printf("%i: This year is not a leap, but the date is valid.\n", year);
    return 0;
  } else {
    printf("The day %i is invalid\n", day);
  }
  printf("Please, enter a valid date!");
  return 0;
}


x86 assembly (clang, -O0):
<verify_valid_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <verify_leap_years@plt>
mov    %eax,-0x14(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xea9(%rip),%rsi
mov    $0x30,%edx
call   1050 <memcpy@plt>
cmpl   $0xc,-0xc(%rbp)
jle    1188 <verify_valid_date+0x58>
mov    -0xc(%rbp),%esi
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1226 <verify_valid_date+0xf6>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x50(%rbp,%rax,4),%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    11cd <verify_valid_date+0x9d>
cmpl   $0x2,-0xc(%rbp)
jne    11cd <verify_valid_date+0x9d>
mov    -0x8(%rbp),%eax
mov    -0x54(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jg     11cd <verify_valid_date+0x9d>
mov    -0x10(%rbp),%esi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x14(%rbp)
je     1200 <verify_valid_date+0xd0>
mov    -0x8(%rbp),%eax
cmp    -0x54(%rbp),%eax
jg     1200 <verify_valid_date+0xd0>
mov    -0x10(%rbp),%esi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1226 <verify_valid_date+0xf6>
mov    -0x8(%rbp),%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verify_valid_date>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r15d
mov    %esi,%ebx
mov    %edi,%r14d
mov    %edx,%edi
call   1040 <verify_leap_years@plt>
cmp    $0xd,%ebx
jl     1153 <verify_valid_date+0x33>
lea    0xeed(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffffff,%ebp
jmp    11c9 <verify_valid_date+0xa9>
mov    %eax,%ebp
movslq %ebx,%rax
lea    0xea1(%rip),%rcx
mov    -0x4(%rcx,%rax,4),%r12d
cmp    $0x2,%ebx
jne    1189 <verify_valid_date+0x69>
cmp    $0x1,%ebp
jne    1189 <verify_valid_date+0x69>
lea    0x1(%r12),%eax
cmp    %r14d,%eax
jl     1189 <verify_valid_date+0x69>
lea    0xeca(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x1,%ebp
je     11a8 <verify_valid_date+0x88>
cmp    %r14d,%r12d
jl     11a8 <verify_valid_date+0x88>
lea    0xecd(%rip),%rdi
xor    %ebp,%ebp
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11c9 <verify_valid_date+0xa9>
lea    0xeed(%rip),%rdi
xor    %ebp,%ebp
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.verify_valid_date.days_in_month = [12 x i32] [i32 31, i32 28, i32 31, i32 30, i32 31, i32 30, i32 31, i32 31, i32 30, i32 31, i32 30, i32 31]
@.str = [25 x i8] c"The month %i is invalid\0A\00"
@.str.1 = [30 x i8] c"%i: Yeap, it is a leap year!\0A\00"
@.str.2 = [53 x i8] c"%i: This year is not a leap, but the date is valid.\0A\00"
@.str.3 = [23 x i8] c"The day %i is invalid\0A\00"
@.str.4 = [28 x i8] c"Please, enter a valid date!\00"
define i32 @verify_valid_date(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [12 x i32]
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%11 = load i32, i32* %7
%12 = call i32 @verify_leap_years(i32 %11)
store i32 %12, i32* %8
%13 = bitcast [12 x i32]* %9 to i8*
%14 = load i32, i32* %6
%15 = icmp sgt i32 %14, 12
br i1 %15, label %16, label %19
16: ; preds = %3
%17 = load i32, i32* %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %17)
store i32 -1, i32* %4
br label %53
19: ; preds = %3
%20 = load i32, i32* %6
%21 = sub nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [12 x i32], [12 x i32]* %9, i64 0, i64 %22
%24 = load i32, i32* %23
store i32 %24, i32* %10
%25 = load i32, i32* %8
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %38
27: ; preds = %19
%28 = load i32, i32* %6
%29 = icmp eq i32 %28, 2
br i1 %29, label %30, label %38
30: ; preds = %27
%31 = load i32, i32* %5
%32 = load i32, i32* %10
%33 = add nsw i32 %32, 1
%34 = icmp sle i32 %31, %33
br i1 %34, label %35, label %38
35: ; preds = %30
%36 = load i32, i32* %7
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %35, %30, %27, %19
%39 = load i32, i32* %8
%40 = icmp eq i32 %39, 1
br i1 %40, label %48, label %41
41: ; preds = %38
%42 = load i32, i32* %5
%43 = load i32, i32* %10
%44 = icmp sle i32 %42, %43
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load i32, i32* %7
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i32 %46)
store i32 0, i32* %4
br label %53
48: ; preds = %41, %38
%49 = load i32, i32* %5
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %48
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %4
br label %53
53: ; preds = %51, %45, %16
%54 = load i32, i32* %4
ret i32 %54
}

LLVM IR (-O2):
@__const.verify_valid_date.days_in_month = [12 x i32] [i32 31, i32 28, i32 31, i32 30, i32 31, i32 30, i32 31, i32 31, i32 30, i32 31, i32 30, i32 31]
@.str = [25 x i8] c"The month %i is invalid\0A\00"
@.str.1 = [30 x i8] c"%i: Yeap, it is a leap year!\0A\00"
@.str.2 = [53 x i8] c"%i: This year is not a leap, but the date is valid.\0A\00"
@.str.3 = [23 x i8] c"The day %i is invalid\0A\00"
@.str.4 = [28 x i8] c"Please, enter a valid date!\00"
define i32 @verify_valid_date(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @verify_leap_years(i32 %2)
%5 = icmp sgt i32 %1, 12
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %30
8: ; preds = %3
%9 = add nsw i32 %1, -1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [12 x i32], [12 x i32]* @__const.verify_valid_date.days_in_month, i64 0, i64 %10
%12 = load i32, i32* %11
%13 = icmp eq i32 %4, 1
%14 = icmp eq i32 %1, 2
%15 = and i1 %14, %13
%16 = xor i1 %15, true
%17 = add nsw i32 %12, 1
%18 = icmp slt i32 %17, %0
%19 = select i1 %16, i1 true, i1 %18
br i1 %19, label %22, label %20
20: ; preds = %8
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %2)
br label %22
22: ; preds = %20, %8
%23 = icmp slt i32 %12, %0
%24 = select i1 %13, i1 true, i1 %23
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i32 %2)
br label %30
27: ; preds = %22
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %0)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
br label %30
30: ; preds = %25, %27, %6
%31 = phi i32 [ -1, %6 ], [ 0, %27 ], [ 0, %25 ]
ret i32 %31
}