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

/* Variables and functions */
char *asctime(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ init_daemon();
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main() {
  FILE *fp;
  time_t t;
  init_daemon();
  while (1) {
    if ((fp = fopen("test.log", "a")) >= 0) {
      t = time(0);
      fprintf(fp, "I'm here at %sn", asctime(localtime(&t)));
      fclose(fp);
    }
    sleep(60);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <init_daemon@plt>
lea    0xe63(%rip),%rdi
lea    0xe65(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jb     11f5 <main+0x75>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x14(%rbp),%rdi
call   1040 <localtime@plt>
mov    %eax,%edi
call   1060 <asctime@plt>
mov    -0x20(%rbp),%rdi
mov    %rax,%rdx
lea    0xe24(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
mov    $0x3c,%edi
call   10a0 <sleep@plt>
jmp    1196 <main+0x16>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1030 <init_daemon@plt>
lea    0xe65(%rip),%r14
lea    0xe67(%rip),%r15
lea    0xc(%rsp),%r12
lea    0xe5d(%rip),%r13
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,0xc(%rsp)
mov    %r12,%rdi
call   1040 <localtime@plt>
mov    %eax,%edi
call   1060 <asctime@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rax,%rdx
call   1070 <fprintf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    $0x3c,%edi
call   10a0 <sleep@plt>
jmp    11b0 <main+0x30>

LLVM IR (-O0):
@.str = [9 x i8] c"test.log\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [16 x i8] c"I'm here at %sn\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (...) @init_daemon()
br label %5
5: ; preds = %0, %16
%6 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %2
%7 = icmp uge i32* %6, null
br i1 %7, label %8, label %16
8: ; preds = %5
%9 = call i32 @time(i32 0)
store i32 %9, i32* %3
%10 = load i32*, i32** %2
%11 = call i32 @localtime(i32* %3)
%12 = call i8* @asctime(i32 %11)
%13 = call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = load i32*, i32** %2
%15 = call i32 @fclose(i32* %14)
br label %16
16: ; preds = %8, %5
%17 = call i32 @sleep(i32 60)
br label %5
}

LLVM IR (-O2):
@.str = [9 x i8] c"test.log\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [16 x i8] c"I'm here at %sn\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (...) @init_daemon()
br label %4
4: ; preds = %4, %0
%5 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @time(i32 0)
store i32 %6, i32* %1
%7 = call i32 @localtime(i32* %1)
%8 = call i8* @asctime(i32 %7)
%9 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = call i32 @fclose(i32* %5)
%11 = call i32 @sleep(i32 60)
br label %4
}