#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 */
double floor(double);
int calculate_day_of_year(int day, int month, int year) {
  int n1 = (int)floor(275.0 * (double)month / 9.0);
  int n2 = (int)floor(((double)month + 9.0) / 12.0);
  int n3 =
      (int)(1.0 + floor(((double)year - 4.0 * floor((double)year / 4.0) + 2.0) /
                        3.0));
  int n = (int)n1 - (n2 * n3) + day - 30.0;
  return n;
}


x86 assembly (clang, -O0):
<calculate_day_of_year>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xf12(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xefe(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <floor@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x10(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xee1(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xecd(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <floor@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xe9e(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <floor@plt>
movsd  -0x28(%rbp),%xmm1
movsd  0xe80(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe68(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe54(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <floor@plt>
movaps %xmm0,%xmm1
movsd  0xe38(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x14(%rbp),%ecx
imul   -0x18(%rbp),%ecx
sub    %ecx,%eax
add    -0x4(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe0a(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate_day_of_year>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %edi,%r14d
cvtsi2sd %esi,%xmm1
movsd  %xmm1,(%rsp)
movsd  0xed3(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  0xecf(%rip),%xmm0
call   1030 <floor@plt>
cvttsd2si %xmm0,%ebp
movsd  (%rsp),%xmm0
addsd  0xeb9(%rip),%xmm0
divsd  0xeb9(%rip),%xmm0
call   1030 <floor@plt>
cvttsd2si %xmm0,%r15d
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd  %xmm1,(%rsp)
movsd  0xea3(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <floor@plt>
mulsd  0xe9a(%rip),%xmm0
addsd  (%rsp),%xmm0
addsd  0xe95(%rip),%xmm0
divsd  0xe95(%rip),%xmm0
call   1030 <floor@plt>
addsd  0xe90(%rip),%xmm0
cvttsd2si %xmm0,%eax
imul   %r15d,%eax
add    %r14d,%ebp
sub    %eax,%ebp
add    $0xffffffe2,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @calculate_day_of_year(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = load i32, i32* %5
%12 = sitofp i32 %11 to double
%13 = fmul double 2.750000e+02, %12
%14 = fdiv double %13, 9.000000e+00
%15 = call double @llvm.floor.f64(double %14)
%16 = fptosi double %15 to i32
store i32 %16, i32* %7
%17 = load i32, i32* %5
%18 = sitofp i32 %17 to double
%19 = fadd double %18, 9.000000e+00
%20 = fdiv double %19, 1.200000e+01
%21 = call double @llvm.floor.f64(double %20)
%22 = fptosi double %21 to i32
store i32 %22, i32* %8
%23 = load i32, i32* %6
%24 = sitofp i32 %23 to double
%25 = load i32, i32* %6
%26 = sitofp i32 %25 to double
%27 = fdiv double %26, 4.000000e+00
%28 = call double @llvm.floor.f64(double %27)
%29 = call double @llvm.fmuladd.f64(double -4.000000e+00, double %28, double %24)
%30 = fadd double %29, 2.000000e+00
%31 = fdiv double %30, 3.000000e+00
%32 = call double @llvm.floor.f64(double %31)
%33 = fadd double 1.000000e+00, %32
%34 = fptosi double %33 to i32
store i32 %34, i32* %9
%35 = load i32, i32* %7
%36 = load i32, i32* %8
%37 = load i32, i32* %9
%38 = mul nsw i32 %36, %37
%39 = sub nsw i32 %35, %38
%40 = load i32, i32* %4
%41 = add nsw i32 %39, %40
%42 = sitofp i32 %41 to double
%43 = fsub double %42, 3.000000e+01
%44 = fptosi double %43 to i32
store i32 %44, i32* %10
%45 = load i32, i32* %10
ret i32 %45
}

LLVM IR (-O2):
define i32 @calculate_day_of_year(i32 %0, i32 %1, i32 %2) {
%4 = sitofp i32 %1 to double
%5 = fmul double %4, 2.750000e+02
%6 = fdiv double %5, 9.000000e+00
%7 = tail call double @llvm.floor.f64(double %6)
%8 = fptosi double %7 to i32
%9 = fadd double %4, 9.000000e+00
%10 = fdiv double %9, 1.200000e+01
%11 = tail call double @llvm.floor.f64(double %10)
%12 = fptosi double %11 to i32
%13 = sitofp i32 %2 to double
%14 = fmul double %13, 2.500000e-01
%15 = tail call double @llvm.floor.f64(double %14)
%16 = tail call double @llvm.fmuladd.f64(double %15, double -4.000000e+00, double %13)
%17 = fadd double %16, 2.000000e+00
%18 = fdiv double %17, 3.000000e+00
%19 = tail call double @llvm.floor.f64(double %18)
%20 = fadd double %19, 1.000000e+00
%21 = fptosi double %20 to i32
%22 = mul nsw i32 %21, %12
%23 = add i32 %8, %0
%24 = sub i32 %23, %22
%25 = add i32 %24, -30
ret i32 %25
}