#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__ gregorian_is_leap_year(int);
int gregorian_days_in_month(int month, int year) {
  if (month == 2)
    return gregorian_is_leap_year(year) ? 29 : 28;
  else if (month == 4 || month == 6 || month == 9 || month == 11)
    return 30;
  else
    return 31;
}


x86 assembly (clang, -O0):
<gregorian_days_in_month>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    114c <gregorian_days_in_month+0x3c>
mov    -0xc(%rbp),%edi
call   1030 <gregorian_is_leap_year@plt>
mov    %rax,%rdx
mov    $0x1c,%eax
mov    $0x1d,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1187 <gregorian_days_in_month+0x77>
cmpl   $0x4,-0x8(%rbp)
je     1174 <gregorian_days_in_month+0x64>
cmpl   $0x6,-0x8(%rbp)
je     1174 <gregorian_days_in_month+0x64>
cmpl   $0x9,-0x8(%rbp)
je     1174 <gregorian_days_in_month+0x64>
cmpl   $0xb,-0x8(%rbp)
jne    1180 <gregorian_days_in_month+0x70>
movl   $0x1e,-0x4(%rbp)
jmp    1187 <gregorian_days_in_month+0x77>
movl   $0x1f,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gregorian_days_in_month>:
cmp    $0xb,%edi
ja     1143 <gregorian_days_in_month+0x33>
mov    $0x1e,%eax
mov    $0xa50,%ecx
bt     %edi,%ecx
jae    1125 <gregorian_days_in_month+0x15>
ret
cmp    $0x2,%edi
jne    1143 <gregorian_days_in_month+0x33>
push   %rax
mov    %esi,%edi
call   1030 <gregorian_is_leap_year@plt>
cmp    $0x1,%rax
mov    $0x1d,%eax
sbb    $0x0,%eax
add    $0x8,%rsp
ret
mov    $0x1f,%eax
ret

LLVM IR (-O0):
define i32 @gregorian_days_in_month(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 eq i32 %6, 2
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = load i32, i32* %5
%10 = call i64 @gregorian_is_leap_year(i32 %9)
%11 = icmp ne i64 %10, 0
%12 = zext i1 %11 to i64
%13 = select i1 %11, i32 29, i32 28
store i32 %13, i32* %3
br label %28
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 4
br i1 %16, label %26, label %17
17: ; preds = %14
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 6
br i1 %19, label %26, label %20
20: ; preds = %17
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 9
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 11
br i1 %25, label %26, label %27
26: ; preds = %23, %20, %17, %14
store i32 30, i32* %3
br label %28
27: ; preds = %23
store i32 31, i32* %3
br label %28
28: ; preds = %27, %26, %8
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
define i32 @gregorian_days_in_month(i32 %0, i32 %1) {
switch i32 %0, label %7 [
i32 2, label %3
i32 11, label %8
i32 9, label %8
i32 6, label %8
i32 4, label %8
]
3: ; preds = %2
%4 = tail call i64 @gregorian_is_leap_year(i32 %1)
%5 = icmp eq i64 %4, 0
%6 = select i1 %5, i32 28, i32 29
br label %8
7: ; preds = %2
br label %8
8: ; preds = %2, %2, %2, %2, %7, %3
%9 = phi i32 [ %6, %3 ], [ 31, %7 ], [ 30, %2 ], [ 30, %2 ], [ 30, %2 ], [ 30, %2 ]
ret i32 %9
}