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    12a4 <check_mday+0x1a4>
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    12ab <check_mday+0x1ab>
jmp    12a4 <check_mday+0x1a4>
cmpl   $0x1,-0x10(%rbp)
jl     1212 <check_mday+0x112>
cmpl   $0x1e,-0x10(%rbp)
jg     1212 <check_mday+0x112>
movl   $0x1,-0x4(%rbp)
jmp    12ab <check_mday+0x1ab>
jmp    12a4 <check_mday+0x1a4>
cmpl   $0x1,-0x10(%rbp)
jl     129f <check_mday+0x19f>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
xor    %eax,%eax
cmp    $0x0,%edx
mov    %al,-0x15(%rbp)
jne    1273 <check_mday+0x173>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    $0x1,%al
cmp    $0x0,%edx
mov    %al,-0x1d(%rbp)
jne    126d <check_mday+0x16d>
mov    -0x8(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
sete   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
mov    %al,-0x15(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x15(%rbp),%sil
mov    $0x1c,%ecx
mov    $0x1d,%edx
test   $0x1,%sil
cmovne %edx,%ecx
cmp    %ecx,%eax
jg     129f <check_mday+0x19f>
movl   $0x1,-0x4(%rbp)
jmp    12ab <check_mday+0x1ab>
jmp    12a4 <check_mday+0x1a4>
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>
mov    $0x1c,%ecx
test   $0x3,%dil
jne    1173 <check_mday+0x73>
imul   $0xc28f5c29,%edi,%eax
add    $0x51eb850,%eax
mov    %eax,%esi
ror    $0x2,%esi
mov    $0x1d,%ecx
cmp    $0x28f5c28,%esi
ja     1173 <check_mday+0x73>
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 %50 [
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 %51
16: ; preds = %12, %9
br label %50
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 %51
24: ; preds = %20, %17
br label %50
25: ; preds = %3
%26 = load i32, i32* %7
%27 = icmp sge i32 %26, 1
br i1 %27, label %28, label %49
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 %43
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
%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 ]
br label %43
43: ; preds = %41, %28
%44 = phi i1 [ false, %28 ], [ %42, %41 ]
%45 = zext i1 %44 to i64
%46 = select i1 %44, i32 29, i32 28
%47 = icmp sle i32 %29, %46
br i1 %47, label %48, label %49
48: ; preds = %43
store i32 1, i32* %4
br label %51
49: ; preds = %43, %25
br label %50
50: ; preds = %3, %49, %24, %16
store i32 0, i32* %4
br label %51
51: ; preds = %50, %48, %23, %15
%52 = load i32, i32* %4
ret i32 %52
}

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 eq i32 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = srem i32 %0, 100
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = srem i32 %0, 400
%20 = icmp eq i32 %19, 0
%21 = select i1 %20, i32 29, i32 28
br label %22
22: ; preds = %15, %18, %12
%23 = phi i32 [ 28, %12 ], [ 29, %15 ], [ %21, %18 ]
%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
}