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

; 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 [13 x i8], align 1

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

51:                                               ; preds = %125, %6
  %52 = load i64, ptr %21, align 8, !tbaa !9
  %53 = load i64, ptr %17, align 8, !tbaa !9
  %54 = icmp sle i64 %52, %53
  br i1 %54, label %55, label %128

55:                                               ; preds = %51
  %56 = load ptr, ptr %12, align 8, !tbaa !5
  %57 = load i64, ptr %21, align 8, !tbaa !9
  %58 = getelementptr inbounds double, ptr %56, i64 %57
  store double 0.000000e+00, ptr %58, align 8, !tbaa !11
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = load i64, ptr %59, align 8, !tbaa !9
  store i64 %60, ptr %18, align 8, !tbaa !9
  store i64 1, ptr %20, align 8, !tbaa !9
  br label %61

61:                                               ; preds = %121, %55
  %62 = load i64, ptr %20, align 8, !tbaa !9
  %63 = load i64, ptr %18, align 8, !tbaa !9
  %64 = icmp sle i64 %62, %63
  br i1 %64, label %65, label %124

65:                                               ; preds = %61
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = load i64, ptr %20, align 8, !tbaa !9
  %68 = load i64, ptr %21, align 8, !tbaa !9
  %69 = load i64, ptr %13, align 8, !tbaa !9
  %70 = mul nsw i64 %68, %69
  %71 = add nsw i64 %67, %70
  %72 = getelementptr inbounds double, ptr %66, i64 %71
  %73 = load double, ptr %72, align 8, !tbaa !11
  %74 = fcmp une double %73, 0.000000e+00
  br i1 %74, label %75, label %120

75:                                               ; preds = %65
  %76 = load double, ptr %23, align 8, !tbaa !11
  %77 = load ptr, ptr %10, align 8, !tbaa !5
  %78 = load i64, ptr %20, align 8, !tbaa !9
  %79 = load i64, ptr %21, align 8, !tbaa !9
  %80 = load i64, ptr %15, align 8, !tbaa !9
  %81 = mul nsw i64 %79, %80
  %82 = add nsw i64 %78, %81
  %83 = getelementptr inbounds double, ptr %77, i64 %82
  %84 = load double, ptr %83, align 8, !tbaa !11
  store double %84, ptr %19, align 8, !tbaa !11
  %85 = load double, ptr %19, align 8, !tbaa !11
  %86 = fcmp oge double %85, 0.000000e+00
  br i1 %86, label %87, label %89

87:                                               ; preds = %75
  %88 = load double, ptr %19, align 8, !tbaa !11
  br label %92

89:                                               ; preds = %75
  %90 = load double, ptr %19, align 8, !tbaa !11
  %91 = fneg double %90
  br label %92

92:                                               ; preds = %89, %87
  %93 = phi double [ %88, %87 ], [ %91, %89 ]
  %94 = fadd double %76, %93
  %95 = load ptr, ptr %11, align 8, !tbaa !5
  %96 = load i64, ptr %20, align 8, !tbaa !9
  %97 = load i64, ptr %21, align 8, !tbaa !9
  %98 = load i64, ptr %13, align 8, !tbaa !9
  %99 = mul nsw i64 %97, %98
  %100 = add nsw i64 %96, %99
  %101 = getelementptr inbounds double, ptr %95, i64 %100
  %102 = load double, ptr %101, align 8, !tbaa !11
  %103 = fdiv double %94, %102
  store double %103, ptr %22, align 8, !tbaa !11
  %104 = load ptr, ptr %12, align 8, !tbaa !5
  %105 = load i64, ptr %21, align 8, !tbaa !9
  %106 = getelementptr inbounds double, ptr %104, i64 %105
  %107 = load double, ptr %106, align 8, !tbaa !11
  store double %107, ptr %19, align 8, !tbaa !11
  %108 = load double, ptr %19, align 8, !tbaa !11
  %109 = load double, ptr %22, align 8, !tbaa !11
  %110 = fcmp oge double %108, %109
  br i1 %110, label %111, label %113

111:                                              ; preds = %92
  %112 = load double, ptr %19, align 8, !tbaa !11
  br label %115

113:                                              ; preds = %92
  %114 = load double, ptr %22, align 8, !tbaa !11
  br label %115

115:                                              ; preds = %113, %111
  %116 = phi double [ %112, %111 ], [ %114, %113 ]
  %117 = load ptr, ptr %12, align 8, !tbaa !5
  %118 = load i64, ptr %21, align 8, !tbaa !9
  %119 = getelementptr inbounds double, ptr %117, i64 %118
  store double %116, ptr %119, align 8, !tbaa !11
  br label %120

120:                                              ; preds = %115, %65
  br label %121

121:                                              ; preds = %120
  %122 = load i64, ptr %20, align 8, !tbaa !9
  %123 = add nsw i64 %122, 1
  store i64 %123, ptr %20, align 8, !tbaa !9
  br label %61, !llvm.loop !13

124:                                              ; preds = %61
  br label %125

125:                                              ; preds = %124
  %126 = load i64, ptr %21, align 8, !tbaa !9
  %127 = add nsw i64 %126, 1
  store i64 %127, ptr %21, align 8, !tbaa !9
  br label %51, !llvm.loop !15

128:                                              ; preds = %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  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
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  ret i32 0
}

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

declare double @dlamch_(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 [13 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @dla_lin_berr__(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr nocapture noundef readonly %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #0 {
  %7 = getelementptr inbounds i8, ptr %5, i64 -8
  %8 = load i64, ptr %0, align 8, !tbaa !5
  %9 = xor i64 %8, -1
  %10 = getelementptr inbounds double, ptr %4, i64 %9
  %11 = getelementptr inbounds double, ptr %3, i64 %9
  %12 = tail call double @dlamch_(ptr noundef nonnull @.str) #3
  %13 = load i64, ptr %1, align 8, !tbaa !5
  %14 = add nsw i64 %13, 1
  %15 = sitofp i64 %14 to double
  %16 = fmul double %12, %15
  %17 = load i64, ptr %2, align 8, !tbaa !5
  %.not49 = icmp slt i64 %17, 1
  br i1 %.not49, label %._crit_edge53, label %.lr.ph52

.lr.ph52:                                         ; preds = %6
  %18 = load i64, ptr %0, align 8, !tbaa !5
  %.not4647 = icmp slt i64 %18, 1
  br i1 %.not4647, label %.lr.ph52.split.us.preheader, label %.lr.ph

.lr.ph52.split.us.preheader:                      ; preds = %.lr.ph52
  %19 = shl nuw i64 %17, 3
  tail call void @llvm.memset.p0.i64(ptr align 8 %5, i8 0, i64 %19, i1 false), !tbaa !9
  br label %._crit_edge53

.lr.ph:                                           ; preds = %.lr.ph52, %._crit_edge
  %.050 = phi i64 [ %41, %._crit_edge ], [ 1, %.lr.ph52 ]
  %20 = getelementptr inbounds double, ptr %7, i64 %.050
  store double 0.000000e+00, ptr %20, align 8, !tbaa !9
  %21 = mul nsw i64 %.050, %8
  br label %22

22:                                               ; preds = %.lr.ph, %38
  %23 = phi double [ 0.000000e+00, %.lr.ph ], [ %39, %38 ]
  %.04448 = phi i64 [ 1, %.lr.ph ], [ %40, %38 ]
  %24 = add nsw i64 %.04448, %21
  %25 = getelementptr inbounds double, ptr %10, i64 %24
  %26 = load double, ptr %25, align 8, !tbaa !9
  %27 = fcmp une double %26, 0.000000e+00
  br i1 %27, label %28, label %38

28:                                               ; preds = %22
  %29 = getelementptr inbounds double, ptr %11, i64 %24
  %30 = load double, ptr %29, align 8, !tbaa !9
  %31 = fcmp oge double %30, 0.000000e+00
  %32 = fneg double %30
  %33 = select i1 %31, double %30, double %32
  %34 = fadd double %16, %33
  %35 = fdiv double %34, %26
  %36 = fcmp oge double %23, %35
  %37 = select i1 %36, double %23, double %35
  store double %37, ptr %20, align 8, !tbaa !9
  br label %38

38:                                               ; preds = %22, %28
  %39 = phi double [ %23, %22 ], [ %37, %28 ]
  %40 = add nuw i64 %.04448, 1
  %exitcond.not = icmp eq i64 %.04448, %18
  br i1 %exitcond.not, label %._crit_edge, label %22, !llvm.loop !11

._crit_edge:                                      ; preds = %38
  %41 = add nuw i64 %.050, 1
  %exitcond55.not = icmp eq i64 %.050, %17
  br i1 %exitcond55.not, label %._crit_edge53, label %.lr.ph, !llvm.loop !13

._crit_edge53:                                    ; preds = %._crit_edge, %.lr.ph52.split.us.preheader, %6
  ret i32 0
}

declare double @dlamch_(ptr noundef) local_unnamed_addr #1

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

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 = { "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 #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"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"}
!13 = distinct !{!13, !12}


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