; LLVM IR from simbody/simbody :: SimTKmath/Optimizers/src/IpOpt (IpExpansionMatrix)

; 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"

@_ZTIN10SimTKIpopt6VectorE = external dso_local constant { ptr, ptr, ptr }, align 8
@_ZTIN10SimTKIpopt11DenseVectorE = external constant ptr

; 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 willreturn memory(read)
declare ptr @__dynamic_cast(ptr, ptr, ptr, i64) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNK10SimTKIpopt15ExpansionMatrix18ExpandedPosIndicesEv(ptr noundef nonnull align 8 dereferenceable(80)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK10SimTKIpopt11DenseVector13IsHomogeneousEv(ptr noundef nonnull align 8 dereferenceable(240)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK10SimTKIpopt11DenseVector6ScalarEv(ptr noundef nonnull align 8 dereferenceable(240)) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK10SimTKIpopt6Matrix5NColsEv(ptr noundef nonnull align 8 dereferenceable(69)) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240)) #4 align 2

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

27:                                               ; preds = %5
  %28 = call ptr @__dynamic_cast(ptr %25, ptr @_ZTIN10SimTKIpopt6VectorE, ptr @_ZTIN10SimTKIpopt11DenseVectorE, i64 0) #7
  br label %30

29:                                               ; preds = %5
  br label %30

30:                                               ; preds = %29, %27
  %31 = phi ptr [ %28, %27 ], [ null, %29 ]
  store ptr %31, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = icmp eq ptr %32, null
  br i1 %33, label %36, label %34

34:                                               ; preds = %30
  %35 = call ptr @__dynamic_cast(ptr %32, ptr @_ZTIN10SimTKIpopt6VectorE, ptr @_ZTIN10SimTKIpopt11DenseVectorE, i64 0) #7
  br label %37

36:                                               ; preds = %30
  br label %37

37:                                               ; preds = %36, %34
  %38 = phi ptr [ %35, %34 ], [ null, %36 ]
  store ptr %38, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  %40 = icmp eq ptr %39, null
  br i1 %40, label %43, label %41

41:                                               ; preds = %37
  %42 = call ptr @__dynamic_cast(ptr %39, ptr @_ZTIN10SimTKIpopt6VectorE, ptr @_ZTIN10SimTKIpopt11DenseVectorE, i64 0) #7
  br label %44

43:                                               ; preds = %37
  br label %44

44:                                               ; preds = %43, %41
  %45 = phi ptr [ %42, %41 ], [ null, %43 ]
  store ptr %45, ptr %13, align 8, !tbaa !5
  %46 = load ptr, ptr %11, align 8, !tbaa !5
  %47 = call noundef zeroext i1 @_ZNK10SimTKIpopt11DenseVector13IsHomogeneousEv(ptr noundef nonnull align 8 dereferenceable(240) %46)
  br i1 %47, label %48, label %53

48:                                               ; preds = %44
  %49 = load double, ptr %7, align 8, !tbaa !9
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZNK10SimTKIpopt6Matrix13AddMSinvZImplEdRKNS_6VectorES3_RS1_(ptr noundef nonnull align 8 dereferenceable(69) %24, double noundef %49, ptr noundef nonnull align 8 dereferenceable(205) %50, ptr noundef nonnull align 8 dereferenceable(205) %51, ptr noundef nonnull align 8 dereferenceable(205) %52)
  store i32 1, ptr %14, align 4
  br label %202

53:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %54 = call noundef ptr @_ZNK10SimTKIpopt15ExpansionMatrix18ExpandedPosIndicesEv(ptr noundef nonnull align 8 dereferenceable(80) %24)
  store ptr %54, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %55 = load ptr, ptr %11, align 8, !tbaa !5
  %56 = call noundef ptr @_ZNK10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240) %55)
  store ptr %56, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %57 = load ptr, ptr %13, align 8, !tbaa !5
  %58 = call noundef ptr @_ZN10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240) %57)
  store ptr %58, ptr %17, align 8, !tbaa !5
  %59 = load ptr, ptr %12, align 8, !tbaa !5
  %60 = call noundef zeroext i1 @_ZNK10SimTKIpopt11DenseVector13IsHomogeneousEv(ptr noundef nonnull align 8 dereferenceable(240) %59)
  br i1 %60, label %61, label %93

61:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %62 = load double, ptr %7, align 8, !tbaa !9
  %63 = load ptr, ptr %12, align 8, !tbaa !5
  %64 = call noundef double @_ZNK10SimTKIpopt11DenseVector6ScalarEv(ptr noundef nonnull align 8 dereferenceable(240) %63)
  %65 = fmul double %62, %64
  store double %65, ptr %18, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #7
  store i32 0, ptr %19, align 4, !tbaa !11
  br label %66

66:                                               ; preds = %89, %61
  %67 = load i32, ptr %19, align 4, !tbaa !11
  %68 = call noundef i32 @_ZNK10SimTKIpopt6Matrix5NColsEv(ptr noundef nonnull align 8 dereferenceable(69) %24)
  %69 = icmp slt i32 %67, %68
  br i1 %69, label %71, label %70

70:                                               ; preds = %66
  store i32 2, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #7
  br label %92

71:                                               ; preds = %66
  %72 = load double, ptr %18, align 8, !tbaa !9
  %73 = load ptr, ptr %16, align 8, !tbaa !5
  %74 = load i32, ptr %19, align 4, !tbaa !11
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds double, ptr %73, i64 %75
  %77 = load double, ptr %76, align 8, !tbaa !9
  %78 = fdiv double %72, %77
  %79 = load ptr, ptr %17, align 8, !tbaa !5
  %80 = load ptr, ptr %15, align 8, !tbaa !5
  %81 = load i32, ptr %19, align 4, !tbaa !11
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds i32, ptr %80, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !11
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds double, ptr %79, i64 %85
  %87 = load double, ptr %86, align 8, !tbaa !9
  %88 = fadd double %87, %78
  store double %88, ptr %86, align 8, !tbaa !9
  br label %89

89:                                               ; preds = %71
  %90 = load i32, ptr %19, align 4, !tbaa !11
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %19, align 4, !tbaa !11
  br label %66, !llvm.loop !13

92:                                               ; preds = %70
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  br label %201

93:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #7
  %94 = load ptr, ptr %12, align 8, !tbaa !5
  %95 = call noundef ptr @_ZNK10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240) %94)
  store ptr %95, ptr %20, align 8, !tbaa !5
  %96 = load double, ptr %7, align 8, !tbaa !9
  %97 = fcmp oeq double %96, 1.000000e+00
  br i1 %97, label %98, label %130

98:                                               ; preds = %93
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #7
  store i32 0, ptr %21, align 4, !tbaa !11
  br label %99

99:                                               ; preds = %126, %98
  %100 = load i32, ptr %21, align 4, !tbaa !11
  %101 = call noundef i32 @_ZNK10SimTKIpopt6Matrix5NColsEv(ptr noundef nonnull align 8 dereferenceable(69) %24)
  %102 = icmp slt i32 %100, %101
  br i1 %102, label %104, label %103

103:                                              ; preds = %99
  store i32 5, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #7
  br label %129

104:                                              ; preds = %99
  %105 = load ptr, ptr %20, align 8, !tbaa !5
  %106 = load i32, ptr %21, align 4, !tbaa !11
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds double, ptr %105, i64 %107
  %109 = load double, ptr %108, align 8, !tbaa !9
  %110 = load ptr, ptr %16, align 8, !tbaa !5
  %111 = load i32, ptr %21, align 4, !tbaa !11
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds double, ptr %110, i64 %112
  %114 = load double, ptr %113, align 8, !tbaa !9
  %115 = fdiv double %109, %114
  %116 = load ptr, ptr %17, align 8, !tbaa !5
  %117 = load ptr, ptr %15, align 8, !tbaa !5
  %118 = load i32, ptr %21, align 4, !tbaa !11
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds i32, ptr %117, i64 %119
  %121 = load i32, ptr %120, align 4, !tbaa !11
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds double, ptr %116, i64 %122
  %124 = load double, ptr %123, align 8, !tbaa !9
  %125 = fadd double %124, %115
  store double %125, ptr %123, align 8, !tbaa !9
  br label %126

126:                                              ; preds = %104
  %127 = load i32, ptr %21, align 4, !tbaa !11
  %128 = add nsw i32 %127, 1
  store i32 %128, ptr %21, align 4, !tbaa !11
  br label %99, !llvm.loop !15

129:                                              ; preds = %103
  br label %200

130:                                              ; preds = %93
  %131 = load double, ptr %7, align 8, !tbaa !9
  %132 = fcmp oeq double %131, -1.000000e+00
  br i1 %132, label %133, label %165

133:                                              ; preds = %130
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #7
  store i32 0, ptr %22, align 4, !tbaa !11
  br label %134

134:                                              ; preds = %161, %133
  %135 = load i32, ptr %22, align 4, !tbaa !11
  %136 = call noundef i32 @_ZNK10SimTKIpopt6Matrix5NColsEv(ptr noundef nonnull align 8 dereferenceable(69) %24)
  %137 = icmp slt i32 %135, %136
  br i1 %137, label %139, label %138

138:                                              ; preds = %134
  store i32 8, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #7
  br label %164

139:                                              ; preds = %134
  %140 = load ptr, ptr %20, align 8, !tbaa !5
  %141 = load i32, ptr %22, align 4, !tbaa !11
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds double, ptr %140, i64 %142
  %144 = load double, ptr %143, align 8, !tbaa !9
  %145 = load ptr, ptr %16, align 8, !tbaa !5
  %146 = load i32, ptr %22, align 4, !tbaa !11
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds double, ptr %145, i64 %147
  %149 = load double, ptr %148, align 8, !tbaa !9
  %150 = fdiv double %144, %149
  %151 = load ptr, ptr %17, align 8, !tbaa !5
  %152 = load ptr, ptr %15, align 8, !tbaa !5
  %153 = load i32, ptr %22, align 4, !tbaa !11
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds i32, ptr %152, i64 %154
  %156 = load i32, ptr %155, align 4, !tbaa !11
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds double, ptr %151, i64 %157
  %159 = load double, ptr %158, align 8, !tbaa !9
  %160 = fsub double %159, %150
  store double %160, ptr %158, align 8, !tbaa !9
  br label %161

161:                                              ; preds = %139
  %162 = load i32, ptr %22, align 4, !tbaa !11
  %163 = add nsw i32 %162, 1
  store i32 %163, ptr %22, align 4, !tbaa !11
  br label %134, !llvm.loop !16

164:                                              ; preds = %138
  br label %199

165:                                              ; preds = %130
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #7
  store i32 0, ptr %23, align 4, !tbaa !11
  br label %166

166:                                              ; preds = %195, %165
  %167 = load i32, ptr %23, align 4, !tbaa !11
  %168 = call noundef i32 @_ZNK10SimTKIpopt6Matrix5NColsEv(ptr noundef nonnull align 8 dereferenceable(69) %24)
  %169 = icmp slt i32 %167, %168
  br i1 %169, label %171, label %170

170:                                              ; preds = %166
  store i32 11, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #7
  br label %198

171:                                              ; preds = %166
  %172 = load double, ptr %7, align 8, !tbaa !9
  %173 = load ptr, ptr %20, align 8, !tbaa !5
  %174 = load i32, ptr %23, align 4, !tbaa !11
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds double, ptr %173, i64 %175
  %177 = load double, ptr %176, align 8, !tbaa !9
  %178 = fmul double %172, %177
  %179 = load ptr, ptr %16, align 8, !tbaa !5
  %180 = load i32, ptr %23, align 4, !tbaa !11
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds double, ptr %179, i64 %181
  %183 = load double, ptr %182, align 8, !tbaa !9
  %184 = fdiv double %178, %183
  %185 = load ptr, ptr %17, align 8, !tbaa !5
  %186 = load ptr, ptr %15, align 8, !tbaa !5
  %187 = load i32, ptr %23, align 4, !tbaa !11
  %188 = sext i32 %187 to i64
  %189 = getelementptr inbounds i32, ptr %186, i64 %188
  %190 = load i32, ptr %189, align 4, !tbaa !11
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds double, ptr %185, i64 %191
  %193 = load double, ptr %192, align 8, !tbaa !9
  %194 = fadd double %193, %184
  store double %194, ptr %192, align 8, !tbaa !9
  br label %195

195:                                              ; preds = %171
  %196 = load i32, ptr %23, align 4, !tbaa !11
  %197 = add nsw i32 %196, 1
  store i32 %197, ptr %23, align 4, !tbaa !11
  br label %166, !llvm.loop !17

198:                                              ; preds = %170
  br label %199

199:                                              ; preds = %198, %164
  br label %200

200:                                              ; preds = %199, %129
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #7
  br label %201

201:                                              ; preds = %200, %92
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  store i32 0, ptr %14, align 4
  br label %202

202:                                              ; preds = %201, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  %203 = load i32, ptr %14, align 4
  switch i32 %203, label %205 [
    i32 0, label %204
    i32 1, label %204
  ]

204:                                              ; preds = %202, %202
  ret void

205:                                              ; preds = %202
  unreachable
}

declare void @_ZNK10SimTKIpopt6Matrix13AddMSinvZImplEdRKNS_6VectorES3_RS1_(ptr noundef nonnull align 8 dereferenceable(69), double noundef, ptr noundef nonnull align 8 dereferenceable(205), ptr noundef nonnull align 8 dereferenceable(205), ptr noundef nonnull align 8 dereferenceable(205)) unnamed_addr #6

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind willreturn memory(read) }
attributes #2 = { inlinehint mustprogress 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 = { mustprogress 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 = { inlinehint mustprogress 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 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 #6 = { "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 #7 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}


; 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"

@_ZTIN10SimTKIpopt6VectorE = external dso_local constant { ptr, ptr, ptr }, align 8
@_ZTIN10SimTKIpopt11DenseVectorE = external constant ptr

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare ptr @__dynamic_cast(ptr, ptr, ptr, i64) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNK10SimTKIpopt15ExpansionMatrix18ExpandedPosIndicesEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK10SimTKIpopt11DenseVector13IsHomogeneousEv(ptr noundef nonnull align 8 dereferenceable(240)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK10SimTKIpopt11DenseVector6ScalarEv(ptr noundef nonnull align 8 dereferenceable(240)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK10SimTKIpopt6Matrix5NColsEv(ptr noundef nonnull align 8 dereferenceable(69)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK10SimTKIpopt15ExpansionMatrix13AddMSinvZImplEdRKNS_6VectorES3_RS1_(ptr noundef nonnull align 8 dereferenceable(80) %0, double noundef %1, ptr noundef nonnull align 8 dereferenceable(205) %2, ptr noundef nonnull align 8 dereferenceable(205) %3, ptr noundef nonnull align 8 dereferenceable(205) %4) unnamed_addr #4 align 2 {
  %6 = tail call ptr @__dynamic_cast(ptr nonnull %2, ptr nonnull @_ZTIN10SimTKIpopt6VectorE, ptr nonnull @_ZTIN10SimTKIpopt11DenseVectorE, i64 0) #6
  %7 = tail call ptr @__dynamic_cast(ptr nonnull %3, ptr nonnull @_ZTIN10SimTKIpopt6VectorE, ptr nonnull @_ZTIN10SimTKIpopt11DenseVectorE, i64 0) #6
  %8 = tail call ptr @__dynamic_cast(ptr nonnull %4, ptr nonnull @_ZTIN10SimTKIpopt6VectorE, ptr nonnull @_ZTIN10SimTKIpopt11DenseVectorE, i64 0) #6
  %9 = tail call noundef zeroext i1 @_ZNK10SimTKIpopt11DenseVector13IsHomogeneousEv(ptr noundef nonnull align 8 dereferenceable(240) %6)
  br i1 %9, label %10, label %11

10:                                               ; preds = %5
  tail call void @_ZNK10SimTKIpopt6Matrix13AddMSinvZImplEdRKNS_6VectorES3_RS1_(ptr noundef nonnull align 8 dereferenceable(69) %0, double noundef %1, ptr noundef nonnull align 8 dereferenceable(205) %2, ptr noundef nonnull align 8 dereferenceable(205) %3, ptr noundef nonnull align 8 dereferenceable(205) %4)
  br label %.loopexit

11:                                               ; preds = %5
  %12 = tail call noundef ptr @_ZNK10SimTKIpopt15ExpansionMatrix18ExpandedPosIndicesEv(ptr noundef nonnull align 8 dereferenceable(80) %0)
  %13 = tail call noundef ptr @_ZNK10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240) %6)
  %14 = tail call noundef ptr @_ZN10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240) %8)
  %15 = tail call noundef zeroext i1 @_ZNK10SimTKIpopt11DenseVector13IsHomogeneousEv(ptr noundef nonnull align 8 dereferenceable(240) %7)
  br i1 %15, label %16, label %33

16:                                               ; preds = %11
  %17 = tail call noundef double @_ZNK10SimTKIpopt11DenseVector6ScalarEv(ptr noundef nonnull align 8 dereferenceable(240) %7)
  %18 = fmul double %17, %1
  %19 = tail call noundef i32 @_ZNK10SimTKIpopt6Matrix5NColsEv(ptr noundef nonnull align 8 dereferenceable(69) %0)
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph67, label %.loopexit

.lr.ph67:                                         ; preds = %16, %.lr.ph67
  %indvars.iv78 = phi i64 [ %indvars.iv.next79, %.lr.ph67 ], [ 0, %16 ]
  %21 = getelementptr inbounds double, ptr %13, i64 %indvars.iv78
  %22 = load double, ptr %21, align 8, !tbaa !5
  %23 = fdiv double %18, %22
  %24 = getelementptr inbounds i32, ptr %12, i64 %indvars.iv78
  %25 = load i32, ptr %24, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds double, ptr %14, i64 %26
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = fadd double %23, %28
  store double %29, ptr %27, align 8, !tbaa !5
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %30 = tail call noundef i32 @_ZNK10SimTKIpopt6Matrix5NColsEv(ptr noundef nonnull align 8 dereferenceable(69) %0)
  %31 = sext i32 %30 to i64
  %32 = icmp slt i64 %indvars.iv.next79, %31
  br i1 %32, label %.lr.ph67, label %.loopexit, !llvm.loop !11

33:                                               ; preds = %11
  %34 = tail call noundef ptr @_ZNK10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240) %7)
  %35 = fcmp oeq double %1, 1.000000e+00
  br i1 %35, label %.preheader, label %52

.preheader:                                       ; preds = %33
  %36 = tail call noundef i32 @_ZNK10SimTKIpopt6Matrix5NColsEv(ptr noundef nonnull align 8 dereferenceable(69) %0)
  %37 = icmp sgt i32 %36, 0
  br i1 %37, label %.lr.ph65, label %.loopexit

.lr.ph65:                                         ; preds = %.preheader, %.lr.ph65
  %indvars.iv75 = phi i64 [ %indvars.iv.next76, %.lr.ph65 ], [ 0, %.preheader ]
  %38 = getelementptr inbounds double, ptr %34, i64 %indvars.iv75
  %39 = load double, ptr %38, align 8, !tbaa !5
  %40 = getelementptr inbounds double, ptr %13, i64 %indvars.iv75
  %41 = load double, ptr %40, align 8, !tbaa !5
  %42 = fdiv double %39, %41
  %43 = getelementptr inbounds i32, ptr %12, i64 %indvars.iv75
  %44 = load i32, ptr %43, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds double, ptr %14, i64 %45
  %47 = load double, ptr %46, align 8, !tbaa !5
  %48 = fadd double %42, %47
  store double %48, ptr %46, align 8, !tbaa !5
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %49 = tail call noundef i32 @_ZNK10SimTKIpopt6Matrix5NColsEv(ptr noundef nonnull align 8 dereferenceable(69) %0)
  %50 = sext i32 %49 to i64
  %51 = icmp slt i64 %indvars.iv.next76, %50
  br i1 %51, label %.lr.ph65, label %.loopexit, !llvm.loop !13

52:                                               ; preds = %33
  %53 = fcmp oeq double %1, -1.000000e+00
  %54 = tail call noundef i32 @_ZNK10SimTKIpopt6Matrix5NColsEv(ptr noundef nonnull align 8 dereferenceable(69) %0)
  %55 = icmp sgt i32 %54, 0
  br i1 %53, label %.preheader57, label %.preheader59

.preheader59:                                     ; preds = %52
  br i1 %55, label %.lr.ph, label %.loopexit

.preheader57:                                     ; preds = %52
  br i1 %55, label %.lr.ph63, label %.loopexit

.lr.ph63:                                         ; preds = %.preheader57, %.lr.ph63
  %indvars.iv72 = phi i64 [ %indvars.iv.next73, %.lr.ph63 ], [ 0, %.preheader57 ]
  %56 = getelementptr inbounds double, ptr %34, i64 %indvars.iv72
  %57 = load double, ptr %56, align 8, !tbaa !5
  %58 = getelementptr inbounds double, ptr %13, i64 %indvars.iv72
  %59 = load double, ptr %58, align 8, !tbaa !5
  %60 = fdiv double %57, %59
  %61 = getelementptr inbounds i32, ptr %12, i64 %indvars.iv72
  %62 = load i32, ptr %61, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds double, ptr %14, i64 %63
  %65 = load double, ptr %64, align 8, !tbaa !5
  %66 = fsub double %65, %60
  store double %66, ptr %64, align 8, !tbaa !5
  %indvars.iv.next73 = add nuw nsw i64 %indvars.iv72, 1
  %67 = tail call noundef i32 @_ZNK10SimTKIpopt6Matrix5NColsEv(ptr noundef nonnull align 8 dereferenceable(69) %0)
  %68 = sext i32 %67 to i64
  %69 = icmp slt i64 %indvars.iv.next73, %68
  br i1 %69, label %.lr.ph63, label %.loopexit, !llvm.loop !14

.lr.ph:                                           ; preds = %.preheader59, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader59 ]
  %70 = getelementptr inbounds double, ptr %34, i64 %indvars.iv
  %71 = load double, ptr %70, align 8, !tbaa !5
  %72 = fmul double %71, %1
  %73 = getelementptr inbounds double, ptr %13, i64 %indvars.iv
  %74 = load double, ptr %73, align 8, !tbaa !5
  %75 = fdiv double %72, %74
  %76 = getelementptr inbounds i32, ptr %12, i64 %indvars.iv
  %77 = load i32, ptr %76, align 4, !tbaa !9
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds double, ptr %14, i64 %78
  %80 = load double, ptr %79, align 8, !tbaa !5
  %81 = fadd double %75, %80
  store double %81, ptr %79, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %82 = tail call noundef i32 @_ZNK10SimTKIpopt6Matrix5NColsEv(ptr noundef nonnull align 8 dereferenceable(69) %0)
  %83 = sext i32 %82 to i64
  %84 = icmp slt i64 %indvars.iv.next, %83
  br i1 %84, label %.lr.ph, label %.loopexit, !llvm.loop !15

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph63, %.lr.ph65, %.lr.ph67, %.preheader59, %.preheader57, %.preheader, %16, %10
  ret void
}

declare void @_ZNK10SimTKIpopt6Matrix13AddMSinvZImplEdRKNS_6VectorES3_RS1_(ptr noundef nonnull align 8 dereferenceable(69), double noundef, ptr noundef nonnull align 8 dereferenceable(205), ptr noundef nonnull align 8 dereferenceable(205), ptr noundef nonnull align 8 dereferenceable(205)) unnamed_addr #5

attributes #0 = { mustprogress nofree nounwind willreturn memory(read) }
attributes #1 = { inlinehint mustprogress 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 #2 = { mustprogress 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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress 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 = { "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 #6 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple 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 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass