int monthLength(int currentMonth, int currentYear) {
  switch (currentMonth) {
  case 1:
  case 3:
  case 5:
  case 7:
  case 8:
  case 10:
  case 12:
    return 31;
    break;
  case 4:
  case 6:
  case 9:
  case 11:
    return 30;
    break;
  case 2:
    if (((currentYear % 4 == 0) && (currentYear % 100 != 0)) ||
        (currentYear % 400 == 0))
      return 29;
    else
      return 28;
    break;
  }
}


x86 assembly (clang, -O0):
<monthLength>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x1,%eax
je     11cb <monthLength+0xcb>
jmp    111e <monthLength+0x1e>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     11e3 <monthLength+0xe3>
jmp    112f <monthLength+0x2f>
mov    -0x10(%rbp),%eax
sub    $0x3,%eax
je     11cb <monthLength+0xcb>
jmp    1140 <monthLength+0x40>
mov    -0x10(%rbp),%eax
sub    $0x4,%eax
je     11d7 <monthLength+0xd7>
jmp    1151 <monthLength+0x51>
mov    -0x10(%rbp),%eax
sub    $0x5,%eax
je     11cb <monthLength+0xcb>
jmp    1162 <monthLength+0x62>
mov    -0x10(%rbp),%eax
sub    $0x6,%eax
je     11d7 <monthLength+0xd7>
jmp    1173 <monthLength+0x73>
mov    -0x10(%rbp),%eax
add    $0xfffffff9,%eax
sub    $0x2,%eax
jb     11cb <monthLength+0xcb>
jmp    1187 <monthLength+0x87>
mov    -0x10(%rbp),%eax
sub    $0x9,%eax
je     11d7 <monthLength+0xd7>
jmp    1198 <monthLength+0x98>
mov    -0x10(%rbp),%eax
sub    $0xa,%eax
je     11cb <monthLength+0xcb>
jmp    11a9 <monthLength+0xa9>
mov    -0x10(%rbp),%eax
sub    $0xb,%eax
je     11d7 <monthLength+0xd7>
jmp    11ba <monthLength+0xba>
mov    -0x10(%rbp),%eax
sub    $0xc,%eax
jne    1232 <monthLength+0x132>
jmp    11cb <monthLength+0xcb>
movl   $0x1f,-0x4(%rbp)
jmp    1232 <monthLength+0x132>
movl   $0x1e,-0x4(%rbp)
jmp    1232 <monthLength+0x132>
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    120b <monthLength+0x10b>
mov    -0xc(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    121f <monthLength+0x11f>
mov    -0xc(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    122b <monthLength+0x12b>
movl   $0x1d,-0x4(%rbp)
jmp    1232 <monthLength+0x132>
movl   $0x1c,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<monthLength>:
mov    $0x1f,%eax
cmp    $0xb,%edi
ja     1156 <monthLength+0x56>
mov    $0xa50,%ecx
bt     %edi,%ecx
jae    111a <monthLength+0x1a>
mov    $0x1e,%eax
ret
cmp    $0x2,%edi
jne    1156 <monthLength+0x56>
test   $0x3,%sil
sete   %al
imul   $0xc28f5c29,%esi,%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

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

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