#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);
void DFSave(double *odf, char fname[100]) {
  FILE *ifp;
  int i;
  ifp = fopen(fname, "w");
  for (i = 0; i < (10 * 10 * 10); i++) {
    fprintf(ifp, "%0.4lf\n", odf[i]);
  }
  fclose(ifp);
}


x86 assembly (clang, -O0):
<DFSave>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3e8,-0x1c(%rbp)
jge    1193 <DFSave+0x63>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe82(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115b <DFSave+0x2b>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DFSave>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rax
mov    %rdi,%r14
lea    0xebb(%rip),%rsi
mov    %rax,%rdi
call   1050 <fopen@plt>
mov    %rax,%r12
xor    %ebx,%ebx
lea    0xea9(%rip),%r15
nopl   0x0(%rax)
movsd  (%r14,%rbx,8),%xmm0
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <fprintf@plt>
add    $0x1,%rbx
cmp    $0x3e8,%rbx
jne    1160 <DFSave+0x30>
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [8 x i8] c"%0.4lf\0A\00"
define void @DFSave(double* %0, i8* %1) {
%3 = alloca double*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
store double* %0, double** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %5
store i32 0, i32* %6
br label %9
9: ; preds = %20, %2
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 1000
br i1 %11, label %12, label %23
12: ; preds = %9
%13 = load i32*, i32** %5
%14 = load double*, double** %3
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %14, i64 %16
%18 = load double, double* %17
%19 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %18)
br label %20
20: ; preds = %12
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %9
23: ; preds = %9
%24 = load i32*, i32** %5
%25 = call i32 @fclose(i32* %24)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [8 x i8] c"%0.4lf\0A\00"
define void @DFSave(double* nocapture %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %2, %4
%5 = phi i64 [ 0, %2 ], [ %9, %4 ]
%6 = getelementptr inbounds double, double* %0, i64 %5
%7 = load double, double* %6
%8 = tail call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %7)
%9 = add nuw nsw i64 %5, 1
%10 = icmp eq i64 %9, 1000
br i1 %10, label %11, label %4
11: ; preds = %4
%12 = tail call i32 @fclose(i32* %3)
ret void
}