#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*/ assert(int);
int max_monthday(int year, int month) {
  static int const days[] = {31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  assert(year > 0);
  assert(month > 0);
  assert(month < 13);
  if (month == 2) {
    if ((year % 400) == 0)
      return 29;
    if ((year % 100) == 0)
      return 28;
    if ((year % 4) == 0)
      return 29;
    return 28;
  } else
    return days[month - 1];
}


x86 assembly (clang, -O0):
<max_monthday>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0xc(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0xd,-0xc(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x2,-0xc(%rbp)
jne    11c7 <max_monthday+0xb7>
mov    -0x8(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    117b <max_monthday+0x6b>
movl   $0x1d,-0x4(%rbp)
jmp    11dd <max_monthday+0xcd>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    119b <max_monthday+0x8b>
movl   $0x1c,-0x4(%rbp)
jmp    11dd <max_monthday+0xcd>
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11bb <max_monthday+0xab>
movl   $0x1d,-0x4(%rbp)
jmp    11dd <max_monthday+0xcd>
movl   $0x1c,-0x4(%rbp)
jmp    11dd <max_monthday+0xcd>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    0xe29(%rip),%rax
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<max_monthday>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
xor    %edi,%edi
test   %ebx,%ebx
setg   %dil
call   1030 <assert@plt>
xor    %edi,%edi
test   %ebp,%ebp
setg   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmp    $0xd,%ebp
setl   %dil
call   1030 <assert@plt>
cmp    $0x2,%ebp
jne    1173 <max_monthday+0x63>
imul   $0xc28f5c29,%ebx,%eax
add    $0x51eb850,%eax
mov    %eax,%ecx
ror    $0x4,%ecx
cmp    $0xa3d70b,%ecx
jb     1183 <max_monthday+0x73>
ror    $0x2,%eax
cmp    $0x28f5c29,%eax
jb     118a <max_monthday+0x7a>
xor    %eax,%eax
test   $0x3,%bl
sete   %al
or     $0x1c,%eax
jmp    118f <max_monthday+0x7f>
movslq %ebp,%rax
lea    0xe83(%rip),%rcx
mov    -0x4(%rcx,%rax,4),%eax
jmp    118f <max_monthday+0x7f>
mov    $0x1d,%eax
jmp    118f <max_monthday+0x7f>
mov    $0x1c,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@max_monthday.days = internal constant [12 x i32] [i32 31, i32 0, i32 31, i32 30, i32 31, i32 30, i32 31, i32 31, i32 30, i32 31, i32 30, i32 31]
define i32 @max_monthday(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = icmp sgt i32 %6, 0
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = load i32, i32* %5
%11 = icmp sgt i32 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 13
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i32, i32* %5
%19 = icmp eq i32 %18, 2
br i1 %19, label %20, label %36
20: ; preds = %2
%21 = load i32, i32* %4
%22 = srem i32 %21, 400
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 29, i32* %3
br label %42
25: ; preds = %20
%26 = load i32, i32* %4
%27 = srem i32 %26, 100
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
store i32 28, i32* %3
br label %42
30: ; preds = %25
%31 = load i32, i32* %4
%32 = srem i32 %31, 4
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
store i32 29, i32* %3
br label %42
35: ; preds = %30
store i32 28, i32* %3
br label %42
36: ; preds = %2
%37 = load i32, i32* %5
%38 = sub nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [12 x i32], [12 x i32]* @max_monthday.days, i64 0, i64 %39
%41 = load i32, i32* %40
store i32 %41, i32* %3
br label %42
42: ; preds = %36, %35, %34, %29, %24
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@max_monthday.days = internal unnamed_addr constant [12 x i32] [i32 31, i32 0, i32 31, i32 30, i32 31, i32 30, i32 31, i32 31, i32 30, i32 31, i32 30, i32 31]
define i32 @max_monthday(i32 %0, i32 %1) {
%3 = icmp sgt i32 %0, 0
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = icmp sgt i32 %1, 0
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = icmp slt i32 %1, 13
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = icmp eq i32 %1, 2
br i1 %12, label %13, label %23
13: ; preds = %2
%14 = srem i32 %0, 400
%15 = icmp eq i32 %14, 0
br i1 %15, label %28, label %16
16: ; preds = %13
%17 = srem i32 %0, 100
%18 = icmp eq i32 %17, 0
br i1 %18, label %28, label %19
19: ; preds = %16
%20 = and i32 %0, 3
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i32 29, i32 28
br label %28
23: ; preds = %2
%24 = add nsw i32 %1, -1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [12 x i32], [12 x i32]* @max_monthday.days, i64 0, i64 %25
%27 = load i32, i32* %26
br label %28
28: ; preds = %19, %16, %13, %23
%29 = phi i32 [ %27, %23 ], [ 29, %13 ], [ 28, %16 ], [ %22, %19 ]
ret i32 %29
}