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

/* Variables and functions */
char *asctime(struct tm *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void mylog(char *log, char *filename) {
  time_t rawtime;
  struct tm timeinfo;
  time(&rawtime);
  timeinfo = *localtime(&rawtime);
  FILE *f = fopen(filename, "a");
  fputs(asctime(&timeinfo), f);
  fputs(log, f);
  fputs("\n", f);
  fclose(f);
}


x86 assembly (clang, -O0):
<mylog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   1070 <time@plt>
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    -0x18(%rbp),%rdi
call   1050 <asctime@plt>
mov    %rax,%rdi
mov    -0x20(%rbp),%rsi
call   1060 <fputs@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xe3a(%rip),%rdi
call   1060 <fputs@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mylog>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
lea    0xe5f(%rip),%rsi
mov    %r15,%rdi
call   1090 <fopen@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%rdi
call   1050 <asctime@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1060 <fputs@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <fputs@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1070 <fputc@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [2 x i8] c"a\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @mylog(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca %struct.tm
%7 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = call i32 @time(i32* %5)
%9 = call %struct.tm* @localtime(i32* %5)
%10 = bitcast %struct.tm* %6 to i8*
%11 = bitcast %struct.tm* %9 to i8*
%12 = load i8*, i8** %4
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %7
%14 = call i8* @asctime(%struct.tm* %6)
%15 = load i32*, i32** %7
%16 = call i32 @fputs(i8* %14, i32* %15)
%17 = load i8*, i8** %3
%18 = load i32*, i32** %7
%19 = call i32 @fputs(i8* %17, i32* %18)
%20 = load i32*, i32** %7
%21 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %20)
%22 = load i32*, i32** %7
%23 = call i32 @fclose(i32* %22)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [2 x i8] c"a\00"
define void @mylog(i8* nocapture %0, i8* nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.tm
%5 = bitcast i32* %3 to i8*
%6 = bitcast %struct.tm* %4 to i8*
%7 = call i32 @time(i32* %3)
%8 = call %struct.tm* @localtime(i32* %3)
%9 = getelementptr %struct.tm, %struct.tm* %8, i64 0, i32 0
%10 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%11 = load i32, i32* %9
store i32 %11, i32* %10
%12 = call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = call i8* @asctime(%struct.tm* %4)
%14 = call i32 @fputs(i8* %13, i32* %12)
%15 = call i32 @fputs(i8* %0, i32* %12)
%16 = call i32 @fputc(i32 10, i32* %12)
%17 = call i32 @fclose(i32* %12)
ret void
}