#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 DBL_DIG;
char *asctime(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char *format_file_full_path(char const *, char *, int, int, unsigned int,
                            double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void write_mass_windowing_results(const char *path, const int *window_sizes,
                                  const unsigned long *mass,
                                  int window_sizes_count, double probability,
                                  int nrealizations, int rows, int columns,
                                  unsigned int seed) {
  int i;
  time_t current_time;
  char *file_full_path;
  FILE *file_handler;
  current_time = time(NULL);
  file_full_path = format_file_full_path(path, "mass_windowing", rows, columns,
                                         seed, probability);
  file_handler = fopen(file_full_path, "w");
  fprintf(file_handler, ";rows:%d\n", rows);
  fprintf(file_handler, ";columns:%d\n", columns);
  fprintf(file_handler, ";probability:%.*e\n", DBL_DIG - 1, probability);
  fprintf(file_handler, ";nrealizations:%d\n", nrealizations);
  fprintf(file_handler, ";seed:%u\n", seed);
  fprintf(file_handler, ";date:%s", asctime(localtime(&current_time)));
  for (i = 0; i < window_sizes_count; i++) {
    fprintf(file_handler, "%d,%lu,%.*e\n", window_sizes[i], mass[i],
            DBL_DIG - 1, ((double)mass[i]) / nrealizations);
  }
  fclose(file_handler);
  free(file_full_path);
}


x86 assembly (clang, -O0):
<write_mass_windowing_results>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9d,-0x30(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%edx
mov    0x10(%rbp),%ecx
mov    0x18(%rbp),%r8d
movsd  -0x28(%rbp),%xmm0
lea    0xe50(%rip),%rsi
call   1090 <format_file_full_path@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x30(%rbp),%edx
lea    0xe36(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x48(%rbp),%rdi
mov    0x10(%rbp),%edx
lea    0xe2b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x48(%rbp),%rdi
mov    0x2dc6(%rip),%rax
mov    (%rax),%edx
sub    $0x1,%edx
movsd  -0x28(%rbp),%xmm0
lea    0xe15(%rip),%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
mov    -0x48(%rbp),%rdi
mov    -0x2c(%rbp),%edx
lea    0xe13(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x48(%rbp),%rdi
mov    0x18(%rbp),%edx
lea    0xe11(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x38(%rbp),%rdi
call   1040 <localtime@plt>
mov    %eax,%edi
call   1060 <asctime@plt>
mov    -0x50(%rbp),%rdi
mov    %rax,%rdx
lea    0xdee(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1315 <write_mass_windowing_results+0x195>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x18(%rbp),%rax
mov    (%rax,%rcx,8),%rcx
mov    0x2d26(%rip),%rax
mov    (%rax),%r8d
add    $0xffffffff,%r8d
movq   %rcx,%xmm0
movaps 0xd2b(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0xd2f(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xd81(%rip),%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1298 <write_mass_windowing_results+0x118>
mov    -0x48(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_mass_windowing_results>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,%r13d
mov    %r8d,0x14(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %ecx,0x18(%rsp)
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%rbx
mov    0x60(%rsp),%ebp
mov    0x68(%rsp),%r15d
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,0x1c(%rsp)
lea    0xe5c(%rip),%rsi
mov    %rbx,%rdi
mov    %r13d,%edx
mov    %ebp,%ecx
mov    %r15d,%r8d
movsd  0x8(%rsp),%xmm0
call   1090 <format_file_full_path@plt>
lea    0xe4e(%rip),%rsi
mov    %rax,0x20(%rsp)
mov    %rax,%rdi
call   10a0 <fopen@plt>
mov    %rax,%rbx
lea    0xe39(%rip),%rsi
mov    %rax,%rdi
mov    %r13d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0xe2f(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    0x14(%rsp),%ebp
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2dc5(%rip),%rax
mov    (%rax),%edx
add    $0xffffffff,%edx
lea    0xe19(%rip),%rsi
mov    %rbx,%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1070 <fprintf@plt>
lea    0xe15(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0xe15(%rip),%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0x1c(%rsp),%rdi
call   1040 <localtime@plt>
mov    %eax,%edi
call   1060 <asctime@plt>
lea    0xdfa(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x18(%rsp),%eax
test   %eax,%eax
jle    1303 <write_mass_windowing_results+0x183>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %eax,%ebp
xor    %r15d,%r15d
lea    0xdd5(%rip),%r13
nopl   0x0(%rax)
mov    (%r12,%r15,4),%edx
mov    (%r14,%r15,8),%rcx
mov    0x2d29(%rip),%rax
mov    (%rax),%r8d
add    $0xffffffff,%r8d
movq   %rcx,%xmm1
punpckldq 0xd2d(%rip),%xmm1
subpd  0xd35(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
divsd  0x8(%rsp),%xmm0
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
add    $0x1,%r15
cmp    %r15,%rbp
jne    12b0 <write_mass_windowing_results+0x130>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"mass_windowing\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [10 x i8] c";rows:%d\0A\00"
@.str.3 = [13 x i8] c";columns:%d\0A\00"
@.str.4 = [19 x i8] c";probability:%.*e\0A\00"
@DBL_DIG = global i32 0
@.str.5 = [19 x i8] c";nrealizations:%d\0A\00"
@.str.6 = [10 x i8] c";seed:%u\0A\00"
@.str.7 = [9 x i8] c";date:%s\00"
@.str.8 = [13 x i8] c"%d,%lu,%.*e\0A\00"
define void @write_mass_windowing_results(i8* %0, i32* %1, i64* %2, i32 %3, double %4, i32 %5, i32 %6, i32 %7, i32 %8) {
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca i64*
%13 = alloca i32
%14 = alloca double
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i8*
%22 = alloca i32*
store i8* %0, i8** %10
store i32* %1, i32** %11
store i64* %2, i64** %12
store i32 %3, i32* %13
store double %4, double* %14
store i32 %5, i32* %15
store i32 %6, i32* %16
store i32 %7, i32* %17
store i32 %8, i32* %18
%23 = call i32 @time(i32* null)
store i32 %23, i32* %20
%24 = load i8*, i8** %10
%25 = load i32, i32* %16
%26 = load i32, i32* %17
%27 = load i32, i32* %18
%28 = load double, double* %14
%29 = call i8* @format_file_full_path(i8* %24, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %26, i32 %27, double %28)
store i8* %29, i8** %21
%30 = load i8*, i8** %21
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %31, i32** %22
%32 = load i32*, i32** %22
%33 = load i32, i32* %16
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = load i32*, i32** %22
%36 = load i32, i32* %17
%37 = call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = load i32*, i32** %22
%39 = load i32, i32* @DBL_DIG
%40 = sub nsw i32 %39, 1
%41 = load double, double* %14
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %40, double %41)
%43 = load i32*, i32** %22
%44 = load i32, i32* %15
%45 = call i32 (i32*, i8*, ...) @fprintf(i32* %43, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %44)
%46 = load i32*, i32** %22
%47 = load i32, i32* %18
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %46, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %47)
%49 = load i32*, i32** %22
%50 = call i32 @localtime(i32* %20)
%51 = call i8* @asctime(i32 %50)
%52 = call i32 (i32*, i8*, ...) @fprintf(i32* %49, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %51)
store i32 0, i32* %19
br label %53
53: ; preds = %81, %9
%54 = load i32, i32* %19
%55 = load i32, i32* %13
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %84
57: ; preds = %53
%58 = load i32*, i32** %22
%59 = load i32*, i32** %11
%60 = load i32, i32* %19
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* %59, i64 %61
%63 = load i32, i32* %62
%64 = load i64*, i64** %12
%65 = load i32, i32* %19
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i64, i64* %64, i64 %66
%68 = load i64, i64* %67
%69 = load i32, i32* @DBL_DIG
%70 = sub nsw i32 %69, 1
%71 = load i64*, i64** %12
%72 = load i32, i32* %19
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i64, i64* %71, i64 %73
%75 = load i64, i64* %74
%76 = uitofp i64 %75 to double
%77 = load i32, i32* %15
%78 = sitofp i32 %77 to double
%79 = fdiv double %76, %78
%80 = call i32 (i32*, i8*, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %63, i64 %68, i32 %70, double %79)
br label %81
81: ; preds = %57
%82 = load i32, i32* %19
%83 = add nsw i32 %82, 1
store i32 %83, i32* %19
br label %53
84: ; preds = %53
%85 = load i32*, i32** %22
%86 = call i32 @fclose(i32* %85)
%87 = load i8*, i8** %21
%88 = call i32 @free(i8* %87)
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"mass_windowing\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [10 x i8] c";rows:%d\0A\00"
@.str.3 = [13 x i8] c";columns:%d\0A\00"
@.str.4 = [19 x i8] c";probability:%.*e\0A\00"
@DBL_DIG = global i32 0
@.str.5 = [19 x i8] c";nrealizations:%d\0A\00"
@.str.6 = [10 x i8] c";seed:%u\0A\00"
@.str.7 = [9 x i8] c";date:%s\00"
@.str.8 = [13 x i8] c"%d,%lu,%.*e\0A\00"
define void @write_mass_windowing_results(i8* %0, i32* nocapture %1, i64* nocapture %2, i32 %3, double %4, i32 %5, i32 %6, i32 %7, i32 %8) {
%10 = alloca i32
%11 = bitcast i32* %10 to i8*
%12 = tail call i32 @time(i32* null)
store i32 %12, i32* %10
%13 = tail call i8* @format_file_full_path(i8* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7, i32 %8, double %4)
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%16 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%17 = load i32, i32* @DBL_DIG
%18 = add nsw i32 %17, -1
%19 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %18, double %4)
%20 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %5)
%21 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %8)
%22 = call i32 @localtime(i32* %10)
%23 = call i8* @asctime(i32 %22)
%24 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %23)
%25 = icmp sgt i32 %3, 0
br i1 %25, label %26, label %42
26: ; preds = %9
%27 = sitofp i32 %5 to double
%28 = zext i32 %3 to i64
br label %29
29: ; preds = %26, %29
%30 = phi i64 [ 0, %26 ], [ %40, %29 ]
%31 = getelementptr inbounds i32, i32* %1, i64 %30
%32 = load i32, i32* %31
%33 = getelementptr inbounds i64, i64* %2, i64 %30
%34 = load i64, i64* %33
%35 = load i32, i32* @DBL_DIG
%36 = add nsw i32 %35, -1
%37 = uitofp i64 %34 to double
%38 = fdiv double %37, %27
%39 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %32, i64 %34, i32 %36, double %38)
%40 = add nuw nsw i64 %30, 1
%41 = icmp eq i64 %40, %28
br i1 %41, label %42, label %29
42: ; preds = %29, %9
%43 = call i32 @fclose(i32* %14)
%44 = call i32 @free(i8* %13)
ret void
}