#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 */
struct tm *localtime(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void time_test() {
  time_t t;
  char *buf;
  struct tm *tp;
  t = time(NULL);
  tp = localtime(&t);
  buf = (char *)malloc(64);
  strftime(buf, 64, "%Y-%m-%d %H:%M:%S", tp);
  printf("time() => %s(%ld) ", buf, t);
}


x86 assembly (clang, -O0):
<time_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
mov    $0x40,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x40,%esi
lea    0xe6d(%rip),%rdx
call   1070 <strftime@plt>
mov    -0x10(%rbp),%rsi
mov    -0x4(%rbp),%edx
lea    0xe6c(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_test>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
mov    %rax,%r14
mov    $0x40,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe80(%rip),%rdx
mov    %rax,%rdi
mov    $0x40,%esi
mov    %r14,%rcx
call   1070 <strftime@plt>
mov    0x4(%rsp),%edx
lea    0xe77(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@.str.1 = [19 x i8] c"time() => %s(%ld) \00"
define void @time_test() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca %struct.tm*
%4 = call i32 @time(i32* null)
store i32 %4, i32* %1
%5 = call %struct.tm* @localtime(i32* %1)
store %struct.tm* %5, %struct.tm** %3
%6 = call i64 @malloc(i32 64)
%7 = inttoptr i64 %6 to i8*
store i8* %7, i8** %2
%8 = load i8*, i8** %2
%9 = load %struct.tm*, %struct.tm** %3
%10 = call i32 @strftime(i8* %8, i32 64, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %9)
%11 = load i8*, i8** %2
%12 = load i32, i32* %1
%13 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %11, i32 %12)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@.str.1 = [19 x i8] c"time() => %s(%ld) \00"
define void @time_test() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @time(i32* null)
store i32 %3, i32* %1
%4 = call %struct.tm* @localtime(i32* %1)
%5 = call i64 @malloc(i32 64)
%6 = inttoptr i64 %5 to i8*
%7 = call i32 @strftime(i8* %6, i32 64, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %4)
%8 = load i32, i32* %1
%9 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %6, i32 %8)
ret void
}