int check_mday(int year, int mon, int mday) {
  switch (mon) {
  case 0:
  case 2:
  case 4:
  case 6:
  case 7:
  case 9:
  case 11:
    if (mday >= 1 && mday <= 31)
      return 1;
    break;
  case 3:
  case 5:
  case 8:
  case 10:
    if (mday >= 1 && mday <= 30)
      return 1;
    break;
  case 1:
    if (mday >= 1 && mday <= (((((year) % 4) == 0 && ((year) % 100) != 0) ||
                               ((year) % 400) == 0)
                                  ? 29
                                  : 28))
      return 1;
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_mday>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
test   %eax,%eax
je     11cd <check_mday+0xcd>
jmp    1120 <check_mday+0x20>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
je     1217 <check_mday+0x117>
jmp    1131 <check_mday+0x31>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     11cd <check_mday+0xcd>
jmp    1142 <check_mday+0x42>
mov    -0x14(%rbp),%eax
sub    $0x3,%eax
je     11f2 <check_mday+0xf2>
jmp    1153 <check_mday+0x53>
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
je     11cd <check_mday+0xcd>
jmp    1164 <check_mday+0x64>
mov    -0x14(%rbp),%eax
sub    $0x5,%eax
je     11f2 <check_mday+0xf2>
jmp    1175 <check_mday+0x75>
mov    -0x14(%rbp),%eax
add    $0xfffffffa,%eax
sub    $0x2,%eax
jb     11cd <check_mday+0xcd>
jmp    1189 <check_mday+0x89>
mov    -0x14(%rbp),%eax
sub    $0x8,%eax
je     11f2 <check_mday+0xf2>
jmp    119a <check_mday+0x9a>
mov    -0x14(%rbp),%eax
sub    $0x9,%eax
je     11cd <check_mday+0xcd>
jmp    11ab <check_mday+0xab>
mov    -0x14(%rbp),%eax
sub    $0xa,%eax
je     11f2 <check_mday+0xf2>
jmp    11bc <check_mday+0xbc>
mov    -0x14(%rbp),%eax
sub    $0xb,%eax
jne    1299 <check_mday+0x199>
jmp    11cd <check_mday+0xcd>
cmpl   $0x1,-0x10(%rbp)
jl     11ed <check_mday+0xed>
cmpl   $0x1f,-0x10(%rbp)
jg     11ed <check_mday+0xed>
movl   $0x1,-0x4(%rbp)
jmp    12a0 <check_mday+0x1a0>
jmp    1299 <check_mday+0x199>
cmpl   $0x1,-0x10(%rbp)
jl     1212 <check_mday+0x112>
cmpl   $0x1e,-0x10(%rbp)
jg     1212 <check_mday+0x112>
movl   $0x1,-0x4(%rbp)
jmp    12a0 <check_mday+0x1a0>
jmp    1299 <check_mday+0x199>
cmpl   $0x1,-0x10(%rbp)
jl     1294 <check_mday+0x194>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1254 <check_mday+0x154>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    $0x1,%al
cmp    $0x0,%edx
mov    %al,-0x19(%rbp)
jne    1268 <check_mday+0x168>
mov    -0x8(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x19(%rbp),%sil
mov    $0x1c,%ecx
mov    $0x1d,%edx
test   $0x1,%sil
cmovne %edx,%ecx
cmp    %ecx,%eax
jg     1294 <check_mday+0x194>
movl   $0x1,-0x4(%rbp)
jmp    12a0 <check_mday+0x1a0>
jmp    1299 <check_mday+0x199>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_mday>:
cmp    $0xb,%esi
ja     1134 <check_mday+0x34>
mov    $0xad5,%eax
bt     %esi,%eax
jae    111d <check_mday+0x1d>
add    $0xffffffff,%edx
mov    $0x1,%eax
cmp    $0x1f,%edx
jae    1134 <check_mday+0x34>
ret
mov    $0x528,%eax
bt     %esi,%eax
jae    1137 <check_mday+0x37>
add    $0xffffffff,%edx
mov    $0x1,%eax
cmp    $0x1e,%edx
jb     111c <check_mday+0x1c>
xor    %eax,%eax
ret
test   %edx,%edx
jle    1134 <check_mday+0x34>
test   $0x3,%dil
jne    1166 <check_mday+0x66>
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,%esi
mov    $0x1d,%ecx
sub    %eax,%esi
jne    1181 <check_mday+0x81>
imul   $0xc28f5c29,%edi,%eax
add    $0x51eb850,%eax
ror    $0x4,%eax
xor    %ecx,%ecx
cmp    $0xa3d70b,%eax
setb   %cl
or     $0x1c,%ecx
mov    $0x1,%eax
cmp    %edx,%ecx
jae    111c <check_mday+0x1c>
jmp    1134 <check_mday+0x34>

LLVM IR (-O0):
define i32 @check_mday(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i32, i32* %6
switch i32 %8, label %48 [
i32 0, label %9
i32 2, label %9
i32 4, label %9
i32 6, label %9
i32 7, label %9
i32 9, label %9
i32 11, label %9
i32 3, label %17
i32 5, label %17
i32 8, label %17
i32 10, label %17
i32 1, label %25
]
9: ; preds = %3, %3, %3, %3, %3, %3, %3
%10 = load i32, i32* %7
%11 = icmp sge i32 %10, 1
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load i32, i32* %7
%14 = icmp sle i32 %13, 31
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 1, i32* %4
br label %49
16: ; preds = %12, %9
br label %48
17: ; preds = %3, %3, %3, %3
%18 = load i32, i32* %7
%19 = icmp sge i32 %18, 1
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* %7
%22 = icmp sle i32 %21, 30
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 1, i32* %4
br label %49
24: ; preds = %20, %17
br label %48
25: ; preds = %3
%26 = load i32, i32* %7
%27 = icmp sge i32 %26, 1
br i1 %27, label %28, label %47
28: ; preds = %25
%29 = load i32, i32* %7
%30 = load i32, i32* %5
%31 = srem i32 %30, 4
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %28
%34 = load i32, i32* %5
%35 = srem i32 %34, 100
%36 = icmp ne i32 %35, 0
br i1 %36, label %41, label %37
37: ; preds = %33, %28
%38 = load i32, i32* %5
%39 = srem i32 %38, 400
%40 = icmp eq i32 %39, 0
br label %41
41: ; preds = %37, %33
%42 = phi i1 [ true, %33 ], [ %40, %37 ]
%43 = zext i1 %42 to i64
%44 = select i1 %42, i32 29, i32 28
%45 = icmp sle i32 %29, %44
br i1 %45, label %46, label %47
46: ; preds = %41
store i32 1, i32* %4
br label %49
47: ; preds = %41, %25
br label %48
48: ; preds = %3, %47, %24, %16
store i32 0, i32* %4
br label %49
49: ; preds = %48, %46, %23, %15
%50 = load i32, i32* %4
ret i32 %50
}

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