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

/* Variables and functions */
char *ctime(int /*<<< orphan*/ *);
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ snprintf(char *, scalar_t__, char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *print_time() {
  time_t t;
  char *buf;
  time(&t);
  buf = (char *)malloc(strlen(ctime(&t)) + 1);
  snprintf(buf, strlen(ctime(&t)), "%s ", ctime(&t));
  return buf;
}


x86 assembly (clang, -O0):
<print_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x4(%rbp),%rdi
call   1060 <time@plt>
lea    -0x4(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,%rdi
call   1040 <strlen@plt>
mov    %rax,-0x18(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <ctime@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    %rax,%rcx
lea    0xe46(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_time>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%r14
mov    %r14,%rdi
call   1060 <time@plt>
mov    %r14,%rdi
call   1030 <ctime@plt>
mov    %rax,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <ctime@plt>
mov    %rax,%rdi
call   1040 <strlen@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <ctime@plt>
lea    0xe5c(%rip),%rdx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rax,%rcx
call   1050 <snprintf@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s \00"
define i8* @print_time() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i32 @time(i32* %1)
%4 = call i8* @ctime(i32* %1)
%5 = call i64 @strlen(i8* %4)
%6 = add nsw i64 %5, 1
%7 = call i64 @malloc(i64 %6)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %2
%9 = load i8*, i8** %2
%10 = call i8* @ctime(i32* %1)
%11 = call i64 @strlen(i8* %10)
%12 = call i8* @ctime(i32* %1)
%13 = call i32 @snprintf(i8* %9, i64 %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %2
ret i8* %14
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s \00"
define i8* @print_time() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @time(i32* %1)
%4 = call i8* @ctime(i32* %1)
%5 = call i64 @strlen(i8* dereferenceable(1) %4)
%6 = add nsw i64 %5, 1
%7 = call i64 @malloc(i64 %6)
%8 = inttoptr i64 %7 to i8*
%9 = call i8* @ctime(i32* %1)
%10 = call i64 @strlen(i8* dereferenceable(1) %9)
%11 = call i8* @ctime(i32* %1)
%12 = call i32 @snprintf(i8* %8, i64 %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %11)
ret i8* %8
}