; LLVM IR from niuyishuai/PDCABB :: LAPACK_BLAS/LAPACK (dlatrz)

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

@.str = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @dlatrz_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #0 {
  %8 = alloca i32, align 4
  %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 ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  %21 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store ptr %3, ptr %12, align 8, !tbaa !5
  store ptr %4, ptr %13, align 8, !tbaa !5
  store ptr %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #3
  %22 = load ptr, ptr %13, align 8, !tbaa !5
  %23 = load i64, ptr %22, align 8, !tbaa !9
  store i64 %23, ptr %16, align 8, !tbaa !9
  %24 = load i64, ptr %16, align 8, !tbaa !9
  %25 = add nsw i64 1, %24
  store i64 %25, ptr %17, align 8, !tbaa !9
  %26 = load i64, ptr %17, align 8, !tbaa !9
  %27 = load ptr, ptr %12, align 8, !tbaa !5
  %28 = sub i64 0, %26
  %29 = getelementptr inbounds double, ptr %27, i64 %28
  store ptr %29, ptr %12, align 8, !tbaa !5
  %30 = load ptr, ptr %14, align 8, !tbaa !5
  %31 = getelementptr inbounds double, ptr %30, i32 -1
  store ptr %31, ptr %14, align 8, !tbaa !5
  %32 = load ptr, ptr %15, align 8, !tbaa !5
  %33 = getelementptr inbounds double, ptr %32, i32 -1
  store ptr %33, ptr %15, align 8, !tbaa !5
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = load i64, ptr %34, align 8, !tbaa !9
  %36 = icmp eq i64 %35, 0
  br i1 %36, label %37, label %38

37:                                               ; preds = %7
  store i32 0, ptr %8, align 4
  store i32 1, ptr %21, align 4
  br label %132

38:                                               ; preds = %7
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = load i64, ptr %39, align 8, !tbaa !9
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = load i64, ptr %41, align 8, !tbaa !9
  %43 = icmp eq i64 %40, %42
  br i1 %43, label %44, label %59

44:                                               ; preds = %38
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = load i64, ptr %45, align 8, !tbaa !9
  store i64 %46, ptr %18, align 8, !tbaa !9
  store i64 1, ptr %20, align 8, !tbaa !9
  br label %47

47:                                               ; preds = %55, %44
  %48 = load i64, ptr %20, align 8, !tbaa !9
  %49 = load i64, ptr %18, align 8, !tbaa !9
  %50 = icmp sle i64 %48, %49
  br i1 %50, label %51, label %58

51:                                               ; preds = %47
  %52 = load ptr, ptr %14, align 8, !tbaa !5
  %53 = load i64, ptr %20, align 8, !tbaa !9
  %54 = getelementptr inbounds double, ptr %52, i64 %53
  store double 0.000000e+00, ptr %54, align 8, !tbaa !11
  br label %55

55:                                               ; preds = %51
  %56 = load i64, ptr %20, align 8, !tbaa !9
  %57 = add nsw i64 %56, 1
  store i64 %57, ptr %20, align 8, !tbaa !9
  br label %47, !llvm.loop !13

58:                                               ; preds = %47
  store i32 0, ptr %8, align 4
  store i32 1, ptr %21, align 4
  br label %132

59:                                               ; preds = %38
  br label %60

60:                                               ; preds = %59
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = load i64, ptr %61, align 8, !tbaa !9
  store i64 %62, ptr %20, align 8, !tbaa !9
  br label %63

63:                                               ; preds = %128, %60
  %64 = load i64, ptr %20, align 8, !tbaa !9
  %65 = icmp sge i64 %64, 1
  br i1 %65, label %66, label %131

66:                                               ; preds = %63
  %67 = load ptr, ptr %11, align 8, !tbaa !5
  %68 = load i64, ptr %67, align 8, !tbaa !9
  %69 = add nsw i64 %68, 1
  store i64 %69, ptr %18, align 8, !tbaa !9
  %70 = load ptr, ptr %12, align 8, !tbaa !5
  %71 = load i64, ptr %20, align 8, !tbaa !9
  %72 = load i64, ptr %20, align 8, !tbaa !9
  %73 = load i64, ptr %16, align 8, !tbaa !9
  %74 = mul nsw i64 %72, %73
  %75 = add nsw i64 %71, %74
  %76 = getelementptr inbounds double, ptr %70, i64 %75
  %77 = load ptr, ptr %12, align 8, !tbaa !5
  %78 = load i64, ptr %20, align 8, !tbaa !9
  %79 = load ptr, ptr %10, align 8, !tbaa !5
  %80 = load i64, ptr %79, align 8, !tbaa !9
  %81 = load ptr, ptr %11, align 8, !tbaa !5
  %82 = load i64, ptr %81, align 8, !tbaa !9
  %83 = sub nsw i64 %80, %82
  %84 = add nsw i64 %83, 1
  %85 = load i64, ptr %16, align 8, !tbaa !9
  %86 = mul nsw i64 %84, %85
  %87 = add nsw i64 %78, %86
  %88 = getelementptr inbounds double, ptr %77, i64 %87
  %89 = load ptr, ptr %13, align 8, !tbaa !5
  %90 = load ptr, ptr %14, align 8, !tbaa !5
  %91 = load i64, ptr %20, align 8, !tbaa !9
  %92 = getelementptr inbounds double, ptr %90, i64 %91
  %93 = call i32 @dlarfp_(ptr noundef %18, ptr noundef %76, ptr noundef %88, ptr noundef %89, ptr noundef %92)
  %94 = load i64, ptr %20, align 8, !tbaa !9
  %95 = sub nsw i64 %94, 1
  store i64 %95, ptr %18, align 8, !tbaa !9
  %96 = load ptr, ptr %10, align 8, !tbaa !5
  %97 = load i64, ptr %96, align 8, !tbaa !9
  %98 = load i64, ptr %20, align 8, !tbaa !9
  %99 = sub nsw i64 %97, %98
  %100 = add nsw i64 %99, 1
  store i64 %100, ptr %19, align 8, !tbaa !9
  %101 = load ptr, ptr %11, align 8, !tbaa !5
  %102 = load ptr, ptr %12, align 8, !tbaa !5
  %103 = load i64, ptr %20, align 8, !tbaa !9
  %104 = load ptr, ptr %10, align 8, !tbaa !5
  %105 = load i64, ptr %104, align 8, !tbaa !9
  %106 = load ptr, ptr %11, align 8, !tbaa !5
  %107 = load i64, ptr %106, align 8, !tbaa !9
  %108 = sub nsw i64 %105, %107
  %109 = add nsw i64 %108, 1
  %110 = load i64, ptr %16, align 8, !tbaa !9
  %111 = mul nsw i64 %109, %110
  %112 = add nsw i64 %103, %111
  %113 = getelementptr inbounds double, ptr %102, i64 %112
  %114 = load ptr, ptr %13, align 8, !tbaa !5
  %115 = load ptr, ptr %14, align 8, !tbaa !5
  %116 = load i64, ptr %20, align 8, !tbaa !9
  %117 = getelementptr inbounds double, ptr %115, i64 %116
  %118 = load ptr, ptr %12, align 8, !tbaa !5
  %119 = load i64, ptr %20, align 8, !tbaa !9
  %120 = load i64, ptr %16, align 8, !tbaa !9
  %121 = mul nsw i64 %119, %120
  %122 = add nsw i64 %121, 1
  %123 = getelementptr inbounds double, ptr %118, i64 %122
  %124 = load ptr, ptr %13, align 8, !tbaa !5
  %125 = load ptr, ptr %15, align 8, !tbaa !5
  %126 = getelementptr inbounds double, ptr %125, i64 1
  %127 = call i32 @dlarz_(ptr noundef @.str, ptr noundef %18, ptr noundef %19, ptr noundef %101, ptr noundef %113, ptr noundef %114, ptr noundef %117, ptr noundef %123, ptr noundef %124, ptr noundef %126)
  br label %128

128:                                              ; preds = %66
  %129 = load i64, ptr %20, align 8, !tbaa !9
  %130 = add nsw i64 %129, -1
  store i64 %130, ptr %20, align 8, !tbaa !9
  br label %63, !llvm.loop !15

131:                                              ; preds = %63
  store i32 0, ptr %8, align 4
  store i32 1, ptr %21, align 4
  br label %132

132:                                              ; preds = %131, %58, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  %133 = load i32, ptr %8, align 4
  ret i32 %133
}

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

declare i32 @dlarfp_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare i32 @dlarz_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

; 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 = { "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 = { 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, !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"

@.str = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @dlatrz_(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) local_unnamed_addr #0 {
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #4
  %10 = load i64, ptr %4, align 8, !tbaa !5
  %11 = xor i64 %10, -1
  %12 = getelementptr inbounds double, ptr %3, i64 %11
  %13 = getelementptr inbounds i8, ptr %5, i64 -8
  %14 = load i64, ptr %0, align 8, !tbaa !5
  %15 = icmp eq i64 %14, 0
  br i1 %15, label %.loopexit, label %16

16:                                               ; preds = %7
  %17 = load i64, ptr %1, align 8, !tbaa !5
  %18 = icmp eq i64 %14, %17
  br i1 %18, label %20, label %.preheader

.preheader:                                       ; preds = %16
  %invariant.gep = getelementptr i8, ptr %12, i64 8
  %19 = icmp sgt i64 %14, 0
  br i1 %19, label %.lr.ph, label %.loopexit

20:                                               ; preds = %16
  %.not53 = icmp slt i64 %14, 1
  br i1 %.not53, label %.loopexit, label %.lr.ph55.preheader

.lr.ph55.preheader:                               ; preds = %20
  %21 = shl nuw i64 %14, 3
  tail call void @llvm.memset.p0.i64(ptr align 8 %5, i8 0, i64 %21, i1 false), !tbaa !9
  br label %.loopexit

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.152 = phi i64 [ %33, %.lr.ph ], [ %14, %.preheader ]
  %22 = load i64, ptr %2, align 8, !tbaa !5
  %23 = add nsw i64 %22, 1
  store i64 %23, ptr %8, align 8, !tbaa !5
  %24 = mul nsw i64 %.152, %10
  %25 = getelementptr double, ptr %12, i64 %.152
  %26 = getelementptr double, ptr %25, i64 %24
  %27 = load i64, ptr %1, align 8, !tbaa !5
  %reass.sub = sub i64 %27, %22
  %28 = add i64 %reass.sub, 1
  %29 = mul nsw i64 %28, %10
  %30 = getelementptr double, ptr %25, i64 %29
  %31 = getelementptr inbounds double, ptr %13, i64 %.152
  %32 = call i32 @dlarfp_(ptr noundef nonnull %8, ptr noundef %26, ptr noundef %30, ptr noundef nonnull %4, ptr noundef nonnull %31) #4
  %33 = add nsw i64 %.152, -1
  store i64 %33, ptr %8, align 8, !tbaa !5
  %34 = load i64, ptr %1, align 8, !tbaa !5
  %reass.sub56 = sub i64 %34, %.152
  %35 = add i64 %reass.sub56, 1
  store i64 %35, ptr %9, align 8, !tbaa !5
  %36 = load i64, ptr %2, align 8, !tbaa !5
  %37 = add i64 %34, 1
  %38 = sub i64 %37, %36
  %39 = mul nsw i64 %38, %10
  %40 = getelementptr double, ptr %25, i64 %39
  %gep = getelementptr double, ptr %invariant.gep, i64 %24
  %41 = call i32 @dlarz_(ptr noundef nonnull @.str, ptr noundef nonnull %8, ptr noundef nonnull %9, ptr noundef nonnull %2, ptr noundef %40, ptr noundef nonnull %4, ptr noundef nonnull %31, ptr noundef %gep, ptr noundef nonnull %4, ptr noundef %6) #4
  %42 = icmp ugt i64 %.152, 1
  br i1 %42, label %.lr.ph, label %.loopexit, !llvm.loop !11

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph55.preheader, %.preheader, %20, %7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  ret i32 0
}

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

declare i32 @dlarfp_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @dlarz_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 = !{!"long", !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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