#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;
};
typedef int /*<<< orphan*/ strTime;

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
char *malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int getLocalCurrentTime(char **buf, int *len) {
  time_t rawtime;
  struct tm *timeinfo;
  time(&rawtime);
  timeinfo = localtime(&rawtime);
  char strTime[100];
  strftime(strTime, sizeof(strTime), "%Y_%m_%d-%H_%M_%S", timeinfo);
  int slen = strlen(strTime) + 1;
  char *p = malloc(slen);
  *(p + slen) = '\0';
  strcpy(p, strTime);
  *buf = p;
  *len = slen;
  return 0;
}


x86 assembly (clang, -O0):
<getLocalCurrentTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   1060 <time@plt>
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x64,%esi
lea    0xe60(%rip),%rdx
call   1080 <strftime@plt>
lea    -0x90(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
mov    -0x94(%rbp),%edi
call   1070 <malloc@plt>
mov    %rax,-0xa0(%rbp)
mov    -0xa0(%rbp),%rax
movslq -0x94(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0xa0(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0xa0(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x94(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLocalCurrentTime>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
lea    0xe70(%rip),%rdx
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0x64,%esi
mov    %rax,%rcx
call   1080 <strftime@plt>
mov    %r12,%rdi
call   1050 <strlen@plt>
movslq %eax,%rbp
lea    0x1(%rbp),%r13
mov    %r13d,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
movb   $0x0,0x1(%rax,%rbp,1)
mov    %rax,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
mov    %rbx,(%r15)
mov    %r13d,(%r14)
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%Y_%m_%d-%H_%M_%S\00"
define i32 @getLocalCurrentTime(i8** %0, i32* %1) {
%3 = alloca i8**
%4 = alloca i32*
%5 = alloca i32
%6 = alloca %struct.tm*
%7 = alloca [100 x i8]
%8 = alloca i32
%9 = alloca i8*
store i8** %0, i8*** %3
store i32* %1, i32** %4
%10 = call i32 @time(i32* %5)
%11 = call %struct.tm* @localtime(i32* %5)
store %struct.tm* %11, %struct.tm** %6
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%13 = load %struct.tm*, %struct.tm** %6
%14 = call i32 @strftime(i8* %12, i32 100, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %13)
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
%17 = add nsw i32 %16, 1
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = call i8* @malloc(i32 %18)
store i8* %19, i8** %9
%20 = load i8*, i8** %9
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8 0, i8* %23
%24 = load i8*, i8** %9
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%26 = call i32 @strcpy(i8* %24, i8* %25)
%27 = load i8*, i8** %9
%28 = load i8**, i8*** %3
store i8* %27, i8** %28
%29 = load i32, i32* %8
%30 = load i32*, i32** %4
store i32 %29, i32* %30
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%Y_%m_%d-%H_%M_%S\00"
define i32 @getLocalCurrentTime(i8** nocapture writeonly %0, i32* nocapture writeonly %1) {
%3 = alloca i32
%4 = alloca [100 x i8]
%5 = bitcast i32* %3 to i8*
%6 = call i32 @time(i32* %3)
%7 = call %struct.tm* @localtime(i32* %3)
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%9 = call i32 @strftime(i8* %8, i32 100, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %7)
%10 = call i32 @strlen(i8* %8)
%11 = add nsw i32 %10, 1
%12 = call i8* @malloc(i32 %11)
%13 = sext i32 %11 to i64
%14 = getelementptr inbounds i8, i8* %12, i64 %13
store i8 0, i8* %14
%15 = call i32 @strcpy(i8* %12, i8* %8)
store i8* %12, i8** %0
store i32 %11, i32* %1
ret i32 0
}