; LLVM IR from HRI-EU/Rcs :: src/RcsCore (Rcs_MatNd)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct._MatNd = type { ptr, i32, i32, i32, i8 }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [39 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@RcsLogLevel = external global i32, align 4
@__func__.MatNd_rwPinv = external hidden unnamed_addr constant [13 x i8], align 1
@.str.126 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.127 = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #0

declare void @print_trace() #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_reshape(ptr noundef, i32 noundef, i32 noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_setZero(ptr noundef) #4

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: nounwind uwtable
declare dso_local ptr @MatNd_create(i32 noundef, i32 noundef) #4

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_destroy(ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_addDiag(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_addSelf(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_transpose(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_mul(ptr noundef, ptr noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_preMulSelf(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
define dso_local double @MatNd_rwPinv(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #4 {
  %5 = alloca double, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca double, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct._MatNd, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 8, !tbaa !9
  store i32 %23, ptr %10, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._MatNd, ptr %24, i32 0, i32 2
  %26 = load i32, ptr %25, align 4, !tbaa !14
  store i32 %26, ptr %11, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %27 = load i32, ptr %10, align 4, !tbaa !13
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %32, label %29

29:                                               ; preds = %4
  %30 = load i32, ptr %11, align 4, !tbaa !13
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %32, label %40

32:                                               ; preds = %29, %4
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._MatNd, ptr %34, i32 0, i32 2
  %36 = load i32, ptr %35, align 4, !tbaa !14
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._MatNd, ptr %37, i32 0, i32 1
  %39 = load i32, ptr %38, align 8, !tbaa !9
  call void @MatNd_reshape(ptr noundef %33, i32 noundef %36, i32 noundef %39)
  store double 1.000000e+00, ptr %5, align 8
  store i32 1, ptr %16, align 4
  br label %257

40:                                               ; preds = %29
  %41 = load i32, ptr %11, align 4, !tbaa !13
  %42 = load i32, ptr %10, align 4, !tbaa !13
  %43 = mul nsw i32 %41, %42
  %44 = icmp sgt i32 %43, 1296
  br i1 %44, label %45, label %49

45:                                               ; preds = %40
  %46 = load i32, ptr %11, align 4, !tbaa !13
  %47 = load i32, ptr %10, align 4, !tbaa !13
  %48 = call ptr @MatNd_create(i32 noundef %46, i32 noundef %47)
  store ptr %48, ptr %13, align 8, !tbaa !5
  br label %87

49:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %50 = load i32, ptr %11, align 4, !tbaa !13
  %51 = load i32, ptr %10, align 4, !tbaa !13
  %52 = mul nsw i32 %50, %51
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %54, label %55

54:                                               ; preds = %49
  br label %59

55:                                               ; preds = %49
  %56 = load i32, ptr %11, align 4, !tbaa !13
  %57 = load i32, ptr %10, align 4, !tbaa !13
  %58 = mul nsw i32 %56, %57
  br label %59

59:                                               ; preds = %55, %54
  %60 = phi i32 [ 1, %54 ], [ %58, %55 ]
  store i32 %60, ptr %17, align 4, !tbaa !13
  %61 = load i32, ptr %17, align 4, !tbaa !13
  %62 = zext i32 %61 to i64
  %63 = mul i64 %62, 8
  %64 = add i64 24, %63
  %65 = alloca i8, i64 %64, align 16
  store ptr %65, ptr %13, align 8, !tbaa !5
  %66 = load ptr, ptr %13, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._MatNd, ptr %66, i64 1
  %68 = load ptr, ptr %13, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._MatNd, ptr %68, i32 0, i32 0
  store ptr %67, ptr %69, align 8, !tbaa !15
  %70 = load i32, ptr %11, align 4, !tbaa !13
  %71 = load ptr, ptr %13, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct._MatNd, ptr %71, i32 0, i32 1
  store i32 %70, ptr %72, align 8, !tbaa !9
  %73 = load i32, ptr %10, align 4, !tbaa !13
  %74 = load ptr, ptr %13, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct._MatNd, ptr %74, i32 0, i32 2
  store i32 %73, ptr %75, align 4, !tbaa !14
  %76 = load i32, ptr %17, align 4, !tbaa !13
  %77 = load ptr, ptr %13, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._MatNd, ptr %77, i32 0, i32 3
  store i32 %76, ptr %78, align 8, !tbaa !16
  %79 = load ptr, ptr %13, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct._MatNd, ptr %79, i32 0, i32 4
  store i8 1, ptr %80, align 4, !tbaa !17
  %81 = load ptr, ptr %13, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct._MatNd, ptr %81, i32 0, i32 0
  %83 = load ptr, ptr %82, align 8, !tbaa !15
  %84 = load i32, ptr %17, align 4, !tbaa !13
  %85 = zext i32 %84 to i64
  %86 = mul i64 %85, 8
  call void @llvm.memset.p0.i64(ptr align 8 %83, i8 0, i64 %86, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %87

87:                                               ; preds = %59, %45
  %88 = load ptr, ptr %13, align 8, !tbaa !5
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  call void @MatNd_transpose(ptr noundef %88, ptr noundef %89)
  %90 = load ptr, ptr %8, align 8, !tbaa !5
  %91 = icmp ne ptr %90, null
  br i1 %91, label %92, label %104

92:                                               ; preds = %87
  %93 = load ptr, ptr %8, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct._MatNd, ptr %93, i32 0, i32 2
  %95 = load i32, ptr %94, align 4, !tbaa !14
  %96 = icmp eq i32 %95, 1
  br i1 %96, label %97, label %100

97:                                               ; preds = %92
  %98 = load ptr, ptr %13, align 8, !tbaa !5
  %99 = load ptr, ptr %8, align 8, !tbaa !5
  call void @MatNd_preMulDiagSelf(ptr noundef %98, ptr noundef %99)
  br label %103

100:                                              ; preds = %92
  %101 = load ptr, ptr %13, align 8, !tbaa !5
  %102 = load ptr, ptr %8, align 8, !tbaa !5
  call void @MatNd_preMulSelf(ptr noundef %101, ptr noundef %102)
  br label %103

103:                                              ; preds = %100, %97
  br label %104

104:                                              ; preds = %103, %87
  %105 = load i32, ptr %10, align 4, !tbaa !13
  %106 = load i32, ptr %10, align 4, !tbaa !13
  %107 = mul nsw i32 %105, %106
  %108 = icmp sgt i32 %107, 1296
  br i1 %108, label %109, label %113

109:                                              ; preds = %104
  %110 = load i32, ptr %10, align 4, !tbaa !13
  %111 = load i32, ptr %10, align 4, !tbaa !13
  %112 = call ptr @MatNd_create(i32 noundef %110, i32 noundef %111)
  store ptr %112, ptr %14, align 8, !tbaa !5
  br label %151

113:                                              ; preds = %104
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  %114 = load i32, ptr %10, align 4, !tbaa !13
  %115 = load i32, ptr %10, align 4, !tbaa !13
  %116 = mul nsw i32 %114, %115
  %117 = icmp eq i32 %116, 0
  br i1 %117, label %118, label %119

118:                                              ; preds = %113
  br label %123

119:                                              ; preds = %113
  %120 = load i32, ptr %10, align 4, !tbaa !13
  %121 = load i32, ptr %10, align 4, !tbaa !13
  %122 = mul nsw i32 %120, %121
  br label %123

123:                                              ; preds = %119, %118
  %124 = phi i32 [ 1, %118 ], [ %122, %119 ]
  store i32 %124, ptr %18, align 4, !tbaa !13
  %125 = load i32, ptr %18, align 4, !tbaa !13
  %126 = zext i32 %125 to i64
  %127 = mul i64 %126, 8
  %128 = add i64 24, %127
  %129 = alloca i8, i64 %128, align 16
  store ptr %129, ptr %14, align 8, !tbaa !5
  %130 = load ptr, ptr %14, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct._MatNd, ptr %130, i64 1
  %132 = load ptr, ptr %14, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct._MatNd, ptr %132, i32 0, i32 0
  store ptr %131, ptr %133, align 8, !tbaa !15
  %134 = load i32, ptr %10, align 4, !tbaa !13
  %135 = load ptr, ptr %14, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct._MatNd, ptr %135, i32 0, i32 1
  store i32 %134, ptr %136, align 8, !tbaa !9
  %137 = load i32, ptr %10, align 4, !tbaa !13
  %138 = load ptr, ptr %14, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct._MatNd, ptr %138, i32 0, i32 2
  store i32 %137, ptr %139, align 4, !tbaa !14
  %140 = load i32, ptr %18, align 4, !tbaa !13
  %141 = load ptr, ptr %14, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct._MatNd, ptr %141, i32 0, i32 3
  store i32 %140, ptr %142, align 8, !tbaa !16
  %143 = load ptr, ptr %14, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct._MatNd, ptr %143, i32 0, i32 4
  store i8 1, ptr %144, align 4, !tbaa !17
  %145 = load ptr, ptr %14, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct._MatNd, ptr %145, i32 0, i32 0
  %147 = load ptr, ptr %146, align 8, !tbaa !15
  %148 = load i32, ptr %18, align 4, !tbaa !13
  %149 = zext i32 %148 to i64
  %150 = mul i64 %149, 8
  call void @llvm.memset.p0.i64(ptr align 8 %147, i8 0, i64 %150, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  br label %151

151:                                              ; preds = %123, %109
  %152 = load ptr, ptr %14, align 8, !tbaa !5
  %153 = load ptr, ptr %7, align 8, !tbaa !5
  %154 = load ptr, ptr %13, align 8, !tbaa !5
  call void @MatNd_mul(ptr noundef %152, ptr noundef %153, ptr noundef %154)
  %155 = load ptr, ptr %9, align 8, !tbaa !5
  %156 = icmp ne ptr %155, null
  br i1 %156, label %157, label %237

157:                                              ; preds = %151
  %158 = load ptr, ptr %9, align 8, !tbaa !5
  %159 = getelementptr inbounds %struct._MatNd, ptr %158, i32 0, i32 2
  %160 = load i32, ptr %159, align 4, !tbaa !14
  %161 = icmp eq i32 %160, 1
  br i1 %161, label %162, label %165

162:                                              ; preds = %157
  %163 = load ptr, ptr %14, align 8, !tbaa !5
  %164 = load ptr, ptr %9, align 8, !tbaa !5
  call void @MatNd_addDiag(ptr noundef %163, ptr noundef %164)
  br label %236

165:                                              ; preds = %157
  %166 = load i32, ptr @RcsLogLevel, align 4, !tbaa !13
  %167 = icmp sle i32 4, %166
  br i1 %167, label %168, label %233

168:                                              ; preds = %165
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  %169 = load i32, ptr %10, align 4, !tbaa !13
  %170 = load i32, ptr %10, align 4, !tbaa !13
  %171 = mul nsw i32 %169, %170
  %172 = icmp sgt i32 %171, 1296
  br i1 %172, label %173, label %177

173:                                              ; preds = %168
  %174 = load i32, ptr %10, align 4, !tbaa !13
  %175 = load i32, ptr %10, align 4, !tbaa !13
  %176 = call ptr @MatNd_create(i32 noundef %174, i32 noundef %175)
  store ptr %176, ptr %19, align 8, !tbaa !5
  br label %215

177:                                              ; preds = %168
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  %178 = load i32, ptr %10, align 4, !tbaa !13
  %179 = load i32, ptr %10, align 4, !tbaa !13
  %180 = mul nsw i32 %178, %179
  %181 = icmp eq i32 %180, 0
  br i1 %181, label %182, label %183

182:                                              ; preds = %177
  br label %187

183:                                              ; preds = %177
  %184 = load i32, ptr %10, align 4, !tbaa !13
  %185 = load i32, ptr %10, align 4, !tbaa !13
  %186 = mul nsw i32 %184, %185
  br label %187

187:                                              ; preds = %183, %182
  %188 = phi i32 [ 1, %182 ], [ %186, %183 ]
  store i32 %188, ptr %20, align 4, !tbaa !13
  %189 = load i32, ptr %20, align 4, !tbaa !13
  %190 = zext i32 %189 to i64
  %191 = mul i64 %190, 8
  %192 = add i64 24, %191
  %193 = alloca i8, i64 %192, align 16
  store ptr %193, ptr %19, align 8, !tbaa !5
  %194 = load ptr, ptr %19, align 8, !tbaa !5
  %195 = getelementptr inbounds %struct._MatNd, ptr %194, i64 1
  %196 = load ptr, ptr %19, align 8, !tbaa !5
  %197 = getelementptr inbounds %struct._MatNd, ptr %196, i32 0, i32 0
  store ptr %195, ptr %197, align 8, !tbaa !15
  %198 = load i32, ptr %10, align 4, !tbaa !13
  %199 = load ptr, ptr %19, align 8, !tbaa !5
  %200 = getelementptr inbounds %struct._MatNd, ptr %199, i32 0, i32 1
  store i32 %198, ptr %200, align 8, !tbaa !9
  %201 = load i32, ptr %10, align 4, !tbaa !13
  %202 = load ptr, ptr %19, align 8, !tbaa !5
  %203 = getelementptr inbounds %struct._MatNd, ptr %202, i32 0, i32 2
  store i32 %201, ptr %203, align 4, !tbaa !14
  %204 = load i32, ptr %20, align 4, !tbaa !13
  %205 = load ptr, ptr %19, align 8, !tbaa !5
  %206 = getelementptr inbounds %struct._MatNd, ptr %205, i32 0, i32 3
  store i32 %204, ptr %206, align 8, !tbaa !16
  %207 = load ptr, ptr %19, align 8, !tbaa !5
  %208 = getelementptr inbounds %struct._MatNd, ptr %207, i32 0, i32 4
  store i8 1, ptr %208, align 4, !tbaa !17
  %209 = load ptr, ptr %19, align 8, !tbaa !5
  %210 = getelementptr inbounds %struct._MatNd, ptr %209, i32 0, i32 0
  %211 = load ptr, ptr %210, align 8, !tbaa !15
  %212 = load i32, ptr %20, align 4, !tbaa !13
  %213 = zext i32 %212 to i64
  %214 = mul i64 %213, 8
  call void @llvm.memset.p0.i64(ptr align 8 %211, i8 0, i64 %214, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  br label %215

215:                                              ; preds = %187, %173
  %216 = load ptr, ptr %19, align 8, !tbaa !5
  %217 = load ptr, ptr %9, align 8, !tbaa !5
  %218 = call double @MatNd_choleskyDecomposition(ptr noundef %216, ptr noundef %217)
  store double %218, ptr %12, align 8, !tbaa !18
  %219 = load ptr, ptr %19, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %219)
  br label %220

220:                                              ; preds = %215
  %221 = load double, ptr %12, align 8, !tbaa !18
  %222 = fcmp ogt double %221, 0.000000e+00
  br i1 %222, label %230, label %223

223:                                              ; preds = %220
  %224 = load ptr, ptr @stderr, align 8, !tbaa !5
  %225 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %224, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__.MatNd_rwPinv, i32 noundef 1887, ptr noundef @.str.126) #6
  %226 = load ptr, ptr @stderr, align 8, !tbaa !5
  %227 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %226, ptr noundef @.str.127) #6
  %228 = load ptr, ptr @stderr, align 8, !tbaa !5
  %229 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %228, ptr noundef @.str.4) #6
  call void @print_trace()
  call void @exit(i32 noundef 1) #7
  unreachable

230:                                              ; preds = %220
  br label %231

231:                                              ; preds = %230
  br label %232

232:                                              ; preds = %231
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  br label %233

233:                                              ; preds = %232, %165
  %234 = load ptr, ptr %14, align 8, !tbaa !5
  %235 = load ptr, ptr %9, align 8, !tbaa !5
  call void @MatNd_addSelf(ptr noundef %234, ptr noundef %235)
  br label %236

236:                                              ; preds = %233, %162
  br label %237

237:                                              ; preds = %236, %151
  %238 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %238, ptr %15, align 8, !tbaa !5
  %239 = load ptr, ptr %15, align 8, !tbaa !5
  %240 = load ptr, ptr %14, align 8, !tbaa !5
  %241 = call double @MatNd_choleskyInverse(ptr noundef %239, ptr noundef %240)
  store double %241, ptr %12, align 8, !tbaa !18
  %242 = load ptr, ptr %6, align 8, !tbaa !5
  %243 = load i32, ptr %11, align 4, !tbaa !13
  %244 = load i32, ptr %10, align 4, !tbaa !13
  call void @MatNd_reshape(ptr noundef %242, i32 noundef %243, i32 noundef %244)
  %245 = load double, ptr %12, align 8, !tbaa !18
  %246 = fcmp ogt double %245, 0.000000e+00
  br i1 %246, label %247, label %251

247:                                              ; preds = %237
  %248 = load ptr, ptr %6, align 8, !tbaa !5
  %249 = load ptr, ptr %13, align 8, !tbaa !5
  %250 = load ptr, ptr %15, align 8, !tbaa !5
  call void @MatNd_mul(ptr noundef %248, ptr noundef %249, ptr noundef %250)
  br label %253

251:                                              ; preds = %237
  %252 = load ptr, ptr %6, align 8, !tbaa !5
  call void @MatNd_setZero(ptr noundef %252)
  br label %253

253:                                              ; preds = %251, %247
  %254 = load ptr, ptr %13, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %254)
  %255 = load ptr, ptr %14, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %255)
  %256 = load double, ptr %12, align 8, !tbaa !18
  store double %256, ptr %5, align 8
  store i32 1, ptr %16, align 4
  br label %257

257:                                              ; preds = %253, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  %258 = load double, ptr %5, align 8
  ret double %258
}

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_preMulDiagSelf(ptr noundef, ptr noundef) #4

declare double @MatNd_choleskyDecomposition(ptr noundef, ptr noundef) #1

declare double @MatNd_choleskyInverse(ptr noundef, ptr noundef) #1

attributes #0 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { noreturn nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }
attributes #7 = { noreturn nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"_MatNd", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !12, i64 20}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !11, i64 12}
!15 = !{!10, !6, i64 0}
!16 = !{!10, !11, i64 16}
!17 = !{!10, !12, i64 20}
!18 = !{!19, !19, i64 0}
!19 = !{!"double", !7, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [39 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@RcsLogLevel = external local_unnamed_addr global i32, align 4
@__func__.MatNd_rwPinv = external hidden unnamed_addr constant [13 x i8], align 1
@.str.126 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.127 = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

declare void @print_trace() local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_reshape(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_setZero(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local ptr @MatNd_create(i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_destroy(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_addDiag(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_addSelf(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_transpose(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_mul(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_preMulSelf(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local double @MatNd_rwPinv(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #3 {
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 12
  %8 = load i32, ptr %7, align 4, !tbaa !12
  %9 = icmp eq i32 %6, 0
  %10 = icmp eq i32 %8, 0
  %or.cond = select i1 %9, i1 true, i1 %10
  br i1 %or.cond, label %11, label %12

11:                                               ; preds = %4
  tail call void @MatNd_reshape(ptr noundef %0, i32 noundef %8, i32 noundef %6)
  br label %89

12:                                               ; preds = %4
  %13 = mul nsw i32 %8, %6
  %14 = icmp sgt i32 %13, 1296
  br i1 %14, label %15, label %17

15:                                               ; preds = %12
  %16 = tail call ptr @MatNd_create(i32 noundef %8, i32 noundef %6)
  br label %28

17:                                               ; preds = %12
  %18 = tail call i32 @llvm.umax.i32(i32 %13, i32 1)
  %19 = zext i32 %18 to i64
  %20 = shl nuw nsw i64 %19, 3
  %21 = add nuw nsw i64 %20, 24
  %22 = alloca i8, i64 %21, align 16
  %23 = getelementptr inbounds i8, ptr %22, i64 24
  store ptr %23, ptr %22, align 16, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %22, i64 8
  store i32 %8, ptr %24, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %22, i64 12
  store i32 %6, ptr %25, align 4, !tbaa !12
  %26 = getelementptr inbounds i8, ptr %22, i64 16
  store i32 %18, ptr %26, align 16, !tbaa !14
  %27 = getelementptr inbounds i8, ptr %22, i64 20
  store i8 1, ptr %27, align 4, !tbaa !15
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %23, i8 0, i64 %20, i1 false)
  br label %28

28:                                               ; preds = %17, %15
  %.0104 = phi ptr [ %16, %15 ], [ %22, %17 ]
  call void @MatNd_transpose(ptr noundef %.0104, ptr noundef nonnull %1)
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %35, label %29

29:                                               ; preds = %28
  %30 = getelementptr inbounds i8, ptr %2, i64 12
  %31 = load i32, ptr %30, align 4, !tbaa !12
  %32 = icmp eq i32 %31, 1
  br i1 %32, label %33, label %34

33:                                               ; preds = %29
  call void @MatNd_preMulDiagSelf(ptr noundef %.0104, ptr noundef nonnull %2)
  br label %35

34:                                               ; preds = %29
  call void @MatNd_preMulSelf(ptr noundef %.0104, ptr noundef nonnull %2)
  br label %35

35:                                               ; preds = %33, %34, %28
  %36 = mul nsw i32 %6, %6
  %37 = icmp ugt i32 %36, 1296
  br i1 %37, label %38, label %40

38:                                               ; preds = %35
  %39 = call ptr @MatNd_create(i32 noundef %6, i32 noundef %6)
  br label %50

40:                                               ; preds = %35
  %41 = shl nuw nsw i32 %36, 3
  %42 = zext nneg i32 %41 to i64
  %43 = add nuw nsw i64 %42, 24
  %44 = alloca i8, i64 %43, align 16
  %45 = getelementptr inbounds i8, ptr %44, i64 24
  store ptr %45, ptr %44, align 16, !tbaa !13
  %46 = getelementptr inbounds i8, ptr %44, i64 8
  store i32 %6, ptr %46, align 8, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %44, i64 12
  store i32 %6, ptr %47, align 4, !tbaa !12
  %48 = getelementptr inbounds i8, ptr %44, i64 16
  store i32 %36, ptr %48, align 16, !tbaa !14
  %49 = getelementptr inbounds i8, ptr %44, i64 20
  store i8 1, ptr %49, align 4, !tbaa !15
  call void @llvm.memset.p0.i64(ptr nonnull align 8 %45, i8 0, i64 %42, i1 false)
  br label %50

50:                                               ; preds = %40, %38
  %.0105 = phi ptr [ %39, %38 ], [ %44, %40 ]
  call void @MatNd_mul(ptr noundef %.0105, ptr noundef nonnull %1, ptr noundef %.0104)
  %.not112 = icmp eq ptr %3, null
  br i1 %.not112, label %83, label %51

51:                                               ; preds = %50
  %52 = getelementptr inbounds i8, ptr %3, i64 12
  %53 = load i32, ptr %52, align 4, !tbaa !12
  %54 = icmp eq i32 %53, 1
  br i1 %54, label %55, label %56

55:                                               ; preds = %51
  call void @MatNd_addDiag(ptr noundef %.0105, ptr noundef nonnull %3)
  br label %83

56:                                               ; preds = %51
  %57 = load i32, ptr @RcsLogLevel, align 4, !tbaa !16
  %58 = icmp sgt i32 %57, 3
  br i1 %58, label %59, label %82

59:                                               ; preds = %56
  br i1 %37, label %60, label %62

60:                                               ; preds = %59
  %61 = call ptr @MatNd_create(i32 noundef %6, i32 noundef %6)
  br label %72

62:                                               ; preds = %59
  %63 = shl nuw nsw i32 %36, 3
  %64 = zext nneg i32 %63 to i64
  %65 = add nuw nsw i64 %64, 24
  %66 = alloca i8, i64 %65, align 16
  %67 = getelementptr inbounds i8, ptr %66, i64 24
  store ptr %67, ptr %66, align 16, !tbaa !13
  %68 = getelementptr inbounds i8, ptr %66, i64 8
  store i32 %6, ptr %68, align 8, !tbaa !5
  %69 = getelementptr inbounds i8, ptr %66, i64 12
  store i32 %6, ptr %69, align 4, !tbaa !12
  %70 = getelementptr inbounds i8, ptr %66, i64 16
  store i32 %36, ptr %70, align 16, !tbaa !14
  %71 = getelementptr inbounds i8, ptr %66, i64 20
  store i8 1, ptr %71, align 4, !tbaa !15
  call void @llvm.memset.p0.i64(ptr nonnull align 8 %67, i8 0, i64 %64, i1 false)
  br label %72

72:                                               ; preds = %62, %60
  %.0103 = phi ptr [ %61, %60 ], [ %66, %62 ]
  %73 = call double @MatNd_choleskyDecomposition(ptr noundef %.0103, ptr noundef nonnull %3) #6
  call void @MatNd_destroy(ptr noundef %.0103)
  %74 = fcmp ogt double %73, 0.000000e+00
  br i1 %74, label %82, label %75

75:                                               ; preds = %72
  %76 = load ptr, ptr @stderr, align 8, !tbaa !17
  %77 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %76, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.MatNd_rwPinv, i32 noundef 1887, ptr noundef nonnull @.str.126) #7
  %78 = load ptr, ptr @stderr, align 8, !tbaa !17
  %79 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %78, ptr noundef nonnull @.str.127) #7
  %80 = load ptr, ptr @stderr, align 8, !tbaa !17
  %81 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %80, ptr noundef nonnull @.str.4) #7
  call void @print_trace() #6
  call void @exit(i32 noundef 1) #8
  unreachable

82:                                               ; preds = %72, %56
  call void @MatNd_addSelf(ptr noundef %.0105, ptr noundef nonnull %3)
  br label %83

83:                                               ; preds = %55, %82, %50
  %84 = call double @MatNd_choleskyInverse(ptr noundef %.0105, ptr noundef %.0105) #6
  call void @MatNd_reshape(ptr noundef %0, i32 noundef %8, i32 noundef %6)
  %85 = fcmp ogt double %84, 0.000000e+00
  br i1 %85, label %86, label %87

86:                                               ; preds = %83
  call void @MatNd_mul(ptr noundef %0, ptr noundef %.0104, ptr noundef %.0105)
  br label %88

87:                                               ; preds = %83
  call void @MatNd_setZero(ptr noundef %0)
  br label %88

88:                                               ; preds = %87, %86
  call void @MatNd_destroy(ptr noundef %.0104)
  call void @MatNd_destroy(ptr noundef %.0105)
  br label %89

89:                                               ; preds = %88, %11
  %.0 = phi double [ 1.000000e+00, %11 ], [ %84, %88 ]
  ret double %.0
}

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_preMulDiagSelf(ptr noundef, ptr noundef) local_unnamed_addr #3

declare double @MatNd_choleskyDecomposition(ptr noundef, ptr noundef) local_unnamed_addr #1

declare double @MatNd_choleskyInverse(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #5

attributes #0 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { noreturn nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { cold nounwind }
attributes #8 = { noreturn nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !10, i64 8}
!6 = !{!"_MatNd", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !11, i64 20}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!6, !10, i64 12}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !10, i64 16}
!15 = !{!6, !11, i64 20}
!16 = !{!10, !10, i64 0}
!17 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass