#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 */
typedef int time_t;
struct tm {
  int dummy;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ localtime_r(int *, struct tm *);
size_t strftime(char *, int, char *, struct tm *);
int time(int /*<<< orphan*/ *);
char const *_long_date(time_t date) {
  static char buf[15];
  struct tm tm;
  static time_t sixmonths = -1;
  size_t len;
  if (sixmonths == -1)
    sixmonths = time(NULL) - 15552000;
  localtime_r(&date, &tm);
  if (date < sixmonths)
    len = strftime(buf, sizeof(buf), "%b %e  %Y", &tm);
  else
    len = strftime(buf, sizeof(buf), "%b %e %H:%M", &tm);
  buf[len] = '\0';
  return buf;
}


x86 assembly (clang, -O0):
<_long_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0xffffffff,0x2ef6(%rip)
jne    115c <_long_date+0x2c>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
sub    $0xed4e00,%eax
mov    %eax,0x2edc(%rip)
lea    -0x4(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1030 <localtime_r@plt>
mov    -0x4(%rbp),%eax
cmp    0x2ec6(%rip),%eax
jge    119d <_long_date+0x6d>
lea    0x2ebe(%rip),%rdi
mov    $0xf,%esi
lea    0xe75(%rip),%rdx
lea    -0x8(%rbp),%rcx
call   1050 <strftime@plt>
mov    %rax,-0x10(%rbp)
jmp    11bd <_long_date+0x8d>
lea    0x2e99(%rip),%rdi
mov    $0xf,%esi
lea    0xe5a(%rip),%rdx
lea    -0x8(%rbp),%rcx
call   1050 <strftime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
lea    0x2e75(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e6a(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_long_date>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,0xc(%rsp)
cmpl   $0xffffffff,0x2ef6(%rip)
jne    1156 <_long_date+0x26>
xor    %edi,%edi
call   1040 <time@plt>
add    $0xff12b200,%eax
mov    %eax,0x2ee2(%rip)
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%r14
mov    %r14,%rsi
call   1030 <localtime_r@plt>
mov    0xc(%rsp),%eax
cmp    0x2ec6(%rip),%eax
lea    0xe87(%rip),%rax
lea    0xe8a(%rip),%rdx
cmovl  %rax,%rdx
lea    0x2eb2(%rip),%rbx
mov    %rbx,%rdi
mov    $0xf,%esi
mov    %r14,%rcx
call   1050 <strftime@plt>
movb   $0x0,(%rax,%rbx,1)
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@_long_date.buf = internal global [15 x i8] zeroinitializer
@_long_date.sixmonths = internal global i32 -1
@.str = [10 x i8] c"%b %e %Y\00"
@.str.1 = [12 x i8] c"%b %e %H:%M\00"
define i8* @_long_date(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.tm
%4 = alloca i64
store i32 %0, i32* %2
%5 = load i32, i32* @_long_date.sixmonths
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = call i32 @time(i32* null)
%9 = sub nsw i32 %8, 15552000
store i32 %9, i32* @_long_date.sixmonths
br label %10
10: ; preds = %7, %1
%11 = call i32 @localtime_r(i32* %2, %struct.tm* %3)
%12 = load i32, i32* %2
%13 = load i32, i32* @_long_date.sixmonths
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = call i64 @strftime(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @_long_date.buf, i64 0, i64 0), i32 15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %struct.tm* %3)
store i64 %16, i64* %4
br label %19
17: ; preds = %10
%18 = call i64 @strftime(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @_long_date.buf, i64 0, i64 0), i32 15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %3)
store i64 %18, i64* %4
br label %19
19: ; preds = %17, %15
%20 = load i64, i64* %4
%21 = getelementptr inbounds [15 x i8], [15 x i8]* @_long_date.buf, i64 0, i64 %20
store i8 0, i8* %21
ret i8* getelementptr inbounds ([15 x i8], [15 x i8]* @_long_date.buf, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@_long_date.buf = internal global [15 x i8] zeroinitializer
@_long_date.sixmonths = internal unnamed_addr global i32 -1
@.str = [10 x i8] c"%b %e %Y\00"
@.str.1 = [12 x i8] c"%b %e %H:%M\00"
define i8* @_long_date(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.tm
store i32 %0, i32* %2
%4 = bitcast %struct.tm* %3 to i8*
%5 = load i32, i32* @_long_date.sixmonths
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = tail call i32 @time(i32* null)
%9 = add nsw i32 %8, -15552000
store i32 %9, i32* @_long_date.sixmonths
br label %10
10: ; preds = %7, %1
%11 = call i32 @localtime_r(i32* %2, %struct.tm* %3)
%12 = load i32, i32* %2
%13 = load i32, i32* @_long_date.sixmonths
%14 = icmp slt i32 %12, %13
%15 = select i1 %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0)
%16 = call i64 @strftime(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @_long_date.buf, i64 0, i64 0), i32 15, i8* %15, %struct.tm* %3)
%17 = getelementptr inbounds [15 x i8], [15 x i8]* @_long_date.buf, i64 0, i64 %16
store i8 0, i8* %17
ret i8* getelementptr inbounds ([15 x i8], [15 x i8]* @_long_date.buf, i64 0, i64 0)
}