#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, double *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ unlink(char *);
void saveTimesFile(double totaltime) {
  FILE *in, *out;
  double prevtimes;
  char filename[100] = "times.tmp_lzma_compressiontimes.fari.txt";
  if ((in = fopen(filename, "rb")) == NULL) {
    prevtimes = 0.0;
  } else {
    fscanf(in, "%lf", &prevtimes);
    fclose(in);
  }
  unlink(filename);
  if ((out = fopen(filename, "w")) == NULL) {
    printf("Cannot open file %s for storing running times\n", filename);
    return;
  }
  fprintf(out, "%lf seconds (acumulated compression user-time of lzma coder)\n",
          totaltime + prevtimes);
  fprintf(out, "%lf seconds (*last run* compression user-time of lzma coder)\n",
          totaltime);
  fclose(out);
  printf("[compression user-time = %3.10lf sec. (acum time = %3.10lfsec)]\n",
         totaltime, prevtimes + totaltime);
}


x86 assembly (clang, -O0):
<saveTimesFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  %xmm0,-0x8(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xe72(%rip),%rsi
mov    $0x64,%edx
call   1080 <memcpy@plt>
lea    -0x90(%rbp),%rdi
lea    0xebe(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11c6 <saveTimesFile+0x56>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11e3 <saveTimesFile+0x73>
mov    -0x10(%rbp),%rdi
lea    0xe96(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1060 <fscanf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x90(%rbp),%rdi
call   1030 <unlink@plt>
lea    -0x90(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    122a <saveTimesFile+0xba>
lea    -0x90(%rbp),%rsi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    127f <saveTimesFile+0x10f>
mov    -0x18(%rbp),%rdi
movsd  -0x8(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
lea    0xe5d(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%rdi
movsd  -0x8(%rbp),%xmm0
lea    0xe86(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movsd  -0x8(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
addsd  -0x8(%rbp),%xmm1
lea    0xea0(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<saveTimesFile>:
push   %rbx
sub    $0x80,%rsp
movsd  %xmm0,(%rsp)
movaps 0xedc(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xec0(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xea4(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe88(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe6c(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movapd 0xe4f(%rip),%xmm0
movapd %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
lea    0xe9e(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     11f6 <saveTimesFile+0x96>
mov    %rax,%rbx
lea    0xe88(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
call   1060 <fscanf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    11ff <saveTimesFile+0x9f>
movq   $0x0,0x8(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <unlink@plt>
lea    0xe58(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     1278 <saveTimesFile+0x118>
mov    %rax,%rbx
movsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
lea    0xe67(%rip),%rsi
mov    %rax,%rdi
call   1070 <fprintf@plt>
lea    0xe96(%rip),%rsi
mov    %rbx,%rdi
movsd  (%rsp),%xmm0
call   1070 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
movsd  0x8(%rsp),%xmm1
movsd  (%rsp),%xmm0
addsd  %xmm0,%xmm1
lea    0xea9(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
jmp    128b <saveTimesFile+0x12b>
lea    0xdee(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.saveTimesFile.filename = [100 x i8] c"times.tmp_lzma_compressiontimes.fari.txt\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [3 x i8] c"rb\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [47 x i8] c"Cannot open file %s for storing running times\0A\00"
@.str.4 = [62 x i8] c"%lf seconds (acumulated compression user-time of lzma coder)\0A\00"
@.str.5 = [62 x i8] c"%lf seconds (*last run* compression user-time of lzma coder)\0A\00"
@.str.6 = [65 x i8] c"[compression user-time = %3.10lf sec. (acum time = %3.10lfsec)]\0A\00"
define void @saveTimesFile(double %0) {
%2 = alloca double
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca double
%6 = alloca [100 x i8]
store double %0, double* %2
%7 = bitcast [100 x i8]* %6 to i8*
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %3
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %12
11: ; preds = %1
store double 0.000000e+00, double* %5
br label %17
12: ; preds = %1
%13 = load i32*, i32** %3
%14 = call i32 @fscanf(i32* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %5)
%15 = load i32*, i32** %3
%16 = call i32 @fclose(i32* %15)
br label %17
17: ; preds = %12, %11
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%19 = call i32 @unlink(i8* %18)
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %21, i32** %4
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %26
23: ; preds = %17
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* %24)
br label %42
26: ; preds = %17
%27 = load i32*, i32** %4
%28 = load double, double* %2
%29 = load double, double* %5
%30 = fadd double %28, %29
%31 = call i32 @fprintf(i32* %27, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0), double %30)
%32 = load i32*, i32** %4
%33 = load double, double* %2
%34 = call i32 @fprintf(i32* %32, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.5, i64 0, i64 0), double %33)
%35 = load i32*, i32** %4
%36 = call i32 @fclose(i32* %35)
%37 = load double, double* %2
%38 = load double, double* %5
%39 = load double, double* %2
%40 = fadd double %38, %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.6, i64 0, i64 0), double %37, double %40)
br label %42
42: ; preds = %26, %23
ret void
}

LLVM IR (-O2):
@__const.saveTimesFile.filename = [100 x i8] c"times.tmp_lzma_compressiontimes.fari.txt\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [3 x i8] c"rb\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [47 x i8] c"Cannot open file %s for storing running times\0A\00"
@.str.4 = [62 x i8] c"%lf seconds (acumulated compression user-time of lzma coder)\0A\00"
@.str.5 = [62 x i8] c"%lf seconds (*last run* compression user-time of lzma coder)\0A\00"
@.str.6 = [65 x i8] c"[compression user-time = %3.10lf sec. (acum time = %3.10lfsec)]\0A\00"
define void @saveTimesFile(double %0) {
%2 = alloca double
%3 = alloca [100 x i8]
%4 = bitcast double* %2 to i8*
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %9
8: ; preds = %1
store double 0.000000e+00, double* %2
br label %12
9: ; preds = %1
%10 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%11 = call i32 @fclose(i32* %6)
br label %12
12: ; preds = %9, %8
%13 = call i32 @unlink(i8* %5)
%14 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* %5)
br label %27
18: ; preds = %12
%19 = load double, double* %2
%20 = fadd double %19, %0
%21 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0), double %20)
%22 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.5, i64 0, i64 0), double %0)
%23 = call i32 @fclose(i32* %14)
%24 = load double, double* %2
%25 = fadd double %24, %0
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.6, i64 0, i64 0), double %0, double %25)
br label %27
27: ; preds = %18, %16
ret void
}