#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 */
scalar_t__ isLeapYear(int);
int daysInMonth(int month, int year) {
  int leapYear = 0;
  int result = 0;
  if (isLeapYear(year))
    leapYear = 1;
  if (month == 2) {
    result = 28 + leapYear;
  } else {
    result = 31 - (month - 1) % 7 % 2;
  }
  return (result);
}


x86 assembly (clang, -O0):
<daysInMonth>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <isLeapYear@plt>
cmp    $0x0,%rax
je     1145 <daysInMonth+0x35>
movl   $0x1,-0xc(%rbp)
cmpl   $0x2,-0x4(%rbp)
jne    115d <daysInMonth+0x4d>
mov    -0xc(%rbp),%eax
add    $0x1c,%eax
mov    %eax,-0x10(%rbp)
jmp    117f <daysInMonth+0x6f>
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    $0x1f,%eax
sub    %edx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<daysInMonth>:
push   %rbx
mov    %edi,%ebx
mov    %esi,%edi
call   1030 <isLeapYear@plt>
cmp    $0x1,%rax
mov    $0x1d,%eax
sbb    $0x0,%eax
cmp    $0x2,%ebx
je     116c <daysInMonth+0x5c>
mov    %ebx,%eax
add    $0xffffffff,%eax
cltq
imul   $0xffffffff92492493,%rax,%rax
shr    $0x20,%rax
add    %ebx,%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
shr    $0x2,%eax
add    %ecx,%eax
lea    0x0(,%rax,8),%ecx
sub    %ecx,%eax
add    %ebx,%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
shr    $0x7,%cl
add    %al,%cl
and    $0xfe,%cl
sub    %al,%cl
add    $0x1f,%cl
movzbl %cl,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @daysInMonth(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%7 = load i32, i32* %4
%8 = call i64 @isLeapYear(i32 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 1, i32* %5
br label %11
11: ; preds = %10, %2
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %5
%16 = add nsw i32 28, %15
store i32 %16, i32* %6
br label %23
17: ; preds = %11
%18 = load i32, i32* %3
%19 = sub nsw i32 %18, 1
%20 = srem i32 %19, 7
%21 = srem i32 %20, 2
%22 = sub nsw i32 31, %21
store i32 %22, i32* %6
br label %23
23: ; preds = %17, %14
%24 = load i32, i32* %6
ret i32 %24
}

LLVM IR (-O2):
define i32 @daysInMonth(i32 %0, i32 %1) {
%3 = tail call i64 @isLeapYear(i32 %1)
%4 = icmp eq i64 %3, 0
%5 = select i1 %4, i32 28, i32 29
%6 = icmp eq i32 %0, 2
br i1 %6, label %14, label %7
7: ; preds = %2
%8 = add nsw i32 %0, -1
%9 = srem i32 %8, 7
%10 = trunc i32 %9 to i8
%11 = srem i8 %10, 2
%12 = sub nsw i8 31, %11
%13 = zext i8 %12 to i32
br label %14
14: ; preds = %2, %7
%15 = phi i32 [ %13, %7 ], [ %5, %2 ]
ret i32 %15
}