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

/* Variables and functions */
scalar_t__ datetime_is_leap_year(int /*<<< orphan*/);
uint8_t datetime_month_days(uint16_t year, uint8_t month) {
  int month_days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  uint8_t days = 0;
  if ((month == 2) && datetime_is_leap_year(year)) {
    days = 29;
  } else if (month >= 1 && month <= 12) {
    days = (uint8_t)month_days[month];
  }
  return days;
}


x86 assembly (clang, -O0):
<datetime_month_days>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xec7(%rip),%rsi
mov    $0x34,%edx
call   1030 <memcpy@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1172 <datetime_month_days+0x52>
mov    -0x4(%rbp),%edi
call   1040 <datetime_is_leap_year@plt>
cmp    $0x0,%rax
je     1172 <datetime_month_days+0x52>
movl   $0x1d,-0x44(%rbp)
jmp    1196 <datetime_month_days+0x76>
cmpl   $0x1,-0x8(%rbp)
jl     1191 <datetime_month_days+0x71>
cmpl   $0xc,-0x8(%rbp)
jg     1191 <datetime_month_days+0x71>
movslq -0x8(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
mov    %eax,-0x44(%rbp)
jmp    1196 <datetime_month_days+0x76>
mov    -0x44(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<datetime_month_days>:
push   %rbx
mov    %esi,%ebx
cmp    $0x2,%esi
jne    112c <datetime_month_days+0x1c>
call   1030 <datetime_is_leap_year@plt>
mov    %rax,%rcx
mov    $0x1d,%eax
test   %rcx,%rcx
jne    1142 <datetime_month_days+0x32>
jmp    1136 <datetime_month_days+0x26>
lea    -0x1(%rbx),%ecx
xor    %eax,%eax
cmp    $0xb,%ecx
ja     1142 <datetime_month_days+0x32>
mov    %ebx,%eax
lea    0xec1(%rip),%rcx
mov    (%rcx,%rax,4),%eax
pop    %rbx
ret

LLVM IR (-O0):
@__const.datetime_month_days.month_days = [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 @datetime_month_days(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [13 x i32]
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = bitcast [13 x i32]* %5 to i8*
store i32 0, i32* %6
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i32, i32* %3
%12 = call i64 @datetime_is_leap_year(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10
store i32 29, i32* %6
br label %27
15: ; preds = %10, %2
%16 = load i32, i32* %4
%17 = icmp sge i32 %16, 1
br i1 %17, label %18, label %26
18: ; preds = %15
%19 = load i32, i32* %4
%20 = icmp sle i32 %19, 12
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [13 x i32], [13 x i32]* %5, i64 0, i64 %23
%25 = load i32, i32* %24
store i32 %25, i32* %6
br label %26
26: ; preds = %21, %18, %15
br label %27
27: ; preds = %26, %14
%28 = load i32, i32* %6
ret i32 %28
}

LLVM IR (-O2):
@__const.datetime_month_days.month_days = [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 @datetime_month_days(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i64 @datetime_is_leap_year(i32 %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %10, label %14
7: ; preds = %2
%8 = add i32 %1, -1
%9 = icmp ult i32 %8, 12
br i1 %9, label %10, label %14
10: ; preds = %4, %7
%11 = zext i32 %1 to i64
%12 = getelementptr inbounds [13 x i32], [13 x i32]* @__const.datetime_month_days.month_days, i64 0, i64 %11
%13 = load i32, i32* %12
br label %14
14: ; preds = %4, %7, %10
%15 = phi i32 [ %13, %10 ], [ 0, %7 ], [ 29, %4 ]
ret i32 %15
}