#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 /*<<< orphan*/ time_t;
struct tm {
  int tm_year;
  size_t tm_wday;
  size_t tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
  size_t tm_isdst;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *, int, int, int,
                            int, char *, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int time_stamp(char *timestamp) {
  time_t current;
  struct tm *t = localtime(&current);
  int year;
  extern char *tzname[2];
  char *weekdays[] = {"Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat"};
  char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
                    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
  current = time(NULL);
  localtime(&current);
  year = t->tm_year + 1900;
  snprintf(timestamp, 64 + 1, "%s %s %2d %02d:%02d:%02d %s %d",
           weekdays[t->tm_wday], months[t->tm_mon], t->tm_mday, t->tm_hour,
           t->tm_min, t->tm_sec, tzname[t->tm_isdst], year);
  timestamp[64] = (char)'\0';
  return 0;
}


x86 assembly (clang, -O0):
<time_stamp>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0xf0,%rsp
mov    %rdi,-0x18(%rbp)
lea    -0x1c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x28(%rbp)
lea    -0x70(%rbp),%rdi
lea    0x2c06(%rip),%rsi
mov    $0x38,%edx
call   1050 <memcpy@plt>
lea    -0xd0(%rbp),%rdi
lea    0x2c2e(%rip),%rsi
mov    $0x60,%edx
call   1050 <memcpy@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x1c(%rbp),%rdi
call   1030 <localtime@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
add    $0x76c,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x70(%rbp,%rax,8),%rcx
mov    -0x28(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0xd0(%rbp,%rax,8),%r8
ff
mov    -0x28(%rbp),%rax
mov    0x18(%rax),%r9d
mov    -0x28(%rbp),%rax
mov    0x1c(%rax),%r14d
mov    -0x28(%rbp),%rax
mov    0x20(%rax),%ebx
mov    -0x28(%rbp),%rax
mov    0x24(%rax),%r11d
mov    -0x28(%rbp),%rax
mov    0x28(%rax),%rdx
mov    0x2de2(%rip),%rax
mov    (%rax,%rdx,8),%r10
mov    -0x2c(%rbp),%eax
mov    $0x41,%esi
lea    0xe3c(%rip),%rdx
mov    %r14d,(%rsp)
mov    %ebx,0x8(%rsp)
mov    %r11d,0x10(%rsp)
mov    %r10,0x18(%rsp)
mov    %eax,0x20(%rsp)
call   1040 <snprintf@plt>
mov    -0x18(%rbp),%rax
movb   $0x0,0x40(%rax)
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_stamp>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0x4(%rsp),%r15
mov    %r15,%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0x4(%rsp)
mov    %r15,%rdi
call   1030 <localtime@plt>
mov    $0x76c,%eax
add    (%rbx),%eax
lea    0xf00(%rip),%rdx
mov    0x8(%rbx),%rcx
mov    0x10(%rbx),%rsi
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
lea    0xf06(%rip),%rdx
movslq (%rdx,%rsi,4),%r8
add    %rdx,%r8
mov    0x18(%rbx),%r9d
mov    0x1c(%rbx),%r10d
mov    0x20(%rbx),%r11d
mov    0x24(%rbx),%r15d
mov    0x28(%rbx),%rbx
mov    0x2e44(%rip),%r12
sub    $0x8,%rsp
lea    0xe9e(%rip),%rdx
mov    %r14,%rdi
mov    $0x41,%esi
push   %rax
push   (%r12,%rbx,8)
push   %r15
push   %r11
push   %r10
call   1040 <snprintf@plt>
add    $0x30,%rsp
movb   $0x0,0x40(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32, i64, i64, i32, i32, i32, i32, i64 }
@.str = [4 x i8] c"Sun\00"
@.str.1 = [4 x i8] c"Mon\00"
@.str.2 = [4 x i8] c"Tue\00"
@.str.3 = [4 x i8] c"Wed\00"
@.str.4 = [5 x i8] c"Thur\00"
@.str.5 = [4 x i8] c"Fri\00"
@.str.6 = [4 x i8] c"Sat\00"
@__const.time_stamp.weekdays = [7 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0)]
@.str.7 = [4 x i8] c"Jan\00"
@.str.8 = [4 x i8] c"Feb\00"
@.str.9 = [4 x i8] c"Mar\00"
@.str.10 = [4 x i8] c"Apr\00"
@.str.11 = [4 x i8] c"May\00"
@.str.12 = [4 x i8] c"Jun\00"
@.str.13 = [4 x i8] c"Jul\00"
@.str.14 = [4 x i8] c"Aug\00"
@.str.15 = [4 x i8] c"Sep\00"
@.str.16 = [4 x i8] c"Oct\00"
@.str.17 = [4 x i8] c"Nov\00"
@.str.18 = [4 x i8] c"Dec\00"
@__const.time_stamp.months = [12 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.18, i32 0, i32 0)]
@.str.19 = [31 x i8] c"%s %s %2d %02d:%02d:%02d %s %d\00"
@tzname = external global [2 x i8*]
define i32 @time_stamp(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca %struct.tm*
%5 = alloca i32
%6 = alloca [7 x i8*]
%7 = alloca [12 x i8*]
store i8* %0, i8** %2
%8 = call %struct.tm* @localtime(i32* %3)
store %struct.tm* %8, %struct.tm** %4
%9 = bitcast [7 x i8*]* %6 to i8*
%10 = bitcast [12 x i8*]* %7 to i8*
%11 = call i32 @time(i32* null)
store i32 %11, i32* %3
%12 = call %struct.tm* @localtime(i32* %3)
%13 = load %struct.tm*, %struct.tm** %4
%14 = getelementptr inbounds %struct.tm, %struct.tm* %13, i32 0, i32 0
%15 = load i32, i32* %14
%16 = add nsw i32 %15, 1900
store i32 %16, i32* %5
%17 = load i8*, i8** %2
%18 = load %struct.tm*, %struct.tm** %4
%19 = getelementptr inbounds %struct.tm, %struct.tm* %18, i32 0, i32 1
%20 = load i64, i64* %19
%21 = getelementptr inbounds [7 x i8*], [7 x i8*]* %6, i64 0, i64 %20
%22 = load i8*, i8** %21
%23 = load %struct.tm*, %struct.tm** %4
%24 = getelementptr inbounds %struct.tm, %struct.tm* %23, i32 0, i32 2
%25 = load i64, i64* %24
%26 = getelementptr inbounds [12 x i8*], [12 x i8*]* %7, i64 0, i64 %25
%27 = load i8*, i8** %26
%28 = load %struct.tm*, %struct.tm** %4
%29 = getelementptr inbounds %struct.tm, %struct.tm* %28, i32 0, i32 3
%30 = load i32, i32* %29
%31 = load %struct.tm*, %struct.tm** %4
%32 = getelementptr inbounds %struct.tm, %struct.tm* %31, i32 0, i32 4
%33 = load i32, i32* %32
%34 = load %struct.tm*, %struct.tm** %4
%35 = getelementptr inbounds %struct.tm, %struct.tm* %34, i32 0, i32 5
%36 = load i32, i32* %35
%37 = load %struct.tm*, %struct.tm** %4
%38 = getelementptr inbounds %struct.tm, %struct.tm* %37, i32 0, i32 6
%39 = load i32, i32* %38
%40 = load %struct.tm*, %struct.tm** %4
%41 = getelementptr inbounds %struct.tm, %struct.tm* %40, i32 0, i32 7
%42 = load i64, i64* %41
%43 = getelementptr inbounds [2 x i8*], [2 x i8*]* @tzname, i64 0, i64 %42
%44 = load i8*, i8** %43
%45 = load i32, i32* %5
%46 = call i32 @snprintf(i8* %17, i32 65, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.19, i64 0, i64 0), i8* %22, i8* %27, i32 %30, i32 %33, i32 %36, i32 %39, i8* %44, i32 %45)
%47 = load i8*, i8** %2
%48 = getelementptr inbounds i8, i8* %47, i64 64
store i8 0, i8* %48
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32, i64, i64, i32, i32, i32, i32, i64 }
@.str = [4 x i8] c"Sun\00"
@.str.1 = [4 x i8] c"Mon\00"
@.str.2 = [4 x i8] c"Tue\00"
@.str.3 = [4 x i8] c"Wed\00"
@.str.4 = [5 x i8] c"Thur\00"
@.str.5 = [4 x i8] c"Fri\00"
@.str.6 = [4 x i8] c"Sat\00"
@reltable.time_stamp = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([7 x i32]* @reltable.time_stamp to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.time_stamp to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.time_stamp to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.time_stamp to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.4 to i64), i64 ptrtoint ([7 x i32]* @reltable.time_stamp to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.time_stamp to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.6 to i64), i64 ptrtoint ([7 x i32]* @reltable.time_stamp to i64)) to i32)]
@.str.7 = [4 x i8] c"Jan\00"
@.str.8 = [4 x i8] c"Feb\00"
@.str.9 = [4 x i8] c"Mar\00"
@.str.10 = [4 x i8] c"Apr\00"
@.str.11 = [4 x i8] c"May\00"
@.str.12 = [4 x i8] c"Jun\00"
@.str.13 = [4 x i8] c"Jul\00"
@.str.14 = [4 x i8] c"Aug\00"
@.str.15 = [4 x i8] c"Sep\00"
@.str.16 = [4 x i8] c"Oct\00"
@.str.17 = [4 x i8] c"Nov\00"
@.str.18 = [4 x i8] c"Dec\00"
@reltable.time_stamp.20 = [12 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.7 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_stamp.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.8 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_stamp.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.9 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_stamp.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.10 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_stamp.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.11 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_stamp.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.12 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_stamp.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.13 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_stamp.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.14 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_stamp.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.15 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_stamp.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.16 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_stamp.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.17 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_stamp.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.18 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_stamp.20 to i64)) to i32)]
@.str.19 = [31 x i8] c"%s %s %2d %02d:%02d:%02d %s %d\00"
@tzname = external global [2 x i8*]
define i32 @time_stamp(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call %struct.tm* @localtime(i32* %2)
%5 = call i32 @time(i32* null)
store i32 %5, i32* %2
%6 = call %struct.tm* @localtime(i32* %2)
%7 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%8 = load i32, i32* %7
%9 = add nsw i32 %8, 1900
%10 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%11 = load i64, i64* %10
%12 = shl i64 %11, 2
%13 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.time_stamp to i8*), i64 %12)
%14 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%15 = load i64, i64* %14
%16 = shl i64 %15, 2
%17 = call i8* @llvm.load.relative.i64(i8* bitcast ([12 x i32]* @reltable.time_stamp.20 to i8*), i64 %16)
%18 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 3
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 4
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 5
%23 = load i32, i32* %22
%24 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 6
%25 = load i32, i32* %24
%26 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 7
%27 = load i64, i64* %26
%28 = getelementptr inbounds [2 x i8*], [2 x i8*]* @tzname, i64 0, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 @snprintf(i8* %0, i32 65, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.19, i64 0, i64 0), i8* %13, i8* %17, i32 %19, i32 %21, i32 %23, i32 %25, i8* %29, i32 %9)
%31 = getelementptr inbounds i8, i8* %0, i64 64
store i8 0, i8* %31
ret i32 0
}