#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 tm_year;
  int tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
struct tm *localtime(int /*<<< orphan*/ *);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void WriteRunLog(char *_Str) {
  FILE *FH;
  time_t tt;
  struct tm *tm;
  FH = fopen("./runlog", "a+");
  if (FH == NULL) {
    return;
  }
  tt = time(NULL);
  tm = localtime(&tt);
  fprintf(FH, "%04d/%02d/%02d %02d:%02d:%02d ", tm->tm_year + 1900,
          tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
  fputs(_Str, FH);
  if (_Str[strlen(_Str) - 1] != '\n')
    fprintf(FH, "\n");
  fclose(FH);
}


x86 assembly (clang, -O0):
<WriteRunLog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe7d(%rip),%rdi
lea    0xe7f(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11a3 <WriteRunLog+0x33>
jmp    125d <WriteRunLog+0xed>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
add    $0x76c,%edx
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x20(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%r10d
mov    -0x20(%rbp),%rax
mov    0x14(%rax),%eax
lea    0xe10(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <fputs@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     1254 <WriteRunLog+0xe4>
mov    -0x10(%rbp),%rdi
lea    0xdde(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WriteRunLog>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xe72(%rip),%rdi
lea    0xe74(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1223 <WriteRunLog+0xa3>
mov    %rax,%rbx
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
mov    $0x76c,%edx
add    (%rax),%edx
mov    0x4(%rax),%ecx
mov    0x8(%rax),%r8d
add    $0x1,%ecx
mov    0xc(%rax),%r9d
mov    0x10(%rax),%r10d
mov    0x14(%rax),%r11d
lea    0xe2d(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
push   %r11
push   %r10
call   1080 <fprintf@plt>
add    $0x10,%rsp
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <fputs@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%r14,1)
je     121b <WriteRunLog+0x9b>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1070 <fputc@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [9 x i8] c"./runlog\00"
@.str.1 = [3 x i8] c"a+\00"
@.str.2 = [31 x i8] c"%04d/%02d/%02d %02d:%02d:%02d \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @WriteRunLog(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca %struct.tm*
store i8* %0, i8** %2
%6 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %3
%7 = load i32*, i32** %3
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %10
9: ; preds = %1
br label %53
10: ; preds = %1
%11 = call i32 @time(i32* null)
store i32 %11, i32* %4
%12 = call %struct.tm* @localtime(i32* %4)
store %struct.tm* %12, %struct.tm** %5
%13 = load i32*, i32** %3
%14 = load %struct.tm*, %struct.tm** %5
%15 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = add nsw i32 %16, 1900
%18 = load %struct.tm*, %struct.tm** %5
%19 = getelementptr inbounds %struct.tm, %struct.tm* %18, i32 0, i32 1
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1
%22 = load %struct.tm*, %struct.tm** %5
%23 = getelementptr inbounds %struct.tm, %struct.tm* %22, i32 0, i32 2
%24 = load i32, i32* %23
%25 = load %struct.tm*, %struct.tm** %5
%26 = getelementptr inbounds %struct.tm, %struct.tm* %25, i32 0, i32 3
%27 = load i32, i32* %26
%28 = load %struct.tm*, %struct.tm** %5
%29 = getelementptr inbounds %struct.tm, %struct.tm* %28, i32 0, i32 4
%30 = load i32, i32* %29
%31 = load %struct.tm*, %struct.tm** %5
%32 = getelementptr inbounds %struct.tm, %struct.tm* %31, i32 0, i32 5
%33 = load i32, i32* %32
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %21, i32 %24, i32 %27, i32 %30, i32 %33)
%35 = load i8*, i8** %2
%36 = load i32*, i32** %3
%37 = call i32 @fputs(i8* %35, i32* %36)
%38 = load i8*, i8** %2
%39 = load i8*, i8** %2
%40 = call i32 @strlen(i8* %39)
%41 = sub nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %38, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %45, 10
br i1 %46, label %47, label %50
47: ; preds = %10
%48 = load i32*, i32** %3
%49 = call i32 (i32*, i8*, ...) @fprintf(i32* %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %50
50: ; preds = %47, %10
%51 = load i32*, i32** %3
%52 = call i32 @fclose(i32* %51)
br label %53
53: ; preds = %50, %9
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [9 x i8] c"./runlog\00"
@.str.1 = [3 x i8] c"a+\00"
@.str.2 = [31 x i8] c"%04d/%02d/%02d %02d:%02d:%02d \00"
define void @WriteRunLog(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %35, label %6
6: ; preds = %1
%7 = tail call i32 @time(i32* null)
store i32 %7, i32* %2
%8 = call %struct.tm* @localtime(i32* %2)
%9 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 0
%10 = load i32, i32* %9
%11 = add nsw i32 %10, 1900
%12 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 1
%13 = load i32, i32* %12
%14 = add nsw i32 %13, 1
%15 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 2
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 3
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 4
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 5
%22 = load i32, i32* %21
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %11, i32 %14, i32 %16, i32 %18, i32 %20, i32 %22)
%24 = call i32 @fputs(i8* %0, i32* %4)
%25 = call i32 @strlen(i8* %0)
%26 = add nsw i32 %25, -1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %0, i64 %27
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 10
br i1 %30, label %33, label %31
31: ; preds = %6
%32 = call i32 @fputc(i32 10, i32* %4)
br label %33
33: ; preds = %31, %6
%34 = call i32 @fclose(i32* %4)
br label %35
35: ; preds = %1, %33
ret void
}