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

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

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

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

50:                                               ; preds = %10
  %51 = load ptr, ptr %21, align 8, !tbaa !5
  store i64 -1, ptr %51, align 8, !tbaa !9
  br label %103

52:                                               ; preds = %10
  %53 = load ptr, ptr %13, align 8, !tbaa !5
  %54 = load i64, ptr %53, align 8, !tbaa !9
  %55 = icmp slt i64 %54, 0
  br i1 %55, label %56, label %58

56:                                               ; preds = %52
  %57 = load ptr, ptr %21, align 8, !tbaa !5
  store i64 -2, ptr %57, align 8, !tbaa !9
  br label %102

58:                                               ; preds = %52
  %59 = load ptr, ptr %14, align 8, !tbaa !5
  %60 = load i64, ptr %59, align 8, !tbaa !9
  %61 = icmp slt i64 %60, 0
  br i1 %61, label %62, label %64

62:                                               ; preds = %58
  %63 = load ptr, ptr %21, align 8, !tbaa !5
  store i64 -3, ptr %63, align 8, !tbaa !9
  br label %101

64:                                               ; preds = %58
  %65 = load ptr, ptr %15, align 8, !tbaa !5
  %66 = load i64, ptr %65, align 8, !tbaa !9
  %67 = icmp slt i64 %66, 0
  br i1 %67, label %68, label %70

68:                                               ; preds = %64
  %69 = load ptr, ptr %21, align 8, !tbaa !5
  store i64 -4, ptr %69, align 8, !tbaa !9
  br label %100

70:                                               ; preds = %64
  %71 = load ptr, ptr %17, align 8, !tbaa !5
  %72 = load i64, ptr %71, align 8, !tbaa !9
  %73 = load ptr, ptr %13, align 8, !tbaa !5
  %74 = load i64, ptr %73, align 8, !tbaa !9
  %75 = shl i64 %74, 1
  %76 = load ptr, ptr %14, align 8, !tbaa !5
  %77 = load i64, ptr %76, align 8, !tbaa !9
  %78 = add nsw i64 %75, %77
  %79 = add nsw i64 %78, 1
  %80 = icmp slt i64 %72, %79
  br i1 %80, label %81, label %83

81:                                               ; preds = %70
  %82 = load ptr, ptr %21, align 8, !tbaa !5
  store i64 -6, ptr %82, align 8, !tbaa !9
  br label %99

83:                                               ; preds = %70
  %84 = load ptr, ptr %20, align 8, !tbaa !5
  %85 = load i64, ptr %84, align 8, !tbaa !9
  %86 = load ptr, ptr %12, align 8, !tbaa !5
  %87 = load i64, ptr %86, align 8, !tbaa !9
  %88 = icmp sge i64 %87, 1
  br i1 %88, label %89, label %92

89:                                               ; preds = %83
  %90 = load ptr, ptr %12, align 8, !tbaa !5
  %91 = load i64, ptr %90, align 8, !tbaa !9
  br label %93

92:                                               ; preds = %83
  br label %93

93:                                               ; preds = %92, %89
  %94 = phi i64 [ %91, %89 ], [ 1, %92 ]
  %95 = icmp slt i64 %85, %94
  br i1 %95, label %96, label %98

96:                                               ; preds = %93
  %97 = load ptr, ptr %21, align 8, !tbaa !5
  store i64 -9, ptr %97, align 8, !tbaa !9
  br label %98

98:                                               ; preds = %96, %93
  br label %99

99:                                               ; preds = %98, %81
  br label %100

100:                                              ; preds = %99, %68
  br label %101

101:                                              ; preds = %100, %62
  br label %102

102:                                              ; preds = %101, %56
  br label %103

103:                                              ; preds = %102, %50
  %104 = load ptr, ptr %21, align 8, !tbaa !5
  %105 = load i64, ptr %104, align 8, !tbaa !9
  %106 = icmp ne i64 %105, 0
  br i1 %106, label %107, label %112

107:                                              ; preds = %103
  %108 = load ptr, ptr %21, align 8, !tbaa !5
  %109 = load i64, ptr %108, align 8, !tbaa !9
  %110 = sub nsw i64 0, %109
  store i64 %110, ptr %26, align 8, !tbaa !9
  %111 = call i32 @xerbla_(ptr noundef @.str, ptr noundef %26)
  store i32 0, ptr %11, align 4
  store i32 1, ptr %27, align 4
  br label %146

112:                                              ; preds = %103
  %113 = load ptr, ptr %12, align 8, !tbaa !5
  %114 = load ptr, ptr %12, align 8, !tbaa !5
  %115 = load ptr, ptr %13, align 8, !tbaa !5
  %116 = load ptr, ptr %14, align 8, !tbaa !5
  %117 = load ptr, ptr %16, align 8, !tbaa !5
  %118 = load i64, ptr %23, align 8, !tbaa !9
  %119 = getelementptr inbounds %struct.complex, ptr %117, i64 %118
  %120 = load ptr, ptr %17, align 8, !tbaa !5
  %121 = load ptr, ptr %18, align 8, !tbaa !5
  %122 = getelementptr inbounds i64, ptr %121, i64 1
  %123 = load ptr, ptr %21, align 8, !tbaa !5
  %124 = call i32 @cgbtrf_(ptr noundef %113, ptr noundef %114, ptr noundef %115, ptr noundef %116, ptr noundef %119, ptr noundef %120, ptr noundef %122, ptr noundef %123)
  %125 = load ptr, ptr %21, align 8, !tbaa !5
  %126 = load i64, ptr %125, align 8, !tbaa !9
  %127 = icmp eq i64 %126, 0
  br i1 %127, label %128, label %145

128:                                              ; preds = %112
  %129 = load ptr, ptr %12, align 8, !tbaa !5
  %130 = load ptr, ptr %13, align 8, !tbaa !5
  %131 = load ptr, ptr %14, align 8, !tbaa !5
  %132 = load ptr, ptr %15, align 8, !tbaa !5
  %133 = load ptr, ptr %16, align 8, !tbaa !5
  %134 = load i64, ptr %23, align 8, !tbaa !9
  %135 = getelementptr inbounds %struct.complex, ptr %133, i64 %134
  %136 = load ptr, ptr %17, align 8, !tbaa !5
  %137 = load ptr, ptr %18, align 8, !tbaa !5
  %138 = getelementptr inbounds i64, ptr %137, i64 1
  %139 = load ptr, ptr %19, align 8, !tbaa !5
  %140 = load i64, ptr %25, align 8, !tbaa !9
  %141 = getelementptr inbounds %struct.complex, ptr %139, i64 %140
  %142 = load ptr, ptr %20, align 8, !tbaa !5
  %143 = load ptr, ptr %21, align 8, !tbaa !5
  %144 = call i32 @cgbtrs_(ptr noundef @.str.1, ptr noundef %129, ptr noundef %130, ptr noundef %131, ptr noundef %132, ptr noundef %135, ptr noundef %136, ptr noundef %138, ptr noundef %141, ptr noundef %142, ptr noundef %143)
  br label %145

145:                                              ; preds = %128, %112
  store i32 0, ptr %11, align 4
  store i32 1, ptr %27, align 4
  br label %146

146:                                              ; preds = %145, %107
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #3
  %147 = load i32, ptr %11, align 4
  ret i32 %147
}

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

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

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

declare i32 @cgbtrs_(ptr noundef, 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}


; 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 [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [13 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @cgbsv_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9) local_unnamed_addr #0 {
  %11 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #4
  store i64 0, ptr %9, align 8, !tbaa !5
  %12 = load i64, ptr %0, align 8, !tbaa !5
  %13 = icmp slt i64 %12, 0
  br i1 %13, label %.thread, label %14

14:                                               ; preds = %10
  %15 = load i64, ptr %1, align 8, !tbaa !5
  %16 = icmp slt i64 %15, 0
  br i1 %16, label %.thread, label %17

17:                                               ; preds = %14
  %18 = load i64, ptr %2, align 8, !tbaa !5
  %19 = icmp slt i64 %18, 0
  br i1 %19, label %.thread, label %20

20:                                               ; preds = %17
  %21 = load i64, ptr %3, align 8, !tbaa !5
  %22 = icmp slt i64 %21, 0
  br i1 %22, label %.thread, label %23

23:                                               ; preds = %20
  %24 = load i64, ptr %5, align 8, !tbaa !5
  %25 = shl nuw i64 %15, 1
  %26 = add nsw i64 %18, %25
  %.not = icmp sgt i64 %24, %26
  br i1 %.not, label %27, label %.thread

27:                                               ; preds = %23
  %28 = load i64, ptr %8, align 8, !tbaa !5
  %spec.select = tail call i64 @llvm.umax.i64(i64 %12, i64 1)
  %29 = icmp slt i64 %28, %spec.select
  br i1 %29, label %.thread, label %31

.thread:                                          ; preds = %27, %23, %20, %17, %14, %10
  %.sink = phi i64 [ -1, %10 ], [ -2, %14 ], [ -3, %17 ], [ -4, %20 ], [ -6, %23 ], [ -9, %27 ]
  %.neg = phi i64 [ 1, %10 ], [ 2, %14 ], [ 3, %17 ], [ 4, %20 ], [ 6, %23 ], [ 9, %27 ]
  store i64 %.sink, ptr %9, align 8, !tbaa !5
  store i64 %.neg, ptr %11, align 8, !tbaa !5
  %30 = call i32 @xerbla_(ptr noundef nonnull @.str, ptr noundef nonnull %11) #4
  br label %37

31:                                               ; preds = %27
  %32 = tail call i32 @cgbtrf_(ptr noundef nonnull %0, ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef %4, ptr noundef nonnull %5, ptr noundef %6, ptr noundef nonnull %9) #4
  %33 = load i64, ptr %9, align 8, !tbaa !5
  %34 = icmp eq i64 %33, 0
  br i1 %34, label %35, label %37

35:                                               ; preds = %31
  %36 = tail call i32 @cgbtrs_(ptr noundef nonnull @.str.1, ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef %4, ptr noundef nonnull %5, ptr noundef %6, ptr noundef %7, ptr noundef nonnull %8, ptr noundef nonnull %9) #4
  br label %37

37:                                               ; preds = %31, %35, %.thread
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #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 @xerbla_(ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare i32 @cgbtrs_(ptr noundef, 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 nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #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 nosync nounwind speculatable willreturn memory(none) }
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"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass