#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*/ asctime(struct tm *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(char *, int, scalar_t__, int /*<<< orphan*/ *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
scalar_t__ strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void update_log(char *file_name) {
  time_t rawtime;
  struct tm *timeinfo;
  time(&rawtime);
  timeinfo = localtime(&rawtime);
  char timestuff[50];
  strcpy(timestuff, asctime(timeinfo));
  FILE *file_pointer = NULL;
  file_pointer = fopen("ftserver.log", "a");
  fwrite(timestuff, sizeof(char), strlen(timestuff) - 1, file_pointer);
  fwrite(" \"", sizeof(char), strlen(" \""), file_pointer);
  fwrite(file_name, sizeof(char), strlen(file_name), file_pointer);
  fwrite("\"\n", sizeof(char), strlen("\"\n"), file_pointer);
  fclose(file_pointer);
}


x86 assembly (clang, -O0):
<update_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
call   1080 <time@plt>
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <asctime@plt>
mov    -0x70(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
movq   $0x0,-0x58(%rbp)
lea    0xe33(%rip),%rdi
lea    0xe39(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    -0x50(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x68(%rbp),%rdi
mov    %rax,%rdx
sub    $0x1,%rdx
mov    -0x58(%rbp),%rcx
mov    $0x1,%esi
call   10a0 <fwrite@plt>
lea    0xe01(%rip),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdx
mov    -0x58(%rbp),%rcx
lea    0xdee(%rip),%rdi
mov    $0x1,%esi
call   10a0 <fwrite@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x60(%rbp),%rdi
mov    %rax,%rdx
mov    -0x58(%rbp),%rcx
mov    $0x1,%esi
call   10a0 <fwrite@plt>
lea    0xdba(%rip),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdx
mov    -0x58(%rbp),%rcx
lea    0xda7(%rip),%rdi
mov    $0x1,%esi
call   10a0 <fwrite@plt>
mov    -0x58(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_log>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rdi,%r14
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
mov    %rax,%rdi
call   1070 <asctime@plt>
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    0xe41(%rip),%rdi
lea    0xe47(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1060 <strlen@plt>
lea    -0x1(%rax),%rdx
mov    %r15,%rdi
mov    $0x1,%esi
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xe1e(%rip),%rdi
mov    $0x2,%edx
mov    $0x1,%esi
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xded(%rip),%rdi
mov    $0x2,%edx
mov    $0x1,%esi
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [13 x i8] c"ftserver.log\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [3 x i8] c" \22\00"
@.str.3 = [3 x i8] c"\22\0A\00"
define void @update_log(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca %struct.tm*
%5 = alloca [50 x i8]
%6 = alloca i32*
store i8* %0, i8** %2
%7 = call i32 @time(i32* %3)
%8 = call %struct.tm* @localtime(i32* %3)
store %struct.tm* %8, %struct.tm** %4
%9 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%10 = load %struct.tm*, %struct.tm** %4
%11 = call i32 @asctime(%struct.tm* %10)
%12 = call i32 @strcpy(i8* %9, i32 %11)
store i32* null, i32** %6
%13 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %6
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%15 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%16 = call i64 @strlen(i8* %15)
%17 = sub nsw i64 %16, 1
%18 = load i32*, i32** %6
%19 = call i32 @fwrite(i8* %14, i32 1, i64 %17, i32* %18)
%20 = call i64 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32*, i32** %6
%22 = call i32 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 1, i64 %20, i32* %21)
%23 = load i8*, i8** %2
%24 = load i8*, i8** %2
%25 = call i64 @strlen(i8* %24)
%26 = load i32*, i32** %6
%27 = call i32 @fwrite(i8* %23, i32 1, i64 %25, i32* %26)
%28 = call i64 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%29 = load i32*, i32** %6
%30 = call i32 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 1, i64 %28, i32* %29)
%31 = load i32*, i32** %6
%32 = call i32 @fclose(i32* %31)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [13 x i8] c"ftserver.log\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [3 x i8] c" \22\00"
@.str.3 = [3 x i8] c"\22\0A\00"
define void @update_log(i8* nocapture %0) {
%2 = alloca i32
%3 = alloca [50 x i8]
%4 = bitcast i32* %2 to i8*
%5 = call i32 @time(i32* %2)
%6 = call %struct.tm* @localtime(i32* %2)
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%8 = call i32 @asctime(%struct.tm* %6)
%9 = call i32 @strcpy(i8* %7, i32 %8)
%10 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = call i64 @strlen(i8* %7)
%12 = add nsw i64 %11, -1
%13 = call i32 @fwrite(i8* %7, i32 1, i64 %12, i32* %10)
%14 = call i32 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 1, i64 2, i32* %10)
%15 = call i64 @strlen(i8* dereferenceable(1) %0)
%16 = call i32 @fwrite(i8* %0, i32 1, i64 %15, i32* %10)
%17 = call i32 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 1, i64 2, i32* %10)
%18 = call i32 @fclose(i32* %10)
ret void
}