; LLVM IR from niuyishuai/PDCABB :: LAPACK_BLAS/LAPACK (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 i32 @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 i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca %struct.complex, align 4
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  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 8, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #2
  call void @llvm.lifetime.start.p0(i64 8, 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 i64, ptr %23, align 8, !tbaa !9
  store i64 %24, ptr %11, align 8, !tbaa !9
  %25 = load i64, ptr %11, align 8, !tbaa !9
  %26 = add nsw i64 1, %25
  store i64 %26, ptr %12, align 8, !tbaa !9
  %27 = load i64, ptr %12, align 8, !tbaa !9
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = sub i64 0, %27
  %30 = getelementptr inbounds %struct.complex, ptr %28, i64 %29
  store ptr %30, ptr %9, align 8, !tbaa !5
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = load i64, ptr %31, align 8, !tbaa !9
  store i64 %32, ptr %13, align 8, !tbaa !9
  store i64 1, ptr %20, align 8, !tbaa !9
  br label %33

33:                                               ; preds = %94, %5
  %34 = load i64, ptr %20, align 8, !tbaa !9
  %35 = load i64, ptr %13, align 8, !tbaa !9
  %36 = icmp sle i64 %34, %35
  br i1 %36, label %37, label %97

37:                                               ; preds = %33
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = load i64, ptr %38, align 8, !tbaa !9
  store i64 %39, ptr %14, align 8, !tbaa !9
  store i64 1, ptr %19, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %90, %37
  %41 = load i64, ptr %19, align 8, !tbaa !9
  %42 = load i64, ptr %14, align 8, !tbaa !9
  %43 = icmp sle i64 %41, %42
  br i1 %43, label %44, label %93

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

90:                                               ; preds = %44
  %91 = load i64, ptr %19, align 8, !tbaa !9
  %92 = add nsw i64 %91, 1
  store i64 %92, ptr %19, align 8, !tbaa !9
  br label %40, !llvm.loop !16

93:                                               ; preds = %40
  br label %94

94:                                               ; preds = %93
  %95 = load i64, ptr %20, align 8, !tbaa !9
  %96 = add nsw i64 %95, 1
  store i64 %96, ptr %20, align 8, !tbaa !9
  br label %33, !llvm.loop !18

97:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  ret i32 0
}

; 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 = !{!"long", !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 noundef i32 @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 i64, ptr %4, align 8, !tbaa !5
  %8 = xor i64 %7, -1
  %9 = getelementptr inbounds %struct.complex, ptr %3, i64 %8
  %10 = load i64, ptr %1, align 8, !tbaa !5
  %.not35 = icmp slt i64 %10, 1
  br i1 %.not35, label %._crit_edge39, label %.lr.ph38

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

.lr.ph.preheader:                                 ; preds = %.lr.ph38
  %12 = add nsw i64 %11, -1
  %13 = shl i64 %7, 3
  %14 = add nuw i64 %10, 2305843009213693951
  %15 = mul i64 %7, %14
  %16 = add i64 %15, %11
  %17 = shl i64 %16, 3
  %scevgep46 = getelementptr i8, ptr %3, i64 %17
  %18 = shl i64 %11, 2
  %scevgep47 = getelementptr i8, ptr %2, i64 %18
  %min.iters.check = icmp ult i64 %11, 4
  %mul.result = shl i64 %12, 3
  %mul.result44 = shl i64 %12, 3
  %mul.overflow45 = icmp ugt i64 %12, 2305843009213693951
  %bound0 = icmp ugt ptr %scevgep47, %3
  %bound1 = icmp ugt ptr %scevgep46, %2
  %found.conflict = and i1 %bound0, %bound1
  %.mask = and i64 %7, 1152921504606846976
  %stride.check = icmp ne i64 %.mask, 0
  %19 = or i1 %found.conflict, %stride.check
  %n.vec = and i64 %11, 4611686018427387900
  %ind.end = or disjoint i64 %n.vec, 1
  %cmp.n = icmp eq i64 %11, %n.vec
  %xtraiter = and i64 %11, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %._crit_edge
  %indvar = phi i64 [ 0, %.lr.ph.preheader ], [ %indvar.next, %._crit_edge ]
  %.036 = phi i64 [ 1, %.lr.ph.preheader ], [ %56, %._crit_edge ]
  %20 = mul nsw i64 %.036, %7
  %invariant.gep = getelementptr %struct.complex, ptr %9, i64 %20
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.scevcheck

vector.scevcheck:                                 ; preds = %.lr.ph
  %21 = mul i64 %13, %indvar
  %scevgep42 = getelementptr i8, ptr %3, i64 %21
  %22 = or disjoint i64 %21, 4
  %scevgep = getelementptr i8, ptr %3, i64 %22
  %23 = getelementptr i8, ptr %scevgep, i64 %mul.result
  %24 = icmp ult ptr %23, %scevgep
  %25 = getelementptr i8, ptr %scevgep42, i64 %mul.result44
  %26 = icmp ult ptr %25, %scevgep42
  %27 = or i1 %26, %mul.overflow45
  %28 = or i1 %24, %27
  %brmerge = select i1 %28, i1 true, i1 %19
  br i1 %brmerge, label %scalar.ph.preheader, label %vector.body

vector.body:                                      ; preds = %vector.scevcheck, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %vector.scevcheck ]
  %offset.idx = or disjoint i64 %index, 1
  %29 = getelementptr %struct.complex, ptr %invariant.gep, i64 %offset.idx
  %wide.vec = load <8 x float>, ptr %29, 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.vec48 = shufflevector <8 x float> %wide.vec, <8 x float> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
  %30 = getelementptr float, ptr %2, i64 %index
  %wide.load = load <4 x float>, ptr %30, align 4, !tbaa !9, !alias.scope !11
  %31 = fdiv <4 x float> %strided.vec, %wide.load
  %32 = fdiv <4 x float> %strided.vec48, %wide.load
  %interleaved.vec = shufflevector <4 x float> %31, <4 x float> %32, <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 %29, align 4, !tbaa !9
  %index.next = add nuw i64 %index, 4
  %33 = icmp eq i64 %index.next, %n.vec
  br i1 %33, 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 = %vector.scevcheck, %middle.block, %.lr.ph
  %.03134.ph = phi i64 [ 1, %vector.scevcheck ], [ 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 %.03134.ph
  %34 = getelementptr inbounds float, ptr %6, i64 %.03134.ph
  %35 = load float, ptr %34, align 4, !tbaa !9
  %36 = load <2 x float>, ptr %gep.prol, align 4, !tbaa !9
  %37 = insertelement <2 x float> poison, float %35, i64 0
  %38 = shufflevector <2 x float> %37, <2 x float> poison, <2 x i32> zeroinitializer
  %39 = fdiv <2 x float> %36, %38
  store <2 x float> %39, ptr %gep.prol, align 4, !tbaa !9
  %40 = add nuw nsw i64 %.03134.ph, 1
  br label %scalar.ph.prol.loopexit

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %.03134.unr = phi i64 [ %.03134.ph, %scalar.ph.preheader ], [ %40, %scalar.ph.prol ]
  %41 = icmp eq i64 %11, %.03134.ph
  br i1 %41, label %._crit_edge, label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %.03134 = phi i64 [ %55, %scalar.ph ], [ %.03134.unr, %scalar.ph.prol.loopexit ]
  %gep = getelementptr %struct.complex, ptr %invariant.gep, i64 %.03134
  %42 = getelementptr inbounds float, ptr %6, i64 %.03134
  %43 = load float, ptr %42, align 4, !tbaa !9
  %44 = load <2 x float>, ptr %gep, align 4, !tbaa !9
  %45 = insertelement <2 x float> poison, float %43, i64 0
  %46 = shufflevector <2 x float> %45, <2 x float> poison, <2 x i32> zeroinitializer
  %47 = fdiv <2 x float> %44, %46
  store <2 x float> %47, ptr %gep, align 4, !tbaa !9
  %48 = add nuw i64 %.03134, 1
  %gep.1 = getelementptr %struct.complex, ptr %invariant.gep, i64 %48
  %49 = getelementptr float, ptr %2, i64 %.03134
  %50 = load float, ptr %49, align 4, !tbaa !9
  %51 = load <2 x float>, ptr %gep.1, align 4, !tbaa !9
  %52 = insertelement <2 x float> poison, float %50, i64 0
  %53 = shufflevector <2 x float> %52, <2 x float> poison, <2 x i32> zeroinitializer
  %54 = fdiv <2 x float> %51, %53
  store <2 x float> %54, ptr %gep.1, align 4, !tbaa !9
  %55 = add nuw i64 %.03134, 2
  %exitcond.not.1 = icmp eq i64 %48, %11
  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
  %56 = add nuw i64 %.036, 1
  %exitcond41.not = icmp eq i64 %.036, %10
  %indvar.next = add i64 %indvar, 1
  br i1 %exitcond41.not, label %._crit_edge39, label %.lr.ph, !llvm.loop !19

._crit_edge39:                                    ; preds = %._crit_edge, %.lr.ph38, %5
  ret i32 0
}

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 = !{!"long", !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,GlobalDCEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass