#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 /*<<< orphan*/ mjd_year(double, double *);
void mjd_dayno(double mj, int *yr, double *dy) {
  double yrd;
  int yri;
  int dpy;
  mjd_year(mj, &yrd);
  *yr = yri = (int)yrd;
  dpy = isleapyear(yri) ? 366 : 365;
  *dy = dpy * (yrd - yri);
}


x86 assembly (clang, -O0):
<mjd_dayno>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
lea    -0x20(%rbp),%rdi
call   1030 <mjd_year@plt>
cvttsd2si -0x20(%rbp),%ecx
mov    %ecx,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x24(%rbp),%edi
call   1040 <isleapyear@plt>
mov    %rax,%rdx
mov    $0x16d,%eax
mov    $0x16e,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %eax,-0x28(%rbp)
cvtsi2sdl -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
cvtsi2sdl -0x24(%rbp),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mjd_dayno>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
call   1030 <mjd_year@plt>
movsd  0x8(%rsp),%xmm0
movapd %xmm0,0x10(%rsp)
cvttsd2si %xmm0,%edi
mov    %edi,(%rbx)
call   1040 <isleapyear@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
cvttpd2dq 0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
cvtdq2pd %xmm0,%xmm0
subsd  %xmm0,%xmm1
lea    0xe8f(%rip),%rax
mulsd  (%rax,%rcx,8),%xmm1
movsd  %xmm1,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @mjd_dayno(double %0, i32* %1, double* %2) {
%4 = alloca double
%5 = alloca i32*
%6 = alloca double*
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
store double %0, double* %4
store i32* %1, i32** %5
store double* %2, double** %6
%10 = load double, double* %4
%11 = call i32 @mjd_year(double %10, double* %7)
%12 = load double, double* %7
%13 = fptosi double %12 to i32
store i32 %13, i32* %8
%14 = load i32*, i32** %5
store i32 %13, i32* %14
%15 = load i32, i32* %8
%16 = call i64 @isleapyear(i32 %15)
%17 = icmp ne i64 %16, 0
%18 = zext i1 %17 to i64
%19 = select i1 %17, i32 366, i32 365
store i32 %19, i32* %9
%20 = load i32, i32* %9
%21 = sitofp i32 %20 to double
%22 = load double, double* %7
%23 = load i32, i32* %8
%24 = sitofp i32 %23 to double
%25 = fsub double %22, %24
%26 = fmul double %21, %25
%27 = load double*, double** %6
store double %26, double* %27
ret void
}

LLVM IR (-O2):
define void @mjd_dayno(double %0, i32* nocapture writeonly %1, double* nocapture writeonly %2) {
%4 = alloca double
%5 = bitcast double* %4 to i8*
%6 = call i32 @mjd_year(double %0, double* %4)
%7 = load double, double* %4
%8 = fptosi double %7 to i32
store i32 %8, i32* %1
%9 = call i64 @isleapyear(i32 %8)
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, double 3.650000e+02, double 3.660000e+02
%12 = load double, double* %4
%13 = sitofp i32 %8 to double
%14 = fsub double %12, %13
%15 = fmul double %11, %14
store double %15, double* %2
ret void
}