#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_cal(double, int *, double *, int *);
void mjd_dpm(double mj, int *ndays) {
  static short dpm[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int m, y;
  double d;
  mjd_cal(mj, &m, &d, &y);
  *ndays = (m == 2 && isleapyear(y)) ? 29 : dpm[m - 1];
}


x86 assembly (clang, -O0):
<mjd_dpm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
lea    -0x14(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <mjd_cal@plt>
cmpl   $0x2,-0x14(%rbp)
jne    1170 <mjd_dpm+0x50>
mov    -0x18(%rbp),%edi
call   1030 <isleapyear@plt>
cmp    $0x0,%rax
je     1170 <mjd_dpm+0x50>
mov    $0x1d,%eax
mov    %eax,-0x24(%rbp)
jmp    1187 <mjd_dpm+0x67>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    0x2ec0(%rip),%rax
movswl (%rax,%rcx,2),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mjd_dpm>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
call   1040 <mjd_cal@plt>
mov    (%rsp),%eax
cmp    $0x2,%eax
jne    1158 <mjd_dpm+0x38>
mov    0x4(%rsp),%edi
call   1030 <isleapyear@plt>
mov    $0x1d,%ecx
test   %rax,%rax
jne    1166 <mjd_dpm+0x46>
mov    (%rsp),%eax
cltq
lea    0xe9f(%rip),%rcx
movswl -0x2(%rcx,%rax,2),%ecx
mov    %ecx,(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@mjd_dpm.dpm = internal global [12 x i16] [i16 31, i16 28, i16 31, i16 30, i16 31, i16 30, i16 31, i16 31, i16 30, i16 31, i16 30, i16 31]
define void @mjd_dpm(double %0, i32* %1) {
%3 = alloca double
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store double %0, double* %3
store i32* %1, i32** %4
%8 = load double, double* %3
%9 = call i32 @mjd_cal(double %8, i32* %5, double* %7, i32* %6)
%10 = load i32, i32* %5
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i32, i32* %6
%14 = call i64 @isleapyear(i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
br label %24
17: ; preds = %12, %2
%18 = load i32, i32* %5
%19 = sub nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [12 x i16], [12 x i16]* @mjd_dpm.dpm, i64 0, i64 %20
%22 = load i16, i16* %21
%23 = sext i16 %22 to i32
br label %24
24: ; preds = %17, %16
%25 = phi i32 [ 29, %16 ], [ %23, %17 ]
%26 = load i32*, i32** %4
store i32 %25, i32* %26
ret void
}

LLVM IR (-O2):
@mjd_dpm.dpm = internal unnamed_addr constant [12 x i16] [i16 31, i16 28, i16 31, i16 30, i16 31, i16 30, i16 31, i16 31, i16 30, i16 31, i16 30, i16 31]
define void @mjd_dpm(double %0, i32* nocapture writeonly %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast double* %5 to i8*
%9 = call i32 @mjd_cal(double %0, i32* %3, double* %5, i32* %4)
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i32, i32* %4
%14 = call i64 @isleapyear(i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = load i32, i32* %3
br label %18
18: ; preds = %16, %2
%19 = phi i32 [ %17, %16 ], [ %10, %2 ]
%20 = add nsw i32 %19, -1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [12 x i16], [12 x i16]* @mjd_dpm.dpm, i64 0, i64 %21
%23 = load i16, i16* %22
%24 = sext i16 %23 to i32
br label %25
25: ; preds = %12, %18
%26 = phi i32 [ %24, %18 ], [ 29, %12 ]
store i32 %26, i32* %1
ret void
}