char *timestring(t)
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
mov    $0x0,%al
call   1050 <time@plt>
lea    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1040 <ctime@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
add    $0x4,%rsi
lea    0x2ee9(%rip),%rdi
call   1030 <strcpy@plt>
movb   $0x0,0x2ee9(%rip)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jg     1199 <timestring+0x69>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1e13380,%rcx
cmp    %rcx,%rax
jge    11b4 <timestring+0x84>
mov    -0x18(%rbp),%rsi
add    $0x14,%rsi
lea    0x2eaf(%rip),%rdi
call   1030 <strcpy@plt>
movb   $0x0,0x2ea7(%rip)
lea    0x2e95(%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
xor    %eax,%eax
call   1050 <time@plt>
mov    %rsp,%rdi
xor    %eax,%eax
call   1040 <ctime@plt>
movslq %eax,%rbx
lea    0x4(%rbx),%rsi
lea    0x2ef3(%rip),%rdi
call   1030 <strcpy@plt>
movb   $0x0,0x2ef3(%rip)
mov    (%rsp),%rax
mov    0x8(%rsp),%rcx
cmp    %rcx,%rax
jg     1183 <timestring+0x53>
add    $0xfffffffffe1ecc80,%rcx
cmp    %rcx,%rax
jge    119d <timestring+0x6d>
add    $0x14,%rbx
lea    0x2ec9(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
movb   $0x0,0x2ebe(%rip)
lea    0x2eac(%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 (i64*, ...) bitcast (i32 (...)* @time to i32 (i64*, ...)*)(i64* %3)
%6 = call i32 (i64*, ...) bitcast (i32 (...)* @ctime to i32 (i64*, ...)*)(i64* %2)
%7 = sext i32 %6 to i64
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %4
%9 = load i8*, i8** %4
%10 = getelementptr inbounds i8, i8* %9, i64 4
%11 = call i8* @strcpy(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @timestring.buf, i64 0, i64 0), i8* %10)
store i8 0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @timestring.buf, i64 0, i64 12)
%12 = load i64, i64* %2
%13 = load i64, i64* %3
%14 = icmp sgt i64 %12, %13
br i1 %14, label %20, label %15
15: ; preds = %1
%16 = load i64, i64* %2
%17 = load i64, i64* %3
%18 = sub nsw i64 %17, 31536000
%19 = icmp slt i64 %16, %18
br i1 %19, label %20, label %24
20: ; preds = %15, %1
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 20
%23 = call i8* @strcpy(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @timestring.buf, i64 0, i64 7), i8* %22)
store i8 0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @timestring.buf, i64 0, i64 11)
br label %24
24: ; preds = %20, %15
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 (i64*, ...) bitcast (i32 (...)* @time to i32 (i64*, ...)*)(i64* %3)
%6 = call i32 (i64*, ...) bitcast (i32 (...)* @ctime to i32 (i64*, ...)*)(i64* %2)
%7 = sext i32 %6 to i64
%8 = inttoptr i64 %7 to i8*
%9 = getelementptr inbounds i8, i8* %8, i64 4
%10 = call i8* @strcpy(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @timestring.buf, i64 0, i64 0), i8* %9)
store i8 0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @timestring.buf, i64 0, i64 12)
%11 = load i64, i64* %2
%12 = load i64, i64* %3
%13 = icmp sgt i64 %11, %12
%14 = add nsw i64 %12, -31536000
%15 = icmp slt i64 %11, %14
%16 = select i1 %13, i1 true, i1 %15
br i1 %16, label %17, label %20
17: ; preds = %1
%18 = getelementptr inbounds i8, i8* %8, i64 20
%19 = call i8* @strcpy(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @timestring.buf, i64 0, i64 7), i8* %18)
store i8 0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @timestring.buf, i64 0, i64 11)
br label %20
20: ; preds = %1, %17
ret i8* getelementptr inbounds ([26 x i8], [26 x i8]* @timestring.buf, i64 0, i64 0)
}