#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;

/* Variables and functions */
char *ctime(int *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ time(int *);
const char *time_string(time_t timeVal) {
  time_t now;
  char *str;
  static char buf[26];
  time(&now);
  str = ctime(&timeVal);
  strcpy(buf, &str[4]);
  buf[12] = '\0';
  if ((timeVal > now) || (timeVal < now - 365 * 24 * 60 * 60L)) {
    strcpy(&buf[7], &str[20]);
    buf[11] = '\0';
  }
  return buf;
}


x86 assembly (clang, -O0):
<time_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1050 <time@plt>
lea    -0x4(%rbp),%rdi
call   1040 <ctime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
add    $0x4,%rsi
lea    0x2ef0(%rip),%rdi
call   1030 <strcpy@plt>
movb   $0x0,0x2ef0(%rip)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1190 <time_string+0x60>
movslq -0x4(%rbp),%rax
movslq -0x8(%rbp),%rcx
sub    $0x1e13380,%rcx
cmp    %rcx,%rax
jge    11ab <time_string+0x7b>
mov    -0x10(%rbp),%rsi
add    $0x14,%rsi
lea    0x2eb8(%rip),%rdi
call   1030 <strcpy@plt>
movb   $0x0,0x2eb0(%rip)
lea    0x2e9e(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_string>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,0x8(%rsp)
lea    0xc(%rsp),%rdi
call   1050 <time@plt>
lea    0x8(%rsp),%rdi
call   1040 <ctime@plt>
mov    %rax,%rbx
lea    0x4(%rax),%rsi
lea    0x2ef5(%rip),%rdi
call   1030 <strcpy@plt>
movb   $0x0,0x2ef5(%rip)
movslq 0x8(%rsp),%rax
movslq 0xc(%rsp),%rcx
cmp    %ecx,%eax
jg     1181 <time_string+0x51>
add    $0xfffffffffe1ecc80,%rcx
cmp    %rax,%rcx
jle    119b <time_string+0x6b>
add    $0x14,%rbx
lea    0x2ecb(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
movb   $0x0,0x2ec0(%rip)
lea    0x2eae(%rip),%rax
add    $0x10,%rsp
pop    %rbx
ret

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

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