#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 */
int asprintf(char **, char *, char const *, char *);
struct tm *localtime(int /*<<< orphan*/ *);
int strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *make_filename(const char *prefix) {
  char *filename;
  struct tm *tm;
  time_t t;
  int rc;
  char buf[64];
  t = time(NULL);
  tm = localtime(&t);
  rc = strftime(buf, sizeof(buf), "%F-%T", tm);
  if (rc < 0)
    return NULL;
  rc = asprintf(&filename, "%s.%s", prefix, buf);
  if (rc < 0)
    return NULL;
  return filename;
}


x86 assembly (clang, -O0):
<make_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x24(%rbp)
lea    -0x24(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x40,%esi
lea    0xe87(%rip),%rdx
call   1060 <strftime@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    1198 <make_filename+0x58>
movq   $0x0,-0x8(%rbp)
jmp    11d2 <make_filename+0x92>
mov    -0x10(%rbp),%rdx
lea    -0x70(%rbp),%rcx
lea    -0x18(%rbp),%rdi
lea    0xe5b(%rip),%rsi
call   1050 <asprintf@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    11ca <make_filename+0x8a>
movq   $0x0,-0x8(%rbp)
jmp    11d2 <make_filename+0x92>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_filename>:
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %rdi,%r14
xor    %ebx,%ebx
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
lea    0xe98(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x40,%esi
mov    %rax,%rcx
call   1060 <strftime@plt>
test   %eax,%eax
js     11a4 <make_filename+0x64>
lea    0xe81(%rip),%rsi
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rcx
mov    %r14,%rdx
call   1050 <asprintf@plt>
test   %eax,%eax
js     11a2 <make_filename+0x62>
mov    0x8(%rsp),%rbx
jmp    11a4 <make_filename+0x64>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [6 x i8] c"%F-%T\00"
@.str.1 = [6 x i8] c"%s.%s\00"
define i8* @make_filename(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca %struct.tm*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [64 x i8]
store i8* %0, i8** %3
%9 = call i32 @time(i32* null)
store i32 %9, i32* %6
%10 = call %struct.tm* @localtime(i32* %6)
store %struct.tm* %10, %struct.tm** %5
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%12 = load %struct.tm*, %struct.tm** %5
%13 = call i32 @strftime(i8* %11, i32 64, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.tm* %12)
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %1
store i8* null, i8** %2
br label %26
17: ; preds = %1
%18 = load i8*, i8** %3
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%20 = call i32 @asprintf(i8** %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* %19)
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %17
store i8* null, i8** %2
br label %26
24: ; preds = %17
%25 = load i8*, i8** %4
store i8* %25, i8** %2
br label %26
26: ; preds = %24, %23, %16
%27 = load i8*, i8** %2
ret i8* %27
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [6 x i8] c"%F-%T\00"
@.str.1 = [6 x i8] c"%s.%s\00"
define i8* @make_filename(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [64 x i8]
%5 = bitcast i8** %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%8 = tail call i32 @time(i32* null)
store i32 %8, i32* %3
%9 = call %struct.tm* @localtime(i32* %3)
%10 = call i32 @strftime(i8* %7, i32 64, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.tm* %9)
%11 = icmp slt i32 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %1
%13 = call i32 @asprintf(i8** %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %7)
%14 = icmp slt i32 %13, 0
%15 = load i8*, i8** %2
%16 = select i1 %14, i8* null, i8* %15
br label %17
17: ; preds = %12, %1
%18 = phi i8* [ null, %1 ], [ %16, %12 ]
ret i8* %18
}