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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *);
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int gl_gllog_add_alt(char *str, char *logfile) {
  FILE *f;
  time_t t;
  char buf[300], *p;
  t = time(0);
  strftime(buf, 300, "%a %b %d %T %Y", localtime(&t));
  f = fopen(logfile, "a");
  if (!f)
    return 0;
  fprintf(f, "%s %s\n", buf, str);
  fclose(f);
  return 1;
}


x86 assembly (clang, -O0):
<gl_gllog_add_alt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,-0x24(%rbp)
lea    -0x150(%rbp),%rax
mov    %rax,-0x160(%rbp)
lea    -0x24(%rbp),%rdi
call   1030 <localtime@plt>
mov    -0x160(%rbp),%rdi
mov    %eax,%ecx
mov    $0x12c,%esi
lea    0xe57(%rip),%rdx
call   1070 <strftime@plt>
mov    -0x18(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11d9 <gl_gllog_add_alt+0x79>
movl   $0x0,-0x4(%rbp)
jmp    1204 <gl_gllog_add_alt+0xa4>
mov    -0x20(%rbp),%rdi
lea    -0x150(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe22(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gl_gllog_add_alt>:
push   %rbp
push   %r14
push   %rbx
sub    $0x140,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %ebp,%ebp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
lea    0xe71(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x12c,%esi
mov    %eax,%ecx
call   1070 <strftime@plt>
lea    0xe68(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     11db <gl_gllog_add_alt+0x7b>
mov    %rax,%rbx
lea    0xe53(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %rax,%rdi
mov    %r14,%rcx
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x140,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"%a %b %d %T %Y\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [7 x i8] c"%s %s\0A\00"
define i32 @gl_gllog_add_alt(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca [300 x i8]
%9 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%10 = call i32 @time(i32 0)
store i32 %10, i32* %7
%11 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 0
%12 = call i32 @localtime(i32* %7)
%13 = call i32 @strftime(i8* %11, i32 300, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i8*, i8** %5
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %15, i32** %6
%16 = load i32*, i32** %6
%17 = icmp ne i32* %16, null
br i1 %17, label %19, label %18
18: ; preds = %2
store i32 0, i32* %3
br label %26
19: ; preds = %2
%20 = load i32*, i32** %6
%21 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 0
%22 = load i8*, i8** %4
%23 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %21, i8* %22)
%24 = load i32*, i32** %6
%25 = call i32 @fclose(i32* %24)
store i32 1, i32* %3
br label %26
26: ; preds = %19, %18
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [15 x i8] c"%a %b %d %T %Y\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [7 x i8] c"%s %s\0A\00"
define i32 @gl_gllog_add_alt(i8* %0, i8* nocapture %1) {
%3 = alloca i32
%4 = alloca [300 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [300 x i8], [300 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @time(i32 0)
store i32 %7, i32* %3
%8 = call i32 @localtime(i32* %3)
%9 = call i32 @strftime(i8* %6, i32 300, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %6, i8* %0)
%14 = call i32 @fclose(i32* %10)
br label %15
15: ; preds = %2, %12
%16 = phi i32 [ 1, %12 ], [ 0, %2 ]
ret i32 %16
}