#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 const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double, double,
                           double);
void pointsToFile(double *points, int size, const char *filename) {
  int i;
  FILE *fp = fopen(filename, "w");
  for (i = 0; i < size; i++) {
    fprintf(fp, "%e %e %e\n", points[3 * i], points[3 * i + 1],
            points[3 * i + 2]);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<pointsToFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xeb2(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11be <pointsToFile+0x8e>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rax
imul   $0x3,-0x1c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
imul   $0x3,-0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
imul   $0x3,-0x1c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
lea    0xe57(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115e <pointsToFile+0x2e>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pointsToFile>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xebc(%rip),%rsi
mov    %rdx,%rdi
call   1050 <fopen@plt>
mov    %rax,%r14
test   %ebp,%ebp
jle    1195 <pointsToFile+0x65>
mov    %ebp,%eax
shl    $0x3,%rax
lea    (%rax,%rax,2),%r12
xor    %ebp,%ebp
lea    0xe9c(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
movsd  (%rbx,%rbp,1),%xmm0
movsd  0x8(%rbx,%rbp,1),%xmm1
movsd  0x10(%rbx,%rbp,1),%xmm2
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <fprintf@plt>
add    $0x18,%rbp
cmp    %rbp,%r12
jne    1170 <pointsToFile+0x40>
mov    %r14,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

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

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