int check_days(int year, int month) {
  int leap = (((year % 4 == 0) && ((year % 100) != 0)) || ((year % 400) == 0));
  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:
    if (leap)
      return 29;
    else
      return 28;
  default:
    return 0;
  }
}


x86 assembly (clang, -O0):
<check_days>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1137 <check_days+0x37>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    $0x1,%al
cmp    $0x0,%edx
mov    %al,-0x11(%rbp)
jne    114b <check_days+0x4b>
mov    -0x8(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
movzbl %al,%eax
and    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x1,%eax
je     1218 <check_days+0x118>
jmp    116b <check_days+0x6b>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
je     1230 <check_days+0x130>
jmp    117c <check_days+0x7c>
mov    -0x18(%rbp),%eax
sub    $0x3,%eax
je     1218 <check_days+0x118>
jmp    118d <check_days+0x8d>
mov    -0x18(%rbp),%eax
sub    $0x4,%eax
je     1224 <check_days+0x124>
jmp    119e <check_days+0x9e>
mov    -0x18(%rbp),%eax
sub    $0x5,%eax
je     1218 <check_days+0x118>
jmp    11af <check_days+0xaf>
mov    -0x18(%rbp),%eax
sub    $0x6,%eax
je     1224 <check_days+0x124>
jmp    11c0 <check_days+0xc0>
mov    -0x18(%rbp),%eax
add    $0xfffffff9,%eax
sub    $0x2,%eax
jb     1218 <check_days+0x118>
jmp    11d4 <check_days+0xd4>
mov    -0x18(%rbp),%eax
sub    $0x9,%eax
je     1224 <check_days+0x124>
jmp    11e5 <check_days+0xe5>
mov    -0x18(%rbp),%eax
sub    $0xa,%eax
je     1218 <check_days+0x118>
jmp    11f6 <check_days+0xf6>
mov    -0x18(%rbp),%eax
sub    $0xb,%eax
je     1224 <check_days+0x124>
jmp    1207 <check_days+0x107>
mov    -0x18(%rbp),%eax
sub    $0xc,%eax
jne    1252 <check_days+0x152>
jmp    1218 <check_days+0x118>
movl   $0x1f,-0x4(%rbp)
jmp    1259 <check_days+0x159>
movl   $0x1e,-0x4(%rbp)
jmp    1259 <check_days+0x159>
cmpl   $0x0,-0x10(%rbp)
je     1246 <check_days+0x146>
movl   $0x1d,-0x4(%rbp)
jmp    1259 <check_days+0x159>
movl   $0x1c,-0x4(%rbp)
jmp    1259 <check_days+0x159>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_days>:
test   $0x3,%dil
jne    112b <check_days+0x2b>
movslq %edi,%rax
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
mov    %edi,%edx
mov    $0x1d,%ecx
sub    %eax,%edx
jne    1146 <check_days+0x46>
imul   $0xc28f5c29,%edi,%eax
add    $0x51eb850,%eax
ror    $0x4,%eax
xor    %ecx,%ecx
cmp    $0xa3d70b,%eax
setb   %cl
or     $0x1c,%ecx
cmp    $0xc,%esi
ja     1172 <check_days+0x72>
mov    $0x1f,%eax
mov    $0x15aa,%edx
bt     %esi,%edx
jae    115b <check_days+0x5b>
ret
mov    $0xa50,%eax
bt     %esi,%eax
jae    116b <check_days+0x6b>
mov    $0x1e,%eax
ret
mov    %ecx,%eax
cmp    $0x2,%esi
je     115a <check_days+0x5a>
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @check_days(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %4
%8 = srem i32 %7, 4
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* %4
%12 = srem i32 %11, 100
%13 = icmp ne i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %10, %2
%15 = load i32, i32* %4
%16 = srem i32 %15, 400
%17 = icmp eq i32 %16, 0
br label %18
18: ; preds = %14, %10
%19 = phi i1 [ true, %10 ], [ %17, %14 ]
%20 = zext i1 %19 to i32
store i32 %20, i32* %6
%21 = load i32, i32* %5
switch i32 %21, label %29 [
i32 1, label %22
i32 3, label %22
i32 5, label %22
i32 7, label %22
i32 8, label %22
i32 10, label %22
i32 12, label %22
i32 4, label %23
i32 6, label %23
i32 9, label %23
i32 11, label %23
i32 2, label %24
]
22: ; preds = %18, %18, %18, %18, %18, %18, %18
store i32 31, i32* %3
br label %30
23: ; preds = %18, %18, %18, %18
store i32 30, i32* %3
br label %30
24: ; preds = %18
%25 = load i32, i32* %6
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 29, i32* %3
br label %30
28: ; preds = %24
store i32 28, i32* %3
br label %30
29: ; preds = %18
store i32 0, i32* %3
br label %30
30: ; preds = %29, %28, %27, %23, %22
%31 = load i32, i32* %3
ret i32 %31
}

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