#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 const greg_month_length(int const, int const);
int greg_check_date(const int year, const int month, const int day) {
  if (month < 1 || month > 12)
    return 0;
  if (day < 1 || (day > 28 && (day > greg_month_length(year, month))))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<greg_check_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x1,-0xc(%rbp)
jl     1135 <greg_check_date+0x25>
cmpl   $0xc,-0xc(%rbp)
jle    1141 <greg_check_date+0x31>
movl   $0x0,-0x4(%rbp)
jmp    1186 <greg_check_date+0x76>
cmpl   $0x1,-0x10(%rbp)
jl     1173 <greg_check_date+0x63>
cmpl   $0x1c,-0x10(%rbp)
jle    117f <greg_check_date+0x6f>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <greg_month_length@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jle    117f <greg_check_date+0x6f>
movl   $0x0,-0x4(%rbp)
jmp    1186 <greg_check_date+0x76>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<greg_check_date>:
push   %rbp
push   %rbx
push   %rax
lea    -0xd(%rsi),%eax
xor    %ebx,%ebx
cmp    $0xfffffff4,%eax
jb     1136 <greg_check_date+0x26>
mov    %edx,%ebp
test   %edx,%edx
jle    1136 <greg_check_date+0x26>
cmp    $0x1d,%ebp
jb     1131 <greg_check_date+0x21>
call   1030 <greg_month_length@plt>
cmp    %ebp,%eax
jl     1136 <greg_check_date+0x26>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @greg_check_date(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 1
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = load i32, i32* %6
%12 = icmp sgt i32 %11, 12
br i1 %12, label %13, label %14
13: ; preds = %10, %3
store i32 0, i32* %4
br label %28
14: ; preds = %10
%15 = load i32, i32* %7
%16 = icmp slt i32 %15, 1
br i1 %16, label %26, label %17
17: ; preds = %14
%18 = load i32, i32* %7
%19 = icmp sgt i32 %18, 28
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = load i32, i32* %7
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = call i32 @greg_month_length(i32 %22, i32 %23)
%25 = icmp sgt i32 %21, %24
br i1 %25, label %26, label %27
26: ; preds = %20, %14
store i32 0, i32* %4
br label %28
27: ; preds = %20, %17
store i32 1, i32* %4
br label %28
28: ; preds = %27, %26, %13
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
define i32 @greg_check_date(i32 %0, i32 %1, i32 %2) {
%4 = add i32 %1, -13
%5 = icmp ult i32 %4, -12
%6 = icmp slt i32 %2, 1
%7 = or i1 %5, %6
br i1 %7, label %14, label %8
8: ; preds = %3
%9 = icmp ugt i32 %2, 28
br i1 %9, label %10, label %13
10: ; preds = %8
%11 = tail call i32 @greg_month_length(i32 %0, i32 %1)
%12 = icmp slt i32 %11, %2
br i1 %12, label %14, label %13
13: ; preds = %10, %8
br label %14
14: ; preds = %10, %3, %13
%15 = phi i32 [ 1, %13 ], [ 0, %3 ], [ 0, %10 ]
ret i32 %15
}