#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, double,
                           double);
int /*<<< orphan*/ printf(char *, char *);
void SavDat(char *OutFil, double *x, double *y, double *dy, int n) {
  FILE *path;
  int i;
  path = fopen(OutFil, "w");
  if (!path)
    return;
  printf("Saving data in file: %s\n", OutFil);
  for (i = 1; i <= n; i++)
    fprintf(path, "%lg\t%lg\t%lg\n", x[i], y[i], dy[i]);
  fclose(path);
}


x86 assembly (clang, -O0):
<SavDat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1180 <SavDat+0x40>
jmp    11f1 <SavDat+0xb1>
mov    -0x8(%rbp),%rsi
lea    0xe77(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     11e8 <SavDat+0xa8>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
lea    0xe46(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1197 <SavDat+0x57>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SavDat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r13d
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbp
lea    0xe9f(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11d0 <SavDat+0x90>
mov    %rax,%rbx
lea    0xe8d(%rip),%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
test   %r13d,%r13d
jle    11ba <SavDat+0x7a>
add    $0x1,%r13d
mov    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
movsd  (%r12,%rbp,8),%xmm0
movsd  (%r15,%rbp,8),%xmm1
movsd  (%r14,%rbp,8),%xmm2
mov    %rbx,%rdi
lea    0xe6f(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1190 <SavDat+0x50>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [25 x i8] c"Saving data in file: %s\0A\00"
@.str.2 = [13 x i8] c"%lg\09%lg\09%lg\0A\00"
define void @SavDat(i8* %0, double* %1, double* %2, double* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32
store i8* %0, i8** %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
store i32 %4, i32* %10
%13 = load i8*, i8** %6
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %11
%15 = load i32*, i32** %11
%16 = icmp ne i32* %15, null
br i1 %16, label %18, label %17
17: ; preds = %5
br label %49
18: ; preds = %5
%19 = load i8*, i8** %6
%20 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %19)
store i32 1, i32* %12
br label %21
21: ; preds = %43, %18
%22 = load i32, i32* %12
%23 = load i32, i32* %10
%24 = icmp sle i32 %22, %23
br i1 %24, label %25, label %46
25: ; preds = %21
%26 = load i32*, i32** %11
%27 = load double*, double** %7
%28 = load i32, i32* %12
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %27, i64 %29
%31 = load double, double* %30
%32 = load double*, double** %8
%33 = load i32, i32* %12
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
%36 = load double, double* %35
%37 = load double*, double** %9
%38 = load i32, i32* %12
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
%41 = load double, double* %40
%42 = call i32 @fprintf(i32* %26, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double %31, double %36, double %41)
br label %43
43: ; preds = %25
%44 = load i32, i32* %12
%45 = add nsw i32 %44, 1
store i32 %45, i32* %12
br label %21
46: ; preds = %21
%47 = load i32*, i32** %11
%48 = call i32 @fclose(i32* %47)
br label %49
49: ; preds = %46, %17
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [25 x i8] c"Saving data in file: %s\0A\00"
@.str.2 = [13 x i8] c"%lg\09%lg\09%lg\0A\00"
define void @SavDat(i8* %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, i32 %4) {
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %27, label %8
8: ; preds = %5
%9 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%10 = icmp slt i32 %4, 1
br i1 %10, label %25, label %11
11: ; preds = %8
%12 = add nuw i32 %4, 1
%13 = zext i32 %12 to i64
br label %14
14: ; preds = %11, %14
%15 = phi i64 [ 1, %11 ], [ %23, %14 ]
%16 = getelementptr inbounds double, double* %1, i64 %15
%17 = load double, double* %16
%18 = getelementptr inbounds double, double* %2, i64 %15
%19 = load double, double* %18
%20 = getelementptr inbounds double, double* %3, i64 %15
%21 = load double, double* %20
%22 = tail call i32 @fprintf(i32* %6, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double %17, double %19, double %21)
%23 = add nuw nsw i64 %15, 1
%24 = icmp eq i64 %23, %13
br i1 %24, label %25, label %14
25: ; preds = %14, %8
%26 = tail call i32 @fclose(i32* %6)
br label %27
27: ; preds = %5, %25
ret void
}