#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__ leapyear(int);
int validday(int yy, int mon, int dd) {
  int daysinmonth[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 21};
  if (mon == 2) {
    daysinmonth[2] += leapyear(yy);
  }
  if (dd <= daysinmonth[mon])
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<validday>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xec4(%rip),%rsi
mov    $0x34,%edx
call   1030 <memcpy@plt>
cmpl   $0x2,-0xc(%rbp)
jne    1165 <validday+0x45>
mov    -0x8(%rbp),%edi
call   1040 <leapyear@plt>
mov    %rax,%rcx
movslq -0x48(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x48(%rbp)
mov    -0x10(%rbp),%eax
movslq -0xc(%rbp),%rcx
cmp    -0x50(%rbp,%rcx,4),%eax
jg     1182 <validday+0x62>
movl   $0x1,-0x4(%rbp)
jmp    1189 <validday+0x69>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validday>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
mov    %edx,%ebx
mov    %esi,%ebp
mov    0xf10(%rip),%eax
mov    %eax,0x30(%rsp)
movaps 0xef5(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xed9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xebd(%rip),%xmm0
movaps %xmm0,(%rsp)
cmp    $0x2,%esi
jne    1158 <validday+0x48>
call   1030 <leapyear@plt>
add    $0x1c,%eax
mov    %eax,0x8(%rsp)
movslq %ebp,%rcx
xor    %eax,%eax
cmp    %ebx,(%rsp,%rcx,4)
setge  %al
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.validday.daysinmonth = [13 x i32] [i32 0, i32 31, i32 28, i32 31, i32 30, i32 31, i32 30, i32 31, i32 31, i32 30, i32 31, i32 30, i32 21]
define i32 @validday(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [13 x i32]
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%9 = bitcast [13 x i32]* %8 to i8*
%10 = load i32, i32* %6
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %20
12: ; preds = %3
%13 = load i32, i32* %5
%14 = call i64 @leapyear(i32 %13)
%15 = getelementptr inbounds [13 x i32], [13 x i32]* %8, i64 0, i64 2
%16 = load i32, i32* %15
%17 = sext i32 %16 to i64
%18 = add nsw i64 %17, %14
%19 = trunc i64 %18 to i32
store i32 %19, i32* %15
br label %20
20: ; preds = %12, %3
%21 = load i32, i32* %7
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [13 x i32], [13 x i32]* %8, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = icmp sle i32 %21, %25
br i1 %26, label %27, label %28
27: ; preds = %20
store i32 1, i32* %4
br label %29
28: ; preds = %20
store i32 0, i32* %4
br label %29
29: ; preds = %28, %27
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
@__const.validday.daysinmonth = [13 x i32] [i32 0, i32 31, i32 28, i32 31, i32 30, i32 31, i32 30, i32 31, i32 31, i32 30, i32 31, i32 30, i32 21]
define i32 @validday(i32 %0, i32 %1, i32 %2) {
%4 = alloca [13 x i32]
%5 = bitcast [13 x i32]* %4 to i8*
%6 = icmp eq i32 %1, 2
br i1 %6, label %7, label %12
7: ; preds = %3
%8 = tail call i64 @leapyear(i32 %0)
%9 = getelementptr inbounds [13 x i32], [13 x i32]* %4, i64 0, i64 2
%10 = trunc i64 %8 to i32
%11 = add i32 %10, 28
store i32 %11, i32* %9
br label %12
12: ; preds = %7, %3
%13 = sext i32 %1 to i64
%14 = getelementptr inbounds [13 x i32], [13 x i32]* %4, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = icmp sge i32 %15, %2
%17 = zext i1 %16 to i32
ret i32 %17
}