; 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
@.str.126 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.127 = external hidden unnamed_addr constant [32 x i8], align 1
@__func__.MatNd_rwPinv2_ = external hidden unnamed_addr constant [15 x i8], align 1
@.str.128 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.129 = external hidden unnamed_addr constant [73 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_fromPtr(ptr dead_on_unwind noalias writable sret(%struct._MatNd) align 8, i32 noundef, i32 noundef, 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_postMulSelf(ptr noundef, ptr noundef) #4

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

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

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

28:                                               ; preds = %5
  %29 = load i32, ptr %13, align 4, !tbaa !13
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %31, label %35

31:                                               ; preds = %28, %5
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = load i32, ptr %13, align 4, !tbaa !13
  %34 = load i32, ptr %12, align 4, !tbaa !13
  call void @MatNd_reshape(ptr noundef %32, i32 noundef %33, i32 noundef %34)
  store double 1.000000e+00, ptr %6, align 8
  store i32 1, ptr %14, align 4
  br label %194

35:                                               ; preds = %28
  br label %36

36:                                               ; preds = %35
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._MatNd, ptr %37, i32 0, i32 3
  %39 = load i32, ptr %38, align 8, !tbaa !15
  %40 = load i32, ptr %12, align 4, !tbaa !13
  %41 = load i32, ptr %13, align 4, !tbaa !13
  %42 = mul i32 %40, %41
  %43 = load i32, ptr %13, align 4, !tbaa !13
  %44 = load i32, ptr %13, align 4, !tbaa !13
  %45 = mul i32 %43, %44
  %46 = add i32 %42, %45
  %47 = icmp uge i32 %39, %46
  br i1 %47, label %67, label %48

48:                                               ; preds = %36
  %49 = load ptr, ptr @stderr, align 8, !tbaa !5
  %50 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__.MatNd_rwPinv2_, i32 noundef 1957, ptr noundef @.str.128) #6
  %51 = load ptr, ptr @stderr, align 8, !tbaa !5
  %52 = load ptr, ptr %11, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._MatNd, ptr %52, i32 0, i32 3
  %54 = load i32, ptr %53, align 8, !tbaa !15
  %55 = load i32, ptr %12, align 4, !tbaa !13
  %56 = load i32, ptr %13, align 4, !tbaa !13
  %57 = mul i32 %55, %56
  %58 = load i32, ptr %13, align 4, !tbaa !13
  %59 = load i32, ptr %13, align 4, !tbaa !13
  %60 = mul i32 %58, %59
  %61 = add i32 %57, %60
  %62 = load i32, ptr %12, align 4, !tbaa !13
  %63 = load i32, ptr %13, align 4, !tbaa !13
  %64 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %51, ptr noundef @.str.129, i32 noundef %54, i32 noundef %61, i32 noundef %62, i32 noundef %63) #6
  %65 = load ptr, ptr @stderr, align 8, !tbaa !5
  %66 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef @.str.4) #6
  call void @print_trace()
  call void @exit(i32 noundef 1) #7
  unreachable

67:                                               ; preds = %36
  br label %68

68:                                               ; preds = %67
  br label %69

69:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr %16) #6
  %70 = load i32, ptr %13, align 4, !tbaa !13
  %71 = load i32, ptr %12, align 4, !tbaa !13
  %72 = load ptr, ptr %11, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct._MatNd, ptr %72, i32 0, i32 0
  %74 = load ptr, ptr %73, align 8, !tbaa !16
  %75 = getelementptr inbounds double, ptr %74, i64 0
  call void @MatNd_fromPtr(ptr dead_on_unwind writable sret(%struct._MatNd) align 8 %16, i32 noundef %70, i32 noundef %71, ptr noundef %75)
  call void @llvm.lifetime.start.p0(i64 24, ptr %17) #6
  %76 = load i32, ptr %13, align 4, !tbaa !13
  %77 = load i32, ptr %13, align 4, !tbaa !13
  %78 = load ptr, ptr %11, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct._MatNd, ptr %78, i32 0, i32 0
  %80 = load ptr, ptr %79, align 8, !tbaa !16
  %81 = load i32, ptr %12, align 4, !tbaa !13
  %82 = load i32, ptr %13, align 4, !tbaa !13
  %83 = mul i32 %81, %82
  %84 = zext i32 %83 to i64
  %85 = getelementptr inbounds double, ptr %80, i64 %84
  call void @MatNd_fromPtr(ptr dead_on_unwind writable sret(%struct._MatNd) align 8 %17, i32 noundef %76, i32 noundef %77, ptr noundef %85)
  %86 = load ptr, ptr %8, align 8, !tbaa !5
  call void @MatNd_transpose(ptr noundef %16, ptr noundef %86)
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  %88 = icmp ne ptr %87, null
  br i1 %88, label %89, label %99

89:                                               ; preds = %69
  %90 = load ptr, ptr %9, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct._MatNd, ptr %90, i32 0, i32 2
  %92 = load i32, ptr %91, align 4, !tbaa !14
  %93 = icmp eq i32 %92, 1
  br i1 %93, label %94, label %96

94:                                               ; preds = %89
  %95 = load ptr, ptr %9, align 8, !tbaa !5
  call void @MatNd_postMulDiagSelf(ptr noundef %16, ptr noundef %95)
  br label %98

96:                                               ; preds = %89
  %97 = load ptr, ptr %9, align 8, !tbaa !5
  call void @MatNd_postMulSelf(ptr noundef %16, ptr noundef %97)
  br label %98

98:                                               ; preds = %96, %94
  br label %99

99:                                               ; preds = %98, %69
  %100 = load ptr, ptr %8, align 8, !tbaa !5
  call void @MatNd_mul(ptr noundef %17, ptr noundef %16, ptr noundef %100)
  %101 = load ptr, ptr %10, align 8, !tbaa !5
  %102 = icmp ne ptr %101, null
  br i1 %102, label %103, label %181

103:                                              ; preds = %99
  %104 = load ptr, ptr %10, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct._MatNd, ptr %104, i32 0, i32 2
  %106 = load i32, ptr %105, align 4, !tbaa !14
  %107 = icmp eq i32 %106, 1
  br i1 %107, label %108, label %110

108:                                              ; preds = %103
  %109 = load ptr, ptr %10, align 8, !tbaa !5
  call void @MatNd_addDiag(ptr noundef %17, ptr noundef %109)
  br label %180

110:                                              ; preds = %103
  %111 = load i32, ptr @RcsLogLevel, align 4, !tbaa !13
  %112 = icmp sle i32 4, %111
  br i1 %112, label %113, label %178

113:                                              ; preds = %110
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %114 = load i32, ptr %13, align 4, !tbaa !13
  %115 = load i32, ptr %13, align 4, !tbaa !13
  %116 = mul i32 %114, %115
  %117 = icmp ugt i32 %116, 1296
  br i1 %117, label %118, label %122

118:                                              ; preds = %113
  %119 = load i32, ptr %13, align 4, !tbaa !13
  %120 = load i32, ptr %13, align 4, !tbaa !13
  %121 = call ptr @MatNd_create(i32 noundef %119, i32 noundef %120)
  store ptr %121, ptr %18, align 8, !tbaa !5
  br label %160

122:                                              ; preds = %113
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  %123 = load i32, ptr %13, align 4, !tbaa !13
  %124 = load i32, ptr %13, align 4, !tbaa !13
  %125 = mul i32 %123, %124
  %126 = icmp eq i32 %125, 0
  br i1 %126, label %127, label %128

127:                                              ; preds = %122
  br label %132

128:                                              ; preds = %122
  %129 = load i32, ptr %13, align 4, !tbaa !13
  %130 = load i32, ptr %13, align 4, !tbaa !13
  %131 = mul i32 %129, %130
  br label %132

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

160:                                              ; preds = %132, %118
  %161 = load ptr, ptr %18, align 8, !tbaa !5
  %162 = load ptr, ptr %10, align 8, !tbaa !5
  %163 = call double @MatNd_choleskyDecomposition(ptr noundef %161, ptr noundef %162)
  store double %163, ptr %15, align 8, !tbaa !18
  %164 = load ptr, ptr %18, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %164)
  br label %165

165:                                              ; preds = %160
  %166 = load double, ptr %15, align 8, !tbaa !18
  %167 = fcmp ogt double %166, 0.000000e+00
  br i1 %167, label %175, label %168

168:                                              ; preds = %165
  %169 = load ptr, ptr @stderr, align 8, !tbaa !5
  %170 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %169, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__.MatNd_rwPinv2_, i32 noundef 1998, ptr noundef @.str.126) #6
  %171 = load ptr, ptr @stderr, align 8, !tbaa !5
  %172 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %171, ptr noundef @.str.127) #6
  %173 = load ptr, ptr @stderr, align 8, !tbaa !5
  %174 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %173, ptr noundef @.str.4) #6
  call void @print_trace()
  call void @exit(i32 noundef 1) #7
  unreachable

175:                                              ; preds = %165
  br label %176

176:                                              ; preds = %175
  br label %177

177:                                              ; preds = %176
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  br label %178

178:                                              ; preds = %177, %110
  %179 = load ptr, ptr %10, align 8, !tbaa !5
  call void @MatNd_addSelf(ptr noundef %17, ptr noundef %179)
  br label %180

180:                                              ; preds = %178, %108
  br label %181

181:                                              ; preds = %180, %99
  %182 = call double @MatNd_choleskyInverse(ptr noundef %17, ptr noundef %17)
  store double %182, ptr %15, align 8, !tbaa !18
  %183 = load ptr, ptr %7, align 8, !tbaa !5
  %184 = load i32, ptr %13, align 4, !tbaa !13
  %185 = load i32, ptr %12, align 4, !tbaa !13
  call void @MatNd_reshape(ptr noundef %183, i32 noundef %184, i32 noundef %185)
  %186 = load double, ptr %15, align 8, !tbaa !18
  %187 = fcmp ogt double %186, 0.000000e+00
  br i1 %187, label %188, label %190

188:                                              ; preds = %181
  %189 = load ptr, ptr %7, align 8, !tbaa !5
  call void @MatNd_mul(ptr noundef %189, ptr noundef %17, ptr noundef %16)
  br label %192

190:                                              ; preds = %181
  %191 = load ptr, ptr %7, align 8, !tbaa !5
  call void @MatNd_setZero(ptr noundef %191)
  br label %192

192:                                              ; preds = %190, %188
  %193 = load double, ptr %15, align 8, !tbaa !18
  store double %193, ptr %6, align 8
  store i32 1, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 24, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br label %194

194:                                              ; preds = %192, %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  %195 = load double, ptr %6, align 8
  ret double %195
}

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

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, !11, i64 16}
!16 = !{!10, !6, i64 0}
!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"

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

@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
@.str.126 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.127 = external hidden unnamed_addr constant [32 x i8], align 1
@__func__.MatNd_rwPinv2_ = external hidden unnamed_addr constant [15 x i8], align 1
@.str.128 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.129 = external hidden unnamed_addr constant [73 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: mustprogress 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) local_unnamed_addr #4

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

; Function Attrs: mustprogress 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) local_unnamed_addr #4

; Function Attrs: mustprogress 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) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_fromPtr(ptr dead_on_unwind noalias writable sret(%struct._MatNd) align 8, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

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

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

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

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

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

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: nounwind uwtable
define dso_local double @MatNd_rwPinv2_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr nocapture noundef readonly %4) local_unnamed_addr #4 {
  %6 = alloca %struct._MatNd, align 8
  %7 = alloca %struct._MatNd, align 8
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load i32, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %1, i64 12
  %11 = load i32, ptr %10, align 4, !tbaa !12
  %12 = icmp eq i32 %9, 0
  %13 = icmp eq i32 %11, 0
  %or.cond = select i1 %12, i1 true, i1 %13
  br i1 %or.cond, label %14, label %15

14:                                               ; preds = %5
  tail call void @MatNd_reshape(ptr noundef %0, i32 noundef %11, i32 noundef %9)
  br label %81

15:                                               ; preds = %5
  %16 = getelementptr inbounds i8, ptr %4, i64 16
  %17 = load i32, ptr %16, align 8, !tbaa !13
  %18 = mul i32 %11, %9
  %19 = mul i32 %11, %11
  %20 = add i32 %18, %19
  %.not = icmp ult i32 %17, %20
  br i1 %.not, label %21, label %29

21:                                               ; preds = %15
  %22 = load ptr, ptr @stderr, align 8, !tbaa !14
  %23 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.MatNd_rwPinv2_, i32 noundef 1957, ptr noundef nonnull @.str.128) #7
  %24 = load ptr, ptr @stderr, align 8, !tbaa !14
  %25 = load i32, ptr %16, align 8, !tbaa !13
  %26 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef nonnull @.str.129, i32 noundef %25, i32 noundef %20, i32 noundef %9, i32 noundef %11) #7
  %27 = load ptr, ptr @stderr, align 8, !tbaa !14
  %28 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef nonnull @.str.4) #7
  tail call void @print_trace() #8
  tail call void @exit(i32 noundef 1) #9
  unreachable

29:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #8
  %30 = load ptr, ptr %4, align 8, !tbaa !15
  call void @MatNd_fromPtr(ptr dead_on_unwind nonnull writable sret(%struct._MatNd) align 8 %6, i32 noundef %11, i32 noundef %9, ptr noundef %30)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #8
  %31 = load ptr, ptr %4, align 8, !tbaa !15
  %32 = zext i32 %18 to i64
  %33 = getelementptr inbounds double, ptr %31, i64 %32
  call void @MatNd_fromPtr(ptr dead_on_unwind nonnull writable sret(%struct._MatNd) align 8 %7, i32 noundef %11, i32 noundef %11, ptr noundef %33)
  call void @MatNd_transpose(ptr noundef nonnull %6, ptr noundef nonnull %1)
  %.not76 = icmp eq ptr %2, null
  br i1 %.not76, label %40, label %34

34:                                               ; preds = %29
  %35 = getelementptr inbounds i8, ptr %2, i64 12
  %36 = load i32, ptr %35, align 4, !tbaa !12
  %37 = icmp eq i32 %36, 1
  br i1 %37, label %38, label %39

38:                                               ; preds = %34
  call void @MatNd_postMulDiagSelf(ptr noundef nonnull %6, ptr noundef nonnull %2)
  br label %40

39:                                               ; preds = %34
  call void @MatNd_postMulSelf(ptr noundef nonnull %6, ptr noundef nonnull %2)
  br label %40

40:                                               ; preds = %38, %39, %29
  call void @MatNd_mul(ptr noundef nonnull %7, ptr noundef nonnull %6, ptr noundef nonnull %1)
  %.not77 = icmp eq ptr %3, null
  br i1 %.not77, label %75, label %41

41:                                               ; preds = %40
  %42 = getelementptr inbounds i8, ptr %3, i64 12
  %43 = load i32, ptr %42, align 4, !tbaa !12
  %44 = icmp eq i32 %43, 1
  br i1 %44, label %45, label %46

45:                                               ; preds = %41
  call void @MatNd_addDiag(ptr noundef nonnull %7, ptr noundef nonnull %3)
  br label %75

46:                                               ; preds = %41
  %47 = load i32, ptr @RcsLogLevel, align 4, !tbaa !16
  %48 = icmp sgt i32 %47, 3
  br i1 %48, label %49, label %74

49:                                               ; preds = %46
  %50 = icmp ugt i32 %19, 1296
  br i1 %50, label %51, label %53

51:                                               ; preds = %49
  %52 = call ptr @MatNd_create(i32 noundef %11, i32 noundef %11)
  br label %64

53:                                               ; preds = %49
  %54 = call i32 @llvm.umax.i32(i32 %19, i32 1)
  %55 = shl nuw nsw i32 %54, 3
  %56 = zext nneg i32 %55 to i64
  %57 = add nuw nsw i64 %56, 24
  %58 = alloca i8, i64 %57, align 16
  %59 = getelementptr inbounds i8, ptr %58, i64 24
  store ptr %59, ptr %58, align 16, !tbaa !15
  %60 = getelementptr inbounds i8, ptr %58, i64 8
  store i32 %11, ptr %60, align 8, !tbaa !5
  %61 = getelementptr inbounds i8, ptr %58, i64 12
  store i32 %11, ptr %61, align 4, !tbaa !12
  %62 = getelementptr inbounds i8, ptr %58, i64 16
  store i32 %54, ptr %62, align 16, !tbaa !13
  %63 = getelementptr inbounds i8, ptr %58, i64 20
  store i8 1, ptr %63, align 4, !tbaa !17
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %59, i8 0, i64 %56, i1 false)
  br label %64

64:                                               ; preds = %53, %51
  %.069 = phi ptr [ %52, %51 ], [ %58, %53 ]
  %65 = call double @MatNd_choleskyDecomposition(ptr noundef %.069, ptr noundef nonnull %3) #8
  call void @MatNd_destroy(ptr noundef %.069)
  %66 = fcmp ogt double %65, 0.000000e+00
  br i1 %66, label %74, label %67

67:                                               ; preds = %64
  %68 = load ptr, ptr @stderr, align 8, !tbaa !14
  %69 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %68, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.MatNd_rwPinv2_, i32 noundef 1998, ptr noundef nonnull @.str.126) #7
  %70 = load ptr, ptr @stderr, align 8, !tbaa !14
  %71 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %70, ptr noundef nonnull @.str.127) #7
  %72 = load ptr, ptr @stderr, align 8, !tbaa !14
  %73 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %72, ptr noundef nonnull @.str.4) #7
  call void @print_trace() #8
  call void @exit(i32 noundef 1) #9
  unreachable

74:                                               ; preds = %64, %46
  call void @MatNd_addSelf(ptr noundef nonnull %7, ptr noundef nonnull %3)
  br label %75

75:                                               ; preds = %45, %74, %40
  %76 = call double @MatNd_choleskyInverse(ptr noundef nonnull %7, ptr noundef nonnull %7) #8
  call void @MatNd_reshape(ptr noundef %0, i32 noundef %11, i32 noundef %9)
  %77 = fcmp ogt double %76, 0.000000e+00
  br i1 %77, label %78, label %79

78:                                               ; preds = %75
  call void @MatNd_mul(ptr noundef %0, ptr noundef nonnull %7, ptr noundef nonnull %6)
  br label %80

79:                                               ; preds = %75
  call void @MatNd_setZero(ptr noundef %0)
  br label %80

80:                                               ; preds = %79, %78
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #8
  br label %81

81:                                               ; preds = %80, %14
  %.0 = phi double [ 1.000000e+00, %14 ], [ %76, %80 ]
  ret double %.0
}

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

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

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 = { mustprogress 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { cold nounwind }
attributes #8 = { nounwind }
attributes #9 = { 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, !10, i64 16}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !7, i64 0}
!16 = !{!10, !10, i64 0}
!17 = !{!6, !11, i64 20}


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