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

; 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.complex = type { float, float }

; Function Attrs: nounwind uwtable
define dso_local void @clarscl2_(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
  %17 = alloca i32, align 4
  %18 = alloca %struct.complex, align 4
  %19 = alloca i32, align 4
  %20 = 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
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #2
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = getelementptr inbounds float, ptr %21, i32 -1
  store ptr %22, ptr %8, align 8, !tbaa !5
  %23 = load ptr, ptr %10, align 8, !tbaa !5
  %24 = load i32, ptr %23, align 4, !tbaa !9
  store i32 %24, ptr %11, align 4, !tbaa !9
  %25 = load i32, ptr %11, align 4, !tbaa !9
  %26 = mul nsw i32 %25, 1
  %27 = add nsw i32 1, %26
  store i32 %27, ptr %12, align 4, !tbaa !9
  %28 = load i32, ptr %12, align 4, !tbaa !9
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = sext i32 %28 to i64
  %31 = sub i64 0, %30
  %32 = getelementptr inbounds %struct.complex, ptr %29, i64 %31
  store ptr %32, ptr %9, align 8, !tbaa !5
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = load i32, ptr %33, align 4, !tbaa !9
  store i32 %34, ptr %13, align 4, !tbaa !9
  store i32 1, ptr %20, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %102, %5
  %36 = load i32, ptr %20, align 4, !tbaa !9
  %37 = load i32, ptr %13, align 4, !tbaa !9
  %38 = icmp sle i32 %36, %37
  br i1 %38, label %39, label %105

39:                                               ; preds = %35
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load i32, ptr %40, align 4, !tbaa !9
  store i32 %41, ptr %14, align 4, !tbaa !9
  store i32 1, ptr %19, align 4, !tbaa !9
  br label %42

42:                                               ; preds = %98, %39
  %43 = load i32, ptr %19, align 4, !tbaa !9
  %44 = load i32, ptr %14, align 4, !tbaa !9
  %45 = icmp sle i32 %43, %44
  br i1 %45, label %46, label %101

46:                                               ; preds = %42
  %47 = load i32, ptr %19, align 4, !tbaa !9
  %48 = load i32, ptr %20, align 4, !tbaa !9
  %49 = load i32, ptr %11, align 4, !tbaa !9
  %50 = mul nsw i32 %48, %49
  %51 = add nsw i32 %47, %50
  store i32 %51, ptr %15, align 4, !tbaa !9
  %52 = load i32, ptr %19, align 4, !tbaa !9
  %53 = load i32, ptr %20, align 4, !tbaa !9
  %54 = load i32, ptr %11, align 4, !tbaa !9
  %55 = mul nsw i32 %53, %54
  %56 = add nsw i32 %52, %55
  store i32 %56, ptr %16, align 4, !tbaa !9
  %57 = load i32, ptr %19, align 4, !tbaa !9
  store i32 %57, ptr %17, align 4, !tbaa !9
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = load i32, ptr %16, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds %struct.complex, ptr %58, i64 %60
  %62 = getelementptr inbounds %struct.complex, ptr %61, i32 0, i32 0
  %63 = load float, ptr %62, align 4, !tbaa !11
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  %65 = load i32, ptr %17, align 4, !tbaa !9
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds float, ptr %64, i64 %66
  %68 = load float, ptr %67, align 4, !tbaa !14
  %69 = fdiv float %63, %68
  %70 = getelementptr inbounds %struct.complex, ptr %18, i32 0, i32 0
  store float %69, ptr %70, align 4, !tbaa !11
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  %72 = load i32, ptr %16, align 4, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds %struct.complex, ptr %71, i64 %73
  %75 = getelementptr inbounds %struct.complex, ptr %74, i32 0, i32 1
  %76 = load float, ptr %75, align 4, !tbaa !15
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  %78 = load i32, ptr %17, align 4, !tbaa !9
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds float, ptr %77, i64 %79
  %81 = load float, ptr %80, align 4, !tbaa !14
  %82 = fdiv float %76, %81
  %83 = getelementptr inbounds %struct.complex, ptr %18, i32 0, i32 1
  store float %82, ptr %83, align 4, !tbaa !15
  %84 = getelementptr inbounds %struct.complex, ptr %18, i32 0, i32 0
  %85 = load float, ptr %84, align 4, !tbaa !11
  %86 = load ptr, ptr %9, align 8, !tbaa !5
  %87 = load i32, ptr %15, align 4, !tbaa !9
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds %struct.complex, ptr %86, i64 %88
  %90 = getelementptr inbounds %struct.complex, ptr %89, i32 0, i32 0
  store float %85, ptr %90, align 4, !tbaa !11
  %91 = getelementptr inbounds %struct.complex, ptr %18, i32 0, i32 1
  %92 = load float, ptr %91, align 4, !tbaa !15
  %93 = load ptr, ptr %9, align 8, !tbaa !5
  %94 = load i32, ptr %15, align 4, !tbaa !9
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds %struct.complex, ptr %93, i64 %95
  %97 = getelementptr inbounds %struct.complex, ptr %96, i32 0, i32 1
  store float %92, ptr %97, align 4, !tbaa !15
  br label %98

98:                                               ; preds = %46
  %99 = load i32, ptr %19, align 4, !tbaa !9
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr %19, align 4, !tbaa !9
  br label %42, !llvm.loop !16

101:                                              ; preds = %42
  br label %102

102:                                              ; preds = %101
  %103 = load i32, ptr %20, align 4, !tbaa !9
  %104 = add nsw i32 %103, 1
  store i32 %104, ptr %20, align 4, !tbaa !9
  br label %35, !llvm.loop !18

105:                                              ; preds = %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #2
  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, !13, i64 0}
!12 = !{!"", !13, i64 0, !13, i64 4}
!13 = !{!"float", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !13, i64 4}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


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

%struct.complex = type { float, float }

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @clarscl2_(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 -4
  %7 = load i32, ptr %4, align 4, !tbaa !5
  %narrow = xor i32 %7, -1
  %8 = sext i32 %narrow to i64
  %9 = getelementptr inbounds %struct.complex, ptr %3, i64 %8
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %.not35 = icmp slt i32 %10, 1
  br i1 %.not35, label %._crit_edge39, label %.lr.ph38

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

.lr.ph.preheader:                                 ; preds = %.lr.ph38
  %12 = add nuw i32 %11, 1
  %13 = sext i32 %7 to i64
  %14 = add nuw i32 %10, 1
  %wide.trip.count45 = 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.count45, 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
  %scevgep47 = getelementptr i8, ptr %24, i64 %22
  %25 = shl nuw nsw i64 %wide.trip.count, 2
  %26 = getelementptr i8, ptr %2, i64 %25
  %scevgep48 = getelementptr i8, ptr %26, i64 -4
  %27 = zext nneg i32 %11 to i64
  %28 = zext nneg i32 %11 to i64
  %min.iters.check = icmp ult i32 %11, 4
  %bound0 = icmp ult ptr %scevgep, %scevgep48
  %bound1 = icmp ugt ptr %scevgep47, %2
  %found.conflict = and i1 %bound0, %bound1
  %stride.check = icmp slt i32 %7, 0
  %29 = or i1 %found.conflict, %stride.check
  %n.vec = and i64 %27, 2147483644
  %ind.end = or disjoint i64 %n.vec, 1
  %cmp.n = icmp eq i64 %n.vec, %27
  %30 = and i32 %11, 1
  %lcmp.mod.not = icmp eq i32 %30, 0
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %._crit_edge
  %indvars.iv42 = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next43, %._crit_edge ]
  %31 = mul nsw i64 %indvars.iv42, %13
  %invariant.gep = getelementptr %struct.complex, ptr %9, i64 %31
  %brmerge = select i1 %min.iters.check, i1 true, i1 %29
  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
  %32 = getelementptr %struct.complex, ptr %invariant.gep, i64 %offset.idx
  %wide.vec = load <8 x float>, ptr %32, align 4, !tbaa !9
  %strided.vec = shufflevector <8 x float> %wide.vec, <8 x float> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
  %strided.vec49 = shufflevector <8 x float> %wide.vec, <8 x float> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
  %33 = getelementptr float, ptr %2, i64 %index
  %wide.load = load <4 x float>, ptr %33, align 4, !tbaa !9, !alias.scope !11
  %34 = fdiv <4 x float> %strided.vec, %wide.load
  %35 = fdiv <4 x float> %strided.vec49, %wide.load
  %interleaved.vec = shufflevector <4 x float> %34, <4 x float> %35, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
  store <8 x float> %interleaved.vec, ptr %32, align 4, !tbaa !9
  %index.next = add nuw i64 %index, 4
  %36 = icmp eq i64 %index.next, %n.vec
  br i1 %36, label %middle.block, label %vector.body, !llvm.loop !14

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 ]
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader
  %gep.prol = getelementptr %struct.complex, ptr %invariant.gep, i64 %indvars.iv.ph
  %37 = getelementptr inbounds float, ptr %6, i64 %indvars.iv.ph
  %38 = load float, ptr %37, align 4, !tbaa !9
  %39 = load <2 x float>, ptr %gep.prol, align 4, !tbaa !9
  %40 = insertelement <2 x float> poison, float %38, i64 0
  %41 = shufflevector <2 x float> %40, <2 x float> poison, <2 x i32> zeroinitializer
  %42 = fdiv <2 x float> %39, %41
  store <2 x float> %42, ptr %gep.prol, align 4, !tbaa !9
  %indvars.iv.next.prol = add nuw nsw i64 %indvars.iv.ph, 1
  br label %scalar.ph.prol.loopexit

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 ]
  %43 = icmp eq i64 %indvars.iv.ph, %28
  br i1 %43, label %._crit_edge, label %scalar.ph.preheader.new

scalar.ph.preheader.new:                          ; preds = %scalar.ph.prol.loopexit
  %invariant.gep50 = 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.1, %scalar.ph ]
  %gep = getelementptr %struct.complex, ptr %invariant.gep, i64 %indvars.iv
  %44 = getelementptr inbounds float, ptr %6, i64 %indvars.iv
  %45 = load float, ptr %44, align 4, !tbaa !9
  %46 = load <2 x float>, ptr %gep, align 4, !tbaa !9
  %47 = insertelement <2 x float> poison, float %45, i64 0
  %48 = shufflevector <2 x float> %47, <2 x float> poison, <2 x i32> zeroinitializer
  %49 = fdiv <2 x float> %46, %48
  store <2 x float> %49, ptr %gep, align 4, !tbaa !9
  %gep51 = getelementptr %struct.complex, ptr %invariant.gep50, i64 %indvars.iv
  %50 = getelementptr float, ptr %2, i64 %indvars.iv
  %51 = load float, ptr %50, align 4, !tbaa !9
  %52 = load <2 x float>, ptr %gep51, align 4, !tbaa !9
  %53 = insertelement <2 x float> poison, float %51, i64 0
  %54 = shufflevector <2 x float> %53, <2 x float> poison, <2 x i32> zeroinitializer
  %55 = fdiv <2 x float> %52, %54
  store <2 x float> %55, ptr %gep51, align 4, !tbaa !9
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, %wide.trip.count
  br i1 %exitcond.not.1, label %._crit_edge, label %scalar.ph, !llvm.loop !18

._crit_edge:                                      ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block
  %indvars.iv.next43 = add nuw nsw i64 %indvars.iv42, 1
  %exitcond46.not = icmp eq i64 %indvars.iv.next43, %wide.trip.count45
  br i1 %exitcond46.not, label %._crit_edge39, label %.lr.ph, !llvm.loop !19

._crit_edge39:                                    ; preds = %._crit_edge, %.lr.ph38, %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 = !{!"float", !7, i64 0}
!11 = !{!12}
!12 = distinct !{!12, !13}
!13 = distinct !{!13, !"LVerDomain"}
!14 = distinct !{!14, !15, !16, !17}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!"llvm.loop.isvectorized", i32 1}
!17 = !{!"llvm.loop.unroll.runtime.disable"}
!18 = distinct !{!18, !15, !16}
!19 = distinct !{!19, !15}


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