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

; 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 [71 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@RCS_GLOBAL_RLOG_CB = external global ptr, align 8
@RcsLogLevel = external global i32, align 4
@.str.6 = external hidden unnamed_addr constant [16 x i8], align 1
@__func__.Math_planeFit3d = external hidden unnamed_addr constant [16 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [37 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 @Vec3d_copy(ptr noundef, ptr noundef) #2

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

declare void @Vec3d_setZero(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @Math_planeFit3d(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #3 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca [3 x [3 x double]], align 16
  %17 = alloca [3 x double], align 16
  %18 = alloca i8, align 1
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = icmp ult i32 %22, 3
  br i1 %23, label %24, label %44

24:                                               ; preds = %4
  br label %25

25:                                               ; preds = %24
  %26 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %31

28:                                               ; preds = %25
  %29 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %30 = load i32, ptr %7, align 4, !tbaa !9
  call void (i32, ptr, ptr, i32, ptr, ...) %29(i32 noundef 1, ptr noundef @.str.1, ptr noundef @__func__.Math_planeFit3d, i32 noundef 1584, ptr noundef @.str.18, i32 noundef %30)
  br label %31

31:                                               ; preds = %28, %25
  %32 = load i32, ptr @RcsLogLevel, align 4, !tbaa !9
  %33 = icmp sle i32 1, %32
  br i1 %33, label %34, label %42

34:                                               ; preds = %31
  %35 = load ptr, ptr @stderr, align 8, !tbaa !5
  %36 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %35, ptr noundef @.str.6, ptr noundef @.str.1, ptr noundef @__func__.Math_planeFit3d, i32 noundef 1584) #4
  %37 = load ptr, ptr @stderr, align 8, !tbaa !5
  %38 = load i32, ptr %7, align 4, !tbaa !9
  %39 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef @.str.18, i32 noundef %38) #4
  %40 = load ptr, ptr @stderr, align 8, !tbaa !5
  %41 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef @.str.4) #4
  br label %42

42:                                               ; preds = %34, %31
  br label %43

43:                                               ; preds = %42
  store i1 false, ptr %5, align 1
  br label %148

44:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %45 = load i32, ptr %7, align 4, !tbaa !9
  %46 = call ptr @MatNd_create(i32 noundef %45, i32 noundef 3)
  store ptr %46, ptr %10, align 8, !tbaa !5
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  call void @Vec3d_setZero(ptr noundef %47)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %65, %44
  %49 = load i32, ptr %11, align 4, !tbaa !9
  %50 = load i32, ptr %7, align 4, !tbaa !9
  %51 = icmp ult i32 %49, %50
  br i1 %51, label %53, label %52

52:                                               ; preds = %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %68

53:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = load i32, ptr %11, align 4, !tbaa !9
  %56 = call ptr @MatNd_getRowPtr(ptr noundef %54, i32 noundef %55)
  store ptr %56, ptr %12, align 8, !tbaa !5
  %57 = load ptr, ptr %12, align 8, !tbaa !5
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = load i32, ptr %11, align 4, !tbaa !9
  %60 = zext i32 %59 to i64
  %61 = getelementptr inbounds [3 x double], ptr %58, i64 %60
  %62 = getelementptr inbounds [3 x double], ptr %61, i64 0, i64 0
  call void @Vec3d_copy(ptr noundef %57, ptr noundef %62)
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = load ptr, ptr %12, align 8, !tbaa !5
  call void @Vec3d_addSelf(ptr noundef %63, ptr noundef %64)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %65

65:                                               ; preds = %53
  %66 = load i32, ptr %11, align 4, !tbaa !9
  %67 = add i32 %66, 1
  store i32 %67, ptr %11, align 4, !tbaa !9
  br label %48, !llvm.loop !11

68:                                               ; preds = %52
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = load i32, ptr %7, align 4, !tbaa !9
  %71 = uitofp i32 %70 to double
  %72 = fdiv double 1.000000e+00, %71
  call void @Vec3d_constMulSelf(ptr noundef %69, double noundef %72)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %73

73:                                               ; preds = %84, %68
  %74 = load i32, ptr %13, align 4, !tbaa !9
  %75 = load i32, ptr %7, align 4, !tbaa !9
  %76 = icmp ult i32 %74, %75
  br i1 %76, label %78, label %77

77:                                               ; preds = %73
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %87

78:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %79 = load ptr, ptr %10, align 8, !tbaa !5
  %80 = load i32, ptr %13, align 4, !tbaa !9
  %81 = call ptr @MatNd_getRowPtr(ptr noundef %79, i32 noundef %80)
  store ptr %81, ptr %14, align 8, !tbaa !5
  %82 = load ptr, ptr %14, align 8, !tbaa !5
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  call void @Vec3d_subSelf(ptr noundef %82, ptr noundef %83)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %84

84:                                               ; preds = %78
  %85 = load i32, ptr %13, align 4, !tbaa !9
  %86 = add i32 %85, 1
  store i32 %86, ptr %13, align 4, !tbaa !9
  br label %73, !llvm.loop !13

87:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %88 = call ptr @MatNd_create(i32 noundef 3, i32 noundef 3)
  store ptr %88, ptr %15, align 8, !tbaa !5
  %89 = load ptr, ptr %15, align 8, !tbaa !5
  %90 = load ptr, ptr %10, align 8, !tbaa !5
  call void @MatNd_dyadicProduct(ptr noundef %89, ptr noundef %90)
  call void @llvm.lifetime.start.p0(i64 72, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %17) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %18) #4
  %91 = getelementptr inbounds [3 x [3 x double]], ptr %16, i64 0, i64 0
  %92 = getelementptr inbounds [3 x double], ptr %17, i64 0, i64 0
  %93 = load ptr, ptr %15, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct._MatNd, ptr %93, i32 0, i32 0
  %95 = load ptr, ptr %94, align 8, !tbaa !14
  %96 = call zeroext i1 @Mat3d_getEigenVectors(ptr noundef %91, ptr noundef %92, ptr noundef %95)
  %97 = zext i1 %96 to i8
  store i8 %97, ptr %18, align 1, !tbaa !17
  %98 = load ptr, ptr %15, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %98)
  %99 = load i8, ptr %18, align 1, !tbaa !17, !range !18, !noundef !19
  %100 = trunc i8 %99 to i1
  %101 = zext i1 %100 to i32
  %102 = icmp eq i32 %101, 0
  br i1 %102, label %103, label %123

103:                                              ; preds = %87
  br label %104

104:                                              ; preds = %103
  %105 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %106 = icmp ne ptr %105, null
  br i1 %106, label %107, label %109

107:                                              ; preds = %104
  %108 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  call void (i32, ptr, ptr, i32, ptr, ...) %108(i32 noundef 1, ptr noundef @.str.1, ptr noundef @__func__.Math_planeFit3d, i32 noundef 1619, ptr noundef @.str.19)
  br label %109

109:                                              ; preds = %107, %104
  %110 = load i32, ptr @RcsLogLevel, align 4, !tbaa !9
  %111 = icmp sle i32 1, %110
  br i1 %111, label %112, label %119

112:                                              ; preds = %109
  %113 = load ptr, ptr @stderr, align 8, !tbaa !5
  %114 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %113, ptr noundef @.str.6, ptr noundef @.str.1, ptr noundef @__func__.Math_planeFit3d, i32 noundef 1619) #4
  %115 = load ptr, ptr @stderr, align 8, !tbaa !5
  %116 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %115, ptr noundef @.str.19) #4
  %117 = load ptr, ptr @stderr, align 8, !tbaa !5
  %118 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %117, ptr noundef @.str.4) #4
  br label %119

119:                                              ; preds = %112, %109
  br label %120

120:                                              ; preds = %119
  br label %121

121:                                              ; preds = %120
  %122 = load ptr, ptr %10, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %122)
  store i1 false, ptr %5, align 1
  store i32 1, ptr %19, align 4
  br label %147

123:                                              ; preds = %87
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  %124 = getelementptr inbounds [3 x double], ptr %17, i64 0, i64 0
  %125 = call i32 @VecNd_indexMin(ptr noundef %124, i32 noundef 3)
  store i32 %125, ptr %20, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  store i32 0, ptr %21, align 4, !tbaa !9
  br label %126

126:                                              ; preds = %142, %123
  %127 = load i32, ptr %21, align 4, !tbaa !9
  %128 = icmp slt i32 %127, 3
  br i1 %128, label %130, label %129

129:                                              ; preds = %126
  store i32 12, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  br label %145

130:                                              ; preds = %126
  %131 = load i32, ptr %21, align 4, !tbaa !9
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [3 x [3 x double]], ptr %16, i64 0, i64 %132
  %134 = load i32, ptr %20, align 4, !tbaa !9
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [3 x double], ptr %133, i64 0, i64 %135
  %137 = load double, ptr %136, align 8, !tbaa !20
  %138 = load ptr, ptr %9, align 8, !tbaa !5
  %139 = load i32, ptr %21, align 4, !tbaa !9
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds double, ptr %138, i64 %140
  store double %137, ptr %141, align 8, !tbaa !20
  br label %142

142:                                              ; preds = %130
  %143 = load i32, ptr %21, align 4, !tbaa !9
  %144 = add nsw i32 %143, 1
  store i32 %144, ptr %21, align 4, !tbaa !9
  br label %126, !llvm.loop !22

145:                                              ; preds = %129
  %146 = load ptr, ptr %10, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %146)
  store i1 true, ptr %5, align 1
  store i32 1, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  br label %147

147:                                              ; preds = %145, %121
  call void @llvm.lifetime.end.p0(i64 1, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 72, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %148

148:                                              ; preds = %147, %43
  %149 = load i1, ptr %5, align 1
  ret i1 %149
}

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

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

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

declare void @Vec3d_constMulSelf(ptr noundef, double noundef) #2

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

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

declare zeroext i1 @Mat3d_getEigenVectors(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 = { 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!15, !6, i64 0}
!15 = !{!"_MatNd", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !16, i64 20}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{!16, !16, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!21, !21, i64 0}
!21 = !{!"double", !7, i64 0}
!22 = distinct !{!22, !12}


; 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 [71 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@RCS_GLOBAL_RLOG_CB = external local_unnamed_addr global ptr, align 8
@RcsLogLevel = external local_unnamed_addr global i32, align 4
@.str.6 = external hidden unnamed_addr constant [16 x i8], align 1
@__func__.Math_planeFit3d = external hidden unnamed_addr constant [16 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [37 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 @Vec3d_copy(ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare void @Vec3d_setZero(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @Math_planeFit3d(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #3 {
  %5 = alloca [3 x [3 x double]], align 16
  %6 = alloca [3 x double], align 16
  %7 = icmp ult i32 %1, 3
  br i1 %7, label %8, label %21

8:                                                ; preds = %4
  %9 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %.not44 = icmp eq ptr %9, null
  br i1 %.not44, label %11, label %10

10:                                               ; preds = %8
  tail call void (i32, ptr, ptr, i32, ptr, ...) %9(i32 noundef 1, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.Math_planeFit3d, i32 noundef 1584, ptr noundef nonnull @.str.18, i32 noundef %1) #4
  br label %11

11:                                               ; preds = %10, %8
  %12 = load i32, ptr @RcsLogLevel, align 4, !tbaa !9
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %14, label %62

14:                                               ; preds = %11
  %15 = load ptr, ptr @stderr, align 8, !tbaa !5
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.Math_planeFit3d, i32 noundef 1584) #5
  %17 = load ptr, ptr @stderr, align 8, !tbaa !5
  %18 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef nonnull @.str.18, i32 noundef %1) #5
  %19 = load ptr, ptr @stderr, align 8, !tbaa !5
  %20 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.4) #5
  br label %62

21:                                               ; preds = %4
  %22 = tail call ptr @MatNd_create(i32 noundef %1, i32 noundef 3) #4
  tail call void @Vec3d_setZero(ptr noundef %2) #4
  %wide.trip.count = zext i32 %1 to i64
  br label %26

23:                                               ; preds = %26
  %24 = uitofp i32 %1 to double
  %25 = fdiv double 1.000000e+00, %24
  tail call void @Vec3d_constMulSelf(ptr noundef %2, double noundef %25) #4
  br label %34

26:                                               ; preds = %21, %26
  %indvars.iv = phi i64 [ 0, %21 ], [ %indvars.iv.next, %26 ]
  %27 = trunc nuw i64 %indvars.iv to i32
  %28 = tail call ptr @MatNd_getRowPtr(ptr noundef %22, i32 noundef %27) #4
  %29 = getelementptr inbounds [3 x double], ptr %0, i64 %indvars.iv
  tail call void @Vec3d_copy(ptr noundef %28, ptr noundef %29) #4
  tail call void @Vec3d_addSelf(ptr noundef %2, ptr noundef %28) #4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %23, label %26, !llvm.loop !11

30:                                               ; preds = %34
  %31 = tail call ptr @MatNd_create(i32 noundef 3, i32 noundef 3) #4
  tail call void @MatNd_dyadicProduct(ptr noundef %31, ptr noundef %22) #4
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #4
  %32 = load ptr, ptr %31, align 8, !tbaa !13
  %33 = call zeroext i1 @Mat3d_getEigenVectors(ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef %32) #4
  call void @MatNd_destroy(ptr noundef nonnull %31) #4
  br i1 %33, label %50, label %37

34:                                               ; preds = %23, %34
  %.03946 = phi i32 [ 0, %23 ], [ %36, %34 ]
  %35 = tail call ptr @MatNd_getRowPtr(ptr noundef %22, i32 noundef %.03946) #4
  tail call void @Vec3d_subSelf(ptr noundef %35, ptr noundef %2) #4
  %36 = add nuw i32 %.03946, 1
  %exitcond49.not = icmp eq i32 %36, %1
  br i1 %exitcond49.not, label %30, label %34, !llvm.loop !16

37:                                               ; preds = %30
  %38 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %.not = icmp eq ptr %38, null
  br i1 %.not, label %40, label %39

39:                                               ; preds = %37
  call void (i32, ptr, ptr, i32, ptr, ...) %38(i32 noundef 1, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.Math_planeFit3d, i32 noundef 1619, ptr noundef nonnull @.str.19) #4
  br label %40

40:                                               ; preds = %39, %37
  %41 = load i32, ptr @RcsLogLevel, align 4, !tbaa !9
  %42 = icmp sgt i32 %41, 0
  br i1 %42, label %43, label %61

43:                                               ; preds = %40
  %44 = load ptr, ptr @stderr, align 8, !tbaa !5
  %45 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %44, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.Math_planeFit3d, i32 noundef 1619) #5
  %46 = load ptr, ptr @stderr, align 8, !tbaa !5
  %47 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef nonnull @.str.19) #5
  %48 = load ptr, ptr @stderr, align 8, !tbaa !5
  %49 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %48, ptr noundef nonnull @.str.4) #5
  br label %61

50:                                               ; preds = %30
  %51 = call i32 @VecNd_indexMin(ptr noundef nonnull %6, i32 noundef 3) #4
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [3 x [3 x double]], ptr %5, i64 0, i64 0, i64 %52
  %54 = load double, ptr %53, align 8, !tbaa !17
  store double %54, ptr %3, align 8, !tbaa !17
  %55 = getelementptr inbounds [3 x [3 x double]], ptr %5, i64 0, i64 1, i64 %52
  %56 = load double, ptr %55, align 8, !tbaa !17
  %57 = getelementptr inbounds i8, ptr %3, i64 8
  store double %56, ptr %57, align 8, !tbaa !17
  %58 = getelementptr inbounds [3 x [3 x double]], ptr %5, i64 0, i64 2, i64 %52
  %59 = load double, ptr %58, align 8, !tbaa !17
  %60 = getelementptr inbounds i8, ptr %3, i64 16
  store double %59, ptr %60, align 8, !tbaa !17
  br label %61

61:                                               ; preds = %40, %43, %50
  call void @MatNd_destroy(ptr noundef %22) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %5) #4
  br label %62

62:                                               ; preds = %14, %11, %61
  %.1 = phi i1 [ %33, %61 ], [ false, %11 ], [ false, %14 ]
  ret i1 %.1
}

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

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

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

declare void @Vec3d_constMulSelf(ptr noundef, double noundef) local_unnamed_addr #2

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

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

declare zeroext i1 @Mat3d_getEigenVectors(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @MatNd_destroy(ptr noundef) local_unnamed_addr #2

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 = { nounwind }
attributes #5 = { cold 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !6, i64 0}
!14 = !{!"_MatNd", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !15, i64 20}
!15 = !{!"_Bool", !7, i64 0}
!16 = distinct !{!16, !12}
!17 = !{!18, !18, i64 0}
!18 = !{!"double", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass