#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 get_last_day_of_month(int const, int const);
int get_day_in_month_range(const int year, const int first_month,
                           const int second_month) {
  if (first_month > second_month)
    return -1 * get_day_in_month_range(year, second_month, first_month);
  if (first_month == second_month || first_month + 1 == second_month)
    return 0;
  return get_last_day_of_month(year, first_month + 1) +
         get_day_in_month_range(year, first_month + 1, second_month);
}


x86 assembly (clang, -O0):
<get_day_in_month_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    1159 <get_day_in_month_range+0x39>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <get_day_in_month_range@plt>
imul   $0xffffffff,%eax,%eax
mov    %eax,-0x4(%rbp)
jmp    11ac <get_day_in_month_range+0x8c>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     1174 <get_day_in_month_range+0x54>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cmp    -0x10(%rbp),%eax
jne    1180 <get_day_in_month_range+0x60>
movl   $0x0,-0x4(%rbp)
jmp    11ac <get_day_in_month_range+0x8c>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
call   1030 <get_last_day_of_month@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
call   1040 <get_day_in_month_range@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_day_in_month_range>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%ebp
mov    %edi,%r14d
cmp    %edx,%esi
jle    1146 <get_day_in_month_range+0x26>
mov    %r14d,%edi
mov    %r15d,%esi
mov    %ebp,%edx
call   1040 <get_day_in_month_range@plt>
mov    %eax,%ebx
neg    %ebx
jmp    114d <get_day_in_month_range+0x2d>
xor    %ebx,%ebx
cmp    %r15d,%ebp
jne    115a <get_day_in_month_range+0x3a>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0x1,%ebp
xor    %ebx,%ebx
cmp    %ebp,%r15d
je     114d <get_day_in_month_range+0x2d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14d,%edi
mov    %ebp,%esi
call   1030 <get_last_day_of_month@plt>
add    %eax,%ebx
add    $0x1,%ebp
cmp    %ebp,%r15d
jne    1170 <get_day_in_month_range+0x50>
jmp    114d <get_day_in_month_range+0x2d>

LLVM IR (-O0):
define i32 @get_day_in_month_range(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
%9 = load i32, i32* %7
%10 = icmp sgt i32 %8, %9
br i1 %10, label %11, label %17
11: ; preds = %3
%12 = load i32, i32* %5
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = call i32 @get_day_in_month_range(i32 %12, i32 %13, i32 %14)
%16 = mul nsw i32 -1, %15
store i32 %16, i32* %4
br label %38
17: ; preds = %3
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = icmp eq i32 %18, %19
br i1 %20, label %26, label %21
21: ; preds = %17
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
%24 = load i32, i32* %7
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %21, %17
store i32 0, i32* %4
br label %38
27: ; preds = %21
%28 = load i32, i32* %5
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
%31 = call i32 @get_last_day_of_month(i32 %28, i32 %30)
%32 = load i32, i32* %5
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
%35 = load i32, i32* %7
%36 = call i32 @get_day_in_month_range(i32 %32, i32 %34, i32 %35)
%37 = add nsw i32 %31, %36
store i32 %37, i32* %4
br label %38
38: ; preds = %27, %26, %11
%39 = load i32, i32* %4
ret i32 %39
}

LLVM IR (-O2):
define i32 @get_day_in_month_range(i32 %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, %2
br i1 %4, label %9, label %5
5: ; preds = %3
%6 = icmp eq i32 %1, %2
br i1 %6, label %7, label %12
7: ; preds = %12, %5, %9
%8 = phi i32 [ %11, %9 ], [ 0, %5 ], [ %13, %12 ]
ret i32 %8
9: ; preds = %3
%10 = tail call i32 @get_day_in_month_range(i32 %0, i32 %2, i32 %1)
%11 = sub i32 0, %10
br label %7
12: ; preds = %5, %17
%13 = phi i32 [ %19, %17 ], [ 0, %5 ]
%14 = phi i32 [ %15, %17 ], [ %1, %5 ]
%15 = add nsw i32 %14, 1
%16 = icmp eq i32 %15, %2
br i1 %16, label %7, label %17
17: ; preds = %12
%18 = tail call i32 @get_last_day_of_month(i32 %0, i32 %15)
%19 = add nsw i32 %18, %13
br label %12
}