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

; 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 }
%struct.doublecomplex = type { double, double }

; Function Attrs: nounwind uwtable
define dso_local void @clag2z_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #0 {
  %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 ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  store ptr %6, ptr %14, align 8, !tbaa !5
  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 4, 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
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #2
  %25 = load ptr, ptr %11, align 8, !tbaa !5
  %26 = load i32, ptr %25, align 4, !tbaa !9
  store i32 %26, ptr %15, align 4, !tbaa !9
  %27 = load i32, ptr %15, align 4, !tbaa !9
  %28 = mul nsw i32 %27, 1
  %29 = add nsw i32 1, %28
  store i32 %29, ptr %16, align 4, !tbaa !9
  %30 = load i32, ptr %16, align 4, !tbaa !9
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = sext i32 %30 to i64
  %33 = sub i64 0, %32
  %34 = getelementptr inbounds %struct.complex, ptr %31, i64 %33
  store ptr %34, ptr %10, align 8, !tbaa !5
  %35 = load ptr, ptr %13, align 8, !tbaa !5
  %36 = load i32, ptr %35, align 4, !tbaa !9
  store i32 %36, ptr %17, align 4, !tbaa !9
  %37 = load i32, ptr %17, align 4, !tbaa !9
  %38 = mul nsw i32 %37, 1
  %39 = add nsw i32 1, %38
  store i32 %39, ptr %18, align 4, !tbaa !9
  %40 = load i32, ptr %18, align 4, !tbaa !9
  %41 = load ptr, ptr %12, align 8, !tbaa !5
  %42 = sext i32 %40 to i64
  %43 = sub i64 0, %42
  %44 = getelementptr inbounds %struct.doublecomplex, ptr %41, i64 %43
  store ptr %44, ptr %12, align 8, !tbaa !5
  %45 = load ptr, ptr %14, align 8, !tbaa !5
  store i32 0, ptr %45, align 4, !tbaa !9
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = load i32, ptr %46, align 4, !tbaa !9
  store i32 %47, ptr %19, align 4, !tbaa !9
  store i32 1, ptr %24, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %98, %7
  %49 = load i32, ptr %24, align 4, !tbaa !9
  %50 = load i32, ptr %19, align 4, !tbaa !9
  %51 = icmp sle i32 %49, %50
  br i1 %51, label %52, label %101

52:                                               ; preds = %48
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = load i32, ptr %53, align 4, !tbaa !9
  store i32 %54, ptr %20, align 4, !tbaa !9
  store i32 1, ptr %23, align 4, !tbaa !9
  br label %55

55:                                               ; preds = %94, %52
  %56 = load i32, ptr %23, align 4, !tbaa !9
  %57 = load i32, ptr %20, align 4, !tbaa !9
  %58 = icmp sle i32 %56, %57
  br i1 %58, label %59, label %97

59:                                               ; preds = %55
  %60 = load i32, ptr %23, align 4, !tbaa !9
  %61 = load i32, ptr %24, align 4, !tbaa !9
  %62 = load i32, ptr %17, align 4, !tbaa !9
  %63 = mul nsw i32 %61, %62
  %64 = add nsw i32 %60, %63
  store i32 %64, ptr %21, align 4, !tbaa !9
  %65 = load i32, ptr %23, align 4, !tbaa !9
  %66 = load i32, ptr %24, align 4, !tbaa !9
  %67 = load i32, ptr %15, align 4, !tbaa !9
  %68 = mul nsw i32 %66, %67
  %69 = add nsw i32 %65, %68
  store i32 %69, ptr %22, align 4, !tbaa !9
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = load i32, ptr %22, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds %struct.complex, ptr %70, i64 %72
  %74 = getelementptr inbounds %struct.complex, ptr %73, i32 0, i32 0
  %75 = load float, ptr %74, align 4, !tbaa !11
  %76 = fpext float %75 to double
  %77 = load ptr, ptr %12, align 8, !tbaa !5
  %78 = load i32, ptr %21, align 4, !tbaa !9
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds %struct.doublecomplex, ptr %77, i64 %79
  %81 = getelementptr inbounds %struct.doublecomplex, ptr %80, i32 0, i32 0
  store double %76, ptr %81, align 8, !tbaa !14
  %82 = load ptr, ptr %10, align 8, !tbaa !5
  %83 = load i32, ptr %22, align 4, !tbaa !9
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds %struct.complex, ptr %82, i64 %84
  %86 = getelementptr inbounds %struct.complex, ptr %85, i32 0, i32 1
  %87 = load float, ptr %86, align 4, !tbaa !17
  %88 = fpext float %87 to double
  %89 = load ptr, ptr %12, align 8, !tbaa !5
  %90 = load i32, ptr %21, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds %struct.doublecomplex, ptr %89, i64 %91
  %93 = getelementptr inbounds %struct.doublecomplex, ptr %92, i32 0, i32 1
  store double %88, ptr %93, align 8, !tbaa !18
  br label %94

94:                                               ; preds = %59
  %95 = load i32, ptr %23, align 4, !tbaa !9
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %23, align 4, !tbaa !9
  br label %55, !llvm.loop !19

97:                                               ; preds = %55
  br label %98

98:                                               ; preds = %97
  %99 = load i32, ptr %24, align 4, !tbaa !9
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr %24, align 4, !tbaa !9
  br label %48, !llvm.loop !21

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


; 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 }
%struct.doublecomplex = type { double, double }

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @clag2z_(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef readonly %5, ptr nocapture noundef writeonly %6) local_unnamed_addr #0 {
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %narrow = xor i32 %8, -1
  %9 = sext i32 %narrow to i64
  %10 = getelementptr inbounds %struct.complex, ptr %2, i64 %9
  %11 = load i32, ptr %5, align 4, !tbaa !5
  %narrow31 = xor i32 %11, -1
  %12 = sext i32 %narrow31 to i64
  %13 = getelementptr inbounds %struct.doublecomplex, ptr %4, i64 %12
  store i32 0, ptr %6, align 4, !tbaa !5
  %14 = load i32, ptr %1, align 4, !tbaa !5
  %.not35 = icmp slt i32 %14, 1
  br i1 %.not35, label %._crit_edge39, label %.lr.ph38

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

.lr.ph.preheader:                                 ; preds = %.lr.ph38
  %16 = add nuw i32 %15, 1
  %17 = sext i32 %11 to i64
  %18 = sext i32 %8 to i64
  %19 = add nuw i32 %14, 1
  %wide.trip.count45 = zext i32 %19 to i64
  %wide.trip.count = zext i32 %16 to i64
  %20 = zext nneg i32 %15 to i64
  %min.iters.check = icmp eq i32 %15, 1
  %n.vec = and i64 %20, 2147483646
  %ind.end = or i64 %20, 1
  %cmp.n = icmp eq i64 %n.vec, %20
  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 ]
  %21 = mul nsw i64 %indvars.iv42, %17
  %22 = mul nsw i64 %indvars.iv42, %18
  %invariant.gep = getelementptr %struct.complex, ptr %10, i64 %22
  %invariant.gep47 = getelementptr %struct.doublecomplex, ptr %13, i64 %21
  br i1 %min.iters.check, 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
  %23 = getelementptr %struct.complex, ptr %invariant.gep, i64 %offset.idx
  %wide.vec = load <4 x float>, ptr %23, align 4, !tbaa !9
  %strided.vec = shufflevector <4 x float> %wide.vec, <4 x float> poison, <2 x i32> <i32 0, i32 2>
  %strided.vec49 = shufflevector <4 x float> %wide.vec, <4 x float> poison, <2 x i32> <i32 1, i32 3>
  %24 = fpext <2 x float> %strided.vec to <2 x double>
  %25 = fpext <2 x float> %strided.vec49 to <2 x double>
  %26 = getelementptr %struct.doublecomplex, ptr %invariant.gep47, i64 %offset.idx
  %interleaved.vec = shufflevector <2 x double> %24, <2 x double> %25, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  store <4 x double> %interleaved.vec, ptr %26, align 8, !tbaa !11
  %index.next = add nuw i64 %index, 2
  %27 = icmp eq i64 %index.next, %n.vec
  br i1 %27, label %middle.block, label %vector.body, !llvm.loop !13

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

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %indvars.iv.ph = phi i64 [ 1, %.lr.ph ], [ %ind.end, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %gep = getelementptr %struct.complex, ptr %invariant.gep, i64 %indvars.iv
  %gep48 = getelementptr %struct.doublecomplex, ptr %invariant.gep47, i64 %indvars.iv
  %28 = load <2 x float>, ptr %gep, align 4, !tbaa !9
  %29 = fpext <2 x float> %28 to <2 x double>
  store <2 x double> %29, ptr %gep48, align 8, !tbaa !11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !17

._crit_edge:                                      ; preds = %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 !18

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


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