#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 */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void write_to_log(char *write_sentence) {
  char dt[275];
  char date[22];
  struct tm tm;
  time_t current_time;
  current_time = time(NULL);
  tm = *localtime(&current_time);
  strftime(dt, sizeof dt, "%d/%m/%Y %H:%M:%S ", &tm);
  strftime(date, sizeof date, "%Y-%m-%d-server.log", &tm);
  strcat(date, "\0");
  FILE *fptr;
  fptr = fopen(date, "a");
  strcat(dt, write_sentence);
  fprintf(fptr, "%s", dt);
  fclose(fptr);
}


x86 assembly (clang, -O0):
<write_to_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x14c(%rbp)
lea    -0x14c(%rbp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%eax
mov    %eax,-0x148(%rbp)
lea    -0x120(%rbp),%rdi
mov    $0x113,%esi
lea    0xe4b(%rip),%rdx
lea    -0x148(%rbp),%rcx
call   1070 <strftime@plt>
lea    -0x140(%rbp),%rdi
mov    $0x16,%esi
lea    0xe3f(%rip),%rdx
lea    -0x148(%rbp),%rcx
call   1070 <strftime@plt>
lea    -0x140(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1090 <strcat@plt>
lea    -0x140(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x158(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1090 <strcat@plt>
mov    -0x158(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xdf7(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x158(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_to_log>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x148,%rsp
mov    %rdi,%r14
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
lea    0xe5d(%rip),%rdx
lea    0x30(%rsp),%r15
lea    0x8(%rsp),%r12
mov    %r15,%rdi
mov    $0x113,%esi
mov    %r12,%rcx
call   1070 <strftime@plt>
lea    0xe4f(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x16,%esi
mov    %r12,%rcx
call   1070 <strftime@plt>
lea    0xe49(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcat@plt>
lea    0xe38(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %r14,%rsi
call   1090 <strcat@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <fputs@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x148,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [19 x i8] c"%d/%m/%Y %H:%M:%S \00"
@.str.1 = [20 x i8] c"%Y-%m-%d-server.log\00"
@.str.2 = [2 x i8] zeroinitializer
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [3 x i8] c"%s\00"
define void @write_to_log(i8* %0) {
%2 = alloca i8*
%3 = alloca [275 x i8]
%4 = alloca [22 x i8]
%5 = alloca %struct.tm
%6 = alloca i32
%7 = alloca i32*
store i8* %0, i8** %2
%8 = call i32 @time(i32* null)
store i32 %8, i32* %6
%9 = call %struct.tm* @localtime(i32* %6)
%10 = bitcast %struct.tm* %5 to i8*
%11 = bitcast %struct.tm* %9 to i8*
%12 = getelementptr inbounds [275 x i8], [275 x i8]* %3, i64 0, i64 0
%13 = call i32 @strftime(i8* %12, i32 275, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %5)
%14 = getelementptr inbounds [22 x i8], [22 x i8]* %4, i64 0, i64 0
%15 = call i32 @strftime(i8* %14, i32 22, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %5)
%16 = getelementptr inbounds [22 x i8], [22 x i8]* %4, i64 0, i64 0
%17 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%18 = getelementptr inbounds [22 x i8], [22 x i8]* %4, i64 0, i64 0
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %19, i32** %7
%20 = getelementptr inbounds [275 x i8], [275 x i8]* %3, i64 0, i64 0
%21 = load i8*, i8** %2
%22 = call i32 @strcat(i8* %20, i8* %21)
%23 = load i32*, i32** %7
%24 = getelementptr inbounds [275 x i8], [275 x i8]* %3, i64 0, i64 0
%25 = call i32 @fprintf(i32* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %24)
%26 = load i32*, i32** %7
%27 = call i32 @fclose(i32* %26)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [19 x i8] c"%d/%m/%Y %H:%M:%S \00"
@.str.1 = [20 x i8] c"%Y-%m-%d-server.log\00"
@.str.2 = [2 x i8] zeroinitializer
@.str.3 = [2 x i8] c"a\00"
define void @write_to_log(i8* %0) {
%2 = alloca [275 x i8]
%3 = alloca [22 x i8]
%4 = alloca %struct.tm
%5 = alloca i32
%6 = getelementptr inbounds [275 x i8], [275 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 0
%8 = bitcast %struct.tm* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = tail call i32 @time(i32* null)
store i32 %10, i32* %5
%11 = call %struct.tm* @localtime(i32* %5)
%12 = getelementptr %struct.tm, %struct.tm* %11, i64 0, i32 0
%13 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%14 = load i32, i32* %12
store i32 %14, i32* %13
%15 = call i32 @strftime(i8* %6, i32 275, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %4)
%16 = call i32 @strftime(i8* %7, i32 22, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %4)
%17 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @strcat(i8* %6, i8* %0)
%20 = call i32 @fputs(i8* %6, i32* %18)
%21 = call i32 @fclose(i32* %18)
ret void
}