#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, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void write_critical_point_bisection_search_results(
    const char *path, double *critical_points, int number_trials, int precision,
    int rows, int columns, double start_probability, 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, "critical_bisection_search",
                                         rows, columns, seed, number_trials);
  file_handler = fopen(file_full_path, "w");
  fprintf(file_handler, ";rows:%d\n", rows);
  fprintf(file_handler, ";columns:%d\n", columns);
  fprintf(file_handler, ";seed:%u\n", seed);
  fprintf(file_handler, ";pini:%.*e\n", DBL_DIG - 1, start_probability);
  fprintf(file_handler, ";ntrials:%d\n", number_trials);
  fprintf(file_handler, ";precision:%d\n", precision);
  fprintf(file_handler, ";date:%s", asctime(localtime(&current_time)));
  for (i = 0; i < number_trials; i++) {
    fprintf(file_handler, "%.*e\n", DBL_DIG - 1, critical_points[i]);
  }
  fclose(file_handler);
  free(file_full_path);
}


x86 assembly (clang, -O0):
<write_critical_point_bisection_search_results>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    0x10(%rbp),%r8d
mov    -0x14(%rbp),%r9d
lea    0xe35(%rip),%rsi
call   1090 <format_file_full_path@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xe1b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x40(%rbp),%rdi
mov    0x10(%rbp),%edx
lea    0xe13(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x40(%rbp),%rdi
mov    0x2db6(%rip),%rax
mov    (%rax),%edx
sub    $0x1,%edx
movsd  -0x28(%rbp),%xmm0
lea    0xdfa(%rip),%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xdf1(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xde9(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x30(%rbp),%rdi
call   1040 <localtime@plt>
mov    %eax,%edi
call   1060 <asctime@plt>
mov    -0x48(%rbp),%rdi
mov    %rax,%rdx
lea    0xdcb(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12ed <write_critical_point_bisection_search_results+0x16d>
mov    -0x40(%rbp),%rdi
mov    0x2d29(%rip),%rax
mov    (%rax),%edx
sub    $0x1,%edx
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xd6b(%rip),%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12a8 <write_critical_point_bisection_search_results+0x128>
mov    -0x40(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_critical_point_bisection_search_results>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %r9d,%r12d
mov    %r8d,%r13d
mov    %ecx,(%rsp)
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x50(%rsp),%r15d
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,0x4(%rsp)
lea    0xe44(%rip),%rsi
mov    %rbx,%rdi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    %r15d,%r8d
mov    %r15d,%ebx
mov    %ebp,%r9d
call   1090 <format_file_full_path@plt>
lea    0xe40(%rip),%rsi
mov    %rax,0x10(%rsp)
mov    %rax,%rdi
call   10a0 <fopen@plt>
mov    %rax,%r15
lea    0xe2b(%rip),%rsi
mov    %rax,%rdi
mov    %r13d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0xe21(%rip),%rsi
mov    %r15,%rdi
mov    %r12d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0xe1a(%rip),%rsi
mov    %r15,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2dbc(%rip),%r12
mov    (%r12),%edx
add    $0xffffffff,%edx
lea    0xe03(%rip),%rsi
mov    %r15,%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1070 <fprintf@plt>
lea    0xdf8(%rip),%rsi
mov    %r15,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0xdf2(%rip),%rsi
mov    %r15,%rdi
mov    (%rsp),%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0x4(%rsp),%rdi
call   1040 <localtime@plt>
mov    %eax,%edi
call   1060 <asctime@plt>
lea    0xddc(%rip),%rsi
mov    %r15,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
test   %ebp,%ebp
jle    12d3 <write_critical_point_bisection_search_results+0x153>
mov    %ebp,%ebp
xor    %ebx,%ebx
lea    0xd9e(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r12),%edx
add    $0xffffffff,%edx
movsd  (%r14,%rbx,8),%xmm0
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    12b0 <write_critical_point_bisection_search_results+0x130>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [26 x i8] c"critical_bisection_search\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 = [10 x i8] c";seed:%u\0A\00"
@.str.5 = [12 x i8] c";pini:%.*e\0A\00"
@DBL_DIG = global i32 0
@.str.6 = [13 x i8] c";ntrials:%d\0A\00"
@.str.7 = [15 x i8] c";precision:%d\0A\00"
@.str.8 = [9 x i8] c";date:%s\00"
@.str.9 = [6 x i8] c"%.*e\0A\00"
define void @write_critical_point_bisection_search_results(i8* %0, double* nocapture %1, i32 %2, i32 %3, i32 %4, i32 %5, double %6, i32 %7) {
%9 = alloca i32
%10 = bitcast i32* %9 to i8*
%11 = tail call i32 @time(i32* null)
store i32 %11, i32* %9
%12 = tail call i8* @format_file_full_path(i8* %0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %5, i32 %7, i32 %2)
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %4)
%15 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %5)
%16 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, 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* %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %18, double %6)
%20 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %2)
%21 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 %3)
%22 = call i32 @localtime(i32* %9)
%23 = call i8* @asctime(i32 %22)
%24 = call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* %23)
%25 = icmp sgt i32 %2, 0
br i1 %25, label %26, label %37
26: ; preds = %8
%27 = zext i32 %2 to i64
br label %28
28: ; preds = %26, %28
%29 = phi i64 [ 0, %26 ], [ %35, %28 ]
%30 = load i32, i32* @DBL_DIG
%31 = add nsw i32 %30, -1
%32 = getelementptr inbounds double, double* %1, i64 %29
%33 = load double, double* %32
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 %31, double %33)
%35 = add nuw nsw i64 %29, 1
%36 = icmp eq i64 %35, %27
br i1 %36, label %37, label %28
37: ; preds = %28, %8
%38 = call i32 @fclose(i32* %13)
%39 = call i32 @free(i8* %12)
ret void
}