#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*/ str_time;
typedef int /*<<< orphan*/ str_date;

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
char *strcat(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *datetimestr(void) {
  struct tm *tm;
  time_t t;
  char str_time[100];
  char str_date[100];
  t = time(NULL);
  tm = localtime(&t);
  strftime(str_time, sizeof(str_time), "%H:%M:%S ", tm);
  strftime(str_date, sizeof(str_date), "%Y-%m-%d ", tm);
  return strcat(str_date, str_time);
}


x86 assembly (clang, -O0):
<datetimestr>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x8(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x64,%esi
lea    0xe88(%rip),%rdx
call   1050 <strftime@plt>
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x64,%esi
lea    0xe76(%rip),%rdx
call   1050 <strftime@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1060 <strcat@plt>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<datetimestr>:
push   %r14
push   %rbx
sub    $0xe8,%rsp
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
lea    0xea7(%rip),%rdx
lea    0x80(%rsp),%rdi
mov    $0x64,%esi
mov    %rax,%rcx
call   1050 <strftime@plt>
lea    0xe95(%rip),%rdx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x64,%esi
mov    %rbx,%rcx
call   1050 <strftime@plt>
mov    %r14,%rax
add    $0xe8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [10 x i8] c"%H:%M:%S \00"
@.str.1 = [10 x i8] c"%Y-%m-%d \00"
define i8* @datetimestr() {
%1 = alloca %struct.tm*
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = call i32 @time(i32* null)
store i32 %5, i32* %2
%6 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %6, %struct.tm** %1
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = load %struct.tm*, %struct.tm** %1
%9 = call i32 @strftime(i8* %7, i32 100, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %struct.tm* %8)
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%11 = load %struct.tm*, %struct.tm** %1
%12 = call i32 @strftime(i8* %10, i32 100, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %11)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%15 = call i8* @strcat(i8* %13, i8* %14)
ret i8* %15
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [10 x i8] c"%H:%M:%S \00"
@.str.1 = [10 x i8] c"%Y-%m-%d \00"
define i8* @datetimestr() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = bitcast i32* %1 to i8*
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @time(i32* null)
store i32 %7, i32* %1
%8 = call %struct.tm* @localtime(i32* %1)
%9 = call i32 @strftime(i8* %5, i32 100, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %struct.tm* %8)
%10 = call i32 @strftime(i8* %6, i32 100, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %8)
ret i8* %6
}