#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__ fb_hTimeDaysInMonth(int, int);
int fb_hGetDayOfYearEx(int year, int month, int day) {
  int result = 0;
  int cur_month;
  for (cur_month = 1; cur_month != month; ++cur_month)
    result += fb_hTimeDaysInMonth(cur_month, year);
  return result + day;
}


x86 assembly (clang, -O0):
<fb_hGetDayOfYearEx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     1161 <fb_hGetDayOfYearEx+0x51>
mov    -0x14(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1030 <fb_hTimeDaysInMonth@plt>
mov    %rax,%rcx
movslq -0x10(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112f <fb_hGetDayOfYearEx+0x1f>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fb_hGetDayOfYearEx>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
xor    %ebp,%ebp
cmp    $0x1,%esi
je     1144 <fb_hGetDayOfYearEx+0x34>
mov    %esi,%r12d
mov    %edi,%r15d
xor    %ebp,%ebp
mov    $0x1,%ebx
nop
mov    %ebx,%edi
mov    %r15d,%esi
call   1030 <fb_hTimeDaysInMonth@plt>
add    %eax,%ebp
add    $0x1,%ebx
cmp    %ebx,%r12d
jne    1130 <fb_hGetDayOfYearEx+0x20>
add    %r14d,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fb_hGetDayOfYearEx(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
store i32 1, i32* %8
br label %9
9: ; preds = %21, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %5
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %24
13: ; preds = %9
%14 = load i32, i32* %8
%15 = load i32, i32* %4
%16 = call i64 @fb_hTimeDaysInMonth(i32 %14, i32 %15)
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = add nsw i64 %18, %16
%20 = trunc i64 %19 to i32
store i32 %20, i32* %7
br label %21
21: ; preds = %13
%22 = load i32, i32* %8
%23 = add nsw i32 %22, 1
store i32 %23, i32* %8
br label %9
24: ; preds = %9
%25 = load i32, i32* %7
%26 = load i32, i32* %6
%27 = add nsw i32 %25, %26
ret i32 %27
}

LLVM IR (-O2):
define i32 @fb_hGetDayOfYearEx(i32 %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %1, 1
br i1 %4, label %13, label %5
5: ; preds = %3, %5
%6 = phi i32 [ %11, %5 ], [ 1, %3 ]
%7 = phi i32 [ %10, %5 ], [ 0, %3 ]
%8 = tail call i64 @fb_hTimeDaysInMonth(i32 %6, i32 %0)
%9 = trunc i64 %8 to i32
%10 = add i32 %7, %9
%11 = add nuw nsw i32 %6, 1
%12 = icmp eq i32 %11, %1
br i1 %12, label %13, label %5
13: ; preds = %5, %3
%14 = phi i32 [ 0, %3 ], [ %10, %5 ]
%15 = add nsw i32 %14, %2
ret i32 %15
}