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

/* Variables and functions */
char *ctime(long *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ time(long *);
void logger(char *message) {
  long hour;
  time(&hour);
  FILE *f_log = fopen("./server.log", "a+");
  fprintf(f_log, "%s", ctime(&hour));
  fprintf(f_log, "\t %s\n", message);
  fclose(f_log);
}


x86 assembly (clang, -O0):
<logger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
call   1060 <time@plt>
lea    0xe94(%rip),%rdi
lea    0xe9a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <ctime@plt>
mov    -0x20(%rbp),%rdi
mov    %rax,%rdx
lea    0xe75(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe64(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logger>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0x8(%rsp),%r15
mov    %r15,%rdi
call   1070 <time@plt>
lea    0xe80(%rip),%rdi
lea    0xe86(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1040 <ctime@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1050 <fputs@plt>
lea    0xe67(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"./server.log\00"
@.str.1 = [3 x i8] c"a+\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [6 x i8] c"\09 %s\0A\00"
define void @logger(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32*
store i8* %0, i8** %2
%5 = call i32 @time(i64* %3)
%6 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 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** %4
%7 = load i32*, i32** %4
%8 = call i8* @ctime(i64* %3)
%9 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = load i32*, i32** %4
%11 = load i8*, i8** %2
%12 = call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%13 = load i32*, i32** %4
%14 = call i32 @fclose(i32* %13)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"./server.log\00"
@.str.1 = [3 x i8] c"a+\00"
@.str.3 = [6 x i8] c"\09 %s\0A\00"
define void @logger(i8* %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to i8*
%4 = call i32 @time(i64* %2)
%5 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = call i8* @ctime(i64* %2)
%7 = call i32 @fputs(i8* %6, i32* %5)
%8 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%9 = call i32 @fclose(i32* %5)
ret void
}