#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;
  int tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int, int, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void getdate(char *s) {
  char *wday[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
  time_t timep;
  struct tm *p;
  time(&timep);
  p = localtime(&timep);
  sprintf(s, "%d-%d-%d %d:%d:%d", (1900 + p->tm_year), (1 + p->tm_mon),
          p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec);
}


x86 assembly (clang, -O0):
<getdate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
lea    0x2c89(%rip),%rsi
mov    $0x38,%edx
call   1040 <memcpy@plt>
lea    -0x44(%rbp),%rdi
call   1050 <time@plt>
lea    -0x44(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x50(%rbp),%rax
mov    (%rax),%edx
add    $0x76c,%edx
mov    -0x50(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    -0x50(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x50(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x50(%rbp),%rax
mov    0x10(%rax),%r10d
mov    -0x50(%rbp),%rax
mov    0x14(%rax),%eax
lea    0xe65(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1060 <sprintf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getdate>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
mov    $0x76c,%edx
add    (%rax),%edx
mov    0x4(%rax),%ecx
mov    0x8(%rax),%r8d
add    $0x1,%ecx
mov    0xc(%rax),%r9d
mov    0x10(%rax),%ebx
mov    0x14(%rax),%eax
lea    0xe92(%rip),%rsi
mov    %r14,%rdi
push   %rax
push   %rbx
call   1050 <sprintf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.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 = [4 x i8] c"Thu\00"
@.str.5 = [4 x i8] c"Fri\00"
@.str.6 = [4 x i8] c"Sat\00"
@__const.getdate.wday = [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 ([4 x i8], [4 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 = [18 x i8] c"%d-%d-%d %d:%d:%d\00"
define void @getdate(i8* %0) {
%2 = alloca i8*
%3 = alloca [7 x i8*]
%4 = alloca i32
%5 = alloca %struct.tm*
store i8* %0, i8** %2
%6 = bitcast [7 x i8*]* %3 to i8*
%7 = call i32 @time(i32* %4)
%8 = call %struct.tm* @localtime(i32* %4)
store %struct.tm* %8, %struct.tm** %5
%9 = load i8*, i8** %2
%10 = load %struct.tm*, %struct.tm** %5
%11 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = add nsw i32 1900, %12
%14 = load %struct.tm*, %struct.tm** %5
%15 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 1
%16 = load i32, i32* %15
%17 = add nsw i32 1, %16
%18 = load %struct.tm*, %struct.tm** %5
%19 = getelementptr inbounds %struct.tm, %struct.tm* %18, i32 0, i32 2
%20 = load i32, i32* %19
%21 = load %struct.tm*, %struct.tm** %5
%22 = getelementptr inbounds %struct.tm, %struct.tm* %21, i32 0, i32 3
%23 = load i32, i32* %22
%24 = load %struct.tm*, %struct.tm** %5
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 4
%26 = load i32, i32* %25
%27 = load %struct.tm*, %struct.tm** %5
%28 = getelementptr inbounds %struct.tm, %struct.tm* %27, i32 0, i32 5
%29 = load i32, i32* %28
%30 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 %13, i32 %17, i32 %20, i32 %23, i32 %26, i32 %29)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str.7 = [18 x i8] c"%d-%d-%d %d:%d:%d\00"
define void @getdate(i8* nocapture writeonly %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @time(i32* %2)
%5 = call %struct.tm* @localtime(i32* %2)
%6 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 0
%7 = load i32, i32* %6
%8 = add nsw i32 %7, 1900
%9 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 1
%10 = load i32, i32* %9
%11 = add nsw i32 %10, 1
%12 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 2
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 3
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 4
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 5
%19 = load i32, i32* %18
%20 = call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 %8, i32 %11, i32 %13, i32 %15, i32 %17, i32 %19)
ret void
}