; 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.1 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [43 x i8], align 1
@__func__.MatNd_calcMeanAndCovariance = external hidden unnamed_addr constant [28 x i8], align 1
@.str.231 = external hidden unnamed_addr constant [37 x i8], align 1

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

declare void @print_trace() #1

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

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

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

; Function Attrs: noreturn nounwind
declare void @abort() #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) #3

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

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

; Function Attrs: nounwind uwtable
declare dso_local double @MatNd_mean(ptr noundef) #3

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

; Function Attrs: nounwind uwtable
define dso_local void @MatNd_calcMeanAndCovariance(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca double, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %3
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._MatNd, ptr %17, i32 0, i32 2
  %19 = load i32, ptr %18, align 4, !tbaa !9
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._MatNd, ptr %20, i32 0, i32 1
  %22 = load i32, ptr %21, align 8, !tbaa !13
  %23 = icmp eq i32 %19, %22
  br i1 %23, label %24, label %32

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

32:                                               ; preds = %24, %16
  %33 = load ptr, ptr @stderr, align 8, !tbaa !5
  %34 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %33, ptr noundef @.str.5, ptr noundef @.str.1, ptr noundef @__func__.MatNd_calcMeanAndCovariance, i32 noundef 3777, ptr noundef @.str.231) #6
  call void @print_trace()
  call void @abort() #7
  unreachable

35:                                               ; preds = %24
  br label %36

36:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store ptr null, ptr %7, align 8, !tbaa !5
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._MatNd, ptr %37, i32 0, i32 1
  %39 = load i32, ptr %38, align 8, !tbaa !13
  %40 = mul i32 %39, 1
  %41 = icmp ugt i32 %40, 1296
  br i1 %41, label %42, label %47

42:                                               ; preds = %36
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct._MatNd, ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 8, !tbaa !13
  %46 = call ptr @MatNd_create(i32 noundef %45, i32 noundef 1)
  store ptr %46, ptr %7, align 8, !tbaa !5
  br label %88

47:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._MatNd, ptr %48, i32 0, i32 1
  %50 = load i32, ptr %49, align 8, !tbaa !13
  %51 = mul i32 %50, 1
  %52 = icmp eq i32 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %47
  br label %59

54:                                               ; preds = %47
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._MatNd, ptr %55, i32 0, i32 1
  %57 = load i32, ptr %56, align 8, !tbaa !13
  %58 = mul i32 %57, 1
  br label %59

59:                                               ; preds = %54, %53
  %60 = phi i32 [ 1, %53 ], [ %58, %54 ]
  store i32 %60, ptr %8, align 4, !tbaa !14
  %61 = load i32, ptr %8, align 4, !tbaa !14
  %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 %7, align 8, !tbaa !5
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._MatNd, ptr %66, i64 1
  %68 = load ptr, ptr %7, 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 ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._MatNd, ptr %70, i32 0, i32 1
  %72 = load i32, ptr %71, align 8, !tbaa !13
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._MatNd, ptr %73, i32 0, i32 1
  store i32 %72, ptr %74, align 8, !tbaa !13
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct._MatNd, ptr %75, i32 0, i32 2
  store i32 1, ptr %76, align 4, !tbaa !9
  %77 = load i32, ptr %8, align 4, !tbaa !14
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct._MatNd, ptr %78, i32 0, i32 3
  store i32 %77, ptr %79, align 8, !tbaa !16
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct._MatNd, ptr %80, i32 0, i32 4
  store i8 1, ptr %81, align 4, !tbaa !17
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct._MatNd, ptr %82, i32 0, i32 0
  %84 = load ptr, ptr %83, align 8, !tbaa !15
  %85 = load i32, ptr %8, align 4, !tbaa !14
  %86 = zext i32 %85 to i64
  %87 = mul i64 %86, 8
  call void @llvm.memset.p0.i64(ptr align 8 %84, i8 0, i64 %87, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %88

88:                                               ; preds = %59, %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  store ptr null, ptr %9, align 8, !tbaa !5
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct._MatNd, ptr %89, i32 0, i32 1
  %91 = load i32, ptr %90, align 8, !tbaa !13
  %92 = mul i32 %91, 1
  %93 = icmp ugt i32 %92, 1296
  br i1 %93, label %94, label %99

94:                                               ; preds = %88
  %95 = load ptr, ptr %4, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct._MatNd, ptr %95, i32 0, i32 1
  %97 = load i32, ptr %96, align 8, !tbaa !13
  %98 = call ptr @MatNd_create(i32 noundef %97, i32 noundef 1)
  store ptr %98, ptr %9, align 8, !tbaa !5
  br label %140

99:                                               ; preds = %88
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct._MatNd, ptr %100, i32 0, i32 1
  %102 = load i32, ptr %101, align 8, !tbaa !13
  %103 = mul i32 %102, 1
  %104 = icmp eq i32 %103, 0
  br i1 %104, label %105, label %106

105:                                              ; preds = %99
  br label %111

106:                                              ; preds = %99
  %107 = load ptr, ptr %4, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct._MatNd, ptr %107, i32 0, i32 1
  %109 = load i32, ptr %108, align 8, !tbaa !13
  %110 = mul i32 %109, 1
  br label %111

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

140:                                              ; preds = %111, %94
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !14
  br label %141

141:                                              ; preds = %205, %140
  %142 = load i32, ptr %11, align 4, !tbaa !14
  %143 = load ptr, ptr %4, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct._MatNd, ptr %143, i32 0, i32 2
  %145 = load i32, ptr %144, align 4, !tbaa !9
  %146 = icmp ult i32 %142, %145
  br i1 %146, label %148, label %147

147:                                              ; preds = %141
  store i32 4, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %208

148:                                              ; preds = %141
  %149 = load ptr, ptr %7, align 8, !tbaa !5
  %150 = load i32, ptr %11, align 4, !tbaa !14
  %151 = load ptr, ptr %4, align 8, !tbaa !5
  call void @MatNd_getColumn(ptr noundef %149, i32 noundef %150, ptr noundef %151)
  %152 = load ptr, ptr %7, align 8, !tbaa !5
  %153 = call double @MatNd_mean(ptr noundef %152)
  %154 = load ptr, ptr %5, align 8, !tbaa !5
  %155 = load i32, ptr %11, align 4, !tbaa !14
  %156 = zext i32 %155 to i64
  %157 = getelementptr inbounds double, ptr %154, i64 %156
  store double %153, ptr %157, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %158 = load i32, ptr %11, align 4, !tbaa !14
  store i32 %158, ptr %13, align 4, !tbaa !14
  br label %159

159:                                              ; preds = %184, %148
  %160 = load i32, ptr %13, align 4, !tbaa !14
  %161 = load ptr, ptr %4, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct._MatNd, ptr %161, i32 0, i32 2
  %163 = load i32, ptr %162, align 4, !tbaa !9
  %164 = icmp ult i32 %160, %163
  br i1 %164, label %166, label %165

165:                                              ; preds = %159
  store i32 7, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %187

166:                                              ; preds = %159
  %167 = load ptr, ptr %9, align 8, !tbaa !5
  %168 = load i32, ptr %13, align 4, !tbaa !14
  %169 = load ptr, ptr %4, align 8, !tbaa !5
  call void @MatNd_getColumn(ptr noundef %167, i32 noundef %168, ptr noundef %169)
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %170 = load ptr, ptr %7, align 8, !tbaa !5
  %171 = getelementptr inbounds %struct._MatNd, ptr %170, i32 0, i32 0
  %172 = load ptr, ptr %171, align 8, !tbaa !15
  %173 = load ptr, ptr %9, align 8, !tbaa !5
  %174 = getelementptr inbounds %struct._MatNd, ptr %173, i32 0, i32 0
  %175 = load ptr, ptr %174, align 8, !tbaa !15
  %176 = load ptr, ptr %4, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct._MatNd, ptr %176, i32 0, i32 1
  %178 = load i32, ptr %177, align 8, !tbaa !13
  %179 = call double @VecNd_covariance(ptr noundef %172, ptr noundef %175, i32 noundef %178)
  store double %179, ptr %14, align 8, !tbaa !18
  %180 = load ptr, ptr %6, align 8, !tbaa !5
  %181 = load i32, ptr %11, align 4, !tbaa !14
  %182 = load i32, ptr %13, align 4, !tbaa !14
  %183 = load double, ptr %14, align 8, !tbaa !18
  call void @MatNd_set(ptr noundef %180, i32 noundef %181, i32 noundef %182, double noundef %183)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %184

184:                                              ; preds = %166
  %185 = load i32, ptr %13, align 4, !tbaa !14
  %186 = add i32 %185, 1
  store i32 %186, ptr %13, align 4, !tbaa !14
  br label %159, !llvm.loop !20

187:                                              ; preds = %165
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 0, ptr %15, align 4, !tbaa !14
  br label %188

188:                                              ; preds = %201, %187
  %189 = load i32, ptr %15, align 4, !tbaa !14
  %190 = load i32, ptr %11, align 4, !tbaa !14
  %191 = icmp ult i32 %189, %190
  br i1 %191, label %193, label %192

192:                                              ; preds = %188
  store i32 10, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  br label %204

193:                                              ; preds = %188
  %194 = load ptr, ptr %6, align 8, !tbaa !5
  %195 = load i32, ptr %11, align 4, !tbaa !14
  %196 = load i32, ptr %15, align 4, !tbaa !14
  %197 = load ptr, ptr %6, align 8, !tbaa !5
  %198 = load i32, ptr %15, align 4, !tbaa !14
  %199 = load i32, ptr %11, align 4, !tbaa !14
  %200 = call double @MatNd_get(ptr noundef %197, i32 noundef %198, i32 noundef %199)
  call void @MatNd_set(ptr noundef %194, i32 noundef %195, i32 noundef %196, double noundef %200)
  br label %201

201:                                              ; preds = %193
  %202 = load i32, ptr %15, align 4, !tbaa !14
  %203 = add i32 %202, 1
  store i32 %203, ptr %15, align 4, !tbaa !14
  br label %188, !llvm.loop !22

204:                                              ; preds = %192
  br label %205

205:                                              ; preds = %204
  %206 = load i32, ptr %11, align 4, !tbaa !14
  %207 = add i32 %206, 1
  store i32 %207, ptr %11, align 4, !tbaa !14
  br label %141, !llvm.loop !23

208:                                              ; preds = %147
  %209 = load ptr, ptr %7, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %209)
  %210 = load ptr, ptr %9, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %210)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  ret void
}

declare double @VecNd_covariance(ptr noundef, ptr noundef, i32 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !11, i64 12}
!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 = !{!10, !11, i64 8}
!14 = !{!11, !11, i64 0}
!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}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}
!23 = distinct !{!23, !21}


; 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.1 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [43 x i8], align 1
@__func__.MatNd_calcMeanAndCovariance = external hidden unnamed_addr constant [28 x i8], align 1
@.str.231 = external hidden unnamed_addr constant [37 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: nounwind uwtable
declare dso_local ptr @MatNd_create(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: noreturn nounwind
declare void @abort() 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 #2

; Function Attrs: nounwind uwtable
declare dso_local double @MatNd_get(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_set(ptr noundef, i32 noundef, i32 noundef, double noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local double @MatNd_mean(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local void @MatNd_calcMeanAndCovariance(ptr noundef %0, ptr nocapture noundef writeonly %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 12
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %2, i64 8
  %7 = load i32, ptr %6, align 8, !tbaa !12
  %8 = icmp eq i32 %5, %7
  br i1 %8, label %9, label %13

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %2, i64 12
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = icmp eq i32 %5, %11
  br i1 %12, label %16, label %13

13:                                               ; preds = %9, %3
  %14 = load ptr, ptr @stderr, align 8, !tbaa !13
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.MatNd_calcMeanAndCovariance, i32 noundef 3777, ptr noundef nonnull @.str.231) #6
  tail call void @print_trace() #7
  tail call void @abort() #8
  unreachable

16:                                               ; preds = %9
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = load i32, ptr %17, align 8, !tbaa !12
  %19 = icmp ugt i32 %18, 1296
  br i1 %19, label %29, label %.thread

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

29:                                               ; preds = %16
  %30 = tail call ptr @MatNd_create(i32 noundef %18, i32 noundef 1)
  %.pre = load i32, ptr %17, align 8, !tbaa !12
  %31 = icmp ugt i32 %.pre, 1296
  br i1 %31, label %32, label %34

32:                                               ; preds = %29
  %33 = tail call ptr @MatNd_create(i32 noundef %.pre, i32 noundef 1)
  br label %45

34:                                               ; preds = %.thread, %29
  %.06788 = phi ptr [ %23, %.thread ], [ %30, %29 ]
  %35 = phi i32 [ %18, %.thread ], [ %.pre, %29 ]
  %spec.select75 = call i32 @llvm.umax.i32(i32 %35, i32 1)
  %36 = shl nuw nsw i32 %spec.select75, 3
  %37 = zext nneg i32 %36 to i64
  %38 = add nuw nsw i64 %37, 24
  %39 = alloca i8, i64 %38, align 16
  %40 = getelementptr inbounds i8, ptr %39, i64 24
  store ptr %40, ptr %39, align 16, !tbaa !14
  %41 = getelementptr inbounds i8, ptr %39, i64 8
  store i32 %35, ptr %41, align 8, !tbaa !12
  %42 = getelementptr inbounds i8, ptr %39, i64 12
  store i32 1, ptr %42, align 4, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %39, i64 16
  store i32 %spec.select75, ptr %43, align 16, !tbaa !15
  %44 = getelementptr inbounds i8, ptr %39, i64 20
  store i8 1, ptr %44, align 4, !tbaa !16
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %40, i8 0, i64 %37, i1 false)
  br label %45

45:                                               ; preds = %34, %32
  %.06787 = phi ptr [ %30, %32 ], [ %.06788, %34 ]
  %.070 = phi ptr [ %33, %32 ], [ %39, %34 ]
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %.not = icmp eq i32 %46, 0
  br i1 %.not, label %._crit_edge82, label %.lr.ph81

._crit_edge82:                                    ; preds = %._crit_edge, %45
  call void @MatNd_destroy(ptr noundef %.06787)
  call void @MatNd_destroy(ptr noundef %.070)
  ret void

.lr.ph81:                                         ; preds = %45, %._crit_edge
  %indvars.iv = phi i64 [ %indvars.iv.next, %._crit_edge ], [ 0, %45 ]
  %47 = trunc nuw i64 %indvars.iv to i32
  call void @MatNd_getColumn(ptr noundef %.06787, i32 noundef %47, ptr noundef nonnull %0)
  %48 = call double @MatNd_mean(ptr noundef %.06787)
  %49 = getelementptr inbounds double, ptr %1, i64 %indvars.iv
  store double %48, ptr %49, align 8, !tbaa !17
  %50 = load i32, ptr %4, align 4, !tbaa !5
  %51 = zext i32 %50 to i64
  %52 = icmp ult i64 %indvars.iv, %51
  br i1 %52, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %.lr.ph, %.lr.ph81
  %53 = phi i32 [ %50, %.lr.ph81 ], [ %59, %.lr.ph ]
  %.not83 = icmp eq i64 %indvars.iv, 0
  br i1 %.not83, label %._crit_edge, label %.lr.ph78

.lr.ph:                                           ; preds = %.lr.ph81, %.lr.ph
  %.06876 = phi i32 [ %58, %.lr.ph ], [ %47, %.lr.ph81 ]
  call void @MatNd_getColumn(ptr noundef %.070, i32 noundef %.06876, ptr noundef nonnull %0)
  %54 = load ptr, ptr %.06787, align 8, !tbaa !14
  %55 = load ptr, ptr %.070, align 8, !tbaa !14
  %56 = load i32, ptr %17, align 8, !tbaa !12
  %57 = call double @VecNd_covariance(ptr noundef %54, ptr noundef %55, i32 noundef %56) #7
  call void @MatNd_set(ptr noundef %2, i32 noundef %47, i32 noundef %.06876, double noundef %57)
  %58 = add nuw i32 %.06876, 1
  %59 = load i32, ptr %4, align 4, !tbaa !5
  %60 = icmp ult i32 %58, %59
  br i1 %60, label %.lr.ph, label %.preheader, !llvm.loop !19

._crit_edge.loopexit:                             ; preds = %.lr.ph78
  %.pre85 = load i32, ptr %4, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %61 = phi i32 [ %.pre85, %._crit_edge.loopexit ], [ %53, %.preheader ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %62 = zext i32 %61 to i64
  %63 = icmp ult i64 %indvars.iv.next, %62
  br i1 %63, label %.lr.ph81, label %._crit_edge82, !llvm.loop !21

.lr.ph78:                                         ; preds = %.preheader, %.lr.ph78
  %.077 = phi i32 [ %65, %.lr.ph78 ], [ 0, %.preheader ]
  %64 = call double @MatNd_get(ptr noundef %2, i32 noundef %.077, i32 noundef %47)
  call void @MatNd_set(ptr noundef %2, i32 noundef %47, i32 noundef %.077, double noundef %64)
  %65 = add nuw i32 %.077, 1
  %66 = zext i32 %65 to i64
  %exitcond.not = icmp eq i64 %indvars.iv, %66
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %.lr.ph78, !llvm.loop !22
}

declare double @VecNd_covariance(ptr noundef, ptr noundef, i32 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 = { 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 #3 = { 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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { cold nounwind }
attributes #7 = { 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 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}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}
!22 = distinct !{!22, !20}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass