#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*/ *);
int /*<<< orphan*/ exit(int);
double fabs(double);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void save_ut_dmatrix(const char filename[], double **A, int n,
                     const char *mode) {
  FILE *fp_m;
  int i, j;
  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 %21
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)
%20 = call i32 @exit(i32 1016)
unreachable
21: ; preds = %4
%22 = call i32 @time(i32* %12)
%23 = load i32*, i32** %9
%24 = load i8*, i8** %5
%25 = call i8* @ctime(i32* %12)
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %24, i8* %25)
%27 = load i32*, i32** %9
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%29 = load i32*, i32** %9
%30 = load i32, i32* %7
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = load i32*, i32** %9
%33 = load i32, i32* %7
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %33)
store i32 1, i32* %10
br label %35
35: ; preds = %111, %21
%36 = load i32, i32* %10
%37 = load i32, i32* %7
%38 = icmp sle i32 %36, %37
br i1 %38, label %39, label %114
39: ; preds = %35
store i32 1, i32* %11
br label %40
40: ; preds = %105, %39
%41 = load i32, i32* %11
%42 = load i32, i32* %7
%43 = icmp sle i32 %41, %42
br i1 %43, label %44, label %108
44: ; preds = %40
%45 = load i32, i32* %10
%46 = load i32, i32* %11
%47 = icmp sgt i32 %45, %46
br i1 %47, label %48, label %76
48: ; preds = %44
%49 = load double**, double*** %6
%50 = load i32, i32* %11
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double*, double** %49, i64 %51
%53 = load double*, double** %52
%54 = load i32, i32* %10
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %53, i64 %55
%57 = load double, double* %56
%58 = call double @llvm.fabs.f64(double %57)
%59 = fcmp ogt double %58, 1.000000e-99
br i1 %59, label %60, label %72
60: ; preds = %48
%61 = load i32*, i32** %9
%62 = load double**, double*** %6
%63 = load i32, i32* %11
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double*, double** %62, i64 %64
%66 = load double*, double** %65
%67 = load i32, i32* %10
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %66, i64 %68
%70 = load double, double* %69
%71 = call i32 (i32*, i8*, ...) @fprintf(i32* %61, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %70)
br label %75
72: ; preds = %48
%73 = load i32*, i32** %9
%74 = call i32 (i32*, i8*, ...) @fprintf(i32* %73, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %75
75: ; preds = %72, %60
br label %104
76: ; preds = %44
%77 = load double**, double*** %6
%78 = load i32, i32* %10
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds double*, double** %77, i64 %79
%81 = load double*, double** %80
%82 = load i32, i32* %11
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds double, double* %81, i64 %83
%85 = load double, double* %84
%86 = call double @llvm.fabs.f64(double %85)
%87 = fcmp ogt double %86, 1.000000e-99
br i1 %87, label %88, label %100
88: ; preds = %76
%89 = load i32*, i32** %9
%90 = load double**, double*** %6
%91 = load i32, i32* %10
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds double*, double** %90, i64 %92
%94 = load double*, double** %93
%95 = load i32, i32* %11
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds double, double* %94, i64 %96
%98 = load double, double* %97
%99 = call i32 (i32*, i8*, ...) @fprintf(i32* %89, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %98)
br label %103
100: ; preds = %76
%101 = load i32*, i32** %9
%102 = call i32 (i32*, i8*, ...) @fprintf(i32* %101, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %103
103: ; preds = %100, %88
br label %104
104: ; preds = %103, %75
br label %105
105: ; preds = %104
%106 = load i32, i32* %11
%107 = add nsw i32 %106, 1
store i32 %107, i32* %11
br label %40
108: ; preds = %40
%109 = load i32*, i32** %9
%110 = call i32 (i32*, i8*, ...) @fprintf(i32* %109, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %111
111: ; preds = %108
%112 = load i32, i32* %10
%113 = add nsw i32 %112, 1
store i32 %113, i32* %10
br label %35
114: ; preds = %35
%115 = load i32*, i32** %9
%116 = call i32 @fclose(i32* %115)
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 %12
9: ; preds = %4
%10 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %0)
%11 = tail call i32 @exit(i32 1016)
unreachable
12: ; preds = %4
%13 = call i32 @time(i32* %5)
%14 = call i8* @ctime(i32* %5)
%15 = 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* %14)
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %2)
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %2)
%19 = icmp slt i32 %2, 1
br i1 %19, label %57, label %20
20: ; preds = %12
%21 = add nuw i32 %2, 1
%22 = zext i32 %21 to i64
br label %23
23: ; preds = %53, %20
%24 = phi i64 [ 1, %20 ], [ %55, %53 ]
%25 = getelementptr inbounds double*, double** %1, i64 %24
br label %26
26: ; preds = %23, %50
%27 = phi i64 [ 1, %23 ], [ %51, %50 ]
%28 = icmp ugt i64 %24, %27
br i1 %28, label %29, label %40
29: ; preds = %26
%30 = getelementptr inbounds double*, double** %1, i64 %27
%31 = load double*, double** %30
%32 = getelementptr inbounds double, double* %31, i64 %24
%33 = load double, double* %32
%34 = call double @llvm.fabs.f64(double %33)
%35 = fcmp ogt double %34, 1.000000e-99
br i1 %35, label %36, label %38
36: ; preds = %29
%37 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %33)
br label %50
38: ; preds = %29
%39 = 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 %50
40: ; preds = %26
%41 = load double*, double** %25
%42 = getelementptr inbounds double, double* %41, i64 %27
%43 = load double, double* %42
%44 = call double @llvm.fabs.f64(double %43)
%45 = fcmp ogt double %44, 1.000000e-99
br i1 %45, label %46, label %48
46: ; preds = %40
%47 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %43)
br label %50
48: ; preds = %40
%49 = 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 %50
50: ; preds = %38, %36, %48, %46
%51 = add nuw nsw i64 %27, 1
%52 = icmp eq i64 %51, %22
br i1 %52, label %53, label %26
53: ; preds = %50
%54 = call i32 @fputc(i32 10, i32* %7)
%55 = add nuw nsw i64 %24, 1
%56 = icmp eq i64 %55, %22
br i1 %56, label %57, label %23
57: ; preds = %53, %12
%58 = call i32 @fclose(i32* %7)
ret void
}