#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 BUFSIZ;
int /*<<< orphan*/ assert(int);
scalar_t__ sprintf(char *, char *, int);
char *strdup(char *);
char *report_delta(double diff) {
  char buffer[BUFSIZ];
  size_t idx;
  int year;
  int day;
  int hour;
  int min;
  int sec;
  assert(diff >= 0.0);
  year = (int)(diff / (60.0 * 60.0 * 24.0 * 365.242199));
  diff -= ((double)year) * (60.0 * 60.0 * 24.0 * 365.242199);
  day = (int)(diff / (60.0 * 60.0 * 24.0));
  diff -= ((double)day) * (60.0 * 60.0 * 24.0);
  hour = (int)(diff / (60.0 * 60.0));
  diff -= ((double)hour) * (60.0 * 60.0);
  min = (int)(diff / (60.0));
  diff -= ((double)min) * (60.0);
  sec = (int)(diff);
  idx = 0;
  if (year)
    idx += sprintf(&buffer[idx], "%dy", year);
  if (day)
    idx += sprintf(&buffer[idx], "%dd", day);
  if (hour)
    idx += sprintf(&buffer[idx], "%dh", hour);
  if (min)
    idx += sprintf(&buffer[idx], "%dm", min);
  if (sec)
    idx += sprintf(&buffer[idx], "%ds", sec);
  assert(idx < BUFSIZ);
  return strdup(buffer);
}


x86 assembly (clang, -O0):
<report_delta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    0x2e9c(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movsd  -0x8(%rbp),%xmm0
movsd  0xe89(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe55(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe33(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x28(%rbp)
cvtsi2sdl -0x28(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xdff(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xddd(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x2c(%rbp)
cvtsi2sdl -0x2c(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xda9(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xd87(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x30(%rbp)
cvtsi2sdl -0x30(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xd53(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
cvttsd2si -0x8(%rbp),%eax
mov    %eax,-0x34(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     12f3 <report_delta+0x1c3>
mov    -0x40(%rbp),%rdi
add    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xd3a(%rip),%rsi
call   1040 <sprintf@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     131c <report_delta+0x1ec>
mov    -0x40(%rbp),%rdi
add    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%edx
lea    0xd15(%rip),%rsi
call   1040 <sprintf@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     1345 <report_delta+0x215>
mov    -0x40(%rbp),%rdi
add    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%edx
lea    0xcf0(%rip),%rsi
call   1040 <sprintf@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     136e <report_delta+0x23e>
mov    -0x40(%rbp),%rdi
add    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%edx
lea    0xccb(%rip),%rsi
call   1040 <sprintf@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     1397 <report_delta+0x267>
mov    -0x40(%rbp),%rdi
add    -0x20(%rbp),%rdi
mov    -0x34(%rbp),%edx
lea    0xca6(%rip),%rsi
call   1040 <sprintf@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x2c3e(%rip),%rcx
movslq (%rcx),%rcx
cmp    %rcx,%rax
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x40(%rbp),%rdi
call   1050 <strdup@plt>
mov    -0x10(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<report_delta>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movsd  %xmm0,-0x30(%rbp)
mov    0x2e93(%rip),%r13
mov    0x0(%r13),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
xorpd  %xmm1,%xmm1
xor    %edi,%edi
ucomisd %xmm1,%xmm0
setae  %dil
call   1030 <assert@plt>
movsd  0xe83(%rip),%xmm0
movsd  -0x30(%rbp),%xmm2
movapd %xmm2,%xmm1
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edx
cvttpd2dq %xmm1,%xmm1
cvtdq2pd %xmm1,%xmm1
mulsd  %xmm0,%xmm1
subsd  %xmm1,%xmm2
movsd  0xe62(%rip),%xmm0
movapd %xmm2,%xmm1
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%r15d
cvttpd2dq %xmm1,%xmm1
cvtdq2pd %xmm1,%xmm1
mulsd  %xmm0,%xmm1
subsd  %xmm1,%xmm2
movsd  0xe45(%rip),%xmm0
movapd %xmm2,%xmm3
divsd  %xmm0,%xmm3
cvttpd2dq %xmm3,%xmm1
cvtdq2pd %xmm1,%xmm1
mulsd  %xmm0,%xmm1
subsd  %xmm1,%xmm2
movsd  0xe2d(%rip),%xmm4
movsd  %xmm2,-0x30(%rbp)
divsd  %xmm4,%xmm2
movapd %xmm2,-0x60(%rbp)
cvttpd2dq %xmm2,%xmm0
cvtdq2pd %xmm0,%xmm1
test   %edx,%edx
je     1234 <report_delta+0x104>
lea    0xe14(%rip),%rsi
mov    %r14,%rdi
movaps %xmm1,-0x40(%rbp)
movapd %xmm3,-0x50(%rbp)
call   1040 <sprintf@plt>
movsd  0xdf3(%rip),%xmm4
movapd -0x50(%rbp),%xmm3
movapd -0x40(%rbp),%xmm1
mov    %rax,%rbx
jmp    1236 <report_delta+0x106>
xor    %ebx,%ebx
mulsd  %xmm4,%xmm1
cvttsd2si %xmm3,%r12d
test   %r15d,%r15d
je     1264 <report_delta+0x134>
lea    (%r14,%rbx,1),%rdi
lea    0xdd5(%rip),%rsi
mov    %r15d,%edx
movapd %xmm1,-0x40(%rbp)
call   1040 <sprintf@plt>
movapd -0x40(%rbp),%xmm1
add    %rax,%rbx
movsd  -0x30(%rbp),%xmm0
subsd  %xmm1,%xmm0
cvttsd2si -0x60(%rbp),%r15d
test   %r12d,%r12d
je     1298 <report_delta+0x168>
lea    (%r14,%rbx,1),%rdi
lea    0xda5(%rip),%rsi
mov    %r12d,%edx
movsd  %xmm0,-0x30(%rbp)
call   1040 <sprintf@plt>
movsd  -0x30(%rbp),%xmm0
add    %rax,%rbx
cvttsd2si %xmm0,%r12d
test   %r15d,%r15d
je     12b8 <report_delta+0x188>
lea    (%r14,%rbx,1),%rdi
lea    0xd7f(%rip),%rsi
mov    %r15d,%edx
call   1040 <sprintf@plt>
add    %rax,%rbx
test   %r12d,%r12d
je     12d3 <report_delta+0x1a3>
lea    (%r14,%rbx,1),%rdi
lea    0xd68(%rip),%rsi
mov    %r12d,%edx
call   1040 <sprintf@plt>
add    %rax,%rbx
movslq 0x0(%r13),%rax
xor    %edi,%edi
cmp    %rax,%rbx
setb   %dil
call   1030 <assert@plt>
mov    %r14,%rdi
call   1050 <strdup@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [4 x i8] c"%dy\00"
@.str.1 = [4 x i8] c"%dd\00"
@.str.2 = [4 x i8] c"%dh\00"
@.str.3 = [4 x i8] c"%dm\00"
@.str.4 = [4 x i8] c"%ds\00"
define i8* @report_delta(double %0) {
%2 = alloca double
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store double %0, double* %2
%11 = load i32, i32* @BUFSIZ
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %3
%14 = alloca i8, i64 %12
store i64 %12, i64* %4
%15 = load double, double* %2
%16 = fcmp oge double %15, 0.000000e+00
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load double, double* %2
%20 = fdiv double %19, 0x417E1853DFE5C91E
%21 = fptosi double %20 to i32
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = sitofp i32 %22 to double
%24 = load double, double* %2
%25 = fneg double %23
%26 = call double @llvm.fmuladd.f64(double %25, double 0x417E1853DFE5C91E, double %24)
store double %26, double* %2
%27 = load double, double* %2
%28 = fdiv double %27, 8.640000e+04
%29 = fptosi double %28 to i32
store i32 %29, i32* %7
%30 = load i32, i32* %7
%31 = sitofp i32 %30 to double
%32 = load double, double* %2
%33 = fneg double %31
%34 = call double @llvm.fmuladd.f64(double %33, double 8.640000e+04, double %32)
store double %34, double* %2
%35 = load double, double* %2
%36 = fdiv double %35, 3.600000e+03
%37 = fptosi double %36 to i32
store i32 %37, i32* %8
%38 = load i32, i32* %8
%39 = sitofp i32 %38 to double
%40 = load double, double* %2
%41 = fneg double %39
%42 = call double @llvm.fmuladd.f64(double %41, double 3.600000e+03, double %40)
store double %42, double* %2
%43 = load double, double* %2
%44 = fdiv double %43, 6.000000e+01
%45 = fptosi double %44 to i32
store i32 %45, i32* %9
%46 = load i32, i32* %9
%47 = sitofp i32 %46 to double
%48 = load double, double* %2
%49 = fneg double %47
%50 = call double @llvm.fmuladd.f64(double %49, double 6.000000e+01, double %48)
store double %50, double* %2
%51 = load double, double* %2
%52 = fptosi double %51 to i32
store i32 %52, i32* %10
store i64 0, i64* %5
%53 = load i32, i32* %6
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %62
55: ; preds = %1
%56 = load i64, i64* %5
%57 = getelementptr inbounds i8, i8* %14, i64 %56
%58 = load i32, i32* %6
%59 = call i64 @sprintf(i8* %57, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %58)
%60 = load i64, i64* %5
%61 = add i64 %60, %59
store i64 %61, i64* %5
br label %62
62: ; preds = %55, %1
%63 = load i32, i32* %7
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %72
65: ; preds = %62
%66 = load i64, i64* %5
%67 = getelementptr inbounds i8, i8* %14, i64 %66
%68 = load i32, i32* %7
%69 = call i64 @sprintf(i8* %67, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %68)
%70 = load i64, i64* %5
%71 = add i64 %70, %69
store i64 %71, i64* %5
br label %72
72: ; preds = %65, %62
%73 = load i32, i32* %8
%74 = icmp ne i32 %73, 0
br i1 %74, label %75, label %82
75: ; preds = %72
%76 = load i64, i64* %5
%77 = getelementptr inbounds i8, i8* %14, i64 %76
%78 = load i32, i32* %8
%79 = call i64 @sprintf(i8* %77, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %78)
%80 = load i64, i64* %5
%81 = add i64 %80, %79
store i64 %81, i64* %5
br label %82
82: ; preds = %75, %72
%83 = load i32, i32* %9
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %92
85: ; preds = %82
%86 = load i64, i64* %5
%87 = getelementptr inbounds i8, i8* %14, i64 %86
%88 = load i32, i32* %9
%89 = call i64 @sprintf(i8* %87, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %88)
%90 = load i64, i64* %5
%91 = add i64 %90, %89
store i64 %91, i64* %5
br label %92
92: ; preds = %85, %82
%93 = load i32, i32* %10
%94 = icmp ne i32 %93, 0
br i1 %94, label %95, label %102
95: ; preds = %92
%96 = load i64, i64* %5
%97 = getelementptr inbounds i8, i8* %14, i64 %96
%98 = load i32, i32* %10
%99 = call i64 @sprintf(i8* %97, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %98)
%100 = load i64, i64* %5
%101 = add i64 %100, %99
store i64 %101, i64* %5
br label %102
102: ; preds = %95, %92
%103 = load i64, i64* %5
%104 = load i32, i32* @BUFSIZ
%105 = sext i32 %104 to i64
%106 = icmp ult i64 %103, %105
%107 = zext i1 %106 to i32
%108 = call i32 @assert(i32 %107)
%109 = call i8* @strdup(i8* %14)
%110 = load i8*, i8** %3
ret i8* %109
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [4 x i8] c"%dy\00"
@.str.1 = [4 x i8] c"%dd\00"
@.str.2 = [4 x i8] c"%dh\00"
@.str.3 = [4 x i8] c"%dm\00"
@.str.4 = [4 x i8] c"%ds\00"
define noalias i8* @report_delta(double %0) {
%2 = load i32, i32* @BUFSIZ
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = fcmp oge double %0, 0.000000e+00
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = fdiv double %0, 0x417E1853DFE5C91E
%9 = fptosi double %8 to i32
%10 = sitofp i32 %9 to double
%11 = fneg double %10
%12 = tail call double @llvm.fmuladd.f64(double %11, double 0x417E1853DFE5C91E, double %0)
%13 = fdiv double %12, 8.640000e+04
%14 = fptosi double %13 to i32
%15 = sitofp i32 %14 to double
%16 = fneg double %15
%17 = tail call double @llvm.fmuladd.f64(double %16, double 8.640000e+04, double %12)
%18 = fdiv double %17, 3.600000e+03
%19 = fptosi double %18 to i32
%20 = sitofp i32 %19 to double
%21 = fneg double %20
%22 = tail call double @llvm.fmuladd.f64(double %21, double 3.600000e+03, double %17)
%23 = fdiv double %22, 6.000000e+01
%24 = fptosi double %23 to i32
%25 = sitofp i32 %24 to double
%26 = fneg double %25
%27 = tail call double @llvm.fmuladd.f64(double %26, double 6.000000e+01, double %22)
%28 = fptosi double %27 to i32
%29 = icmp eq i32 %9, 0
br i1 %29, label %32, label %30
30: ; preds = %1
%31 = call i64 @sprintf(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %32
32: ; preds = %30, %1
%33 = phi i64 [ %31, %30 ], [ 0, %1 ]
%34 = icmp eq i32 %14, 0
br i1 %34, label %39, label %35
35: ; preds = %32
%36 = getelementptr inbounds i8, i8* %4, i64 %33
%37 = call i64 @sprintf(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%38 = add i64 %37, %33
br label %39
39: ; preds = %35, %32
%40 = phi i64 [ %38, %35 ], [ %33, %32 ]
%41 = icmp eq i32 %19, 0
br i1 %41, label %46, label %42
42: ; preds = %39
%43 = getelementptr inbounds i8, i8* %4, i64 %40
%44 = call i64 @sprintf(i8* %43, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%45 = add i64 %44, %40
br label %46
46: ; preds = %42, %39
%47 = phi i64 [ %45, %42 ], [ %40, %39 ]
%48 = icmp eq i32 %24, 0
br i1 %48, label %53, label %49
49: ; preds = %46
%50 = getelementptr inbounds i8, i8* %4, i64 %47
%51 = call i64 @sprintf(i8* %50, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%52 = add i64 %51, %47
br label %53
53: ; preds = %49, %46
%54 = phi i64 [ %52, %49 ], [ %47, %46 ]
%55 = icmp eq i32 %28, 0
br i1 %55, label %60, label %56
56: ; preds = %53
%57 = getelementptr inbounds i8, i8* %4, i64 %54
%58 = call i64 @sprintf(i8* %57, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %28)
%59 = add i64 %58, %54
br label %60
60: ; preds = %56, %53
%61 = phi i64 [ %59, %56 ], [ %54, %53 ]
%62 = load i32, i32* @BUFSIZ
%63 = sext i32 %62 to i64
%64 = icmp ult i64 %61, %63
%65 = zext i1 %64 to i32
%66 = call i32 @assert(i32 %65)
%67 = call i8* @strdup(i8* %4)
ret i8* %67
}