#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*/ date;

/* Variables and functions */
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/);
void log_with_date(char *line) {
  char date[50];
  struct tm *current_time;
  time_t now = time(0);
  current_time = gmtime(&now);
  strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", current_time);
  printf("[%s] %s\n", date, line);
}


x86 assembly (clang, -O0):
<log_with_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,-0x4c(%rbp)
lea    -0x4c(%rbp),%rdi
call   1060 <gmtime@plt>
mov    %rax,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rcx
mov    $0x32,%esi
lea    0xe89(%rip),%rdx
call   1050 <strftime@plt>
lea    -0x40(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_with_date>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rdi,%r14
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1060 <gmtime@plt>
lea    0xe9a(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x32,%esi
mov    %rax,%rcx
call   1050 <strftime@plt>
lea    0xe90(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <printf@plt>
add    $0x48,%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 = [9 x i8] c"[%s] %s\0A\00"
define void @log_with_date(i8* %0) {
%2 = alloca i8*
%3 = alloca [50 x i8]
%4 = alloca %struct.tm*
%5 = alloca i32
store i8* %0, i8** %2
%6 = call i32 @time(i32 0)
store i32 %6, i32* %5
%7 = call %struct.tm* @gmtime(i32* %5)
store %struct.tm* %7, %struct.tm** %4
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%9 = load %struct.tm*, %struct.tm** %4
%10 = call i32 @strftime(i8* %8, i32 50, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %9)
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%12 = load i8*, i8** %2
%13 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %11, i8* %12)
ret void
}

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