#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(float);
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_matrix(char filename[], float **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(1015);
  }
  (void)time(&now);
  fprintf(fp_m, "%% filename: %s - %s", 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, "%15.6e", A[j][i]);
        else
          fprintf(fp_m, "    0          ");
      } else {
        if (fabs(A[i][j]) > 1.e-99)
          fprintf(fp_m, "%15.6e", A[i][j]);
        else
          fprintf(fp_m, "    0          ");
      }
    }
    fprintf(fp_m, "\n");
  }
  fclose(fp_m);
  return;
}


x86 assembly (clang, -O0):
<save_ut_matrix>:
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   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11cc <save_ut_matrix+0x4c>
mov    -0x8(%rbp),%rsi
lea    0xe4b(%rip),%rdi
call   1050 <printf@plt>
mov    $0x3f7,%edi
call   10a0 <exit@plt>
lea    -0x34(%rbp),%rdi
call   1080 <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    0xe27(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe2a(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe27(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe1f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     138e <save_ut_matrix+0x20e>
movl   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     136e <save_ut_matrix+0x1ee>
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jle    12e8 <save_ut_matrix+0x168>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x2c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
call   1060 <fabs@plt>
movsd  0xd69(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12d1 <save_ut_matrix+0x151>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x2c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xda6(%rip),%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
jmp    12e3 <save_ut_matrix+0x163>
mov    -0x28(%rbp),%rdi
lea    0xd96(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    135b <save_ut_matrix+0x1db>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
call   1060 <fabs@plt>
movsd  0xcf6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1344 <save_ut_matrix+0x1c4>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd33(%rip),%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
jmp    1356 <save_ut_matrix+0x1d6>
mov    -0x28(%rbp),%rdi
lea    0xd23(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    135b <save_ut_matrix+0x1db>
jmp    1360 <save_ut_matrix+0x1e0>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    125d <save_ut_matrix+0xdd>
mov    -0x28(%rbp),%rdi
lea    0xcac(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    124a <save_ut_matrix+0xca>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<save_ut_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%r12
mov    %rcx,%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1321 <save_ut_matrix+0x181>
mov    %rax,%r15
lea    0x4(%rsp),%r13
mov    %r13,%rdi
call   1090 <time@plt>
mov    %r13,%rdi
call   1040 <ctime@plt>
lea    0xe43(%rip),%rsi
mov    %r15,%rdi
mov    %r12,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0xe41(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0xe42(%rip),%rsi
mov    %r15,%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0xe3b(%rip),%rsi
mov    %r15,%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
test   %r14d,%r14d
jle    130a <save_ut_matrix+0x16a>
add    $0x1,%r14d
mov    $0x1,%ebp
lea    0xe2c(%rip),%r13
jmp    126a <save_ut_matrix+0xca>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %r15,%rsi
call   1060 <fputc@plt>
add    $0x1,%rbp
cmp    %r14,%rbp
je     130a <save_ut_matrix+0x16a>
mov    $0x1,%r12d
jmp    129e <save_ut_matrix+0xfe>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0xf,%esi
mov    $0x1,%edx
mov    %r13,%rdi
mov    %r15,%rcx
call   10c0 <fwrite@plt>
add    $0x1,%r12
cmp    %r12,%r14
je     1250 <save_ut_matrix+0xb0>
cmp    %r12,%rbp
jbe    12d0 <save_ut_matrix+0x130>
mov    (%rbx,%r12,8),%rax
movss  (%rax,%rbp,4),%xmm0
call   1070 <fabs@plt>
ucomisd 0xd47(%rip),%xmm0
jbe    1280 <save_ut_matrix+0xe0>
mov    (%rbx,%r12,8),%rax
movss  (%rax,%rbp,4),%xmm0
jmp    12f3 <save_ut_matrix+0x153>
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rax
movss  (%rax,%r12,4),%xmm0
call   1070 <fabs@plt>
ucomisd 0xd19(%rip),%xmm0
jbe    1280 <save_ut_matrix+0xe0>
mov    (%rbx,%rbp,8),%rax
movss  (%rax,%r12,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
lea    0xd6a(%rip),%rsi
mov    $0x1,%al
call   1080 <fprintf@plt>
jmp    1295 <save_ut_matrix+0xf5>
mov    %r15,%rdi
call   1030 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xce0(%rip),%rdi
mov    %r12,%rsi
call   1050 <printf@plt>
mov    $0x3f7,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [31 x i8] c" error: cannot open file: %s \0A\00"
@.str.1 = [21 x i8] c"%% filename: %s - %s\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 = [7 x i8] c"%15.6e\00"
@.str.6 = [16 x i8] c" 0 \00"
@.str.7 = [2 x i8] c"\0A\00"
define void @save_ut_matrix(i8* %0, float** %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca float**
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %5
store float** %1, float*** %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 1015)
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 ([21 x i8], [21 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 = %113, %21
%36 = load i32, i32* %10
%37 = load i32, i32* %7
%38 = icmp sle i32 %36, %37
br i1 %38, label %39, label %116
39: ; preds = %35
store i32 1, i32* %11
br label %40
40: ; preds = %107, %39
%41 = load i32, i32* %11
%42 = load i32, i32* %7
%43 = icmp sle i32 %41, %42
br i1 %43, label %44, label %110
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 %77
48: ; preds = %44
%49 = load float**, float*** %6
%50 = load i32, i32* %11
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds float*, float** %49, i64 %51
%53 = load float*, float** %52
%54 = load i32, i32* %10
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds float, float* %53, i64 %55
%57 = load float, float* %56
%58 = call double @fabs(float %57)
%59 = fcmp ogt double %58, 1.000000e-99
br i1 %59, label %60, label %73
60: ; preds = %48
%61 = load i32*, i32** %9
%62 = load float**, float*** %6
%63 = load i32, i32* %11
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds float*, float** %62, i64 %64
%66 = load float*, float** %65
%67 = load i32, i32* %10
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds float, float* %66, i64 %68
%70 = load float, float* %69
%71 = fpext float %70 to double
%72 = call i32 (i32*, i8*, ...) @fprintf(i32* %61, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), double %71)
br label %76
73: ; preds = %48
%74 = load i32*, i32** %9
%75 = call i32 (i32*, i8*, ...) @fprintf(i32* %74, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
br label %76
76: ; preds = %73, %60
br label %106
77: ; preds = %44
%78 = load float**, float*** %6
%79 = load i32, i32* %10
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds float*, float** %78, i64 %80
%82 = load float*, float** %81
%83 = load i32, i32* %11
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds float, float* %82, i64 %84
%86 = load float, float* %85
%87 = call double @fabs(float %86)
%88 = fcmp ogt double %87, 1.000000e-99
br i1 %88, label %89, label %102
89: ; preds = %77
%90 = load i32*, i32** %9
%91 = load float**, float*** %6
%92 = load i32, i32* %10
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds float*, float** %91, i64 %93
%95 = load float*, float** %94
%96 = load i32, i32* %11
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds float, float* %95, i64 %97
%99 = load float, float* %98
%100 = fpext float %99 to double
%101 = call i32 (i32*, i8*, ...) @fprintf(i32* %90, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), double %100)
br label %105
102: ; preds = %77
%103 = load i32*, i32** %9
%104 = call i32 (i32*, i8*, ...) @fprintf(i32* %103, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
br label %105
105: ; preds = %102, %89
br label %106
106: ; preds = %105, %76
br label %107
107: ; preds = %106
%108 = load i32, i32* %11
%109 = add nsw i32 %108, 1
store i32 %109, i32* %11
br label %40
110: ; preds = %40
%111 = load i32*, i32** %9
%112 = call i32 (i32*, i8*, ...) @fprintf(i32* %111, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %113
113: ; preds = %110
%114 = load i32, i32* %10
%115 = add nsw i32 %114, 1
store i32 %115, i32* %10
br label %35
116: ; preds = %35
%117 = load i32*, i32** %9
%118 = call i32 @fclose(i32* %117)
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c" error: cannot open file: %s \0A\00"
@.str.1 = [21 x i8] c"%% filename: %s - %s\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 = [7 x i8] c"%15.6e\00"
@.str.6 = [16 x i8] c" 0 \00"
define void @save_ut_matrix(i8* %0, float** 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 1015)
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 ([21 x i8], [21 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 %65, label %20
20: ; preds = %12
%21 = add nuw i32 %2, 1
%22 = zext i32 %21 to i64
br label %23
23: ; preds = %61, %20
%24 = phi i64 [ 1, %20 ], [ %63, %61 ]
%25 = getelementptr inbounds float*, float** %1, i64 %24
br label %26
26: ; preds = %23, %58
%27 = phi i64 [ 1, %23 ], [ %59, %58 ]
%28 = icmp ugt i64 %24, %27
br i1 %28, label %29, label %44
29: ; preds = %26
%30 = getelementptr inbounds float*, float** %1, i64 %27
%31 = load float*, float** %30
%32 = getelementptr inbounds float, float* %31, i64 %24
%33 = load float, float* %32
%34 = call double @fabs(float %33)
%35 = fcmp ogt double %34, 1.000000e-99
br i1 %35, label %36, label %42
36: ; preds = %29
%37 = load float*, float** %30
%38 = getelementptr inbounds float, float* %37, i64 %24
%39 = load float, float* %38
%40 = fpext float %39 to double
%41 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), double %40)
br label %58
42: ; preds = %29
%43 = call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i64 15, i64 1, i32* %7)
br label %58
44: ; preds = %26
%45 = load float*, float** %25
%46 = getelementptr inbounds float, float* %45, i64 %27
%47 = load float, float* %46
%48 = call double @fabs(float %47)
%49 = fcmp ogt double %48, 1.000000e-99
br i1 %49, label %50, label %56
50: ; preds = %44
%51 = load float*, float** %25
%52 = getelementptr inbounds float, float* %51, i64 %27
%53 = load float, float* %52
%54 = fpext float %53 to double
%55 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), double %54)
br label %58
56: ; preds = %44
%57 = call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i64 15, i64 1, i32* %7)
br label %58
58: ; preds = %42, %36, %56, %50
%59 = add nuw nsw i64 %27, 1
%60 = icmp eq i64 %59, %22
br i1 %60, label %61, label %26
61: ; preds = %58
%62 = call i32 @fputc(i32 10, i32* %7)
%63 = add nuw nsw i64 %24, 1
%64 = icmp eq i64 %63, %22
br i1 %64, label %65, label %23
65: ; preds = %61, %12
%66 = call i32 @fclose(i32* %7)
ret void
}