int _daysInMonth(int month, int year) {
  if (month < 0) {
    --year;
    month = 11;
  }
  switch (month) {
  case 0:
  case 2:
  case 4:
  case 6:
  case 7:
  case 9:
  case 11:
    return 31;
  case 1:
    return (year % 4 == 0) ? 29 : 28;
  default:
    return 30;
  };
}


x86 assembly (clang, -O0):
<_daysInMonth>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1124 <_daysInMonth+0x24>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
movl   $0xb,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     11a0 <_daysInMonth+0xa0>
jmp    1137 <_daysInMonth+0x37>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     11ac <_daysInMonth+0xac>
jmp    1148 <_daysInMonth+0x48>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     11a0 <_daysInMonth+0xa0>
jmp    1159 <_daysInMonth+0x59>
mov    -0x10(%rbp),%eax
sub    $0x4,%eax
je     11a0 <_daysInMonth+0xa0>
jmp    116a <_daysInMonth+0x6a>
mov    -0x10(%rbp),%eax
add    $0xfffffffa,%eax
sub    $0x2,%eax
jb     11a0 <_daysInMonth+0xa0>
jmp    117e <_daysInMonth+0x7e>
mov    -0x10(%rbp),%eax
sub    $0x9,%eax
je     11a0 <_daysInMonth+0xa0>
jmp    118f <_daysInMonth+0x8f>
mov    -0x10(%rbp),%eax
sub    $0xb,%eax
jne    11cf <_daysInMonth+0xcf>
jmp    11a0 <_daysInMonth+0xa0>
movl   $0x1f,-0x4(%rbp)
jmp    11d6 <_daysInMonth+0xd6>
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    $0x1c,%eax
mov    $0x1d,%ecx
cmp    $0x0,%edx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11d6 <_daysInMonth+0xd6>
movl   $0x1e,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_daysInMonth>:
test   %edi,%edi
mov    $0xb,%ecx
cmovns %edi,%ecx
cmp    $0xb,%ecx
ja     1136 <_daysInMonth+0x36>
mov    $0x1f,%eax
mov    $0xad5,%edx
bt     %ecx,%edx
jae    111f <_daysInMonth+0x1f>
ret
cmp    $0x1,%ecx
jne    1136 <_daysInMonth+0x36>
sar    $0x1f,%edi
add    %esi,%edi
xor    %eax,%eax
test   $0x3,%dil
sete   %al
or     $0x1c,%eax
ret
mov    $0x1e,%eax
ret

LLVM IR (-O0):
define i32 @_daysInMonth(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 slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* %5
%10 = add nsw i32 %9, -1
store i32 %10, i32* %5
store i32 11, i32* %4
br label %11
11: ; preds = %8, %2
%12 = load i32, i32* %4
switch i32 %12, label %20 [
i32 0, label %13
i32 2, label %13
i32 4, label %13
i32 6, label %13
i32 7, label %13
i32 9, label %13
i32 11, label %13
i32 1, label %14
]
13: ; preds = %11, %11, %11, %11, %11, %11, %11
store i32 31, i32* %3
br label %21
14: ; preds = %11
%15 = load i32, i32* %5
%16 = srem i32 %15, 4
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i64
%19 = select i1 %17, i32 29, i32 28
store i32 %19, i32* %3
br label %21
20: ; preds = %11
store i32 30, i32* %3
br label %21
21: ; preds = %20, %14, %13
%22 = load i32, i32* %3
ret i32 %22
}

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