#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 */
struct timeval {
  int /*<<< orphan*/ tv_usec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int /*<<< orphan*/,
                           int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ timersub(struct timeval *, struct timeval *,
                            struct timeval *);
int main(int argc, char **argv) {
  char *line = NULL;
  size_t linesize = 0;
  struct timeval start;
  gettimeofday(&start, NULL);
  while (getline(&line, &linesize, stdin) != -1) {
    struct timeval now;
    struct timeval diff;
    gettimeofday(&now, NULL);
    timersub(&now, &start, &diff);
    fprintf(stdout, "[%8ld.%06ld] %s", diff.tv_sec, diff.tv_usec, line);
  }
  free(line);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
je     11e4 <main+0x94>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
lea    -0x30(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1070 <timersub@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x18(%rbp),%r8
lea    0xe26(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1183 <main+0x33>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movq   $0x0,(%rsp)
movq   $0x0,0x10(%rsp)
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    0x2e66(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
lea    0x10(%rsp),%rsi
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
je     120a <main+0xba>
lea    0x20(%rsp),%rbx
lea    0x8(%rsp),%r15
mov    0x2e31(%rip),%r14
lea    0xe52(%rip),%r12
mov    %rsp,%r13
lea    0x10(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    %rbx,%rdi
lea    0x18(%rsp),%rsi
mov    %r15,%rdx
call   1070 <timersub@plt>
mov    (%r14),%edi
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%edx
mov    (%rsp),%r8
mov    %r12,%rsi
call   1050 <fprintf@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    %rbp,%rsi
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
jne    11c0 <main+0x70>
mov    (%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@stdin = global i32 0
@stdout = global i32 0
@.str = [16 x i8] c"[%8ld.%06ld] %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca %struct.timeval
%9 = alloca %struct.timeval
%10 = alloca %struct.timeval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i64 0, i64* %7
%11 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
br label %12
12: ; preds = %16, %2
%13 = load i32, i32* @stdin
%14 = call i32 @getline(i8** %6, i64* %7, i32 %13)
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = call i32 @gettimeofday(%struct.timeval* %9, i32* null)
%18 = call i32 @timersub(%struct.timeval* %9, %struct.timeval* %8, %struct.timeval* %10)
%19 = load i32, i32* @stdout
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 1
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
%23 = load i32, i32* %22
%24 = load i8*, i8** %6
%25 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %23, i8* %24)
br label %12
26: ; preds = %12
%27 = load i8*, i8** %6
%28 = call i32 @free(i8* %27)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@stdin = global i32 0
@stdout = global i32 0
@.str = [16 x i8] c"[%8ld.%06ld] %s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca %struct.timeval
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
%8 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%9 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%10 = bitcast %struct.timeval* %5 to i8*
%11 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%12 = load i32, i32* @stdin
%13 = call i32 @getline(i8** %3, i64* %4, i32 %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %31, label %15
15: ; preds = %2
%16 = bitcast %struct.timeval* %6 to i8*
%17 = bitcast %struct.timeval* %7 to i8*
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 1
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 0
br label %20
20: ; preds = %15, %20
%21 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%22 = call i32 @timersub(%struct.timeval* %6, %struct.timeval* %5, %struct.timeval* %7)
%23 = load i32, i32* @stdout
%24 = load i32, i32* %18
%25 = load i32, i32* %19
%26 = load i8*, i8** %3
%27 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %25, i8* %26)
%28 = load i32, i32* @stdin
%29 = call i32 @getline(i8** %3, i64* %4, i32 %28)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %20
31: ; preds = %20, %2
%32 = load i8*, i8** %3
%33 = call i32 @free(i8* %32)
ret i32 0
}