#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*/ strftime(char *, int, char *, struct tm *);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *now() {
  char *example = "2020-05-27 12:12:12";
  char *str = (char *)malloc(sizeof(char) * (strlen(example) + 1));
  struct tm info;
  time_t now;
  time(&now);
  info = *localtime(&now);
  strftime(str, strlen(example) + 1, "%Y-%m-%d %H:%M:%S", &info);
  return str;
}


x86 assembly (clang, -O0):
<now>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xea1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    -0x1c(%rbp),%rdi
call   1050 <time@plt>
lea    -0x1c(%rbp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
add    $0x1,%esi
lea    0xe5c(%rip),%rdx
lea    -0x18(%rbp),%rcx
call   1070 <strftime@plt>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<now>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xea0(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xc(%rsp),%r15
mov    %r15,%rdi
call   1050 <time@plt>
mov    %r15,%rdi
call   1030 <localtime@plt>
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%esi
lea    0xe74(%rip),%rdx
lea    0x8(%rsp),%rcx
mov    %rbx,%rdi
call   1070 <strftime@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [20 x i8] c"2020-05-27 12:12:12\00"
@.str.1 = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
define i8* @now() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca %struct.tm
%4 = alloca i32
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8** %1
%5 = load i8*, i8** %1
%6 = call i32 @strlen(i8* %5)
%7 = add nsw i32 %6, 1
%8 = sext i32 %7 to i64
%9 = mul i64 1, %8
%10 = trunc i64 %9 to i32
%11 = call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %2
%13 = call i32 @time(i32* %4)
%14 = call %struct.tm* @localtime(i32* %4)
%15 = bitcast %struct.tm* %3 to i8*
%16 = bitcast %struct.tm* %14 to i8*
%17 = load i8*, i8** %2
%18 = load i8*, i8** %1
%19 = call i32 @strlen(i8* %18)
%20 = add nsw i32 %19, 1
%21 = call i32 @strftime(i8* %17, i32 %20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %3)
%22 = load i8*, i8** %2
ret i8* %22
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [20 x i8] c"2020-05-27 12:12:12\00"
@.str.1 = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
define i8* @now() {
%1 = alloca %struct.tm
%2 = alloca i32
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = add nsw i32 %3, 1
%5 = tail call i64 @malloc(i32 %4)
%6 = inttoptr i64 %5 to i8*
%7 = bitcast %struct.tm* %1 to i8*
%8 = bitcast i32* %2 to i8*
%9 = call i32 @time(i32* %2)
%10 = call %struct.tm* @localtime(i32* %2)
%11 = getelementptr %struct.tm, %struct.tm* %10, i64 0, i32 0
%12 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 0
%13 = load i32, i32* %11
store i32 %13, i32* %12
%14 = call i32 @strlen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%15 = add nsw i32 %14, 1
%16 = call i32 @strftime(i8* %6, i32 %15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %1)
ret i8* %6
}