#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 /*<<< orphan*/ tm_sec;
};

/* Variables and functions */
char *getenv(char *);
struct tm *localtime(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int, int,
                           int /*<<< orphan*/);
int /*<<< orphan*/ strcat(char *, char const *);
int strlen(char const *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *Get_File_Spec() {
  struct tm *local;
  time_t t;
  const char *user;
  char time_stmp[57];
  char *file_spec = 0;
  t = time(NULL);
  local = localtime(&t);
  sprintf(time_stmp, "%02d-%02d-%02d.%02d%02d%02d.", local->tm_year,
          (local->tm_mon + 1), local->tm_mday, local->tm_hour, local->tm_min,
          local->tm_sec);
  user = getenv("USER");
  file_spec =
      (char *)malloc(sizeof(char) * (strlen(time_stmp) + strlen(user) + 1));
  file_spec[0] = '\0';
  strcat(file_spec, time_stmp);
  strcat(file_spec, user);
  return file_spec;
}


x86 assembly (clang, -O0):
<Get_File_Spec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movq   $0x0,-0x68(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
call   1040 <localtime@plt>
mov    %rax,-0x8(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%r10d
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%eax
lea    0xe2a(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1090 <sprintf@plt>
lea    0xe33(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
lea    -0x60(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x6c(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x68(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x68(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x68(%rbp),%rax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Get_File_Spec>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1040 <localtime@plt>
mov    (%rax),%edx
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    0x8(%rax),%r8d
mov    0xc(%rax),%r9d
mov    0x10(%rax),%ebx
mov    0x14(%rax),%eax
lea    0xe55(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
push   %rax
push   %rbx
call   1090 <sprintf@plt>
add    $0x10,%rsp
lea    0xe58(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1050 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x1,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    %rax,%rdi
mov    %r14,%rsi
call   1080 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <strcat@plt>
mov    %rbx,%rax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [29 x i8] c"%02d-%02d-%02d.%02d%02d%02d.\00"
@.str.1 = [5 x i8] c"USER\00"
define i8* @Get_File_Spec() {
%1 = alloca %struct.tm*
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [57 x i8]
%5 = alloca i8*
store i8* null, i8** %5
%6 = call i32 @time(i32* null)
store i32 %6, i32* %2
%7 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %7, %struct.tm** %1
%8 = getelementptr inbounds [57 x i8], [57 x i8]* %4, i64 0, i64 0
%9 = load %struct.tm*, %struct.tm** %1
%10 = getelementptr inbounds %struct.tm, %struct.tm* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = load %struct.tm*, %struct.tm** %1
%13 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 1
%14 = load i32, i32* %13
%15 = add nsw i32 %14, 1
%16 = load %struct.tm*, %struct.tm** %1
%17 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 2
%18 = load i32, i32* %17
%19 = load %struct.tm*, %struct.tm** %1
%20 = getelementptr inbounds %struct.tm, %struct.tm* %19, i32 0, i32 3
%21 = load i32, i32* %20
%22 = load %struct.tm*, %struct.tm** %1
%23 = getelementptr inbounds %struct.tm, %struct.tm* %22, i32 0, i32 4
%24 = load i32, i32* %23
%25 = load %struct.tm*, %struct.tm** %1
%26 = getelementptr inbounds %struct.tm, %struct.tm* %25, i32 0, i32 5
%27 = load i32, i32* %26
%28 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %15, i32 %18, i32 %21, i32 %24, i32 %27)
%29 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %29, i8** %3
%30 = getelementptr inbounds [57 x i8], [57 x i8]* %4, i64 0, i64 0
%31 = call i32 @strlen(i8* %30)
%32 = load i8*, i8** %3
%33 = call i32 @strlen(i8* %32)
%34 = add nsw i32 %31, %33
%35 = add nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = mul i64 1, %36
%38 = trunc i64 %37 to i32
%39 = call i64 @malloc(i32 %38)
%40 = inttoptr i64 %39 to i8*
store i8* %40, i8** %5
%41 = load i8*, i8** %5
%42 = getelementptr inbounds i8, i8* %41, i64 0
store i8 0, i8* %42
%43 = load i8*, i8** %5
%44 = getelementptr inbounds [57 x i8], [57 x i8]* %4, i64 0, i64 0
%45 = call i32 @strcat(i8* %43, i8* %44)
%46 = load i8*, i8** %5
%47 = load i8*, i8** %3
%48 = call i32 @strcat(i8* %46, i8* %47)
%49 = load i8*, i8** %5
ret i8* %49
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [29 x i8] c"%02d-%02d-%02d.%02d%02d%02d.\00"
@.str.1 = [5 x i8] c"USER\00"
define i8* @Get_File_Spec() {
%1 = alloca i32
%2 = alloca [57 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [57 x i8], [57 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @time(i32* null)
store i32 %5, i32* %1
%6 = call %struct.tm* @localtime(i32* %1)
%7 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 0
%8 = load i32, i32* %7
%9 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 1
%10 = load i32, i32* %9
%11 = add nsw i32 %10, 1
%12 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 2
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 3
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 4
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 5
%19 = load i32, i32* %18
%20 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %11, i32 %13, i32 %15, i32 %17, i32 %19)
%21 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @strlen(i8* %4)
%23 = call i32 @strlen(i8* %21)
%24 = add i32 %22, 1
%25 = add i32 %24, %23
%26 = call i64 @malloc(i32 %25)
%27 = inttoptr i64 %26 to i8*
store i8 0, i8* %27
%28 = call i32 @strcat(i8* %27, i8* %4)
%29 = call i32 @strcat(i8* %27, i8* %21)
ret i8* %27
}