#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*/ ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, int);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void output_log(int code) {
  time_t rawtime;
  struct tm *timeinfo;
  char logname[34] = "/var/log/lwsfc/lwsfc.log-", date[9];
  time(&rawtime);
  timeinfo = localtime(&rawtime);
  strftime(date, 9, "%Y%m%d", timeinfo);
  strcat(logname, date);
  FILE *fp = fopen(logname, "a");
  time_t timep;
  time(&timep);
  char p[32];
  strcpy(p, ctime(&timep));
  p[strlen(p) - 1] = 0;
  fprintf(fp, "[%s]: %d\n", p, code);
  fclose(fp);
}


x86 assembly (clang, -O0):
<output_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe37(%rip),%rsi
mov    $0x22,%edx
call   1090 <memcpy@plt>
lea    -0x8(%rbp),%rdi
call   10a0 <time@plt>
lea    -0x8(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
lea    -0x49(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x9,%esi
lea    0xe25(%rip),%rdx
call   10b0 <strftime@plt>
lea    -0x40(%rbp),%rdi
lea    -0x49(%rbp),%rsi
call   10d0 <strcat@plt>
lea    -0x40(%rbp),%rdi
lea    0xe0f(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x58(%rbp)
lea    -0x5c(%rbp),%rdi
call   10a0 <time@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    -0x5c(%rbp),%rdi
call   1060 <ctime@plt>
mov    -0x88(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    -0x80(%rbp),%rdi
call   1070 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x80(%rbp,%rax,1)
mov    -0x58(%rbp),%rdi
lea    -0x80(%rbp),%rdx
mov    -0x4(%rbp),%ecx
lea    0xdb8(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x58(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_log>:
push   %rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %edi,%r14d
movaps 0xe5e(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe42(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movw   $0x0,0x30(%rsp)
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1090 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
lea    0xe3c(%rip),%rdx
lea    0x37(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x9,%esi
mov    %rax,%rcx
call   10a0 <strftime@plt>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10c0 <strcat@plt>
lea    0xe17(%rip),%rsi
mov    %rbp,%rdi
call   10b0 <fopen@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%rbp
mov    %rbp,%rdi
call   1090 <time@plt>
mov    %rbp,%rdi
call   1060 <ctime@plt>
lea    0x40(%rsp),%rbp
mov    %rbp,%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
mov    %rbp,%rdi
call   1070 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbp,1)
lea    0xdd4(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    %r14d,%ecx
call   1080 <fprintf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@__const.output_log.logname = [34 x i8] c"/var/log/lwsfc/lwsfc.log-\00\00\00\00\00\00\00\00\00"
@.str = [7 x i8] c"%Y%m%d\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [10 x i8] c"[%s]: %d\0A\00"
define void @output_log(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.tm*
%5 = alloca [34 x i8]
%6 = alloca [9 x i8]
%7 = alloca i32*
%8 = alloca i32
%9 = alloca [32 x i8]
store i32 %0, i32* %2
%10 = bitcast [34 x i8]* %5 to i8*
%11 = call i32 @time(i32* %3)
%12 = call %struct.tm* @localtime(i32* %3)
store %struct.tm* %12, %struct.tm** %4
%13 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 0
%14 = load %struct.tm*, %struct.tm** %4
%15 = call i32 @strftime(i8* %13, i32 9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %struct.tm* %14)
%16 = getelementptr inbounds [34 x i8], [34 x i8]* %5, i64 0, i64 0
%17 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 0
%18 = call i32 @strcat(i8* %16, i8* %17)
%19 = getelementptr inbounds [34 x i8], [34 x i8]* %5, i64 0, i64 0
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %7
%21 = call i32 @time(i32* %8)
%22 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%23 = call i32 @ctime(i32* %8)
%24 = call i32 @strcpy(i8* %22, i32 %23)
%25 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%26 = call i32 @strlen(i8* %25)
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 %28
store i8 0, i8* %29
%30 = load i32*, i32** %7
%31 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%32 = load i32, i32* %2
%33 = call i32 @fprintf(i32* %30, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %31, i32 %32)
%34 = load i32*, i32** %7
%35 = call i32 @fclose(i32* %34)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@__const.output_log.logname = [34 x i8] c"/var/log/lwsfc/lwsfc.log-\00\00\00\00\00\00\00\00\00"
@.str = [7 x i8] c"%Y%m%d\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [10 x i8] c"[%s]: %d\0A\00"
define void @output_log(i32 %0) {
%2 = alloca i32
%3 = alloca [34 x i8]
%4 = alloca [9 x i8]
%5 = alloca i32
%6 = alloca [32 x i8]
%7 = bitcast i32* %2 to i8*
%8 = getelementptr inbounds [34 x i8], [34 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%10 = call i32 @time(i32* %2)
%11 = call %struct.tm* @localtime(i32* %2)
%12 = call i32 @strftime(i8* %9, i32 9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %struct.tm* %11)
%13 = call i32 @strcat(i8* %8, i8* %9)
%14 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = bitcast i32* %5 to i8*
%16 = call i32 @time(i32* %5)
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%18 = call i32 @ctime(i32* %5)
%19 = call i32 @strcpy(i8* %17, i32 %18)
%20 = call i32 @strlen(i8* %17)
%21 = add nsw i32 %20, -1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 %22
store i8 0, i8* %23
%24 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %17, i32 %0)
%25 = call i32 @fclose(i32* %14)
ret void
}