#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 num_days(int year, int month) {
  assert(year >= 0 && month >= 0 && month < 12);
  static size_t days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  if (month == 1 && year % 4 == 0) {
    if (year % 100 != 0 || year % 400 == 0) {
      return 29;
    }
  }
  return days[month];
}


x86 assembly (clang, -O0):
<num_days>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0xd(%rbp)
jl     1146 <num_days+0x36>
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jl     1146 <num_days+0x36>
cmpl   $0xc,-0xc(%rbp)
setl   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x1,-0xc(%rbp)
jne    11aa <num_days+0x9a>
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11aa <num_days+0x9a>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1199 <num_days+0x89>
mov    -0x8(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11a5 <num_days+0x95>
movl   $0x1d,-0x4(%rbp)
jmp    11bc <num_days+0xac>
jmp    11aa <num_days+0x9a>
movslq -0xc(%rbp),%rcx
lea    0x2e7b(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<num_days>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
cmp    $0xc,%esi
setl   %al
mov    %esi,%ecx
or     %edi,%ecx
setns  %cl
and    %al,%cl
movzbl %cl,%edi
call   1030 <assert@plt>
cmp    $0x1,%ebx
jne    1177 <num_days+0x67>
mov    %ebp,%eax
and    $0x3,%eax
jne    1177 <num_days+0x67>
imul   $0xc28f5c29,%ebp,%ecx
add    $0x51eb850,%ecx
ror    $0x2,%ecx
mov    $0x1d,%eax
cmp    $0x28f5c28,%ecx
ja     1184 <num_days+0x74>
movslq %ebp,%rcx
imul   $0x51eb851f,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x27,%rcx
add    %edx,%ecx
imul   $0x190,%ecx,%ecx
sub    %ecx,%ebp
je     1184 <num_days+0x74>
movslq %ebx,%rax
lea    0xe7f(%rip),%rcx
mov    (%rcx,%rax,8),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@num_days.days = internal global [12 x i64] [i64 31, i64 28, i64 31, i64 30, i64 31, i64 30, i64 31, i64 31, i64 30, i64 31, i64 30, i64 31]
define i32 @num_days(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 sge i32 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = load i32, i32* %5
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 12
br label %14
14: ; preds = %11, %8, %2
%15 = phi i1 [ false, %8 ], [ false, %2 ], [ %13, %11 ]
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i32, i32* %5
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %34
20: ; preds = %14
%21 = load i32, i32* %4
%22 = srem i32 %21, 4
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %34
24: ; preds = %20
%25 = load i32, i32* %4
%26 = srem i32 %25, 100
%27 = icmp ne i32 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %24
%29 = load i32, i32* %4
%30 = srem i32 %29, 400
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %28, %24
store i32 29, i32* %3
br label %40
33: ; preds = %28
br label %34
34: ; preds = %33, %20, %14
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [12 x i64], [12 x i64]* @num_days.days, i64 0, i64 %36
%38 = load i64, i64* %37
%39 = trunc i64 %38 to i32
store i32 %39, i32* %3
br label %40
40: ; preds = %34, %32
%41 = load i32, i32* %3
ret i32 %41
}

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