#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);
void writecols(char *fname, double x[], double y[], size_t N) {
  FILE *outfile = fopen(fname, "w");
  if (outfile != NULL) {
    for (size_t i = 0; i < N; ++i) {
      fprintf(outfile, "%15.9e %18.9e\n", x[i], y[i]);
    }
    fclose(outfile);
  }
}


x86 assembly (clang, -O0):
<writecols>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xead(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11c1 <writecols+0x91>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11b8 <writecols+0x88>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
lea    0xe60(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    116f <writecols+0x3f>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writecols>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
lea    0xeb5(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11a6 <writecols+0x76>
mov    %rax,%rbx
test   %r12,%r12
je     1190 <writecols+0x60>
xor    %ebp,%ebp
lea    0xe9c(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
movsd  (%r15,%rbp,8),%xmm0
movsd  (%r14,%rbp,8),%xmm1
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1170 <writecols+0x40>
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 = [15 x i8] c"%15.9e %18.9e\0A\00"
define void @writecols(i8* %0, double* %1, double* %2, i64 %3) {
%5 = alloca i8*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i64
%9 = alloca i32*
%10 = alloca i64
store i8* %0, i8** %5
store double* %1, double** %6
store double* %2, double** %7
store i64 %3, i64* %8
%11 = load i8*, i8** %5
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %9
%13 = load i32*, i32** %9
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %37
15: ; preds = %4
store i64 0, i64* %10
br label %16
16: ; preds = %31, %15
%17 = load i64, i64* %10
%18 = load i64, i64* %8
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %34
20: ; preds = %16
%21 = load i32*, i32** %9
%22 = load double*, double** %6
%23 = load i64, i64* %10
%24 = getelementptr inbounds double, double* %22, i64 %23
%25 = load double, double* %24
%26 = load double*, double** %7
%27 = load i64, i64* %10
%28 = getelementptr inbounds double, double* %26, i64 %27
%29 = load double, double* %28
%30 = call i32 @fprintf(i32* %21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %25, double %29)
br label %31
31: ; preds = %20
%32 = load i64, i64* %10
%33 = add i64 %32, 1
store i64 %33, i64* %10
br label %16
34: ; preds = %16
%35 = load i32*, i32** %9
%36 = call i32 @fclose(i32* %35)
br label %37
37: ; preds = %34, %4
ret void
}

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