int function(int x, int y) {
  switch (y) {
  case 2:
    if ((x % 4 == 0 && x % 100 != 0) || x % 400 == 0) {
      return 29;
    } else {
      return 28;
    }
  case 4:
  case 6:
  case 9:
  case 11:
    return 30;
  default:
    return 31;
  }
}


x86 assembly (clang, -O0):
<function>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x2,%eax
je     1162 <function+0x62>
jmp    111e <function+0x1e>
mov    -0x10(%rbp),%eax
sub    $0x4,%eax
je     11b6 <function+0xb6>
jmp    112f <function+0x2f>
mov    -0x10(%rbp),%eax
sub    $0x6,%eax
je     11b6 <function+0xb6>
jmp    1140 <function+0x40>
mov    -0x10(%rbp),%eax
sub    $0x9,%eax
je     11b6 <function+0xb6>
jmp    1151 <function+0x51>
mov    -0x10(%rbp),%eax
sub    $0xb,%eax
je     11b6 <function+0xb6>
jmp    11c2 <function+0xc2>
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    118a <function+0x8a>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    119e <function+0x9e>
mov    -0x8(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11aa <function+0xaa>
movl   $0x1d,-0x4(%rbp)
jmp    11c9 <function+0xc9>
movl   $0x1c,-0x4(%rbp)
jmp    11c9 <function+0xc9>
movl   $0x1e,-0x4(%rbp)
jmp    11c9 <function+0xc9>
movl   $0x1f,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<function>:
cmp    $0xb,%esi
ja     1152 <function+0x52>
mov    $0x1e,%eax
mov    $0xa50,%ecx
bt     %esi,%ecx
jae    1115 <function+0x15>
ret
cmp    $0x2,%esi
jne    1152 <function+0x52>
test   $0x3,%dil
sete   %al
imul   $0xc28f5c29,%edi,%ecx
add    $0x51eb850,%ecx
mov    %ecx,%edx
ror    $0x2,%edx
cmp    $0x28f5c29,%edx
setae  %dl
and    %al,%dl
ror    $0x4,%ecx
cmp    $0xa3d70b,%ecx
setb   %al
or     %dl,%al
movzbl %al,%eax
or     $0x1c,%eax
ret
mov    $0x1f,%eax
ret

LLVM IR (-O0):
define i32 @function(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
switch i32 %6, label %22 [
i32 2, label %7
i32 4, label %21
i32 6, label %21
i32 9, label %21
i32 11, label %21
]
7: ; preds = %2
%8 = load i32, i32* %4
%9 = srem i32 %8, 4
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = load i32, i32* %4
%13 = srem i32 %12, 100
%14 = icmp ne i32 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %11, %7
%16 = load i32, i32* %4
%17 = srem i32 %16, 400
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15, %11
store i32 29, i32* %3
br label %23
20: ; preds = %15
store i32 28, i32* %3
br label %23
21: ; preds = %2, %2, %2, %2
store i32 30, i32* %3
br label %23
22: ; preds = %2
store i32 31, i32* %3
br label %23
23: ; preds = %22, %21, %20, %19
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
define i32 @function(i32 %0, i32 %1) {
switch i32 %1, label %13 [
i32 2, label %3
i32 4, label %14
i32 6, label %14
i32 9, label %14
i32 11, label %14
]
3: ; preds = %2
%4 = and i32 %0, 3
%5 = icmp eq i32 %4, 0
%6 = srem i32 %0, 100
%7 = icmp ne i32 %6, 0
%8 = and i1 %5, %7
%9 = srem i32 %0, 400
%10 = icmp eq i32 %9, 0
%11 = or i1 %10, %8
%12 = select i1 %11, i32 29, i32 28
br label %14
13: ; preds = %2
br label %14
14: ; preds = %3, %2, %2, %2, %2, %13
%15 = phi i32 [ 31, %13 ], [ 30, %2 ], [ 30, %2 ], [ 30, %2 ], [ 30, %2 ], [ %12, %3 ]
ret i32 %15
}