#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 */

/* Variables and functions */
double sqrt(double);
int spofa(double mat[4][4]) {
  int i, j, k;
  double sum;
  double p[4];
  for (i = 0; i < 4; i++) {
    for (j = i; j < 4; j++) {
      for (sum = mat[i][j], k = i - 1; k >= 0; k--) {
        sum -= mat[i][k] * mat[j][k];
      }
      if (i == j) {
        if (sum <= 0.0) {
          return 0;
        } else {
          p[i] = sqrt(sum);
        }
      } else {
        mat[j][i] = sum / p[i];
      }
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<spofa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    1260 <spofa+0x150>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x4,-0x18(%rbp)
jge    124d <spofa+0x13d>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     11d4 <spofa+0xc4>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x28(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1163 <spofa+0x53>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    1213 <spofa+0x103>
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     11fa <spofa+0xea>
movl   $0x0,-0x4(%rbp)
jmp    1267 <spofa+0x157>
movsd  -0x28(%rbp),%xmm0
call   1030 <sqrt@plt>
movslq -0x14(%rbp),%rax
movsd  %xmm0,-0x50(%rbp,%rax,8)
jmp    123a <spofa+0x12a>
movsd  -0x28(%rbp),%xmm0
movslq -0x14(%rbp),%rax
divsd  -0x50(%rbp,%rax,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    123f <spofa+0x12f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1133 <spofa+0x23>
jmp    1252 <spofa+0x142>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <spofa+0x13>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spofa>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
movsd  (%rdi),%xmm0
xor    %ebp,%ebp
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    128d <spofa+0x17d>
mov    %rdi,%rbx
ucomisd %xmm1,%xmm0
jb     1139 <spofa+0x29>
sqrtsd %xmm0,%xmm0
jmp    113e <spofa+0x2e>
call   1030 <sqrt@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rbx),%xmm1
movsd  0x10(%rbx),%xmm2
divsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rbx)
divsd  (%rsp),%xmm2
movsd  %xmm2,0x40(%rbx)
movsd  0x18(%rbx),%xmm0
divsd  (%rsp),%xmm0
movsd  %xmm0,0x60(%rbx)
movsd  0x28(%rbx),%xmm0
mulsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    128d <spofa+0x17d>
ucomisd %xmm1,%xmm0
jb     1196 <spofa+0x86>
sqrtsd %xmm0,%xmm0
jmp    119b <spofa+0x8b>
call   1030 <sqrt@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rbx),%xmm1
movsd  0x30(%rbx),%xmm2
movsd  0x40(%rbx),%xmm3
movapd %xmm1,%xmm4
mulsd  %xmm3,%xmm4
subsd  %xmm4,%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,0x48(%rbx)
movsd  0x38(%rbx),%xmm0
mulsd  0x60(%rbx),%xmm1
subsd  %xmm1,%xmm0
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x68(%rbx)
movsd  0x50(%rbx),%xmm0
mulsd  %xmm2,%xmm2
subsd  %xmm2,%xmm0
mulsd  %xmm3,%xmm3
subsd  %xmm3,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    128d <spofa+0x17d>
ucomisd %xmm1,%xmm0
jb     120d <spofa+0xfd>
sqrtsd %xmm0,%xmm0
jmp    1212 <spofa+0x102>
call   1030 <sqrt@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x68(%rbx),%xmm1
movsd  0x48(%rbx),%xmm2
mulsd  %xmm1,%xmm2
movsd  0x58(%rbx),%xmm3
subsd  %xmm2,%xmm3
movsd  0x60(%rbx),%xmm2
movsd  0x40(%rbx),%xmm4
mulsd  %xmm2,%xmm4
subsd  %xmm4,%xmm3
divsd  %xmm0,%xmm3
movsd  %xmm3,0x70(%rbx)
movsd  0x78(%rbx),%xmm0
mulsd  %xmm3,%xmm3
subsd  %xmm3,%xmm0
mulsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm2
subsd  %xmm2,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    128d <spofa+0x17d>
ucomisd %xmm1,%xmm0
jb     127d <spofa+0x16d>
sqrtsd %xmm0,%xmm0
jmp    1282 <spofa+0x172>
call   1030 <sqrt@plt>
movsd  %xmm0,0x18(%rsp)
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @spofa([4 x double]* %0) {
%2 = alloca i32
%3 = alloca [4 x double]*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca [4 x double]
store [4 x double]* %0, [4 x double]** %3
store i32 0, i32* %4
br label %9
9: ; preds = %88, %1
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %91
12: ; preds = %9
%13 = load i32, i32* %4
store i32 %13, i32* %5
br label %14
14: ; preds = %84, %12
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 4
br i1 %16, label %17, label %87
17: ; preds = %14
%18 = load [4 x double]*, [4 x double]** %3
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [4 x double], [4 x double]* %18, i64 %20
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [4 x double], [4 x double]* %21, i64 0, i64 %23
%25 = load double, double* %24
store double %25, double* %7
%26 = load i32, i32* %4
%27 = sub nsw i32 %26, 1
store i32 %27, i32* %6
br label %28
28: ; preds = %51, %17
%29 = load i32, i32* %6
%30 = icmp sge i32 %29, 0
br i1 %30, label %31, label %54
31: ; preds = %28
%32 = load [4 x double]*, [4 x double]** %3
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [4 x double], [4 x double]* %32, i64 %34
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [4 x double], [4 x double]* %35, i64 0, i64 %37
%39 = load double, double* %38
%40 = load [4 x double]*, [4 x double]** %3
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [4 x double], [4 x double]* %40, i64 %42
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [4 x double], [4 x double]* %43, i64 0, i64 %45
%47 = load double, double* %46
%48 = load double, double* %7
%49 = fneg double %39
%50 = call double @llvm.fmuladd.f64(double %49, double %47, double %48)
store double %50, double* %7
br label %51
51: ; preds = %31
%52 = load i32, i32* %6
%53 = add nsw i32 %52, -1
store i32 %53, i32* %6
br label %28
54: ; preds = %28
%55 = load i32, i32* %4
%56 = load i32, i32* %5
%57 = icmp eq i32 %55, %56
br i1 %57, label %58, label %69
58: ; preds = %54
%59 = load double, double* %7
%60 = fcmp ole double %59, 0.000000e+00
br i1 %60, label %61, label %62
61: ; preds = %58
store i32 0, i32* %2
br label %92
62: ; preds = %58
%63 = load double, double* %7
%64 = call double @sqrt(double %63)
%65 = load i32, i32* %4
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [4 x double], [4 x double]* %8, i64 0, i64 %66
store double %64, double* %67
br label %68
68: ; preds = %62
br label %83
69: ; preds = %54
%70 = load double, double* %7
%71 = load i32, i32* %4
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [4 x double], [4 x double]* %8, i64 0, i64 %72
%74 = load double, double* %73
%75 = fdiv double %70, %74
%76 = load [4 x double]*, [4 x double]** %3
%77 = load i32, i32* %5
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [4 x double], [4 x double]* %76, i64 %78
%80 = load i32, i32* %4
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [4 x double], [4 x double]* %79, i64 0, i64 %81
store double %75, double* %82
br label %83
83: ; preds = %69, %68
br label %84
84: ; preds = %83
%85 = load i32, i32* %5
%86 = add nsw i32 %85, 1
store i32 %86, i32* %5
br label %14
87: ; preds = %14
br label %88
88: ; preds = %87
%89 = load i32, i32* %4
%90 = add nsw i32 %89, 1
store i32 %90, i32* %4
br label %9
91: ; preds = %9
store i32 1, i32* %2
br label %92
92: ; preds = %91, %61
%93 = load i32, i32* %2
ret i32 %93
}

LLVM IR (-O2):
define i32 @spofa([4 x double]* nocapture %0) {
%2 = alloca [4 x double]
%3 = bitcast [4 x double]* %2 to i8*
%4 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 0, i64 0
%5 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 0
%6 = load double, double* %5
%7 = fcmp ugt double %6, 0.000000e+00
br i1 %7, label %8, label %106
8: ; preds = %1
%9 = tail call double @sqrt(double %6)
store double %9, double* %4
%10 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 1
%11 = load double, double* %10
%12 = load double, double* %4
%13 = fdiv double %11, %12
%14 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 0
store double %13, double* %14
%15 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 2
%16 = load double, double* %15
%17 = load double, double* %4
%18 = fdiv double %16, %17
%19 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 0
store double %18, double* %19
%20 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 3
%21 = load double, double* %20
%22 = load double, double* %4
%23 = fdiv double %21, %22
%24 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 0
store double %23, double* %24
%25 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 0, i64 1
%26 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 1
%27 = load double, double* %26
%28 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 0
%29 = load double, double* %28
%30 = fneg double %29
%31 = tail call double @llvm.fmuladd.f64(double %30, double %29, double %27)
%32 = fcmp ugt double %31, 0.000000e+00
br i1 %32, label %33, label %106
33: ; preds = %8
%34 = tail call double @sqrt(double %31)
store double %34, double* %25
%35 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 2
%36 = load double, double* %35
%37 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 0
%38 = load double, double* %37
%39 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 0
%40 = load double, double* %39
%41 = fneg double %38
%42 = tail call double @llvm.fmuladd.f64(double %41, double %40, double %36)
%43 = load double, double* %25
%44 = fdiv double %42, %43
%45 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 1
store double %44, double* %45
%46 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 3
%47 = load double, double* %46
%48 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 0
%49 = load double, double* %48
%50 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 0
%51 = load double, double* %50
%52 = fneg double %49
%53 = tail call double @llvm.fmuladd.f64(double %52, double %51, double %47)
%54 = load double, double* %25
%55 = fdiv double %53, %54
%56 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 1
store double %55, double* %56
%57 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 0, i64 2
%58 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 2
%59 = load double, double* %58
%60 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 1
%61 = load double, double* %60
%62 = fneg double %61
%63 = tail call double @llvm.fmuladd.f64(double %62, double %61, double %59)
%64 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 0
%65 = load double, double* %64
%66 = fneg double %65
%67 = tail call double @llvm.fmuladd.f64(double %66, double %65, double %63)
%68 = fcmp ugt double %67, 0.000000e+00
br i1 %68, label %69, label %106
69: ; preds = %33
%70 = tail call double @sqrt(double %67)
store double %70, double* %57
%71 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 3
%72 = load double, double* %71
%73 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 1
%74 = load double, double* %73
%75 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 1
%76 = load double, double* %75
%77 = fneg double %74
%78 = tail call double @llvm.fmuladd.f64(double %77, double %76, double %72)
%79 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 0
%80 = load double, double* %79
%81 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 0
%82 = load double, double* %81
%83 = fneg double %80
%84 = tail call double @llvm.fmuladd.f64(double %83, double %82, double %78)
%85 = load double, double* %57
%86 = fdiv double %84, %85
%87 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 2
store double %86, double* %87
%88 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 0, i64 3
%89 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 3
%90 = load double, double* %89
%91 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 2
%92 = load double, double* %91
%93 = fneg double %92
%94 = tail call double @llvm.fmuladd.f64(double %93, double %92, double %90)
%95 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 1
%96 = load double, double* %95
%97 = fneg double %96
%98 = tail call double @llvm.fmuladd.f64(double %97, double %96, double %94)
%99 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 0
%100 = load double, double* %99
%101 = fneg double %100
%102 = tail call double @llvm.fmuladd.f64(double %101, double %100, double %98)
%103 = fcmp ugt double %102, 0.000000e+00
br i1 %103, label %104, label %106
104: ; preds = %69
%105 = tail call double @sqrt(double %102)
store double %105, double* %88
br label %106
106: ; preds = %1, %8, %33, %69, %104
%107 = phi i32 [ 1, %104 ], [ 0, %69 ], [ 0, %33 ], [ 0, %8 ], [ 0, %1 ]
ret i32 %107
}