#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int abs(int);
int g_numdays(int month, int year) {
  int y;
  y = abs(year);
  switch (month) {
  case 2:
    if ((((y % 4) == 0) && ((y % 100) != 0)) || ((y % 400) == 0))
      return (29);
    else
      return (28);
  case 4:
  case 6:
  case 9:
  case 11:
    return (30);
  default:
    return (31);
  }
}


x86 assembly (clang, -O0):
<g_numdays>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x2,%eax
je     1181 <g_numdays+0x71>
jmp    113d <g_numdays+0x2d>
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
je     11d5 <g_numdays+0xc5>
jmp    114e <g_numdays+0x3e>
mov    -0x14(%rbp),%eax
sub    $0x6,%eax
je     11d5 <g_numdays+0xc5>
jmp    115f <g_numdays+0x4f>
mov    -0x14(%rbp),%eax
sub    $0x9,%eax
je     11d5 <g_numdays+0xc5>
jmp    1170 <g_numdays+0x60>
mov    -0x14(%rbp),%eax
sub    $0xb,%eax
je     11d5 <g_numdays+0xc5>
jmp    11e1 <g_numdays+0xd1>
mov    -0x10(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11a9 <g_numdays+0x99>
mov    -0x10(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11bd <g_numdays+0xad>
mov    -0x10(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11c9 <g_numdays+0xb9>
movl   $0x1d,-0x4(%rbp)
jmp    11e8 <g_numdays+0xd8>
movl   $0x1c,-0x4(%rbp)
jmp    11e8 <g_numdays+0xd8>
movl   $0x1e,-0x4(%rbp)
jmp    11e8 <g_numdays+0xd8>
movl   $0x1f,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<g_numdays>:
mov    %esi,%ecx
neg    %ecx
cmovs  %esi,%ecx
cmp    $0xb,%edi
ja     1152 <g_numdays+0x52>
mov    $0x1e,%eax
mov    $0xa50,%edx
bt     %edi,%edx
jae    111c <g_numdays+0x1c>
ret
cmp    $0x2,%edi
jne    1152 <g_numdays+0x52>
test   $0x3,%cl
sete   %al
imul   $0xc28f5c29,%ecx,%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 @g_numdays(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* %5
%8 = call i32 @abs(i32 %7)
store i32 %8, i32* %6
%9 = load i32, i32* %4
switch i32 %9, label %25 [
i32 2, label %10
i32 4, label %24
i32 6, label %24
i32 9, label %24
i32 11, label %24
]
10: ; preds = %2
%11 = load i32, i32* %6
%12 = srem i32 %11, 4
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i32, i32* %6
%16 = srem i32 %15, 100
%17 = icmp ne i32 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %14, %10
%19 = load i32, i32* %6
%20 = srem i32 %19, 400
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18, %14
store i32 29, i32* %3
br label %26
23: ; preds = %18
store i32 28, i32* %3
br label %26
24: ; preds = %2, %2, %2, %2
store i32 30, i32* %3
br label %26
25: ; preds = %2
store i32 31, i32* %3
br label %26
26: ; preds = %25, %24, %23, %22
%27 = load i32, i32* %3
ret i32 %27
}

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