#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 *, ...);
int /*<<< orphan*/ printf(char *, char *);
void save_fmatrixn(char *output_filename, float **data, int nx, int ny, int n) {
  int i, j;
  FILE *output_file;
  output_file = fopen(output_filename, "w");
  if (!output_file)
    printf("I could not open the file %s for writing\n", output_filename);
  if (n == 6) {
    for (i = 1; i <= nx; i++) {
      for (j = 1; j <= ny; j++) {
        fprintf(output_file, "%.6f\t", data[i][j]);
      }
      fprintf(output_file, "\n");
    }
  } else {
    if (n == 8) {
      for (i = 1; i <= nx; i++) {
        for (j = 1; j <= ny; j++) {
          fprintf(output_file, "%.8f\t", data[i][j]);
        }
        fprintf(output_file, "\n");
      }
    } else {
      for (i = 1; i <= nx; i++) {
        for (j = 1; j <= ny; j++) {
          fprintf(output_file, "%.6f\t", data[i][j]);
        }
        fprintf(output_file, "\n");
      }
    }
  }
  fclose(output_file);
}


x86 assembly (clang, -O0):
<save_fmatrixn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1189 <save_fmatrixn+0x49>
mov    -0x8(%rbp),%rsi
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x6,-0x1c(%rbp)
jne    1217 <save_fmatrixn+0xd7>
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1212 <save_fmatrixn+0xd2>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11f2 <save_fmatrixn+0xb2>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x24(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe4f(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ad <save_fmatrixn+0x6d>
mov    -0x30(%rbp),%rdi
lea    0xe2d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    119a <save_fmatrixn+0x5a>
jmp    132e <save_fmatrixn+0x1ee>
cmpl   $0x8,-0x1c(%rbp)
jne    12a5 <save_fmatrixn+0x165>
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     12a0 <save_fmatrixn+0x160>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     1280 <save_fmatrixn+0x140>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x24(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdc7(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    123b <save_fmatrixn+0xfb>
mov    -0x30(%rbp),%rdi
lea    0xd9f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1228 <save_fmatrixn+0xe8>
jmp    1329 <save_fmatrixn+0x1e9>
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1324 <save_fmatrixn+0x1e4>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     1304 <save_fmatrixn+0x1c4>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x24(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd3d(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12bf <save_fmatrixn+0x17f>
mov    -0x30(%rbp),%rdi
lea    0xd1b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12ac <save_fmatrixn+0x16c>
jmp    1329 <save_fmatrixn+0x1e9>
jmp    132e <save_fmatrixn+0x1ee>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<save_fmatrixn>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%ebx
mov    %rcx,0x10(%rsp)
mov    %rdx,0x8(%rsp)
mov    %rsi,%r12
mov    %rdi,%rbp
lea    0xe88(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r13
test   %rax,%rax
je     1225 <save_fmatrixn+0xd5>
cmp    $0x6,%ebx
je     123d <save_fmatrixn+0xed>
cmp    $0x8,%ebx
jne    12c6 <save_fmatrixn+0x176>
cmpl   $0x0,0x8(%rsp)
jle    1355 <save_fmatrixn+0x205>
mov    0x10(%rsp),%rax
lea    0x1(%rax),%r14d
mov    0x8(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x8(%rsp)
mov    $0x1,%ebp
lea    0xe6a(%rip),%r15
jmp    11ec <save_fmatrixn+0x9c>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %r13,%rsi
call   1050 <fputc@plt>
add    $0x1,%rbp
cmp    0x8(%rsp),%rbp
je     1355 <save_fmatrixn+0x205>
cmpl   $0x0,0x10(%rsp)
jle    11d0 <save_fmatrixn+0x80>
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbp,8),%rax
movss  (%rax,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1200 <save_fmatrixn+0xb0>
jmp    11d0 <save_fmatrixn+0x80>
lea    0xdd6(%rip),%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
cmp    $0x6,%ebx
jne    1192 <save_fmatrixn+0x42>
cmpl   $0x0,0x8(%rsp)
jle    1355 <save_fmatrixn+0x205>
mov    0x10(%rsp),%rax
lea    0x1(%rax),%ebp
mov    0x8(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x8(%rsp)
mov    $0x1,%r14d
lea    0xdc2(%rip),%rbx
jmp    128c <save_fmatrixn+0x13c>
nopl   0x0(%rax)
mov    $0xa,%edi
mov    %r13,%rsi
call   1050 <fputc@plt>
add    $0x1,%r14
cmp    0x8(%rsp),%r14
je     1355 <save_fmatrixn+0x205>
cmpl   $0x0,0x10(%rsp)
jle    1270 <save_fmatrixn+0x120>
mov    $0x1,%r15d
nopl   0x0(%rax)
mov    (%r12,%r14,8),%rax
movss  (%rax,%r15,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r13,%rdi
mov    %rbx,%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0x1,%r15
cmp    %r15,%rbp
jne    12a0 <save_fmatrixn+0x150>
jmp    1270 <save_fmatrixn+0x120>
cmpl   $0x0,0x8(%rsp)
jle    1355 <save_fmatrixn+0x205>
mov    0x10(%rsp),%rax
lea    0x1(%rax),%r14d
mov    0x8(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x8(%rsp)
mov    $0x1,%ebp
lea    0xd39(%rip),%r15
jmp    1318 <save_fmatrixn+0x1c8>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
mov    %r13,%rsi
call   1050 <fputc@plt>
add    $0x1,%rbp
cmp    0x8(%rsp),%rbp
je     1355 <save_fmatrixn+0x205>
cmpl   $0x0,0x10(%rsp)
jle    1300 <save_fmatrixn+0x1b0>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r12,%rbp,8),%rax
movss  (%rax,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1330 <save_fmatrixn+0x1e0>
jmp    1300 <save_fmatrixn+0x1b0>
mov    %r13,%rdi
add    $0x18,%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 = [42 x i8] c"I could not open the file %s for writing\0A\00"
@.str.2 = [6 x i8] c"%.6f\09\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [6 x i8] c"%.8f\09\00"
define void @save_fmatrixn(i8* %0, float** %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca float**
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
store i8* %0, i8** %6
store float** %1, float*** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%14 = load i8*, i8** %6
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %13
%16 = load i32*, i32** %13
%17 = icmp ne i32* %16, null
br i1 %17, label %21, label %18
18: ; preds = %5
%19 = load i8*, i8** %6
%20 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %18, %5
%22 = load i32, i32* %10
%23 = icmp eq i32 %22, 6
br i1 %23, label %24, label %57
24: ; preds = %21
store i32 1, i32* %11
br label %25
25: ; preds = %53, %24
%26 = load i32, i32* %11
%27 = load i32, i32* %8
%28 = icmp sle i32 %26, %27
br i1 %28, label %29, label %56
29: ; preds = %25
store i32 1, i32* %12
br label %30
30: ; preds = %47, %29
%31 = load i32, i32* %12
%32 = load i32, i32* %9
%33 = icmp sle i32 %31, %32
br i1 %33, label %34, label %50
34: ; preds = %30
%35 = load i32*, i32** %13
%36 = load float**, float*** %7
%37 = load i32, i32* %11
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds float*, float** %36, i64 %38
%40 = load float*, float** %39
%41 = load i32, i32* %12
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds float, float* %40, i64 %42
%44 = load float, float* %43
%45 = fpext float %44 to double
%46 = call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %45)
br label %47
47: ; preds = %34
%48 = load i32, i32* %12
%49 = add nsw i32 %48, 1
store i32 %49, i32* %12
br label %30
50: ; preds = %30
%51 = load i32*, i32** %13
%52 = call i32 (i32*, i8*, ...) @fprintf(i32* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %53
53: ; preds = %50
%54 = load i32, i32* %11
%55 = add nsw i32 %54, 1
store i32 %55, i32* %11
br label %25
56: ; preds = %25
br label %127
57: ; preds = %21
%58 = load i32, i32* %10
%59 = icmp eq i32 %58, 8
br i1 %59, label %60, label %93
60: ; preds = %57
store i32 1, i32* %11
br label %61
61: ; preds = %89, %60
%62 = load i32, i32* %11
%63 = load i32, i32* %8
%64 = icmp sle i32 %62, %63
br i1 %64, label %65, label %92
65: ; preds = %61
store i32 1, i32* %12
br label %66
66: ; preds = %83, %65
%67 = load i32, i32* %12
%68 = load i32, i32* %9
%69 = icmp sle i32 %67, %68
br i1 %69, label %70, label %86
70: ; preds = %66
%71 = load i32*, i32** %13
%72 = load float**, float*** %7
%73 = load i32, i32* %11
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds float*, float** %72, i64 %74
%76 = load float*, float** %75
%77 = load i32, i32* %12
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds float, float* %76, i64 %78
%80 = load float, float* %79
%81 = fpext float %80 to double
%82 = call i32 (i32*, i8*, ...) @fprintf(i32* %71, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double %81)
br label %83
83: ; preds = %70
%84 = load i32, i32* %12
%85 = add nsw i32 %84, 1
store i32 %85, i32* %12
br label %66
86: ; preds = %66
%87 = load i32*, i32** %13
%88 = call i32 (i32*, i8*, ...) @fprintf(i32* %87, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %89
89: ; preds = %86
%90 = load i32, i32* %11
%91 = add nsw i32 %90, 1
store i32 %91, i32* %11
br label %61
92: ; preds = %61
br label %126
93: ; preds = %57
store i32 1, i32* %11
br label %94
94: ; preds = %122, %93
%95 = load i32, i32* %11
%96 = load i32, i32* %8
%97 = icmp sle i32 %95, %96
br i1 %97, label %98, label %125
98: ; preds = %94
store i32 1, i32* %12
br label %99
99: ; preds = %116, %98
%100 = load i32, i32* %12
%101 = load i32, i32* %9
%102 = icmp sle i32 %100, %101
br i1 %102, label %103, label %119
103: ; preds = %99
%104 = load i32*, i32** %13
%105 = load float**, float*** %7
%106 = load i32, i32* %11
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds float*, float** %105, i64 %107
%109 = load float*, float** %108
%110 = load i32, i32* %12
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds float, float* %109, i64 %111
%113 = load float, float* %112
%114 = fpext float %113 to double
%115 = call i32 (i32*, i8*, ...) @fprintf(i32* %104, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %114)
br label %116
116: ; preds = %103
%117 = load i32, i32* %12
%118 = add nsw i32 %117, 1
store i32 %118, i32* %12
br label %99
119: ; preds = %99
%120 = load i32*, i32** %13
%121 = call i32 (i32*, i8*, ...) @fprintf(i32* %120, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %122
122: ; preds = %119
%123 = load i32, i32* %11
%124 = add nsw i32 %123, 1
store i32 %124, i32* %11
br label %94
125: ; preds = %94
br label %126
126: ; preds = %125, %92
br label %127
127: ; preds = %126, %56
%128 = load i32*, i32** %13
%129 = call i32 @fclose(i32* %128)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [42 x i8] c"I could not open the file %s for writing\0A\00"
@.str.2 = [6 x i8] c"%.6f\09\00"
@.str.4 = [6 x i8] c"%.8f\09\00"
define void @save_fmatrixn(i8* %0, float** nocapture %1, i32 %2, i32 %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 %8, label %10
8: ; preds = %5
%9 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %10
10: ; preds = %8, %5
switch i32 %4, label %27 [
i32 6, label %19
i32 8, label %11
]
11: ; preds = %10
%12 = icmp slt i32 %2, 1
br i1 %12, label %86, label %13
13: ; preds = %11
%14 = icmp slt i32 %3, 1
%15 = add i32 %3, 1
%16 = add nuw i32 %2, 1
%17 = zext i32 %16 to i64
%18 = zext i32 %15 to i64
br label %52
19: ; preds = %10
%20 = icmp slt i32 %2, 1
br i1 %20, label %86, label %21
21: ; preds = %19
%22 = icmp slt i32 %3, 1
%23 = add i32 %3, 1
%24 = add nuw i32 %2, 1
%25 = zext i32 %24 to i64
%26 = zext i32 %23 to i64
br label %35
27: ; preds = %10
%28 = icmp slt i32 %2, 1
br i1 %28, label %86, label %29
29: ; preds = %27
%30 = icmp slt i32 %3, 1
%31 = add i32 %3, 1
%32 = add nuw i32 %2, 1
%33 = zext i32 %32 to i64
%34 = zext i32 %31 to i64
br label %69
35: ; preds = %21, %48
%36 = phi i64 [ 1, %21 ], [ %50, %48 ]
br i1 %22, label %48, label %37
37: ; preds = %35
%38 = getelementptr inbounds float*, float** %1, i64 %36
br label %39
39: ; preds = %37, %39
%40 = phi i64 [ 1, %37 ], [ %46, %39 ]
%41 = load float*, float** %38
%42 = getelementptr inbounds float, float* %41, i64 %40
%43 = load float, float* %42
%44 = fpext float %43 to double
%45 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %44)
%46 = add nuw nsw i64 %40, 1
%47 = icmp eq i64 %46, %26
br i1 %47, label %48, label %39
48: ; preds = %39, %35
%49 = tail call i32 @fputc(i32 10, i32* %6)
%50 = add nuw nsw i64 %36, 1
%51 = icmp eq i64 %50, %25
br i1 %51, label %86, label %35
52: ; preds = %13, %65
%53 = phi i64 [ 1, %13 ], [ %67, %65 ]
br i1 %14, label %65, label %54
54: ; preds = %52
%55 = getelementptr inbounds float*, float** %1, i64 %53
br label %56
56: ; preds = %54, %56
%57 = phi i64 [ 1, %54 ], [ %63, %56 ]
%58 = load float*, float** %55
%59 = getelementptr inbounds float, float* %58, i64 %57
%60 = load float, float* %59
%61 = fpext float %60 to double
%62 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double %61)
%63 = add nuw nsw i64 %57, 1
%64 = icmp eq i64 %63, %18
br i1 %64, label %65, label %56
65: ; preds = %56, %52
%66 = tail call i32 @fputc(i32 10, i32* %6)
%67 = add nuw nsw i64 %53, 1
%68 = icmp eq i64 %67, %17
br i1 %68, label %86, label %52
69: ; preds = %29, %82
%70 = phi i64 [ 1, %29 ], [ %84, %82 ]
br i1 %30, label %82, label %71
71: ; preds = %69
%72 = getelementptr inbounds float*, float** %1, i64 %70
br label %73
73: ; preds = %71, %73
%74 = phi i64 [ 1, %71 ], [ %80, %73 ]
%75 = load float*, float** %72
%76 = getelementptr inbounds float, float* %75, i64 %74
%77 = load float, float* %76
%78 = fpext float %77 to double
%79 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %78)
%80 = add nuw nsw i64 %74, 1
%81 = icmp eq i64 %80, %34
br i1 %81, label %82, label %73
82: ; preds = %73, %69
%83 = tail call i32 @fputc(i32 10, i32* %6)
%84 = add nuw nsw i64 %70, 1
%85 = icmp eq i64 %84, %33
br i1 %85, label %86, label %69
86: ; preds = %65, %48, %82, %11, %19, %27
%87 = tail call i32 @fclose(i32* %6)
ret void
}