#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 */
typedef int uint8_t;

/* Variables and functions */
scalar_t__ is_leap_year(int);
uint8_t days_in_month(uint8_t y, uint8_t m) {
  static const uint8_t days_in_month_nonleap[13] = {0,  31, 28, 31, 30, 31, 30,
                                                    31, 31, 30, 31, 30, 31};
  if (m == 2 && is_leap_year(y)) {
    return days_in_month_nonleap[m] + 1;
  } else {
    return days_in_month_nonleap[m];
  }
}


x86 assembly (clang, -O0):
<days_in_month>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jne    1153 <days_in_month+0x43>
mov    -0x8(%rbp),%edi
call   1030 <is_leap_year@plt>
cmp    $0x0,%rax
je     1153 <days_in_month+0x43>
movslq -0xc(%rbp),%rcx
lea    0xebb(%rip),%rax
mov    (%rax,%rcx,4),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1164 <days_in_month+0x54>
movslq -0xc(%rbp),%rcx
lea    0xea2(%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):
<days_in_month>:
push   %rbx
mov    %esi,%ebx
cmp    $0x2,%esi
jne    112c <days_in_month+0x1c>
call   1030 <is_leap_year@plt>
mov    %rax,%rcx
mov    $0x1d,%eax
test   %rcx,%rcx
je     112c <days_in_month+0x1c>
pop    %rbx
ret
movslq %ebx,%rax
lea    0xeca(%rip),%rcx
mov    (%rcx,%rax,4),%eax
pop    %rbx
ret

LLVM IR (-O0):
@days_in_month.days_in_month_nonleap = internal constant [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 31]
define i32 @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* %5
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %18
8: ; preds = %2
%9 = load i32, i32* %4
%10 = call i64 @is_leap_year(i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %8
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [13 x i32], [13 x i32]* @days_in_month.days_in_month_nonleap, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %23
18: ; preds = %8, %2
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [13 x i32], [13 x i32]* @days_in_month.days_in_month_nonleap, i64 0, i64 %20
%22 = load i32, i32* %21
store i32 %22, i32* %3
br label %23
23: ; preds = %18, %12
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@days_in_month.days_in_month_nonleap = internal unnamed_addr constant [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 31]
define i32 @days_in_month(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i64 @is_leap_year(i32 %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %4, %2
%8 = sext i32 %1 to i64
%9 = getelementptr inbounds [13 x i32], [13 x i32]* @days_in_month.days_in_month_nonleap, i64 0, i64 %8
%10 = load i32, i32* %9
br label %11
11: ; preds = %4, %7
%12 = phi i32 [ %10, %7 ], [ 29, %4 ]
ret i32 %12
}