#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 scalar_t__ time_t;
struct tm {
  int tm_year;
  scalar_t__ tm_mday;
  scalar_t__ tm_mon;
};

/* Variables and functions */
int /*<<< orphan*/ PATH_MAX;
struct tm *localtime_r(scalar_t__ *, struct tm *);
int /*<<< orphan*/ snprintf(char *, int /*<<< orphan*/, char *, char const *,
                            int, long long, long long, long long, char const *);
int /*<<< orphan*/ time(scalar_t__ *);
void get_core_name(const char *core_dir, const char *exe_name,
                   char *core_name) {
  struct tm *tm;
  struct tm tm_buf;
  time_t now;
  time(&now);
  tm = localtime_r(&now, &tm_buf);
  snprintf(core_name, PATH_MAX, "%s/core.%d-%lld-%lld_%lld.%s", core_dir,
           tm->tm_year + 1900, (long long)tm->tm_mon, (long long)tm->tm_mday,
           (long long)now, exe_name);
}


x86 assembly (clang, -O0):
<get_core_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x40(%rbp),%rdi
call   1050 <time@plt>
lea    -0x40(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1030 <localtime_r@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2e87(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    (%rax),%r8d
add    $0x76c,%r8d
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%r9
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%r11
mov    -0x40(%rbp),%r10
mov    -0x10(%rbp),%rax
lea    0xe64(%rip),%rdx
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <snprintf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_core_name>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <time@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <localtime_r@plt>
mov    0x2e8b(%rip),%rcx
mov    (%rcx),%esi
mov    $0x76c,%r8d
add    (%rax),%r8d
mov    0x10(%rax),%r9
sub    $0x8,%rsp
lea    0xe81(%rip),%rdx
mov    %r12,%rdi
mov    %r15,%rcx
push   %r14
push   0x18(%rsp)
push   0x8(%rax)
call   1040 <snprintf@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32, i64, i64 }
@PATH_MAX = global i32 0
@.str = [29 x i8] c"%s/core.%d-%lld-%lld_%lld.%s\00"
define void @get_core_name(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca %struct.tm*
%8 = alloca %struct.tm
%9 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%10 = call i32 @time(i64* %9)
%11 = call %struct.tm* @localtime_r(i64* %9, %struct.tm* %8)
store %struct.tm* %11, %struct.tm** %7
%12 = load i8*, i8** %6
%13 = load i32, i32* @PATH_MAX
%14 = load i8*, i8** %4
%15 = load %struct.tm*, %struct.tm** %7
%16 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 0
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1900
%19 = load %struct.tm*, %struct.tm** %7
%20 = getelementptr inbounds %struct.tm, %struct.tm* %19, i32 0, i32 2
%21 = load i64, i64* %20
%22 = load %struct.tm*, %struct.tm** %7
%23 = getelementptr inbounds %struct.tm, %struct.tm* %22, i32 0, i32 1
%24 = load i64, i64* %23
%25 = load i64, i64* %9
%26 = load i8*, i8** %5
%27 = call i32 @snprintf(i8* %12, i32 %13, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %14, i32 %18, i64 %21, i64 %24, i64 %25, i8* %26)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i64, i64 }
@PATH_MAX = global i32 0
@.str = [29 x i8] c"%s/core.%d-%lld-%lld_%lld.%s\00"
define void @get_core_name(i8* %0, i8* %1, i8* %2) {
%4 = alloca %struct.tm
%5 = alloca i64
%6 = bitcast %struct.tm* %4 to i8*
%7 = bitcast i64* %5 to i8*
%8 = call i32 @time(i64* %5)
%9 = call %struct.tm* @localtime_r(i64* %5, %struct.tm* %4)
%10 = load i32, i32* @PATH_MAX
%11 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 0
%12 = load i32, i32* %11
%13 = add nsw i32 %12, 1900
%14 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 2
%15 = load i64, i64* %14
%16 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 1
%17 = load i64, i64* %16
%18 = load i64, i64* %5
%19 = call i32 @snprintf(i8* %2, i32 %10, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %13, i64 %15, i64 %17, i64 %18, i8* %1)
ret void
}