#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*/ is_leap_year(int);
int days_for_month(int month, int year) {
  switch (month) {
  case 1:
  case 3:
  case 5:
  case 7:
  case 8:
  case 10:
  case 12:
    return 31;
  case 4:
  case 6:
  case 9:
  case 11:
    return 30;
  case 2:
    return is_leap_year(year) ? 29 : 28;
  default:
    return -1;
  }
}


x86 assembly (clang, -O0):
<days_for_month>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x1,%eax
je     11df <days_for_month+0xcf>
jmp    1132 <days_for_month+0x22>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     11f7 <days_for_month+0xe7>
jmp    1143 <days_for_month+0x33>
mov    -0x10(%rbp),%eax
sub    $0x3,%eax
je     11df <days_for_month+0xcf>
jmp    1154 <days_for_month+0x44>
mov    -0x10(%rbp),%eax
sub    $0x4,%eax
je     11eb <days_for_month+0xdb>
jmp    1165 <days_for_month+0x55>
mov    -0x10(%rbp),%eax
sub    $0x5,%eax
je     11df <days_for_month+0xcf>
jmp    1176 <days_for_month+0x66>
mov    -0x10(%rbp),%eax
sub    $0x6,%eax
je     11eb <days_for_month+0xdb>
jmp    1187 <days_for_month+0x77>
mov    -0x10(%rbp),%eax
add    $0xfffffff9,%eax
sub    $0x2,%eax
jb     11df <days_for_month+0xcf>
jmp    119b <days_for_month+0x8b>
mov    -0x10(%rbp),%eax
sub    $0x9,%eax
je     11eb <days_for_month+0xdb>
jmp    11ac <days_for_month+0x9c>
mov    -0x10(%rbp),%eax
sub    $0xa,%eax
je     11df <days_for_month+0xcf>
jmp    11bd <days_for_month+0xad>
mov    -0x10(%rbp),%eax
sub    $0xb,%eax
je     11eb <days_for_month+0xdb>
jmp    11ce <days_for_month+0xbe>
mov    -0x10(%rbp),%eax
sub    $0xc,%eax
jne    1219 <days_for_month+0x109>
jmp    11df <days_for_month+0xcf>
movl   $0x1f,-0x4(%rbp)
jmp    1220 <days_for_month+0x110>
movl   $0x1e,-0x4(%rbp)
jmp    1220 <days_for_month+0x110>
mov    -0xc(%rbp),%edi
call   1030 <is_leap_year@plt>
mov    %eax,%edx
mov    $0x1c,%eax
mov    $0x1d,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1220 <days_for_month+0x110>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<days_for_month>:
cmp    $0xc,%edi
ja     1152 <days_for_month+0x42>
mov    $0x1f,%eax
mov    $0x15aa,%ecx
bt     %edi,%ecx
jae    1125 <days_for_month+0x15>
ret
mov    $0xa50,%eax
bt     %edi,%eax
jae    1135 <days_for_month+0x25>
mov    $0x1e,%eax
ret
cmp    $0x2,%edi
jne    1152 <days_for_month+0x42>
push   %rax
mov    %esi,%edi
call   1030 <is_leap_year@plt>
cmp    $0x1,%eax
mov    $0x1d,%eax
sbb    $0x0,%eax
add    $0x8,%rsp
ret
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
define i32 @days_for_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
switch i32 %6, label %15 [
i32 1, label %7
i32 3, label %7
i32 5, label %7
i32 7, label %7
i32 8, label %7
i32 10, label %7
i32 12, label %7
i32 4, label %8
i32 6, label %8
i32 9, label %8
i32 11, label %8
i32 2, label %9
]
7: ; preds = %2, %2, %2, %2, %2, %2, %2
store i32 31, i32* %3
br label %16
8: ; preds = %2, %2, %2, %2
store i32 30, i32* %3
br label %16
9: ; preds = %2
%10 = load i32, i32* %5
%11 = call i32 @is_leap_year(i32 %10)
%12 = icmp ne i32 %11, 0
%13 = zext i1 %12 to i64
%14 = select i1 %12, i32 29, i32 28
store i32 %14, i32* %3
br label %16
15: ; preds = %2
store i32 -1, i32* %3
br label %16
16: ; preds = %15, %9, %8, %7
%17 = load i32, i32* %3
ret i32 %17
}

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