#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_mon;
  int tm_mday;
  int tm_year;
  int /*<<< orphan*/ tm_sec;
  int /*<<< orphan*/ tm_min;
  int /*<<< orphan*/ tm_hour;
};

/* Variables and functions */
char *calloc(int, int);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int, int, int, int,
                            int, int /*<<< orphan*/, int, int /*<<< orphan*/,
                            int, int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *config_default_log_filename() {
  char *filename = calloc(64, sizeof(char));
  time_t current_time = time(NULL);
  struct tm *ltime = localtime(&current_time);
  snprintf(filename, 64, "peabot.%.*d-%.*d-%.*d_%.*d-%.*d-%.*d.log", 2,
           ltime->tm_mon, 2, ltime->tm_mday, 2, ltime->tm_year % 100, 2,
           ltime->tm_hour, 2, ltime->tm_min, 2, ltime->tm_sec);
  return filename;
}


x86 assembly (clang, -O0):
<config_default_log_filename>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    $0x40,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x1c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    (%rax),%r8d
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%r14d
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%ebx
mov    -0x28(%rbp),%rax
mov    0x14(%rax),%r11d
mov    -0x28(%rbp),%rax
mov    0x10(%rax),%r10d
mov    -0x28(%rbp),%rax
mov    0xc(%rax),%eax
mov    $0x40,%esi
lea    0xe42(%rip),%rdx
mov    $0x2,%r9d
mov    %r9d,%ecx
mov    %r14d,(%rsp)
movl   $0x2,0x8(%rsp)
mov    %ebx,0x10(%rsp)
movl   $0x2,0x18(%rsp)
mov    %r11d,0x20(%rsp)
movl   $0x2,0x28(%rsp)
mov    %r10d,0x30(%rsp)
movl   $0x2,0x38(%rsp)
mov    %eax,0x40(%rsp)
call   1040 <snprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_default_log_filename>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0x40,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%r14
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%r8d
mov    0x4(%rax),%r10d
movslq 0x8(%rax),%rbx
imul   $0x51eb851f,%rbx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%ebx
mov    0x14(%rax),%r11d
mov    0x10(%rax),%r15d
mov    0xc(%rax),%eax
sub    $0x8,%rsp
lea    0xe56(%rip),%rdx
mov    %r14,%rdi
mov    $0x40,%esi
mov    $0x2,%ecx
mov    $0x2,%r9d
push   %rax
push   $0x2
push   %r15
push   $0x2
push   %r11
push   $0x2
push   %rbx
push   $0x2
push   %r10
call   1040 <snprintf@plt>
add    $0x50,%rsp
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [41 x i8] c"peabot.%.*d-%.*d-%.*d_%.*d-%.*d-%.*d.log\00"
define i8* @config_default_log_filename() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca %struct.tm*
%4 = call i8* @calloc(i32 64, i32 1)
store i8* %4, i8** %1
%5 = call i32 @time(i32* null)
store i32 %5, i32* %2
%6 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %6, %struct.tm** %3
%7 = load i8*, i8** %1
%8 = load %struct.tm*, %struct.tm** %3
%9 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = load %struct.tm*, %struct.tm** %3
%12 = getelementptr inbounds %struct.tm, %struct.tm* %11, i32 0, i32 1
%13 = load i32, i32* %12
%14 = load %struct.tm*, %struct.tm** %3
%15 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 2
%16 = load i32, i32* %15
%17 = srem i32 %16, 100
%18 = load %struct.tm*, %struct.tm** %3
%19 = getelementptr inbounds %struct.tm, %struct.tm* %18, i32 0, i32 5
%20 = load i32, i32* %19
%21 = load %struct.tm*, %struct.tm** %3
%22 = getelementptr inbounds %struct.tm, %struct.tm* %21, i32 0, i32 4
%23 = load i32, i32* %22
%24 = load %struct.tm*, %struct.tm** %3
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 3
%26 = load i32, i32* %25
%27 = call i32 @snprintf(i8* %7, i32 64, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 2, i32 %10, i32 2, i32 %13, i32 2, i32 %17, i32 2, i32 %20, i32 2, i32 %23, i32 2, i32 %26)
%28 = load i8*, i8** %1
ret i8* %28
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [41 x i8] c"peabot.%.*d-%.*d-%.*d_%.*d-%.*d-%.*d.log\00"
define i8* @config_default_log_filename() {
%1 = alloca i32
%2 = tail call dereferenceable_or_null(64) i8* @calloc(i32 64, i32 1)
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @time(i32* null)
store i32 %4, i32* %1
%5 = call %struct.tm* @localtime(i32* %1)
%6 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 0
%7 = load i32, i32* %6
%8 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 1
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 2
%11 = load i32, i32* %10
%12 = srem i32 %11, 100
%13 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 5
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 4
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 3
%18 = load i32, i32* %17
%19 = call i32 @snprintf(i8* %2, i32 64, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 2, i32 %7, i32 2, i32 %9, i32 2, i32 %12, i32 2, i32 %14, i32 2, i32 %16, i32 2, i32 %18)
ret i8* %2
}