#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;
};

/* Variables and functions */
scalar_t__ calloc(size_t, int);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strftime(char *, size_t, char const *, struct tm *);
int strlen(char const *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *getCrrentTime(const char *df) {
  char *datetime;
  struct tm *tm_ptr;
  time_t ttime;
  size_t df_len = strlen(df) + 1;
  datetime = (char *)calloc(df_len, sizeof(char));
  (void)time(&ttime);
  tm_ptr = localtime(&ttime);
  strftime(datetime, df_len, df, tm_ptr);
  printf("current time: %s\n", datetime);
  return datetime;
}


x86 assembly (clang, -O0):
<getCrrentTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x10(%rbp)
lea    -0x1c(%rbp),%rdi
call   1070 <time@plt>
lea    -0x1c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1080 <strftime@plt>
mov    -0x10(%rbp),%rsi
lea    0xe3a(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCrrentTime>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <strlen@plt>
add    $0x1,%eax
movslq %eax,%r15
mov    %r15,%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%rbx
lea    0x4(%rsp),%r12
mov    %r12,%rdi
call   1070 <time@plt>
mov    %r12,%rdi
call   1030 <localtime@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %rax,%rcx
call   1080 <strftime@plt>
lea    0xe4d(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [18 x i8] c"current time: %s\0A\00"
define i8* @getCrrentTime(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca %struct.tm*
%5 = alloca i32
%6 = alloca i64
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = add nsw i32 %8, 1
%10 = sext i32 %9 to i64
store i64 %10, i64* %6
%11 = load i64, i64* %6
%12 = call i64 @calloc(i64 %11, i32 1)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %3
%14 = call i32 @time(i32* %5)
%15 = call %struct.tm* @localtime(i32* %5)
store %struct.tm* %15, %struct.tm** %4
%16 = load i8*, i8** %3
%17 = load i64, i64* %6
%18 = load i8*, i8** %2
%19 = load %struct.tm*, %struct.tm** %4
%20 = call i32 @strftime(i8* %16, i64 %17, i8* %18, %struct.tm* %19)
%21 = load i8*, i8** %3
%22 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %3
ret i8* %23
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [18 x i8] c"current time: %s\0A\00"
define i8* @getCrrentTime(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @strlen(i8* %0)
%5 = add nsw i32 %4, 1
%6 = sext i32 %5 to i64
%7 = tail call i64 @calloc(i64 %6, i32 1)
%8 = inttoptr i64 %7 to i8*
%9 = call i32 @time(i32* %2)
%10 = call %struct.tm* @localtime(i32* %2)
%11 = call i32 @strftime(i8* %8, i64 %6, i8* %0, %struct.tm* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %8)
ret i8* %8
}