; LLVM IR from stan-dev/math :: lib/sundials_6.1.1/src/sundials (sundials_iterative)

; 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._SUNQRData = type { ptr, ptr, ptr }

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

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #2

declare void @N_VLinearSum(double noundef, ptr noundef, double noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

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

declare i32 @N_VDotProdMulti(i32 noundef, ptr noundef, ptr noundef, ptr noundef) #1

declare i32 @N_VLinearCombination(i32 noundef, ptr noundef, ptr noundef, ptr noundef) #1

declare void @N_VScale(double noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @SUNQRAdd_ICWY(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef %5) #4 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !9
  store ptr %5, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %16 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %16, ptr %15, align 8, !tbaa !5
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = load ptr, ptr %15, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._SUNQRData, ptr %18, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  call void @N_VScale(double noundef 1.000000e+00, ptr noundef %17, ptr noundef %20)
  %21 = load i32, ptr %10, align 4, !tbaa !9
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %23, label %140

23:                                               ; preds = %6
  %24 = load i32, ptr %10, align 4, !tbaa !9
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = load i32, ptr %10, align 4, !tbaa !9
  %27 = sub nsw i32 %26, 1
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds ptr, ptr %25, i64 %28
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = load ptr, ptr %15, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._SUNQRData, ptr %32, i32 0, i32 2
  %34 = load ptr, ptr %33, align 8, !tbaa !13
  %35 = load i32, ptr %10, align 4, !tbaa !9
  %36 = sub nsw i32 %35, 1
  %37 = load i32, ptr %11, align 4, !tbaa !9
  %38 = mul nsw i32 %36, %37
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds double, ptr %34, i64 %39
  %41 = call i32 @N_VDotProdMulti(i32 noundef %24, ptr noundef %30, ptr noundef %31, ptr noundef %40)
  %42 = load ptr, ptr %15, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._SUNQRData, ptr %42, i32 0, i32 2
  %44 = load ptr, ptr %43, align 8, !tbaa !13
  %45 = load i32, ptr %10, align 4, !tbaa !9
  %46 = sub nsw i32 %45, 1
  %47 = load i32, ptr %11, align 4, !tbaa !9
  %48 = mul nsw i32 %46, %47
  %49 = load i32, ptr %10, align 4, !tbaa !9
  %50 = sub nsw i32 %49, 1
  %51 = add nsw i32 %48, %50
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds double, ptr %44, i64 %52
  store double 1.000000e+00, ptr %53, align 8, !tbaa !14
  %54 = load i32, ptr %10, align 4, !tbaa !9
  %55 = load ptr, ptr %15, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._SUNQRData, ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !11
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = load i32, ptr %10, align 4, !tbaa !9
  %61 = load i32, ptr %11, align 4, !tbaa !9
  %62 = mul nsw i32 %60, %61
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds double, ptr %59, i64 %63
  %65 = call i32 @N_VDotProdMulti(i32 noundef %54, ptr noundef %57, ptr noundef %58, ptr noundef %64)
  store i64 0, ptr %14, align 8, !tbaa !16
  br label %66

66:                                               ; preds = %115, %23
  %67 = load i64, ptr %14, align 8, !tbaa !16
  %68 = load i32, ptr %10, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = icmp slt i64 %67, %69
  br i1 %70, label %71, label %118

71:                                               ; preds = %66
  %72 = load i64, ptr %14, align 8, !tbaa !16
  %73 = add nsw i64 %72, 1
  store i64 %73, ptr %13, align 8, !tbaa !16
  br label %74

74:                                               ; preds = %111, %71
  %75 = load i64, ptr %13, align 8, !tbaa !16
  %76 = load i32, ptr %10, align 4, !tbaa !9
  %77 = sext i32 %76 to i64
  %78 = icmp slt i64 %75, %77
  br i1 %78, label %79, label %114

79:                                               ; preds = %74
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = load i32, ptr %10, align 4, !tbaa !9
  %82 = load i32, ptr %11, align 4, !tbaa !9
  %83 = mul nsw i32 %81, %82
  %84 = sext i32 %83 to i64
  %85 = load i64, ptr %14, align 8, !tbaa !16
  %86 = add nsw i64 %84, %85
  %87 = getelementptr inbounds double, ptr %80, i64 %86
  %88 = load double, ptr %87, align 8, !tbaa !14
  %89 = load ptr, ptr %15, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct._SUNQRData, ptr %89, i32 0, i32 2
  %91 = load ptr, ptr %90, align 8, !tbaa !13
  %92 = load i64, ptr %13, align 8, !tbaa !16
  %93 = load i32, ptr %11, align 4, !tbaa !9
  %94 = sext i32 %93 to i64
  %95 = mul nsw i64 %92, %94
  %96 = load i64, ptr %14, align 8, !tbaa !16
  %97 = add nsw i64 %95, %96
  %98 = getelementptr inbounds double, ptr %91, i64 %97
  %99 = load double, ptr %98, align 8, !tbaa !14
  %100 = load ptr, ptr %8, align 8, !tbaa !5
  %101 = load i32, ptr %10, align 4, !tbaa !9
  %102 = load i32, ptr %11, align 4, !tbaa !9
  %103 = mul nsw i32 %101, %102
  %104 = sext i32 %103 to i64
  %105 = load i64, ptr %13, align 8, !tbaa !16
  %106 = add nsw i64 %104, %105
  %107 = getelementptr inbounds double, ptr %100, i64 %106
  %108 = load double, ptr %107, align 8, !tbaa !14
  %109 = fneg double %88
  %110 = call double @llvm.fmuladd.f64(double %109, double %99, double %108)
  store double %110, ptr %107, align 8, !tbaa !14
  br label %111

111:                                              ; preds = %79
  %112 = load i64, ptr %13, align 8, !tbaa !16
  %113 = add nsw i64 %112, 1
  store i64 %113, ptr %13, align 8, !tbaa !16
  br label %74, !llvm.loop !18

114:                                              ; preds = %74
  br label %115

115:                                              ; preds = %114
  %116 = load i64, ptr %14, align 8, !tbaa !16
  %117 = add nsw i64 %116, 1
  store i64 %117, ptr %14, align 8, !tbaa !16
  br label %66, !llvm.loop !20

118:                                              ; preds = %66
  %119 = load i32, ptr %10, align 4, !tbaa !9
  %120 = load ptr, ptr %8, align 8, !tbaa !5
  %121 = load i32, ptr %10, align 4, !tbaa !9
  %122 = load i32, ptr %11, align 4, !tbaa !9
  %123 = mul nsw i32 %121, %122
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds double, ptr %120, i64 %124
  %126 = load ptr, ptr %7, align 8, !tbaa !5
  %127 = load ptr, ptr %15, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct._SUNQRData, ptr %127, i32 0, i32 1
  %129 = load ptr, ptr %128, align 8, !tbaa !21
  %130 = call i32 @N_VLinearCombination(i32 noundef %119, ptr noundef %125, ptr noundef %126, ptr noundef %129)
  %131 = load ptr, ptr %15, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct._SUNQRData, ptr %131, i32 0, i32 0
  %133 = load ptr, ptr %132, align 8, !tbaa !11
  %134 = load ptr, ptr %15, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct._SUNQRData, ptr %134, i32 0, i32 1
  %136 = load ptr, ptr %135, align 8, !tbaa !21
  %137 = load ptr, ptr %15, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct._SUNQRData, ptr %137, i32 0, i32 0
  %139 = load ptr, ptr %138, align 8, !tbaa !11
  call void @N_VLinearSum(double noundef 1.000000e+00, ptr noundef %133, double noundef -1.000000e+00, ptr noundef %136, ptr noundef %139)
  br label %140

140:                                              ; preds = %118, %6
  %141 = load ptr, ptr %15, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct._SUNQRData, ptr %141, i32 0, i32 0
  %143 = load ptr, ptr %142, align 8, !tbaa !11
  %144 = load ptr, ptr %15, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct._SUNQRData, ptr %144, i32 0, i32 0
  %146 = load ptr, ptr %145, align 8, !tbaa !11
  %147 = call double @N_VDotProd(ptr noundef %143, ptr noundef %146)
  %148 = fcmp ole double %147, 0.000000e+00
  br i1 %148, label %149, label %150

149:                                              ; preds = %140
  br label %159

150:                                              ; preds = %140
  %151 = load ptr, ptr %15, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct._SUNQRData, ptr %151, i32 0, i32 0
  %153 = load ptr, ptr %152, align 8, !tbaa !11
  %154 = load ptr, ptr %15, align 8, !tbaa !5
  %155 = getelementptr inbounds %struct._SUNQRData, ptr %154, i32 0, i32 0
  %156 = load ptr, ptr %155, align 8, !tbaa !11
  %157 = call double @N_VDotProd(ptr noundef %153, ptr noundef %156)
  %158 = call double @sqrt(double noundef %157) #5
  br label %159

159:                                              ; preds = %150, %149
  %160 = phi double [ 0.000000e+00, %149 ], [ %158, %150 ]
  %161 = load ptr, ptr %8, align 8, !tbaa !5
  %162 = load i32, ptr %10, align 4, !tbaa !9
  %163 = load i32, ptr %11, align 4, !tbaa !9
  %164 = mul nsw i32 %162, %163
  %165 = load i32, ptr %10, align 4, !tbaa !9
  %166 = add nsw i32 %164, %165
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds double, ptr %161, i64 %167
  store double %160, ptr %168, align 8, !tbaa !14
  %169 = load ptr, ptr %8, align 8, !tbaa !5
  %170 = load i32, ptr %10, align 4, !tbaa !9
  %171 = load i32, ptr %11, align 4, !tbaa !9
  %172 = mul nsw i32 %170, %171
  %173 = load i32, ptr %10, align 4, !tbaa !9
  %174 = add nsw i32 %172, %173
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds double, ptr %169, i64 %175
  %177 = load double, ptr %176, align 8, !tbaa !14
  %178 = fdiv double 1.000000e+00, %177
  %179 = load ptr, ptr %15, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct._SUNQRData, ptr %179, i32 0, i32 0
  %181 = load ptr, ptr %180, align 8, !tbaa !11
  %182 = load ptr, ptr %7, align 8, !tbaa !5
  %183 = load i32, ptr %10, align 4, !tbaa !9
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds ptr, ptr %182, i64 %184
  %186 = load ptr, ptr %185, align 8, !tbaa !5
  call void @N_VScale(double noundef %178, ptr noundef %181, ptr noundef %186)
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  ret i32 0
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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, !6, i64 0}
!12 = !{!"_SUNQRData", !6, i64 0, !6, i64 8, !6, i64 16}
!13 = !{!12, !6, i64 16}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = !{!12, !6, i64 8}


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

declare double @N_VDotProd(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #1

declare void @N_VLinearSum(double noundef, ptr noundef, double noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

declare i32 @N_VDotProdMulti(i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

declare i32 @N_VLinearCombination(i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

declare void @N_VScale(double noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @SUNQRAdd_ICWY(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, ptr nocapture noundef readonly %5) local_unnamed_addr #3 {
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  tail call void @N_VScale(double noundef 1.000000e+00, ptr noundef %2, ptr noundef %7) #5
  %8 = icmp sgt i32 %3, 0
  br i1 %8, label %9, label %69

9:                                                ; preds = %6
  %10 = add nsw i32 %3, -1
  %11 = zext nneg i32 %10 to i64
  %12 = getelementptr inbounds ptr, ptr %0, i64 %11
  %13 = load ptr, ptr %12, align 8, !tbaa !10
  %14 = getelementptr inbounds i8, ptr %5, i64 16
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = mul nsw i32 %10, %4
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds double, ptr %15, i64 %17
  %19 = tail call i32 @N_VDotProdMulti(i32 noundef %3, ptr noundef %13, ptr noundef %0, ptr noundef %18) #5
  %20 = load ptr, ptr %14, align 8, !tbaa !11
  %21 = add nsw i32 %16, %10
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds double, ptr %20, i64 %22
  store double 1.000000e+00, ptr %23, align 8, !tbaa !12
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = mul nsw i32 %4, %3
  %26 = sext i32 %25 to i64
  %27 = getelementptr double, ptr %1, i64 %26
  %28 = tail call i32 @N_VDotProdMulti(i32 noundef %3, ptr noundef %24, ptr noundef %0, ptr noundef %27) #5
  %29 = zext nneg i32 %3 to i64
  %30 = sext i32 %4 to i64
  %31 = shl nsw i64 %26, 3
  %32 = shl nuw nsw i64 %29, 3
  %33 = getelementptr i8, ptr %1, i64 %31
  %scevgep72 = getelementptr i8, ptr %33, i64 %32
  %34 = getelementptr i8, ptr %1, i64 %31
  %35 = getelementptr i8, ptr %34, i64 8
  %ident.check.not = icmp eq i32 %4, 1
  br label %36

.loopexit:                                        ; preds = %scalar.ph, %middle.block, %36
  %exitcond.not = icmp eq i64 %41, %29
  br i1 %exitcond.not, label %63, label %36, !llvm.loop !14

36:                                               ; preds = %9, %.loopexit
  %.06371 = phi i64 [ 0, %9 ], [ %41, %.loopexit ]
  %37 = xor i64 %.06371, -1
  %38 = add nsw i64 %37, %29
  %39 = shl nuw nsw i64 %.06371, 4
  %40 = or disjoint i64 %39, 8
  %41 = add nuw nsw i64 %.06371, 1
  %42 = icmp ult i64 %41, %29
  br i1 %42, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %36
  %gep70 = getelementptr double, ptr %27, i64 %.06371
  %43 = load ptr, ptr %14, align 8, !tbaa !11
  %invariant.gep67 = getelementptr double, ptr %43, i64 %.06371
  %min.iters.check = icmp ugt i64 %38, 3
  %or.cond = and i1 %min.iters.check, %ident.check.not
  br i1 %or.cond, label %vector.memcheck, label %scalar.ph.preheader

vector.memcheck:                                  ; preds = %.lr.ph
  %scevgep73 = getelementptr i8, ptr %43, i64 %40
  %44 = getelementptr i8, ptr %43, i64 %32
  %bound0 = icmp ult ptr %35, %44
  %bound1 = icmp ult ptr %scevgep73, %scevgep72
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %38, -4
  %ind.end = add i64 %41, %n.vec
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = add i64 %41, %index
  %45 = load double, ptr %gep70, align 8, !tbaa !12, !alias.scope !16
  %broadcast.splatinsert78 = insertelement <2 x double> poison, double %45, i64 0
  %broadcast.splat79 = shufflevector <2 x double> %broadcast.splatinsert78, <2 x double> poison, <2 x i32> zeroinitializer
  %46 = getelementptr double, ptr %invariant.gep67, i64 %offset.idx
  %47 = getelementptr i8, ptr %46, i64 16
  %wide.load = load <2 x double>, ptr %46, align 8, !tbaa !12, !alias.scope !19
  %wide.load75 = load <2 x double>, ptr %47, align 8, !tbaa !12, !alias.scope !19
  %48 = getelementptr double, ptr %27, i64 %offset.idx
  %49 = getelementptr i8, ptr %48, i64 16
  %wide.load76 = load <2 x double>, ptr %48, align 8, !tbaa !12, !alias.scope !21, !noalias !19
  %wide.load77 = load <2 x double>, ptr %49, align 8, !tbaa !12, !alias.scope !21, !noalias !19
  %50 = fneg <2 x double> %broadcast.splat79
  %51 = fneg <2 x double> %broadcast.splat79
  %52 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %50, <2 x double> %wide.load, <2 x double> %wide.load76)
  %53 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %51, <2 x double> %wide.load75, <2 x double> %wide.load77)
  store <2 x double> %52, ptr %48, align 8, !tbaa !12, !alias.scope !21, !noalias !19
  store <2 x double> %53, ptr %49, align 8, !tbaa !12, !alias.scope !21, !noalias !19
  %index.next = add nuw i64 %index, 4
  %54 = icmp eq i64 %index.next, %n.vec
  br i1 %54, label %middle.block, label %vector.body, !llvm.loop !23

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %38, %n.vec
  br i1 %cmp.n, label %.loopexit, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %vector.memcheck, %.lr.ph
  %.066.ph = phi i64 [ %41, %vector.memcheck ], [ %41, %.lr.ph ], [ %ind.end, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %.066 = phi i64 [ %61, %scalar.ph ], [ %.066.ph, %scalar.ph.preheader ]
  %55 = load double, ptr %gep70, align 8, !tbaa !12
  %56 = mul nsw i64 %.066, %30
  %gep68 = getelementptr double, ptr %invariant.gep67, i64 %56
  %57 = load double, ptr %gep68, align 8, !tbaa !12
  %gep = getelementptr double, ptr %27, i64 %.066
  %58 = load double, ptr %gep, align 8, !tbaa !12
  %59 = fneg double %55
  %60 = tail call double @llvm.fmuladd.f64(double %59, double %57, double %58)
  store double %60, ptr %gep, align 8, !tbaa !12
  %61 = add nuw nsw i64 %.066, 1
  %62 = icmp ult i64 %61, %29
  br i1 %62, label %scalar.ph, label %.loopexit, !llvm.loop !26

63:                                               ; preds = %.loopexit
  %64 = getelementptr inbounds i8, ptr %5, i64 8
  %65 = load ptr, ptr %64, align 8, !tbaa !27
  %66 = tail call i32 @N_VLinearCombination(i32 noundef %3, ptr noundef %27, ptr noundef %0, ptr noundef %65) #5
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = load ptr, ptr %64, align 8, !tbaa !27
  tail call void @N_VLinearSum(double noundef 1.000000e+00, ptr noundef %67, double noundef -1.000000e+00, ptr noundef %68, ptr noundef %67) #5
  br label %69

69:                                               ; preds = %63, %6
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = tail call double @N_VDotProd(ptr noundef %70, ptr noundef %70) #5
  %72 = fcmp ugt double %71, 0.000000e+00
  br i1 %72, label %73, label %77

73:                                               ; preds = %69
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = tail call double @N_VDotProd(ptr noundef %74, ptr noundef %74) #5
  %76 = tail call double @sqrt(double noundef %75) #5
  br label %77

77:                                               ; preds = %69, %73
  %78 = phi double [ %76, %73 ], [ 0.000000e+00, %69 ]
  %79 = add i32 %4, 1
  %80 = mul i32 %79, %3
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds double, ptr %1, i64 %81
  store double %78, ptr %82, align 8, !tbaa !12
  %83 = fdiv double 1.000000e+00, %78
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = sext i32 %3 to i64
  %86 = getelementptr inbounds ptr, ptr %0, i64 %85
  %87 = load ptr, ptr %86, align 8, !tbaa !10
  tail call void @N_VScale(double noundef %83, ptr noundef %84, ptr noundef %87) #5
  ret i32 0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #4

attributes #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 #1 = { mustprogress nofree nounwind willreturn memory(write) "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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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, !7, i64 0}
!6 = !{!"_SUNQRData", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!7, !7, i64 0}
!11 = !{!6, !7, i64 16}
!12 = !{!13, !13, i64 0}
!13 = !{!"double", !8, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17}
!17 = distinct !{!17, !18}
!18 = distinct !{!18, !"LVerDomain"}
!19 = !{!20}
!20 = distinct !{!20, !18}
!21 = !{!22}
!22 = distinct !{!22, !18}
!23 = distinct !{!23, !15, !24, !25}
!24 = !{!"llvm.loop.isvectorized", i32 1}
!25 = !{!"llvm.loop.unroll.runtime.disable"}
!26 = distinct !{!26, !15, !24}
!27 = !{!6, !7, i64 8}


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