#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*/);
main() {
  FILE *fp;
  time_t t;
  init_daemon();
  while (1) {
    sleep(1);
    if ((fp = fopen("thao.log", "a")) >= 0) {
      t = time(0);
      fprintf(fp, "The programe run here at %s", asctime(localtime(&t)));
      fclose(fp);
    }
  }
}


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>
mov    $0x1,%edi
call   10a0 <sleep@plt>
lea    0xe59(%rip),%rdi
lea    0xe5b(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jb     11ff <main+0x7f>
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    0xe1a(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@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    $0x1,%edi
call   10a0 <sleep@plt>
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>
jmp    11b0 <main+0x30>

LLVM IR (-O0):
@.str = [9 x i8] c"thao.log\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [28 x i8] c"The programe run here at %s\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, %17
%6 = call i32 @sleep(i32 1)
%7 = 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* %7, i32** %2
%8 = icmp uge i32* %7, null
br i1 %8, label %9, label %17
9: ; preds = %5
%10 = call i32 @time(i32 0)
store i32 %10, i32* %3
%11 = load i32*, i32** %2
%12 = call i32 @localtime(i32* %3)
%13 = call i8* @asctime(i32 %12)
%14 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = load i32*, i32** %2
%16 = call i32 @fclose(i32* %15)
br label %17
17: ; preds = %9, %5
br label %5
}

LLVM IR (-O2):
@.str = [9 x i8] c"thao.log\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [28 x i8] c"The programe run here at %s\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 @sleep(i32 1)
%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))
%7 = call i32 @time(i32 0)
store i32 %7, i32* %1
%8 = call i32 @localtime(i32* %1)
%9 = call i8* @asctime(i32 %8)
%10 = call i32 @fprintf(i32* %6, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%11 = call i32 @fclose(i32* %6)
br label %4
}