; LLVM IR from OpenMathLib/OpenBLAS :: lapack-netlib/SRC (dlarscl2)

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

; Function Attrs: nounwind uwtable
define dso_local void @dlarscl2_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #2
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = getelementptr inbounds double, ptr %17, i32 -1
  store ptr %18, ptr %8, align 8, !tbaa !5
  %19 = load ptr, ptr %10, align 8, !tbaa !5
  %20 = load i32, ptr %19, align 4, !tbaa !9
  store i32 %20, ptr %11, align 4, !tbaa !9
  %21 = load i32, ptr %11, align 4, !tbaa !9
  %22 = mul nsw i32 %21, 1
  %23 = add nsw i32 1, %22
  store i32 %23, ptr %12, align 4, !tbaa !9
  %24 = load i32, ptr %12, align 4, !tbaa !9
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = sext i32 %24 to i64
  %27 = sub i64 0, %26
  %28 = getelementptr inbounds double, ptr %25, i64 %27
  store ptr %28, ptr %9, align 8, !tbaa !5
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = load i32, ptr %29, align 4, !tbaa !9
  store i32 %30, ptr %13, align 4, !tbaa !9
  store i32 1, ptr %16, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %62, %5
  %32 = load i32, ptr %16, align 4, !tbaa !9
  %33 = load i32, ptr %13, align 4, !tbaa !9
  %34 = icmp sle i32 %32, %33
  br i1 %34, label %35, label %65

35:                                               ; preds = %31
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = load i32, ptr %36, align 4, !tbaa !9
  store i32 %37, ptr %14, align 4, !tbaa !9
  store i32 1, ptr %15, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %58, %35
  %39 = load i32, ptr %15, align 4, !tbaa !9
  %40 = load i32, ptr %14, align 4, !tbaa !9
  %41 = icmp sle i32 %39, %40
  br i1 %41, label %42, label %61

42:                                               ; preds = %38
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = load i32, ptr %15, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds double, ptr %43, i64 %45
  %47 = load double, ptr %46, align 8, !tbaa !11
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = load i32, ptr %15, align 4, !tbaa !9
  %50 = load i32, ptr %16, align 4, !tbaa !9
  %51 = load i32, ptr %11, align 4, !tbaa !9
  %52 = mul nsw i32 %50, %51
  %53 = add nsw i32 %49, %52
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds double, ptr %48, i64 %54
  %56 = load double, ptr %55, align 8, !tbaa !11
  %57 = fdiv double %56, %47
  store double %57, ptr %55, align 8, !tbaa !11
  br label %58

58:                                               ; preds = %42
  %59 = load i32, ptr %15, align 4, !tbaa !9
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %15, align 4, !tbaa !9
  br label %38, !llvm.loop !13

61:                                               ; preds = %38
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr %16, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %16, align 4, !tbaa !9
  br label %31, !llvm.loop !15

65:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  ret void
}

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !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"

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @dlarscl2_(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef %3, ptr nocapture noundef readonly %4) local_unnamed_addr #0 {
  %6 = getelementptr inbounds i8, ptr %2, i64 -8
  %7 = load i32, ptr %4, align 4, !tbaa !5
  %narrow = xor i32 %7, -1
  %8 = sext i32 %narrow to i64
  %9 = getelementptr inbounds double, ptr %3, i64 %8
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %.not22 = icmp slt i32 %10, 1
  br i1 %.not22, label %._crit_edge26, label %.lr.ph25

.lr.ph25:                                         ; preds = %5
  %11 = load i32, ptr %0, align 4, !tbaa !5
  %.not1920 = icmp slt i32 %11, 1
  br i1 %.not1920, label %._crit_edge26, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph25
  %12 = add nuw i32 %11, 1
  %13 = sext i32 %7 to i64
  %14 = add nuw i32 %10, 1
  %wide.trip.count32 = zext i32 %14 to i64
  %wide.trip.count = zext i32 %12 to i64
  %15 = shl nsw i64 %13, 3
  %16 = shl nsw i64 %8, 3
  %17 = getelementptr i8, ptr %3, i64 %15
  %18 = getelementptr i8, ptr %17, i64 %16
  %scevgep = getelementptr i8, ptr %18, i64 8
  %19 = shl nuw nsw i64 %wide.trip.count32, 3
  %20 = add nsw i64 %19, -8
  %21 = mul i64 %20, %13
  %22 = shl nuw nsw i64 %wide.trip.count, 3
  %23 = getelementptr i8, ptr %3, i64 %21
  %24 = getelementptr i8, ptr %23, i64 %16
  %scevgep34 = getelementptr i8, ptr %24, i64 %22
  %25 = getelementptr i8, ptr %2, i64 %22
  %scevgep35 = getelementptr i8, ptr %25, i64 -8
  %26 = zext nneg i32 %11 to i64
  %27 = zext nneg i32 %11 to i64
  %min.iters.check = icmp eq i32 %11, 1
  %bound0 = icmp ult ptr %scevgep, %scevgep35
  %bound1 = icmp ugt ptr %scevgep34, %2
  %found.conflict = and i1 %bound0, %bound1
  %stride.check = icmp slt i32 %7, 0
  %28 = or i1 %found.conflict, %stride.check
  %n.vec = and i64 %26, 2147483646
  %ind.end = or i64 %26, 1
  %cmp.n = icmp eq i64 %n.vec, %26
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %._crit_edge
  %indvars.iv29 = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next30, %._crit_edge ]
  %29 = mul nsw i64 %indvars.iv29, %13
  %invariant.gep = getelementptr double, ptr %9, i64 %29
  %brmerge = select i1 %min.iters.check, i1 true, i1 %28
  br i1 %brmerge, label %scalar.ph.preheader, label %vector.body

vector.body:                                      ; preds = %.lr.ph, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %.lr.ph ]
  %offset.idx = or disjoint i64 %index, 1
  %30 = getelementptr double, ptr %2, i64 %index
  %wide.load = load <2 x double>, ptr %30, align 8, !tbaa !9, !alias.scope !11
  %31 = getelementptr double, ptr %invariant.gep, i64 %offset.idx
  %wide.load36 = load <2 x double>, ptr %31, align 8, !tbaa !9, !alias.scope !14, !noalias !11
  %32 = fdiv <2 x double> %wide.load36, %wide.load
  store <2 x double> %32, ptr %31, align 8, !tbaa !9, !alias.scope !14, !noalias !11
  %index.next = add nuw i64 %index, 2
  %33 = icmp eq i64 %index.next, %n.vec
  br i1 %33, label %middle.block, label %vector.body, !llvm.loop !16

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %.lr.ph, %middle.block
  %indvars.iv.ph = phi i64 [ 1, %.lr.ph ], [ %ind.end, %middle.block ]
  %34 = sub nsw i64 %wide.trip.count, %indvars.iv.ph
  %35 = sub nsw i64 %27, %indvars.iv.ph
  %xtraiter = and i64 %34, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader, %scalar.ph.prol
  %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %scalar.ph.prol ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %scalar.ph.prol ], [ 0, %scalar.ph.preheader ]
  %36 = getelementptr inbounds double, ptr %6, i64 %indvars.iv.prol
  %37 = load double, ptr %36, align 8, !tbaa !9
  %gep.prol = getelementptr double, ptr %invariant.gep, i64 %indvars.iv.prol
  %38 = load double, ptr %gep.prol, align 8, !tbaa !9
  %39 = fdiv double %38, %37
  store double %39, ptr %gep.prol, align 8, !tbaa !9
  %indvars.iv.next.prol = add nuw nsw i64 %indvars.iv.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol, !llvm.loop !20

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %scalar.ph.preheader ], [ %indvars.iv.next.prol, %scalar.ph.prol ]
  %40 = icmp ult i64 %35, 3
  br i1 %40, label %._crit_edge, label %scalar.ph.preheader.new

scalar.ph.preheader.new:                          ; preds = %scalar.ph.prol.loopexit
  %invariant.gep37 = getelementptr i8, ptr %invariant.gep, i64 8
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph, %scalar.ph.preheader.new
  %indvars.iv = phi i64 [ %indvars.iv.unr, %scalar.ph.preheader.new ], [ %indvars.iv.next.3, %scalar.ph ]
  %41 = getelementptr inbounds double, ptr %6, i64 %indvars.iv
  %42 = load double, ptr %41, align 8, !tbaa !9
  %gep = getelementptr double, ptr %invariant.gep, i64 %indvars.iv
  %43 = load double, ptr %gep, align 8, !tbaa !9
  %44 = fdiv double %43, %42
  store double %44, ptr %gep, align 8, !tbaa !9
  %45 = getelementptr double, ptr %2, i64 %indvars.iv
  %46 = load double, ptr %45, align 8, !tbaa !9
  %gep38 = getelementptr double, ptr %invariant.gep37, i64 %indvars.iv
  %47 = load double, ptr %gep38, align 8, !tbaa !9
  %48 = fdiv double %47, %46
  store double %48, ptr %gep38, align 8, !tbaa !9
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %49 = getelementptr inbounds double, ptr %6, i64 %indvars.iv.next.1
  %50 = load double, ptr %49, align 8, !tbaa !9
  %gep.2 = getelementptr double, ptr %invariant.gep, i64 %indvars.iv.next.1
  %51 = load double, ptr %gep.2, align 8, !tbaa !9
  %52 = fdiv double %51, %50
  store double %52, ptr %gep.2, align 8, !tbaa !9
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %53 = getelementptr inbounds double, ptr %6, i64 %indvars.iv.next.2
  %54 = load double, ptr %53, align 8, !tbaa !9
  %gep.3 = getelementptr double, ptr %invariant.gep, i64 %indvars.iv.next.2
  %55 = load double, ptr %gep.3, align 8, !tbaa !9
  %56 = fdiv double %55, %54
  store double %56, ptr %gep.3, align 8, !tbaa !9
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %exitcond.not.3 = icmp eq i64 %indvars.iv.next.3, %wide.trip.count
  br i1 %exitcond.not.3, label %._crit_edge, label %scalar.ph, !llvm.loop !22

._crit_edge:                                      ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block
  %indvars.iv.next30 = add nuw nsw i64 %indvars.iv29, 1
  %exitcond33.not = icmp eq i64 %indvars.iv.next30, %wide.trip.count32
  br i1 %exitcond33.not, label %._crit_edge26, label %.lr.ph, !llvm.loop !23

._crit_edge26:                                    ; preds = %._crit_edge, %.lr.ph25, %5
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: readwrite) 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" }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12}
!12 = distinct !{!12, !13}
!13 = distinct !{!13, !"LVerDomain"}
!14 = !{!15}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !17, !18, !19}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!"llvm.loop.isvectorized", i32 1}
!19 = !{!"llvm.loop.unroll.runtime.disable"}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.unroll.disable"}
!22 = distinct !{!22, !17, !18}
!23 = distinct !{!23, !17}


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