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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int LogFile_printTime(char *FileName, double time_spent, int seconds) {
  char buf[256];
  snprintf(buf, sizeof buf, "%s%s", FileName, ".log");
  FILE *LogFile;
  if ((LogFile = fopen(buf, "a")) == NULL) {
    printf("ERROR! unable to open .log file!\n");
    exit(1);
  }
  fprintf(LogFile, "Run Time %g seconds\n", time_spent);
  fprintf(LogFile, "user : %d secs\n", seconds);
  fclose(LogFile);
  return 0;
}


x86 assembly (clang, -O0):
<LogFile_printTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x100,%esi
lea    0xe72(%rip),%rdx
lea    0xe70(%rip),%r8
call   1050 <snprintf@plt>
lea    -0x120(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x128(%rbp)
cmp    $0x0,%rax
jne    11d4 <LogFile_printTime+0x74>
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x128(%rbp),%rdi
cvttsd2si -0x10(%rbp),%edx
lea    0xe47(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x128(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe46(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x128(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LogFile_printTime>:
push   %rbp
push   %rbx
sub    $0x118,%rsp
mov    %esi,%ebp
movsd  %xmm0,0x8(%rsp)
mov    %rdi,%rcx
lea    0xe85(%rip),%rdx
lea    0xe83(%rip),%r8
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1050 <snprintf@plt>
lea    0xe6f(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     11e5 <LogFile_printTime+0x85>
mov    %rax,%rbx
cvttsd2si 0x8(%rsp),%edx
lea    0xe54(%rip),%rsi
mov    %rax,%rdi
call   1060 <fprintf@plt>
lea    0xe5a(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe45(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [5 x i8] c".log\00"
@.str.2 = [2 x i8] c"a\00"
@.str.3 = [34 x i8] c"ERROR! unable to open .log file!\0A\00"
@.str.4 = [21 x i8] c"Run Time %g seconds\0A\00"
@.str.5 = [16 x i8] c"user : %d secs\0A\00"
define i32 @LogFile_printTime(i8* %0, double %1, i32 %2) {
%4 = alloca i8*
%5 = alloca double
%6 = alloca i32
%7 = alloca [256 x i8]
%8 = alloca i32*
store i8* %0, i8** %4
store double %1, double* %5
store i32 %2, i32* %6
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%10 = load i8*, i8** %4
%11 = call i32 @snprintf(i8* %9, i32 256, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %13, i32** %8
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %3
%16 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %3
%19 = load i32*, i32** %8
%20 = load double, double* %5
%21 = fptosi double %20 to i32
%22 = call i32 @fprintf(i32* %19, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %21)
%23 = load i32*, i32** %8
%24 = load i32, i32* %6
%25 = call i32 @fprintf(i32* %23, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %24)
%26 = load i32*, i32** %8
%27 = call i32 @fclose(i32* %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [5 x i8] c".log\00"
@.str.2 = [2 x i8] c"a\00"
@.str.4 = [21 x i8] c"Run Time %g seconds\0A\00"
@.str.5 = [16 x i8] c"user : %d secs\0A\00"
@str = [33 x i8] c"ERROR! unable to open .log file!\00"
define i32 @LogFile_printTime(i8* %0, double %1, i32 %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = call i32 @snprintf(i8* %5, i32 256, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %3
%13 = fptosi double %1 to i32
%14 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %13)
%15 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %2)
%16 = call i32 @fclose(i32* %7)
ret i32 0
}