#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*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void sys_log(char *str) {
  FILE *fp;
  char content[100] = {0};
  struct tm *timeinfo;
  time_t boxtime = 0;
  time(&boxtime);
  timeinfo = localtime(&boxtime);
  fp = fopen("/tmp/usbmounts/sda1/www/cgi-bin/box/sys_log", "a");
  sprintf(content, "%s ----- %s\n", asctime(timeinfo), str);
  fputs(content, fp);
  fclose(fp);
}


x86 assembly (clang, -O0):
<sys_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1070 <memset@plt>
movl   $0x0,-0x8c(%rbp)
lea    -0x8c(%rbp),%rdi
call   1080 <time@plt>
lea    -0x8c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x88(%rbp)
lea    0xe31(%rip),%rdi
lea    0xe56(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x80(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x88(%rbp),%rdi
call   1050 <asctime@plt>
mov    -0x98(%rbp),%rdi
mov    %rax,%rdx
mov    -0x8(%rbp),%rcx
lea    0xe23(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <fputs@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sys_log>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
mov    %rax,%r15
lea    0xe31(%rip),%rdi
lea    0xe56(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1050 <asctime@plt>
lea    0xe41(%rip),%rsi
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    %rax,%rdx
mov    %r14,%rcx
call   1090 <sprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <fputs@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [44 x i8] c"/tmp/usbmounts/sda1/www/cgi-bin/box/sys_log\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [13 x i8] c"%s ----- %s\0A\00"
define void @sys_log(i8* %0) {
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = call i32 @time(i32* %3)
%7 = call %struct.tm* @localtime(i32* %3)
%8 = call i32* @fopen(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = call i8* @asctime(%struct.tm* %7)
%10 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %9, i8* %0)
%11 = call i32 @fputs(i8* %4, i32* %8)
%12 = call i32 @fclose(i32* %8)
ret void
}