#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*/ fname;
typedef int /*<<< orphan*/ date;

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ const *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *, char, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm const *);
char *export_get_filename(const time_t time) {
  const struct tm *tm_ = localtime(&time);
  char reason = 'X';
  char *prefix = "data";
  char date[128];
  strftime(date, sizeof(date), "%Y-%m-%d.%H:%M:%S", tm_);
  static char fname[256];
  snprintf(fname, sizeof(fname), "%s.%s.%c.%s", prefix, date, reason, "csv");
  return fname;
}


x86 assembly (clang, -O0):
<export_get_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
movb   $0x58,-0x11(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x80,%esi
lea    0xe94(%rip),%rdx
call   1050 <strftime@plt>
mov    -0x20(%rbp),%rcx
lea    -0xa0(%rbp),%r8
lea    0x2ec8(%rip),%rdi
mov    $0x100,%esi
lea    0xe83(%rip),%rdx
lea    0xe88(%rip),%rax
movsbl -0x11(%rbp),%r9d
mov    %rax,(%rsp)
call   1040 <snprintf@plt>
lea    0x2ea0(%rip),%rax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<export_get_filename>:
push   %r14
push   %rbx
sub    $0x98,%rsp
mov    %edi,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
lea    0xeb6(%rip),%rdx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x80,%esi
mov    %rax,%rcx
call   1050 <strftime@plt>
lea    0xeb8(%rip),%rax
mov    %rax,(%rsp)
lea    0x2eda(%rip),%rbx
lea    0xe9a(%rip),%rdx
lea    0xe7c(%rip),%rcx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r14,%r8
mov    $0x58,%r9d
call   1040 <snprintf@plt>
mov    %rbx,%rax
add    $0x98,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [5 x i8] c"data\00"
@.str.1 = [18 x i8] c"%Y-%m-%d.%H:%M:%S\00"
@export_get_filename.fname = internal global [256 x i8] zeroinitializer
@.str.2 = [12 x i8] c"%s.%s.%c.%s\00"
@.str.3 = [4 x i8] c"csv\00"
define i8* @export_get_filename(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.tm*
%4 = alloca i8
%5 = alloca i8*
%6 = alloca [128 x i8]
store i32 %0, i32* %2
%7 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %7, %struct.tm** %3
store i8 88, i8* %4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %5
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%9 = load %struct.tm*, %struct.tm** %3
%10 = call i32 @strftime(i8* %8, i32 128, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %9)
%11 = load i8*, i8** %5
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%13 = load i8, i8* %4
%14 = call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @export_get_filename.fname, i64 0, i64 0), i32 256, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %11, i8* %12, i8 signext %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @export_get_filename.fname, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [5 x i8] c"data\00"
@.str.1 = [18 x i8] c"%Y-%m-%d.%H:%M:%S\00"
@export_get_filename.fname = internal global [256 x i8] zeroinitializer
@.str.2 = [12 x i8] c"%s.%s.%c.%s\00"
@.str.3 = [4 x i8] c"csv\00"
define i8* @export_get_filename(i32 %0) {
%2 = alloca i32
%3 = alloca [128 x i8]
store i32 %0, i32* %2
%4 = call %struct.tm* @localtime(i32* %2)
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = call i32 @strftime(i8* %5, i32 128, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %4)
%7 = call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @export_get_filename.fname, i64 0, i64 0), i32 256, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %5, i8 signext 88, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @export_get_filename.fname, i64 0, i64 0)
}