#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*/ buf;

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
scalar_t__ malloc(int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/);
char *curdate() {
  time_t now = time(0);
  struct tm tstruct;
  char buf[80], *ans;
  tstruct = *localtime(&now);
  strftime(buf, sizeof(buf), "%Y-%m-%d.%X", &tstruct);
  ans = (char *)malloc(strlen(buf));
  strcpy(ans, buf);
  return ans;
}


x86 assembly (clang, -O0):
<curdate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
lea    -0x60(%rbp),%rdi
mov    $0x50,%esi
lea    0xe70(%rip),%rdx
lea    -0x8(%rbp),%rcx
call   1080 <strftime@plt>
lea    -0x60(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x68(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<curdate>:
push   %r14
push   %rbx
sub    $0x68,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
lea    0xe77(%rip),%rdx
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%rcx
mov    %r14,%rdi
mov    $0x50,%esi
call   1080 <strftime@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [12 x i8] c"%Y-%m-%d.%X\00"
define i8* @curdate() {
%1 = alloca i32
%2 = alloca %struct.tm
%3 = alloca [80 x i8]
%4 = alloca i8*
%5 = call i32 @time(i32 0)
store i32 %5, i32* %1
%6 = call %struct.tm* @localtime(i32* %1)
%7 = bitcast %struct.tm* %2 to i8*
%8 = bitcast %struct.tm* %6 to i8*
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%10 = call i32 @strftime(i8* %9, i32 80, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %struct.tm* %2)
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %4
%15 = load i8*, i8** %4
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%17 = call i32 @strcpy(i8* %15, i8* %16)
%18 = load i8*, i8** %4
ret i8* %18
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [12 x i8] c"%Y-%m-%d.%X\00"
define i8* @curdate() {
%1 = alloca i32
%2 = alloca %struct.tm
%3 = alloca [80 x i8]
%4 = bitcast i32* %1 to i8*
%5 = tail call i32 @time(i32 0)
store i32 %5, i32* %1
%6 = bitcast %struct.tm* %2 to i8*
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%8 = call %struct.tm* @localtime(i32* %1)
%9 = getelementptr %struct.tm, %struct.tm* %8, i64 0, i32 0
%10 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 0
%11 = load i32, i32* %9
store i32 %11, i32* %10
%12 = call i32 @strftime(i8* %7, i32 80, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %struct.tm* %2)
%13 = call i32 @strlen(i8* %7)
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i8*
%16 = call i32 @strcpy(i8* %15, i8* %7)
ret i8* %15
}