#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 */
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main(void) {
  char message[1024];
  char timestamp[1024];
  time_t now;
  struct tm *nowtm;
  while (fgets(message, 1024, stdin)) {
    if (message[0] != '\0' && message[0] != '\n') {
      now = time(0);
      nowtm = localtime(&now);
      strftime(timestamp, 1024, "[%F %r]", nowtm);
      printf("%s %s", timestamp, message);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x410(%rbp),%rdi
mov    0x2e78(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1204 <main+0xb4>
movsbl -0x410(%rbp),%eax
cmp    $0x0,%eax
je     11ff <main+0xaf>
movsbl -0x410(%rbp),%eax
cmp    $0xa,%eax
je     11ff <main+0xaf>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,-0x814(%rbp)
lea    -0x814(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x820(%rbp)
lea    -0x810(%rbp),%rdi
mov    -0x820(%rbp),%rcx
mov    $0x400,%esi
lea    0xe20(%rip),%rdx
call   1070 <strftime@plt>
lea    -0x810(%rbp),%rsi
lea    -0x410(%rbp),%rdx
lea    0xe0e(%rip),%rdi
call   1040 <printf@plt>
jmp    1162 <main+0x12>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
mov    0x2e80(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0x10(%rsp),%rdi
mov    $0x400,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     1208 <main+0xb8>
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%r14
lea    0xe6c(%rip),%r15
lea    0x410(%rsp),%r12
lea    0xe65(%rip),%r13
jmp    11c5 <main+0x75>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     1208 <main+0xb8>
movzbl 0x10(%rsp),%eax
test   %al,%al
je     11b0 <main+0x60>
cmp    $0xa,%al
je     11b0 <main+0x60>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0xc(%rsp)
mov    %r14,%rdi
call   1030 <localtime@plt>
mov    %r12,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
mov    %rax,%rcx
call   1070 <strftime@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1040 <printf@plt>
jmp    11b0 <main+0x60>
xor    %eax,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@stdin = global i32 0
@.str = [8 x i8] c"[%F %r]\00"
@.str.1 = [6 x i8] c"%s %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = alloca i32
%5 = alloca %struct.tm*
store i32 0, i32* %1
br label %6
6: ; preds = %30, %0
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i64 @fgets(i8* %7, i32 1024, i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %31
11: ; preds = %6
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %30
16: ; preds = %11
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 10
br i1 %20, label %21, label %30
21: ; preds = %16
%22 = call i32 @time(i32 0)
store i32 %22, i32* %4
%23 = call %struct.tm* @localtime(i32* %4)
store %struct.tm* %23, %struct.tm** %5
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%25 = load %struct.tm*, %struct.tm** %5
%26 = call i32 @strftime(i8* %24, i32 1024, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %struct.tm* %25)
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%29 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %27, i8* %28)
br label %30
30: ; preds = %21, %16, %11
br label %6
31: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@stdin = global i32 0
@.str = [8 x i8] c"[%F %r]\00"
@.str.1 = [6 x i8] c"%s %s\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
%7 = load i32, i32* @stdin
%8 = call i64 @fgets(i8* %4, i32 1024, i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %21, label %10
10: ; preds = %0, %17
%11 = load i8, i8* %4
switch i8 %11, label %12 [
i8 10, label %17
i8 0, label %17
]
12: ; preds = %10
%13 = call i32 @time(i32 0)
store i32 %13, i32* %3
%14 = call %struct.tm* @localtime(i32* %3)
%15 = call i32 @strftime(i8* %5, i32 1024, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %struct.tm* %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* %4)
br label %17
17: ; preds = %10, %10, %12
%18 = load i32, i32* @stdin
%19 = call i64 @fgets(i8* %4, i32 1024, i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %10
21: ; preds = %17, %0
ret i32 0
}