#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*/ time_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *ctime(int /*<<< orphan*/ *);
double fabs(double);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void save_ut_dmatrix(char filename[], double **A, int n, const char *mode) {
  FILE *fp_m;
  int i, j;
  void exit();
  time_t now;
  if ((fp_m = fopen(filename, mode)) == NULL) {
    printf(" error: cannot open file: %s \n", filename);
    exit(1016);
  }
  (void)time(&now);
  fprintf(fp_m, "%% filename: %s - %s\n", filename, ctime(&now));
  fprintf(fp_m, "%% type: matrix \n");
  fprintf(fp_m, "%% rows: %d\n", n);
  fprintf(fp_m, "%% columns: %d\n", n);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      if (i > j) {
        if (fabs(A[j][i]) > 1.e-99)
          fprintf(fp_m, "%21.12e", A[j][i]);
        else
          fprintf(fp_m, "    0                ");
      } else {
        if (fabs(A[i][j]) > 1.e-99)
          fprintf(fp_m, "%21.12e", A[i][j]);
        else
          fprintf(fp_m, "    0                ");
      }
    }
    fprintf(fp_m, "\n");
  }
  fclose(fp_m);
  return;
}


x86 assembly (clang, -O0):
<save_ut_dmatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11bc <save_ut_dmatrix+0x4c>
mov    -0x8(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1050 <printf@plt>
mov    $0x3f8,%edi
call   1090 <exit@plt>
lea    -0x34(%rbp),%rdi
call   1070 <time@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x34(%rbp),%rdi
call   1040 <ctime@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    %rax,%rcx
lea    0xe4f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1382 <save_ut_dmatrix+0x212>
movl   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1362 <save_ut_dmatrix+0x1f2>
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jle    12da <save_ut_dmatrix+0x16a>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xd8f(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xd73(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12c3 <save_ut_dmatrix+0x153>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xdcd(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
jmp    12d5 <save_ut_dmatrix+0x165>
mov    -0x28(%rbp),%rdi
lea    0xdbe(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    134f <save_ut_dmatrix+0x1df>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xd1a(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xcfe(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1338 <save_ut_dmatrix+0x1c8>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xd58(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
jmp    134a <save_ut_dmatrix+0x1da>
mov    -0x28(%rbp),%rdi
lea    0xd49(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    134f <save_ut_dmatrix+0x1df>
jmp    1354 <save_ut_dmatrix+0x1e4>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    124d <save_ut_dmatrix+0xdd>
mov    -0x28(%rbp),%rdi
lea    0xcd0(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    123a <save_ut_dmatrix+0xca>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<save_ut_dmatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%r12
mov    %rcx,%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12da <save_ut_dmatrix+0x14a>
mov    %rax,%rbx
lea    0x4(%rsp),%r13
mov    %r13,%rdi
call   1080 <time@plt>
mov    %r13,%rdi
call   1040 <ctime@plt>
lea    0xe63(%rip),%rsi
mov    %rbx,%rdi
mov    %r12,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0xe62(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0xe63(%rip),%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0xe5c(%rip),%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
test   %r15d,%r15d
jle    12c3 <save_ut_dmatrix+0x133>
add    $0x1,%r15d
mov    $0x1,%ebp
lea    0xe4e(%rip),%r13
jmp    1256 <save_ut_dmatrix+0xc6>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
add    $0x1,%rbp
cmp    %r15,%rbp
je     12c3 <save_ut_dmatrix+0x133>
mov    $0x1,%r12d
jmp    127e <save_ut_dmatrix+0xee>
xchg   %ax,%ax
mov    $0x15,%esi
mov    $0x1,%edx
mov    %r13,%rdi
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
add    $0x1,%r12
cmp    %r12,%r15
je     1240 <save_ut_dmatrix+0xb0>
cmp    %r12,%rbp
jbe    1290 <save_ut_dmatrix+0x100>
mov    (%r14,%r12,8),%rax
movsd  (%rax,%rbp,8),%xmm0
jmp    129a <save_ut_dmatrix+0x10a>
xchg   %ax,%ax
mov    (%r14,%rbp,8),%rax
movsd  (%rax,%r12,8),%xmm0
movapd %xmm0,%xmm1
andpd  0xd5a(%rip),%xmm1
ucomisd 0xd62(%rip),%xmm1
jbe    1260 <save_ut_dmatrix+0xd0>
mov    %rbx,%rdi
lea    0xdc2(%rip),%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
jmp    1275 <save_ut_dmatrix+0xe5>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd37(%rip),%rdi
mov    %r12,%rsi
call   1050 <printf@plt>
mov    $0x3f8,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [31 x i8] c" error: cannot open file: %s \0A\00"
@.str.1 = [22 x i8] c"%% filename: %s - %s\0A\00"
@.str.2 = [18 x i8] c"%% type: matrix \0A\00"
@.str.3 = [13 x i8] c"%% rows: %d\0A\00"
@.str.4 = [16 x i8] c"%% columns: %d\0A\00"
@.str.5 = [8 x i8] c"%21.12e\00"
@.str.6 = [22 x i8] c" 0 \00"
@.str.7 = [2 x i8] c"\0A\00"
define void @save_ut_dmatrix(i8* %0, double** %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca double**
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %5
store double** %1, double*** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%13 = load i8*, i8** %5
%14 = load i8*, i8** %8
%15 = call i32* @fopen(i8* %13, i8* %14)
store i32* %15, i32** %9
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %20
17: ; preds = %4
%18 = load i8*, i8** %5
%19 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %18)
unreachable
20: ; preds = %4
%21 = call i32 @time(i32* %12)
%22 = load i32*, i32** %9
%23 = load i8*, i8** %5
%24 = call i8* @ctime(i32* %12)
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %23, i8* %24)
%26 = load i32*, i32** %9
%27 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%28 = load i32*, i32** %9
%29 = load i32, i32* %7
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = load i32*, i32** %9
%32 = load i32, i32* %7
%33 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %32)
store i32 1, i32* %10
br label %34
34: ; preds = %110, %20
%35 = load i32, i32* %10
%36 = load i32, i32* %7
%37 = icmp sle i32 %35, %36
br i1 %37, label %38, label %113
38: ; preds = %34
store i32 1, i32* %11
br label %39
39: ; preds = %104, %38
%40 = load i32, i32* %11
%41 = load i32, i32* %7
%42 = icmp sle i32 %40, %41
br i1 %42, label %43, label %107
43: ; preds = %39
%44 = load i32, i32* %10
%45 = load i32, i32* %11
%46 = icmp sgt i32 %44, %45
br i1 %46, label %47, label %75
47: ; preds = %43
%48 = load double**, double*** %6
%49 = load i32, i32* %11
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double*, double** %48, i64 %50
%52 = load double*, double** %51
%53 = load i32, i32* %10
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %52, i64 %54
%56 = load double, double* %55
%57 = call double @llvm.fabs.f64(double %56)
%58 = fcmp ogt double %57, 1.000000e-99
br i1 %58, label %59, label %71
59: ; preds = %47
%60 = load i32*, i32** %9
%61 = load double**, double*** %6
%62 = load i32, i32* %11
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds double*, double** %61, i64 %63
%65 = load double*, double** %64
%66 = load i32, i32* %10
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double, double* %65, i64 %67
%69 = load double, double* %68
%70 = call i32 (i32*, i8*, ...) @fprintf(i32* %60, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %69)
br label %74
71: ; preds = %47
%72 = load i32*, i32** %9
%73 = call i32 (i32*, i8*, ...) @fprintf(i32* %72, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %74
74: ; preds = %71, %59
br label %103
75: ; preds = %43
%76 = load double**, double*** %6
%77 = load i32, i32* %10
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds double*, double** %76, i64 %78
%80 = load double*, double** %79
%81 = load i32, i32* %11
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds double, double* %80, i64 %82
%84 = load double, double* %83
%85 = call double @llvm.fabs.f64(double %84)
%86 = fcmp ogt double %85, 1.000000e-99
br i1 %86, label %87, label %99
87: ; preds = %75
%88 = load i32*, i32** %9
%89 = load double**, double*** %6
%90 = load i32, i32* %10
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds double*, double** %89, i64 %91
%93 = load double*, double** %92
%94 = load i32, i32* %11
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds double, double* %93, i64 %95
%97 = load double, double* %96
%98 = call i32 (i32*, i8*, ...) @fprintf(i32* %88, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %97)
br label %102
99: ; preds = %75
%100 = load i32*, i32** %9
%101 = call i32 (i32*, i8*, ...) @fprintf(i32* %100, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %102
102: ; preds = %99, %87
br label %103
103: ; preds = %102, %74
br label %104
104: ; preds = %103
%105 = load i32, i32* %11
%106 = add nsw i32 %105, 1
store i32 %106, i32* %11
br label %39
107: ; preds = %39
%108 = load i32*, i32** %9
%109 = call i32 (i32*, i8*, ...) @fprintf(i32* %108, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %110
110: ; preds = %107
%111 = load i32, i32* %10
%112 = add nsw i32 %111, 1
store i32 %112, i32* %10
br label %34
113: ; preds = %34
%114 = load i32*, i32** %9
%115 = call i32 @fclose(i32* %114)
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c" error: cannot open file: %s \0A\00"
@.str.1 = [22 x i8] c"%% filename: %s - %s\0A\00"
@.str.2 = [18 x i8] c"%% type: matrix \0A\00"
@.str.3 = [13 x i8] c"%% rows: %d\0A\00"
@.str.4 = [16 x i8] c"%% columns: %d\0A\00"
@.str.5 = [8 x i8] c"%21.12e\00"
@.str.6 = [22 x i8] c" 0 \00"
define void @save_ut_dmatrix(i8* %0, double** nocapture %1, i32 %2, i8* nocapture %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = tail call i32* @fopen(i8* %0, i8* %3)
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %0)
tail call void @exit(i32 1016)
unreachable
11: ; preds = %4
%12 = call i32 @time(i32* %5)
%13 = call i8* @ctime(i32* %5)
%14 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %13)
%15 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %2)
%17 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %2)
%18 = icmp slt i32 %2, 1
br i1 %18, label %56, label %19
19: ; preds = %11
%20 = add nuw i32 %2, 1
%21 = zext i32 %20 to i64
br label %22
22: ; preds = %52, %19
%23 = phi i64 [ 1, %19 ], [ %54, %52 ]
%24 = getelementptr inbounds double*, double** %1, i64 %23
br label %25
25: ; preds = %22, %49
%26 = phi i64 [ 1, %22 ], [ %50, %49 ]
%27 = icmp ugt i64 %23, %26
br i1 %27, label %28, label %39
28: ; preds = %25
%29 = getelementptr inbounds double*, double** %1, i64 %26
%30 = load double*, double** %29
%31 = getelementptr inbounds double, double* %30, i64 %23
%32 = load double, double* %31
%33 = call double @llvm.fabs.f64(double %32)
%34 = fcmp ogt double %33, 1.000000e-99
br i1 %34, label %35, label %37
35: ; preds = %28
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %32)
br label %49
37: ; preds = %28
%38 = call i64 @fwrite(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i64 21, i64 1, i32* %7)
br label %49
39: ; preds = %25
%40 = load double*, double** %24
%41 = getelementptr inbounds double, double* %40, i64 %26
%42 = load double, double* %41
%43 = call double @llvm.fabs.f64(double %42)
%44 = fcmp ogt double %43, 1.000000e-99
br i1 %44, label %45, label %47
45: ; preds = %39
%46 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %42)
br label %49
47: ; preds = %39
%48 = call i64 @fwrite(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i64 21, i64 1, i32* %7)
br label %49
49: ; preds = %37, %35, %47, %45
%50 = add nuw nsw i64 %26, 1
%51 = icmp eq i64 %50, %21
br i1 %51, label %52, label %25
52: ; preds = %49
%53 = call i32 @fputc(i32 10, i32* %7)
%54 = add nuw nsw i64 %23, 1
%55 = icmp eq i64 %54, %21
br i1 %55, label %56, label %22
56: ; preds = %52, %11
%57 = call i32 @fclose(i32* %7)
ret void
}