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

; 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.1 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [43 x i8], align 1
@__func__.Math_generalizedSquaredInterpointDistance = external hidden unnamed_addr constant [42 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [17 x i8], align 1

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

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

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

declare void @print_trace() #2

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @Math_isNAN(double noundef) #3

; Function Attrs: nounwind uwtable
define dso_local double @Math_generalizedSquaredInterpointDistance(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4) #3 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca double, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca double, align 8
  %18 = alloca %struct._MatNd, align 8
  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 i32 %3, ptr %9, align 4, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store ptr null, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  store double 0.000000e+00, ptr %12, align 8, !tbaa !11
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct._MatNd, ptr %19, i32 0, i32 2
  %21 = load i32, ptr %20, align 4, !tbaa !13
  %22 = icmp eq i32 %21, 1
  br i1 %22, label %23, label %81

23:                                               ; preds = %5
  br label %24

24:                                               ; preds = %23
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._MatNd, ptr %25, i32 0, i32 1
  %27 = load i32, ptr %26, align 8, !tbaa !16
  %28 = load i32, ptr %9, align 4, !tbaa !9
  %29 = icmp eq i32 %27, %28
  br i1 %29, label %33, label %30

30:                                               ; preds = %24
  %31 = load ptr, ptr @stderr, align 8, !tbaa !5
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef @.str.19, ptr noundef @.str.1, ptr noundef @__func__.Math_generalizedSquaredInterpointDistance, i32 noundef 689, ptr noundef @.str.20) #6
  call void @print_trace()
  call void @abort() #7
  unreachable

33:                                               ; preds = %24
  br label %34

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = mul i32 %36, 1
  %38 = icmp ugt i32 %37, 1296
  br i1 %38, label %39, label %42

39:                                               ; preds = %35
  %40 = load i32, ptr %9, align 4, !tbaa !9
  %41 = call ptr @MatNd_create(i32 noundef %40, i32 noundef 1)
  store ptr %41, ptr %11, align 8, !tbaa !5
  br label %77

42:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %43 = load i32, ptr %9, align 4, !tbaa !9
  %44 = mul i32 %43, 1
  %45 = icmp eq i32 %44, 0
  br i1 %45, label %46, label %47

46:                                               ; preds = %42
  br label %50

47:                                               ; preds = %42
  %48 = load i32, ptr %9, align 4, !tbaa !9
  %49 = mul i32 %48, 1
  br label %50

50:                                               ; preds = %47, %46
  %51 = phi i32 [ 1, %46 ], [ %49, %47 ]
  store i32 %51, ptr %13, align 4, !tbaa !9
  %52 = load i32, ptr %13, align 4, !tbaa !9
  %53 = zext i32 %52 to i64
  %54 = mul i64 %53, 8
  %55 = add i64 24, %54
  %56 = alloca i8, i64 %55, align 16
  store ptr %56, ptr %11, align 8, !tbaa !5
  %57 = load ptr, ptr %11, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct._MatNd, ptr %57, i64 1
  %59 = load ptr, ptr %11, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct._MatNd, ptr %59, i32 0, i32 0
  store ptr %58, ptr %60, align 8, !tbaa !17
  %61 = load i32, ptr %9, align 4, !tbaa !9
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct._MatNd, ptr %62, i32 0, i32 1
  store i32 %61, ptr %63, align 8, !tbaa !16
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct._MatNd, ptr %64, i32 0, i32 2
  store i32 1, ptr %65, align 4, !tbaa !13
  %66 = load i32, ptr %13, align 4, !tbaa !9
  %67 = load ptr, ptr %11, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct._MatNd, ptr %67, i32 0, i32 3
  store i32 %66, ptr %68, align 8, !tbaa !18
  %69 = load ptr, ptr %11, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct._MatNd, ptr %69, i32 0, i32 4
  store i8 1, ptr %70, align 4, !tbaa !19
  %71 = load ptr, ptr %11, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct._MatNd, ptr %71, i32 0, i32 0
  %73 = load ptr, ptr %72, align 8, !tbaa !17
  %74 = load i32, ptr %13, align 4, !tbaa !9
  %75 = zext i32 %74 to i64
  %76 = mul i64 %75, 8
  call void @llvm.memset.p0.i64(ptr align 8 %73, i8 0, i64 %76, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %77

77:                                               ; preds = %50, %39
  %78 = load ptr, ptr %11, align 8, !tbaa !5
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = call double @MatNd_inverseDiag(ptr noundef %78, ptr noundef %79)
  store double %80, ptr %12, align 8, !tbaa !11
  br label %159

81:                                               ; preds = %5
  br label %82

82:                                               ; preds = %81
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct._MatNd, ptr %83, i32 0, i32 1
  %85 = load i32, ptr %84, align 8, !tbaa !16
  %86 = load i32, ptr %9, align 4, !tbaa !9
  %87 = icmp eq i32 %85, %86
  br i1 %87, label %88, label %94

88:                                               ; preds = %82
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct._MatNd, ptr %89, i32 0, i32 2
  %91 = load i32, ptr %90, align 4, !tbaa !13
  %92 = load i32, ptr %9, align 4, !tbaa !9
  %93 = icmp eq i32 %91, %92
  br i1 %93, label %97, label %94

94:                                               ; preds = %88, %82
  %95 = load ptr, ptr @stderr, align 8, !tbaa !5
  %96 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %95, ptr noundef @.str.19, ptr noundef @.str.1, ptr noundef @__func__.Math_generalizedSquaredInterpointDistance, i32 noundef 695, ptr noundef @.str.21) #6
  call void @print_trace()
  call void @abort() #7
  unreachable

97:                                               ; preds = %88
  br label %98

98:                                               ; preds = %97
  br label %99

99:                                               ; preds = %98
  %100 = load i32, ptr %9, align 4, !tbaa !9
  %101 = load i32, ptr %9, align 4, !tbaa !9
  %102 = mul i32 %100, %101
  %103 = icmp ugt i32 %102, 1296
  br i1 %103, label %104, label %108

104:                                              ; preds = %99
  %105 = load i32, ptr %9, align 4, !tbaa !9
  %106 = load i32, ptr %9, align 4, !tbaa !9
  %107 = call ptr @MatNd_create(i32 noundef %105, i32 noundef %106)
  store ptr %107, ptr %11, align 8, !tbaa !5
  br label %146

108:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %109 = load i32, ptr %9, align 4, !tbaa !9
  %110 = load i32, ptr %9, align 4, !tbaa !9
  %111 = mul i32 %109, %110
  %112 = icmp eq i32 %111, 0
  br i1 %112, label %113, label %114

113:                                              ; preds = %108
  br label %118

114:                                              ; preds = %108
  %115 = load i32, ptr %9, align 4, !tbaa !9
  %116 = load i32, ptr %9, align 4, !tbaa !9
  %117 = mul i32 %115, %116
  br label %118

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

146:                                              ; preds = %118, %104
  %147 = load ptr, ptr %11, align 8, !tbaa !5
  %148 = load ptr, ptr %6, align 8, !tbaa !5
  %149 = call double @MatNd_choleskyInverse(ptr noundef %147, ptr noundef %148)
  store double %149, ptr %12, align 8, !tbaa !11
  br label %150

150:                                              ; preds = %146
  %151 = load double, ptr %12, align 8, !tbaa !11
  %152 = call zeroext i1 @Math_isNAN(double noundef %151)
  br i1 %152, label %153, label %156

153:                                              ; preds = %150
  %154 = load ptr, ptr @stderr, align 8, !tbaa !5
  %155 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %154, ptr noundef @.str.19, ptr noundef @.str.1, ptr noundef @__func__.Math_generalizedSquaredInterpointDistance, i32 noundef 698, ptr noundef @.str.22) #6
  call void @print_trace()
  call void @abort() #7
  unreachable

156:                                              ; preds = %150
  br label %157

157:                                              ; preds = %156
  br label %158

158:                                              ; preds = %157
  br label %159

159:                                              ; preds = %158, %77
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  store ptr null, ptr %15, align 8, !tbaa !5
  %160 = load i32, ptr %9, align 4, !tbaa !9
  %161 = mul i32 %160, 1
  %162 = icmp ugt i32 %161, 1296
  br i1 %162, label %163, label %166

163:                                              ; preds = %159
  %164 = load i32, ptr %9, align 4, !tbaa !9
  %165 = call ptr @MatNd_create(i32 noundef %164, i32 noundef 1)
  store ptr %165, ptr %15, align 8, !tbaa !5
  br label %201

166:                                              ; preds = %159
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  %167 = load i32, ptr %9, align 4, !tbaa !9
  %168 = mul i32 %167, 1
  %169 = icmp eq i32 %168, 0
  br i1 %169, label %170, label %171

170:                                              ; preds = %166
  br label %174

171:                                              ; preds = %166
  %172 = load i32, ptr %9, align 4, !tbaa !9
  %173 = mul i32 %172, 1
  br label %174

174:                                              ; preds = %171, %170
  %175 = phi i32 [ 1, %170 ], [ %173, %171 ]
  store i32 %175, ptr %16, align 4, !tbaa !9
  %176 = load i32, ptr %16, align 4, !tbaa !9
  %177 = zext i32 %176 to i64
  %178 = mul i64 %177, 8
  %179 = add i64 24, %178
  %180 = alloca i8, i64 %179, align 16
  store ptr %180, ptr %15, align 8, !tbaa !5
  %181 = load ptr, ptr %15, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct._MatNd, ptr %181, i64 1
  %183 = load ptr, ptr %15, align 8, !tbaa !5
  %184 = getelementptr inbounds %struct._MatNd, ptr %183, i32 0, i32 0
  store ptr %182, ptr %184, align 8, !tbaa !17
  %185 = load i32, ptr %9, align 4, !tbaa !9
  %186 = load ptr, ptr %15, align 8, !tbaa !5
  %187 = getelementptr inbounds %struct._MatNd, ptr %186, i32 0, i32 1
  store i32 %185, ptr %187, align 8, !tbaa !16
  %188 = load ptr, ptr %15, align 8, !tbaa !5
  %189 = getelementptr inbounds %struct._MatNd, ptr %188, i32 0, i32 2
  store i32 1, ptr %189, align 4, !tbaa !13
  %190 = load i32, ptr %16, align 4, !tbaa !9
  %191 = load ptr, ptr %15, align 8, !tbaa !5
  %192 = getelementptr inbounds %struct._MatNd, ptr %191, i32 0, i32 3
  store i32 %190, ptr %192, align 8, !tbaa !18
  %193 = load ptr, ptr %15, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct._MatNd, ptr %193, i32 0, i32 4
  store i8 1, ptr %194, align 4, !tbaa !19
  %195 = load ptr, ptr %15, align 8, !tbaa !5
  %196 = getelementptr inbounds %struct._MatNd, ptr %195, i32 0, i32 0
  %197 = load ptr, ptr %196, align 8, !tbaa !17
  %198 = load i32, ptr %16, align 4, !tbaa !9
  %199 = zext i32 %198 to i64
  %200 = mul i64 %199, 8
  call void @llvm.memset.p0.i64(ptr align 8 %197, i8 0, i64 %200, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  br label %201

201:                                              ; preds = %174, %163
  %202 = load ptr, ptr %15, align 8, !tbaa !5
  %203 = getelementptr inbounds %struct._MatNd, ptr %202, i32 0, i32 0
  %204 = load ptr, ptr %203, align 8, !tbaa !17
  %205 = load ptr, ptr %8, align 8, !tbaa !5
  %206 = load ptr, ptr %7, align 8, !tbaa !5
  %207 = load i32, ptr %9, align 4, !tbaa !9
  call void @VecNd_sub(ptr noundef %204, ptr noundef %205, ptr noundef %206, i32 noundef %207)
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  store double 0.000000e+00, ptr %17, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 24, ptr %18) #6
  call void @MatNd_fromPtr(ptr dead_on_unwind writable sret(%struct._MatNd) align 8 %18, i32 noundef 1, i32 noundef 1, ptr noundef %17)
  %208 = load ptr, ptr %15, align 8, !tbaa !5
  %209 = load ptr, ptr %11, align 8, !tbaa !5
  call void @MatNd_sqrMulAtBA(ptr noundef %18, ptr noundef %208, ptr noundef %209)
  %210 = load ptr, ptr %11, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %210)
  %211 = load ptr, ptr %15, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %211)
  %212 = load ptr, ptr %10, align 8, !tbaa !5
  %213 = icmp ne ptr %212, null
  br i1 %213, label %214, label %217

214:                                              ; preds = %201
  %215 = load double, ptr %12, align 8, !tbaa !11
  %216 = load ptr, ptr %10, align 8, !tbaa !5
  store double %215, ptr %216, align 8, !tbaa !11
  br label %217

217:                                              ; preds = %214, %201
  %218 = load double, ptr %17, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 24, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  ret double %218
}

; Function Attrs: noreturn nounwind
declare void @abort() #4

declare ptr @MatNd_create(i32 noundef, i32 noundef) #2

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

declare double @MatNd_inverseDiag(ptr noundef, ptr noundef) #2

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

declare void @VecNd_sub(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #2

declare void @MatNd_fromPtr(ptr dead_on_unwind writable sret(%struct._MatNd) align 8, i32 noundef, i32 noundef, ptr noundef) #2

declare void @MatNd_sqrMulAtBA(ptr noundef, ptr noundef, ptr noundef) #2

declare void @MatNd_destroy(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 = { 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !10, i64 12}
!14 = !{!"_MatNd", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !15, i64 20}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!14, !10, i64 8}
!17 = !{!14, !6, i64 0}
!18 = !{!14, !10, i64 16}
!19 = !{!14, !15, i64 20}


; 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.1 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [43 x i8], align 1
@__func__.Math_generalizedSquaredInterpointDistance = external hidden unnamed_addr constant [42 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [17 x i8], align 1

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

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

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

declare void @print_trace() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @Math_isNAN(double noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local double @Math_generalizedSquaredInterpointDistance(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef writeonly %4) local_unnamed_addr #3 {
  %6 = alloca double, align 8
  %7 = alloca %struct._MatNd, align 8
  %8 = getelementptr inbounds i8, ptr %0, i64 12
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = icmp eq i32 %9, 1
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = load i32, ptr %11, align 8, !tbaa !12
  %13 = icmp eq i32 %12, %3
  br i1 %10, label %14, label %35

14:                                               ; preds = %5
  br i1 %13, label %18, label %15

15:                                               ; preds = %14
  %16 = load ptr, ptr @stderr, align 8, !tbaa !13
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.Math_generalizedSquaredInterpointDistance, i32 noundef 689, ptr noundef nonnull @.str.20) #7
  tail call void @print_trace() #8
  tail call void @abort() #9
  unreachable

18:                                               ; preds = %14
  %19 = icmp ugt i32 %3, 1296
  br i1 %19, label %20, label %22

20:                                               ; preds = %18
  %21 = tail call ptr @MatNd_create(i32 noundef %3, i32 noundef 1) #8
  br label %33

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

33:                                               ; preds = %22, %20
  %.0 = phi ptr [ %21, %20 ], [ %27, %22 ]
  %34 = call double @MatNd_inverseDiag(ptr noundef %.0, ptr noundef nonnull %0) #8
  br label %62

35:                                               ; preds = %5
  %36 = icmp eq i32 %9, %3
  %or.cond = and i1 %36, %13
  br i1 %or.cond, label %40, label %37

37:                                               ; preds = %35
  %38 = load ptr, ptr @stderr, align 8, !tbaa !13
  %39 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %38, ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.Math_generalizedSquaredInterpointDistance, i32 noundef 695, ptr noundef nonnull @.str.21) #7
  tail call void @print_trace() #8
  tail call void @abort() #9
  unreachable

40:                                               ; preds = %35
  %41 = mul i32 %3, %3
  %42 = icmp ugt i32 %41, 1296
  br i1 %42, label %43, label %45

43:                                               ; preds = %40
  %44 = tail call ptr @MatNd_create(i32 noundef %3, i32 noundef %3) #8
  br label %56

45:                                               ; preds = %40
  %46 = tail call i32 @llvm.umax.i32(i32 %41, i32 1)
  %47 = shl nuw nsw i32 %46, 3
  %48 = zext nneg i32 %47 to i64
  %49 = add nuw nsw i64 %48, 24
  %50 = alloca i8, i64 %49, align 16
  %51 = getelementptr inbounds i8, ptr %50, i64 24
  store ptr %51, ptr %50, align 16, !tbaa !14
  %52 = getelementptr inbounds i8, ptr %50, i64 8
  store i32 %3, ptr %52, align 8, !tbaa !12
  %53 = getelementptr inbounds i8, ptr %50, i64 12
  store i32 %3, ptr %53, align 4, !tbaa !5
  %54 = getelementptr inbounds i8, ptr %50, i64 16
  store i32 %46, ptr %54, align 16, !tbaa !15
  %55 = getelementptr inbounds i8, ptr %50, i64 20
  store i8 1, ptr %55, align 4, !tbaa !16
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %51, i8 0, i64 %48, i1 false)
  br label %56

56:                                               ; preds = %45, %43
  %.1 = phi ptr [ %44, %43 ], [ %50, %45 ]
  %57 = call double @MatNd_choleskyInverse(ptr noundef %.1, ptr noundef nonnull %0) #8
  %58 = call zeroext i1 @Math_isNAN(double noundef %57)
  br i1 %58, label %59, label %62

59:                                               ; preds = %56
  %60 = load ptr, ptr @stderr, align 8, !tbaa !13
  %61 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %60, ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.Math_generalizedSquaredInterpointDistance, i32 noundef 698, ptr noundef nonnull @.str.22) #7
  call void @print_trace() #8
  call void @abort() #9
  unreachable

62:                                               ; preds = %56, %33
  %.073 = phi double [ %34, %33 ], [ %57, %56 ]
  %.2 = phi ptr [ %.0, %33 ], [ %.1, %56 ]
  %63 = icmp ugt i32 %3, 1296
  br i1 %63, label %64, label %66

64:                                               ; preds = %62
  %65 = call ptr @MatNd_create(i32 noundef %3, i32 noundef 1) #8
  %.pre = load ptr, ptr %65, align 8, !tbaa !14
  br label %77

66:                                               ; preds = %62
  %67 = call i32 @llvm.umax.i32(i32 %3, i32 1)
  %68 = shl nuw nsw i32 %67, 3
  %69 = zext nneg i32 %68 to i64
  %70 = add nuw nsw i64 %69, 24
  %71 = alloca i8, i64 %70, align 16
  %72 = getelementptr inbounds i8, ptr %71, i64 24
  store ptr %72, ptr %71, align 16, !tbaa !14
  %73 = getelementptr inbounds i8, ptr %71, i64 8
  store i32 %3, ptr %73, align 8, !tbaa !12
  %74 = getelementptr inbounds i8, ptr %71, i64 12
  store i32 1, ptr %74, align 4, !tbaa !5
  %75 = getelementptr inbounds i8, ptr %71, i64 16
  store i32 %67, ptr %75, align 16, !tbaa !15
  %76 = getelementptr inbounds i8, ptr %71, i64 20
  store i8 1, ptr %76, align 4, !tbaa !16
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %72, i8 0, i64 %69, i1 false)
  br label %77

77:                                               ; preds = %66, %64
  %78 = phi ptr [ %.pre, %64 ], [ %72, %66 ]
  %.072 = phi ptr [ %65, %64 ], [ %71, %66 ]
  call void @VecNd_sub(ptr noundef %78, ptr noundef %2, ptr noundef %1, i32 noundef %3) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #8
  store double 0.000000e+00, ptr %6, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #8
  call void @MatNd_fromPtr(ptr dead_on_unwind nonnull writable sret(%struct._MatNd) align 8 %7, i32 noundef 1, i32 noundef 1, ptr noundef nonnull %6) #8
  call void @MatNd_sqrMulAtBA(ptr noundef nonnull %7, ptr noundef nonnull %.072, ptr noundef %.2) #8
  call void @MatNd_destroy(ptr noundef %.2) #8
  call void @MatNd_destroy(ptr noundef nonnull %.072) #8
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %80, label %79

79:                                               ; preds = %77
  store double %.073, ptr %4, align 8, !tbaa !17
  br label %80

80:                                               ; preds = %79, %77
  %81 = load double, ptr %6, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #8
  ret double %81
}

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #4

declare ptr @MatNd_create(i32 noundef, i32 noundef) local_unnamed_addr #2

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

declare double @MatNd_inverseDiag(ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare void @VecNd_sub(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @MatNd_fromPtr(ptr dead_on_unwind writable sret(%struct._MatNd) align 8, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

declare void @MatNd_sqrMulAtBA(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @MatNd_destroy(ptr noundef) local_unnamed_addr #2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 = { 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 #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 12}
!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 8}
!13 = !{!7, !7, i64 0}
!14 = !{!6, !7, i64 0}
!15 = !{!6, !10, i64 16}
!16 = !{!6, !11, i64 20}
!17 = !{!18, !18, i64 0}
!18 = !{!"double", !8, i64 0}


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