#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 */
char *ctime(long *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ time(long *);
char *timestring(long t) {
  long now;
  char *str;
  static char buf[26];
  time(&now);
  str = ctime(&t);
  strcpy(buf, &str[4]);
  buf[12] = '\0';
  if ((t > now) || (t < now - 365 * 24 * 60 * 60L)) {
    strcpy(&buf[7], &str[20]);
    buf[11] = '\0';
  }
  return buf;
}


x86 assembly (clang, -O0):
<timestring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
call   1050 <time@plt>
lea    -0x8(%rbp),%rdi
call   1040 <ctime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
add    $0x4,%rsi
lea    0x2eef(%rip),%rdi
call   1030 <strcpy@plt>
movb   $0x0,0x2eef(%rip)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jg     1193 <timestring+0x63>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1e13380,%rcx
cmp    %rcx,%rax
jge    11ae <timestring+0x7e>
mov    -0x18(%rbp),%rsi
add    $0x14,%rsi
lea    0x2eb5(%rip),%rdi
call   1030 <strcpy@plt>
movb   $0x0,0x2ead(%rip)
lea    0x2e9b(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timestring>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,(%rsp)
lea    0x8(%rsp),%rdi
call   1050 <time@plt>
mov    %rsp,%rdi
call   1040 <ctime@plt>
mov    %rax,%rbx
lea    0x4(%rax),%rsi
lea    0x2ef7(%rip),%rdi
call   1030 <strcpy@plt>
movb   $0x0,0x2ef7(%rip)
mov    (%rsp),%rax
mov    0x8(%rsp),%rcx
cmp    %rcx,%rax
jg     117f <timestring+0x4f>
add    $0xfffffffffe1ecc80,%rcx
cmp    %rcx,%rax
jge    1199 <timestring+0x69>
add    $0x14,%rbx
lea    0x2ecd(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
movb   $0x0,0x2ec2(%rip)
lea    0x2eb0(%rip),%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@timestring.buf = internal global [26 x i8] zeroinitializer
define i8* @timestring(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i8*
store i64 %0, i64* %2
%5 = call i32 @time(i64* %3)
%6 = call i8* @ctime(i64* %2)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = getelementptr inbounds i8, i8* %7, i64 4
%9 = call i32 @strcpy(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @timestring.buf, i64 0, i64 0), i8* %8)
store i8 0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @timestring.buf, i64 0, i64 12)
%10 = load i64, i64* %2
%11 = load i64, i64* %3
%12 = icmp sgt i64 %10, %11
br i1 %12, label %18, label %13
13: ; preds = %1
%14 = load i64, i64* %2
%15 = load i64, i64* %3
%16 = sub nsw i64 %15, 31536000
%17 = icmp slt i64 %14, %16
br i1 %17, label %18, label %22
18: ; preds = %13, %1
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 20
%21 = call i32 @strcpy(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @timestring.buf, i64 0, i64 7), i8* %20)
store i8 0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @timestring.buf, i64 0, i64 11)
br label %22
22: ; preds = %18, %13
ret i8* getelementptr inbounds ([26 x i8], [26 x i8]* @timestring.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@timestring.buf = internal global [26 x i8] zeroinitializer
define i8* @timestring(i64 %0) {
%2 = alloca i64
%3 = alloca i64
store i64 %0, i64* %2
%4 = bitcast i64* %3 to i8*
%5 = call i32 @time(i64* %3)
%6 = call i8* @ctime(i64* %2)
%7 = getelementptr inbounds i8, i8* %6, i64 4
%8 = call i32 @strcpy(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @timestring.buf, i64 0, i64 0), i8* %7)
store i8 0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @timestring.buf, i64 0, i64 12)
%9 = load i64, i64* %2
%10 = load i64, i64* %3
%11 = icmp sgt i64 %9, %10
%12 = add nsw i64 %10, -31536000
%13 = icmp slt i64 %9, %12
%14 = select i1 %11, i1 true, i1 %13
br i1 %14, label %15, label %18
15: ; preds = %1
%16 = getelementptr inbounds i8, i8* %6, i64 20
%17 = call i32 @strcpy(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @timestring.buf, i64 0, i64 7), i8* %16)
store i8 0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @timestring.buf, i64 0, i64 11)
br label %18
18: ; preds = %1, %15
ret i8* getelementptr inbounds ([26 x i8], [26 x i8]* @timestring.buf, i64 0, i64 0)
}