#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 *, ...);
void save(double **X, unsigned long int x, unsigned long int y,
          char *filename) {
  unsigned long int i, j;
  FILE *file;
  file = fopen(filename, "w");
  for (i = 0; i < x; i++) {
    for (j = 0; j < y; j++) {
      fprintf(file, "%8.3f ", X[i][j]);
    }
    fprintf(file, "\n");
  }
  fclose(file);
}


x86 assembly (clang, -O0):
<save>:
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    -0x20(%rbp),%rdi
lea    0xead(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x38(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11e3 <save+0xb3>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11c0 <save+0x90>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe5a(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    117a <save+0x4a>
mov    -0x38(%rbp),%rdi
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1164 <save+0x34>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<save>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%rbp
mov    %rdi,%r15
lea    0xea5(%rip),%rsi
mov    %rcx,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbx
mov    %rbp,(%rsp)
test   %rbp,%rbp
je     11c2 <save+0x82>
xor    %ebp,%ebp
lea    0xe8a(%rip),%r13
jmp    1197 <save+0x57>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
add    $0x1,%rbp
cmp    (%rsp),%rbp
je     11c2 <save+0x82>
test   %r12,%r12
je     1180 <save+0x40>
xor    %r14d,%r14d
nop
mov    (%r15,%rbp,8),%rax
movsd  (%rax,%r14,8),%xmm0
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
add    $0x1,%r14
cmp    %r14,%r12
jne    11a0 <save+0x60>
jmp    1180 <save+0x40>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

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

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