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