#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 dummy;
};
typedef int /*<<< orphan*/ s;

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void get_date(char *date) {
  time_t now = time(NULL);
  struct tm *tm = localtime(&now);
  char s[11];
  strftime(s, sizeof(s), "%F", tm);
  s[10] = '\0';
  strncpy(date, s, strlen(s));
}


x86 assembly (clang, -O0):
<get_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
lea    -0x23(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0xb,%esi
lea    0xe77(%rip),%rdx
call   1070 <strftime@plt>
movb   $0x0,-0x19(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x23(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x23(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_date>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <localtime@plt>
lea    0xe8a(%rip),%rdx
lea    0xd(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xb,%esi
mov    %rax,%rcx
call   1070 <strftime@plt>
movb   $0x0,0x17(%rsp)
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [3 x i8] c"%F\00"
define void @get_date(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca %struct.tm*
%5 = alloca [11 x i8]
store i8* %0, i8** %2
%6 = call i32 @time(i32* null)
store i32 %6, i32* %3
%7 = call %struct.tm* @localtime(i32* %3)
store %struct.tm* %7, %struct.tm** %4
%8 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%9 = load %struct.tm*, %struct.tm** %4
%10 = call i32 @strftime(i8* %8, i32 11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.tm* %9)
%11 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 10
store i8 0, i8* %11
%12 = load i8*, i8** %2
%13 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = call i32 @strncpy(i8* %12, i8* %13, i32 %15)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [3 x i8] c"%F\00"
define void @get_date(i8* %0) {
%2 = alloca i32
%3 = alloca [11 x i8]
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @time(i32* null)
store i32 %5, i32* %2
%6 = call %struct.tm* @localtime(i32* %2)
%7 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%8 = call i32 @strftime(i8* %7, i32 11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.tm* %6)
%9 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 10
store i8 0, i8* %9
%10 = call i32 @strlen(i8* %7)
%11 = call i32 @strncpy(i8* %0, i8* %7, i32 %10)
ret void
}