#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 floor(int);
int /*<<< orphan*/ printf(char *, int);
void date_to_mjd(int day, int month, int year) {
  int f, j_day;
  f = floor((14 - month) / 12.0);
  j_day =
      floor(30.61 * (month + 1 + f * 12.0)) + day + floor(365.25 * (year - f));
  j_day =
      j_day - floor((floor((year - f) / 100.0) + 1) * .75) + 1720997 - 2400001;
  printf("%d", j_day);
}


x86 assembly (clang, -O0):
<date_to_mjd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    $0xe,%eax
sub    -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xedb(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <floor@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xeb4(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe9c(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <floor@plt>
add    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x10(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xe6f(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <floor@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x10(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe38(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <floor@plt>
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe14(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <floor@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
sub    %ecx,%eax
add    $0x1a42a5,%eax
sub    $0x249f01,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe11(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<date_to_mjd>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%ebp
mov    %edi,%r14d
mov    $0xe,%eax
sub    %esi,%eax
cvtsi2sd %eax,%xmm0
divsd  0xebe(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <floor@plt>
mov    %eax,%ebx
add    $0x1,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
cvtsi2sd %eax,%xmm1
mulsd  0xe9d(%rip),%xmm1
addsd  %xmm0,%xmm1
mulsd  0xe99(%rip),%xmm1
cvttsd2si %xmm1,%edi
call   1040 <floor@plt>
mov    %eax,%ebp
sub    %ebx,%r15d
xorps  %xmm1,%xmm1
cvtsi2sd %r15d,%xmm1
movsd  %xmm1,(%rsp)
movsd  0xe7e(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <floor@plt>
mov    %eax,%ebx
movsd  (%rsp),%xmm0
divsd  0xe6a(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <floor@plt>
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe57(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <floor@plt>
add    %r14d,%ebp
add    %ebx,%ebp
sub    %eax,%ebp
add    $0xfff5a3a4,%ebp
lea    0xe42(%rip),%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define void @date_to_mjd(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
%9 = load i32, i32* %5
%10 = sub nsw i32 14, %9
%11 = sitofp i32 %10 to double
%12 = fdiv double %11, 1.200000e+01
%13 = fptosi double %12 to i32
%14 = call i32 @floor(i32 %13)
store i32 %14, i32* %7
%15 = load i32, i32* %5
%16 = add nsw i32 %15, 1
%17 = sitofp i32 %16 to double
%18 = load i32, i32* %7
%19 = sitofp i32 %18 to double
%20 = call double @llvm.fmuladd.f64(double %19, double 1.200000e+01, double %17)
%21 = fmul double 3.061000e+01, %20
%22 = fptosi double %21 to i32
%23 = call i32 @floor(i32 %22)
%24 = load i32, i32* %4
%25 = add nsw i32 %23, %24
%26 = load i32, i32* %6
%27 = load i32, i32* %7
%28 = sub nsw i32 %26, %27
%29 = sitofp i32 %28 to double
%30 = fmul double 3.652500e+02, %29
%31 = fptosi double %30 to i32
%32 = call i32 @floor(i32 %31)
%33 = add nsw i32 %25, %32
store i32 %33, i32* %8
%34 = load i32, i32* %8
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = sub nsw i32 %35, %36
%38 = sitofp i32 %37 to double
%39 = fdiv double %38, 1.000000e+02
%40 = fptosi double %39 to i32
%41 = call i32 @floor(i32 %40)
%42 = add nsw i32 %41, 1
%43 = sitofp i32 %42 to double
%44 = fmul double %43, 7.500000e-01
%45 = fptosi double %44 to i32
%46 = call i32 @floor(i32 %45)
%47 = sub nsw i32 %34, %46
%48 = add nsw i32 %47, 1720997
%49 = sub nsw i32 %48, 2400001
store i32 %49, i32* %8
%50 = load i32, i32* %8
%51 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %50)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @date_to_mjd(i32 %0, i32 %1, i32 %2) {
%4 = sub nsw i32 14, %1
%5 = sitofp i32 %4 to double
%6 = fdiv double %5, 1.200000e+01
%7 = fptosi double %6 to i32
%8 = tail call i32 @floor(i32 %7)
%9 = add nsw i32 %1, 1
%10 = sitofp i32 %9 to double
%11 = sitofp i32 %8 to double
%12 = tail call double @llvm.fmuladd.f64(double %11, double 1.200000e+01, double %10)
%13 = fmul double %12, 3.061000e+01
%14 = fptosi double %13 to i32
%15 = tail call i32 @floor(i32 %14)
%16 = sub nsw i32 %2, %8
%17 = sitofp i32 %16 to double
%18 = fmul double %17, 3.652500e+02
%19 = fptosi double %18 to i32
%20 = tail call i32 @floor(i32 %19)
%21 = fdiv double %17, 1.000000e+02
%22 = fptosi double %21 to i32
%23 = tail call i32 @floor(i32 %22)
%24 = add nsw i32 %23, 1
%25 = sitofp i32 %24 to double
%26 = fmul double %25, 7.500000e-01
%27 = fptosi double %26 to i32
%28 = tail call i32 @floor(i32 %27)
%29 = add i32 %0, -679004
%30 = add i32 %29, %15
%31 = add i32 %30, %20
%32 = sub i32 %31, %28
%33 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %32)
ret void
}