#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*/ s;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *,
                           char *);
char *getenv(char *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  FILE *f;
  time_t t;
  struct tm *tmp;
  char s[20];
  t = time(NULL);
  tmp = localtime(&t);
  strftime(s, sizeof(s), "%Y-%m-%d %H:%M:%S", tmp);
  while (!(f = fopen("/home/FIXME/.local/share/uzbl/history", "a")))
    sleep(1);
  fprintf(f, "%s %s %s\n", s, getenv("UZBL_URI"), getenv("UZBL_TITLE"));
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x1c(%rbp),%rdi
call   1040 <localtime@plt>
mov    %rax,-0x28(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x14,%esi
lea    0xe3d(%rip),%rdx
call   1080 <strftime@plt>
lea    0xe43(%rip),%rdi
lea    0xe62(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11f5 <main+0x75>
jmp    1204 <main+0x84>
mov    $0x1,%edi
call   10a0 <sleep@plt>
jmp    11c8 <main+0x48>
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    0xe29(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x48(%rbp)
lea    0xe22(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    %rax,%r8
lea    0xdf4(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1040 <localtime@plt>
lea    0xe5b(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x14,%esi
mov    %rax,%rcx
call   1080 <strftime@plt>
lea    0xe54(%rip),%rdi
lea    0xe73(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11fd <main+0x7d>
lea    0xe39(%rip),%r14
lea    0xe58(%rip),%r15
mov    $0x1,%edi
call   10a0 <sleep@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     11e0 <main+0x60>
mov    %rax,%rbx
lea    0xe40(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r14
lea    0xe3a(%rip),%rdi
call   1030 <getenv@plt>
lea    0xe1b(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14,%rcx
mov    %rax,%r8
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@.str.1 = [38 x i8] c"/home/FIXME/.local/share/uzbl/history\00"
@.str.2 = [2 x i8] c"a\00"
@.str.3 = [10 x i8] c"%s %s %s\0A\00"
@.str.4 = [9 x i8] c"UZBL_URI\00"
@.str.5 = [11 x i8] c"UZBL_TITLE\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca %struct.tm*
%9 = alloca [20 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @time(i32* null)
store i32 %10, i32* %7
%11 = call %struct.tm* @localtime(i32* %7)
store %struct.tm* %11, %struct.tm** %8
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%13 = load %struct.tm*, %struct.tm** %8
%14 = call i32 @strftime(i8* %12, i32 20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %13)
br label %15
15: ; preds = %19, %2
%16 = call i32* @fopen(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %16, i32** %6
%17 = icmp ne i32* %16, null
%18 = xor i1 %17, true
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @sleep(i32 1)
br label %15
21: ; preds = %15
%22 = load i32*, i32** %6
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%24 = call i8* @getenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%25 = call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%26 = call i32 @fprintf(i32* %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %23, i8* %24, i8* %25)
%27 = load i32*, i32** %6
%28 = call i32 @fclose(i32* %27)
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@.str.1 = [38 x i8] c"/home/FIXME/.local/share/uzbl/history\00"
@.str.2 = [2 x i8] c"a\00"
@.str.3 = [10 x i8] c"%s %s %s\0A\00"
@.str.4 = [9 x i8] c"UZBL_URI\00"
@.str.5 = [11 x i8] c"UZBL_TITLE\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [20 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @time(i32* null)
store i32 %7, i32* %3
%8 = call %struct.tm* @localtime(i32* %3)
%9 = call i32 @strftime(i8* %6, i32 20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %8)
%10 = call i32* @fopen(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %16
12: ; preds = %2, %12
%13 = call i32 @sleep(i32 1)
%14 = call i32* @fopen(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %12, label %16
16: ; preds = %12, %2
%17 = phi i32* [ %10, %2 ], [ %14, %12 ]
%18 = call i8* @getenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%19 = call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 @fprintf(i32* %17, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %6, i8* %18, i8* %19)
%21 = call i32 @fclose(i32* %17)
ret i32 0
}